export type AnyFunction = (...args: any[]) => any; export type Constructable = new (...args: any[]) => any; /** * Specifies an object with unknown keys * * Useful when you don't care about exact props passed to the component. * @privateRemarks Don't use `{}` as a type. `{}` actually means "any non-nullish value". * @internal */ export type UnknownObject = Record; /** * Forces deeply all properties to be marked as partial (undefined) */ export type DeepPartial = { [P in keyof T]?: T[P] extends Array ? Array> : T[P] extends ReadonlyArray ? ReadonlyArray> : DeepPartial; }; /** * Overwrites properties from T1 with one from T2 * @internal * @example * ```ts * Overwrite<{ foo: boolean, bar: string }, { foo: number }> // { foo: number, bar: string } * ``` */ export type Overwrite = DistributiveOmit & T2; /** * Change the type of exclusive properties from T in U to `never` and `undefined` * @internal * @example * ```ts * Without<{ foo: boolean, bar: string }, { foo: boolean }> // { bar?: never } * ``` */ export type Without = { [P in Exclude]?: never; }; /** * Makes union exclusive. Useful in situations when only single prop can be provided at the same time * @internal * @example * ```ts * XOR<{ foo: boolean}, { bar: number }> // { foo: boolean, bar?: never } | { foo?: never, bar: number } * ``` */ export type XOR = (Without & U) | (Without & T); /** * Only one of the properties can be provided at the same time * @internal * @example * ```ts * OneOf; * ``` */ export type OneOf = Prettify & { [k in K]: Pick, k> & { [k1 in Exclude]?: never; }; }[K]>; /** * At least one of the properties must be provided */ export type AtLeastOneOf; }> = Partial & U[keyof U]; /** * Ask TS to re-check that A1 extends A2. And if it fails, A2 will be enforced anyway. * @internal */ export type Cast = A extends B ? A : B; /** * Prevent type widening on generic parameters * @internal */ export type Narrow = Cast; }>; /** * Extracts simple JSON paths from a nested type. * It does not support square brackets notation (yet). */ export type Gettify = P extends string | number ? T[P] extends UnknownObject ? `${P}.${Gettify}` : P : never; /** * Primitive types * @internal */ export type Primitive = string | number | boolean | bigint | symbol | undefined | null; /** * Omits properties from an union type, preserving the union. * @internal */ export type DistributiveOmit = T extends any ? Omit : never; /** * Distributes TAdd over a union TUnion. * @internal */ export type Distribute = TUnion extends unknown ? TUnion & TAdd : never; /** * Declares a non empty array of the specified type. */ export type NonEmptyArray = Overwrite<[ T, ...T[] ], { map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): NonEmptyArray; }>; /** * Declares an array of at least two elements of the specified type. * @internal */ export type TwoAtLeastArray = Overwrite<[ T, T, ...T[] ], { map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): TwoAtLeastArray; }>; /** * Beautify the readout of all of the members of that intersection. * * As seen on tv: https://twitter.com/mattpocockuk/status/1622730173446557697 * * @internal */ export type Prettify = { [K in keyof T]: T[K]; } & {}; /** * Branding function * * @internal */ export type Brand = T & { [K in ReservedName]: TBrand; }; /** * @internal */ type BrandOf = [A] extends [Brand] ? R : never; /** * @internal */ export type RecursiveUnbrand = T extends Brand> ? R : { [K in keyof T]: RecursiveUnbrand; }; export {};