import type { ListOf } from './union.js'; export type Cast = T extends U ? T : U; /** * Returns whether the type is exact (i.e. has only one possible value). * * @example * ```typescript * type R = IsExact<1>; // R :: true * type R = IsExact<1 | 2>; // R :: false * type R = IsExact<{ a: 1; b: { c: readonly [4, 5, 6]; d: [true, false] } }>; // R :: true * type R = IsExact<{ a: number }>; // R :: false * type R = IsExact<{ b: 4 | 5 }>; // R :: false * type R = IsExact<{ a: 1; b: 2 }>; // R :: true * type R = IsExact<[true] | [true, false]>; // R :: false * type R = IsExact<[true, false, 3, 4, 5]>; // R :: true * ``` */ export type IsExact = ListOf['length'] extends 1 ? IsExactPrimitive extends true ? true : IsExactObject extends true ? true : IsExactArray extends true ? true : false : false; type IsExactObject = ListOf['length'] extends 1 ? T extends object ? IsLiteral extends true ? { [P in keyof T]: IsExact extends true ? true : false; }[keyof T] extends true ? true : false : false : false : false; type IsExactArray = ListOf['length'] extends 1 ? AS extends readonly [infer AHead, ...infer ATail] ? IsExact extends true ? IsExactArray : false : AS extends [] ? true : false : false; type IsExactPrimitive = ListOf['length'] extends 1 ? T extends Primitive ? IsLiteral extends true ? true : T extends undefined | null | void ? true : false : false : false; export type IsLiteral = IsNotFalse>; export type IsNotFalse = [T] extends [false] ? false : true; type IsLiteralUnion = | IsStringLiteral | IsNumericLiteral | IsBooleanLiteral | IsSymbolLiteral; export type IsStringLiteral = LiteralCheck; export type IsNumericLiteral = LiteralChecks; export type IsBooleanLiteral = LiteralCheck; export type IsSymbolLiteral = LiteralCheck; type LiteralCheck = IsNever extends false ? [T] extends [LiteralType] ? [LiteralType] extends [T] ? false : true : false : false; type LiteralChecks = IsNotFalse< LiteralUnionType extends Primitive ? LiteralCheck : never >; export type IsNever = [T] extends [never] ? true : false; export type IsAny = boolean extends (T extends never ? true : false) ? true : false; type Numeric = number | bigint; type Primitive = string | number | bigint | boolean | symbol | null | undefined; export {}; //# sourceMappingURL=assertion.d.ts.map