/// /** * @see https://devblogs.microsoft.com/typescript/announcing-typescript-2-9-2/#support-for-symbols-and-numeric-literals-in-keyof-and-mapped-object-types */ export declare type KeyofBase = keyof any; /** * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types} */ export declare type Primative = string | number | boolean | bigint | symbol | null | undefined; /** * @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type} */ export declare type NonPrimative = object; export interface EmptyInterface { } export declare type Cast = T extends SafeT ? T : SafeT; export declare type Try = T extends SafeT ? T : Catch; /** * Predicate whether the target is `undefined`. */ export declare type IsUndefined = Exclude extends never ? true : false; export declare type IfUndefined = IsUndefined extends true ? TRUE : FALSE; export declare type CastUndefined = T extends undefined ? T : undefined; /** * Predicate whether the target is `null`. */ export declare type IsNull = Exclude extends never ? true : false; export declare type IfNull = IsNull extends true ? TRUE : FALSE; export declare type CastNull = T extends null ? T : null; /** * Predicate whether the target is `null | undefined`. */ export declare type IsNil = Exclude extends never ? true : false; export declare type IfNil = IsNil extends true ? TRUE : FALSE; export declare type CastNil = T extends undefined | null ? T : undefined | null; export declare type IsUndefinedable = T extends Exclude ? false : true; export declare type IsNullable = T extends Exclude ? false : true; export declare type IsNilable = T extends Exclude ? false : true; export declare type IfUndefinedable = IsUndefinedable extends true ? TRUE : FALSE; export declare type IfNullable = IsNullable extends true ? TRUE : FALSE; export declare type IfNilable = IsNilable extends true ? TRUE : FALSE; export declare type Undefinedable = T | undefined; export declare type Nullable = T | null; export declare type Nilable = T | null | undefined; export declare type NonUndefinedable = Exclude; export declare type NonNullable = Exclude; export declare type NonNilable = Exclude; /** * Predicate whether the target is `never`. */ export declare type IsNever = [T] extends [never] ? true : false; export declare type IfNever = IsNever extends true ? TRUE : FALSE; export declare type CastNever = T extends never ? T : never; /** * Predicate whether the target is `any`. * @see Copyright - The idea is get from {@link https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360} */ export declare type IsAny = 0 extends (1 & T) ? true : false; export declare type IfAny = 0 extends (1 & T) ? TRUE : FALSE; export declare type CastAny = T extends any ? T : any; /** * @see {@link https://www.typescriptlang.org/docs/handbook/type-compatibility.html#any-unknown-object-void-undefined-null-and-never-assignability} */ export declare type IsUnknown = IsNever extends true ? false : (T extends unknown ? (unknown extends T ? (IsAny extends true ? false : true) : false) : false); export declare type IfUnknown = IsUnknown extends true ? TRUE : FALSE; export declare type CastUnknown = T extends unknown ? T : unknown; /** * Predicate whether the target is `boolean`. */ export declare type IsBoolean = T extends boolean ? true : false; export declare type IfBoolean = IsBoolean extends true ? TRUE : FALSE; export declare type CastBoolean = T extends boolean ? T : boolean; export declare type IsBooleanLiteral = T extends boolean ? (boolean extends T ? false : true) : false; /** * Predicate whether the target is `string`. */ export declare type IsString = T extends string ? true : false; export declare type IfString = IsString extends true ? TRUE : FALSE; export declare type CastString = T extends string ? T : string; export declare type IsStringLiteral = T extends string ? (string extends T ? false : true) : false; /** * Predicate whether the target is `number`. */ export declare type IsNumber = T extends number ? true : false; export declare type IfNumber = IsNumber extends true ? TRUE : FALSE; export declare type CastNumber = T extends number ? T : number; export declare type IsNumberLiteral = T extends number ? (number extends T ? false : true) : false; /** * Predicate whether the target is `symbol`. */ export declare type IsSymbol = T extends symbol ? true : false; export declare type IfSymbol = IsSymbol extends true ? TRUE : FALSE; export declare type CastSymbol = T extends symbol ? T : symbol; /** * Predicate whether the target is of type function. */ export declare type IsFunction = T extends AnyFunction ? true : false; export declare type IfFunction = IsFunction extends true ? TRUE : FALSE; export declare type CastFunction = T extends AnyFunction ? T : AnyFunction; declare type ExpandedDistribution = T extends any ? T[] : never; declare type ClosedDistribution = [T] extends [any] ? T[] : never; /** * Predicate whether the target is `Union` type. * * @see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types */ export declare type IsUnion = ClosedDistribution extends ExpandedDistribution ? false : true; export declare type IfUnion = IsUnion extends true ? TRUE : FALSE; /** * Predicate whether the target is `Array`. */ export declare type IsArray = T extends readonly any[] ? (number extends T['length'] ? true : false) : false; export declare type IfArray = IsArray extends true ? TRUE : FALSE; export declare type IsReadonlyArray = T extends readonly any[] ? (T extends any[] ? false : true) : false; export declare type IfReadonlyArray = IsReadonlyArray extends true ? TRUE : FALSE; export declare type IsWritableArray = T extends any[] ? (number extends T['length'] ? true : false) : false; export declare type IfWritableArray = IsWritableArray extends true ? TRUE : FALSE; /** * Predicate whether the target is `Tuple`. * * @see https://github.com/type-challenges/type-challenges/issues/4491#issuecomment-975808109 */ export declare type IsTuple = T extends readonly any[] ? (number extends T['length'] ? false : true) : false; export declare type IfTuple = IsTuple extends true ? TRUE : FALSE; export declare type IsReadonlyTuple = T extends readonly any[] ? (T extends any[] ? false : true) : false; export declare type IfReadonlyTuple = IsReadonlyTuple extends true ? TRUE : FALSE; export declare type IsWritableTuple = T extends any[] ? (number extends T['length'] ? false : true) : false; export declare type IfWritableTuple = IsWritableTuple extends true ? TRUE : FALSE; /** * Predicate whether the target is `Array` or `Tuple`. */ export declare type IsArrayOrTuple = T extends readonly any[] ? true : false; export declare type IfArrayOrTuple = IsArrayOrTuple extends true ? TRUE : FALSE; export declare type IsRecord = T extends Record ? true : false; export declare type IfRecord = IsRecord extends true ? TRUE : FALSE; export declare type IsStringRecord = T extends Record ? true : false; export declare type IfStringRecord = IsStringRecord extends true ? TRUE : FALSE; export declare type IsNumberRecord = T extends Record ? true : false; export declare type IfNumberRecord = IsNumberRecord extends true ? TRUE : FALSE; export declare type IsSymbolRecord = T extends Record ? true : false; export declare type IfSymbolRecord = IsSymbolRecord extends true ? TRUE : FALSE; /** * Predicate whether the target is `Record`. */ export declare type IsEmptyObject> = keyof Target extends never ? true : false; export declare type IfEmptyObject, TRUE = true, FALSE = never> = IsEmptyObject extends true ? TRUE : FALSE; export declare type IsPrimative = T extends string ? true : T extends number ? true : T extends boolean ? true : T extends symbol ? true : T extends bigint ? true : T extends undefined ? true : T extends null ? true : false; export declare type IfPrimative = IsPrimative extends true ? TRUE : FALSE; export declare type IsPrimativeUnion = T extends Primative ? true : false; export declare type IfPrimativeUnion = IsPrimativeUnion extends true ? TRUE : FALSE; /** * @see Copyright - The code is copy from {@Link https://github.com/millsp/ts-toolbelt/blob/319e55123b9571d49f34eca3e5926e41ca73e0f3/sources/Any/Keys.ts#L11} */ export declare type Keys = A extends readonly any[] ? Exclude | number : keyof A; export {}; //# sourceMappingURL=base.d.ts.map