{"version":3,"file":"type.utils-LmaT3BDm.cjs","names":["val: T","x: never"],"sources":["../src/shared/type.utils.ts"],"sourcesContent":["import type { AppResult } from \"../app/result/index.ts\";\n\nexport type EmptyObject = Record<string | number | symbol, never>;\n\nexport type UnsafeCast<T, U> = T extends U ? T : U;\nexport const unsafeCast = <U, T = unknown>(val: T): U => val as unknown as U;\n\ntype JsonValue =\n  | string\n  | number\n  | boolean\n  | null\n  | Date\n  | JsonValue[]\n  | { [k: string]: JsonValue }; // JsonObject\n\ntype JsonObject = { [x: string]: JsonValue };\ntype JsonGuard<T> = T extends JsonValue ? T : never;\n\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\nexport type Omitt<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;\n\nexport type Constructable<T> = new (...args: unknown[]) => T;\n\nexport type ExtractAppResultType<U> = U extends AppResult<infer X> ? X : never;\n\nexport type ArrType<T> = T extends Array<infer R> ? R : never;\nexport type IterType<T> = T extends { [Symbol.iterator](): infer I }\n  ? I\n  : never;\n\nexport type InferAppResult<\n  T extends (...args: unknown[]) => Promise<AppResult<unknown>>,\n> = ExtractAppResultType<Awaited<ReturnType<T>>>;\n\nexport type GetKeysWithSpecificTypeValue<\n  T extends Record<string, unknown>,\n  ValType,\n> = {\n  [K in keyof T]: T[K] extends ValType ? K : never;\n}[keyof T];\n\ntype FooBar = { a: number; b: number; c: string; d: Date };\ntype KeyForNumber = GetKeysWithSpecificTypeValue<FooBar, number>; // is 'a' | 'b'\n\nexport type RequireAtLeastOne<T> = {\n  [K in keyof T]-?: Required<Pick<T, K>> &\n    Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n// BETTER TO COMPOSE THE UTILITIES LISTED ABOVE\n\n// export type ExtractAsyncAppResultVal<\n//   T extends (...args: any[]) => Promise<AppResult<any>>,\n// > = ExtractAppResultVal<AsyncReturnType<T>>;\n//\n// export type ExtractAppResultAsyncVal<\n//   T extends (...args: any[]) => AppResult<Promise<any>>,\n// > = ExtractAppResultVal<ReturnType<T>>;\n//\n// ------------------------------------------------------------------------\n\n/**\n * Is used to ensure that all cases are handled in a switch statement. Throws error on runtime\n * @internal\n * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking\n *\n * @param x {never} - This is a type that should never be used. It is used to ensure that the switch statement is exhaustive.\n */\nexport const assertUnreachable = (x: never): never => {\n  throw new Error(`Unexpected object: ${x}`);\n};\n\n/**\n * Is used to ensure that all cases are handled in a switch statement. Passes through the value on runtime\n * @internal\n * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking\n *\n * @param x {never} - This is a type that should never be used. It is used to ensure that the switch statement is exhaustive.\n */\nexport const assertUnreachablePassthrough = (x: never): never => x;\n\nexport type AppendToTuple<T, U> = T extends [...infer Rest, infer L]\n  ? [...Rest, L, U]\n  : [T, U];\n\nexport type IsUnion<T, U extends T = T> = ( // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n  T extends any\n    ? U extends T\n      ? false\n      : true\n    : never\n) extends false\n  ? false\n  : true;\nexport type EnsureNotUnion<T> = IsUnion<T> extends true ? never : T;\n"],"mappings":";;;AAKA,MAAa,aAAa,CAAiBA,QAAc;;;;;;;;AAgEzD,MAAa,oBAAoB,CAACC,MAAoB;AACpD,OAAM,IAAI,OAAO,qBAAqB,EAAE;AACzC;;;;;;;;AASD,MAAa,+BAA+B,CAACA,MAAoB"}