= {
[P in keyof T as Exclude]: T[P];
};
/**
* Creates a type as one of const array elements.
*
* @example
* const TIME_UNITS = ['hours', 'minutes', 'seconds'] as const;
* type TimeUnit = OneOf;
*/
export type OneOf = T extends readonly (infer K)[] ? K : never;
/** Deeply replaces `Date` and `Buffer` fields to their JSON representation in a type */
export type Serialized = {
[P in keyof T]: T[P] extends Date ? string : T[P] extends Buffer ? {
type: 'Buffer';
data: number[];
} : Serialized;
};
/** Signifies that a type can be wrapped in a promise */
export type PromiseOrNot = Promise | T;
/** Constructor function */
export type Constructor = {
new (...args: Args): T;
};
/** Extracts method names of a class */
export type MethodNames = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
}[keyof T];
/**
* Replaces a key type
*
* @example
* type ExampleType = {a: number, b: string};
* type ReplacedType = Replace;
*/
export type Replace = {
[P in keyof T]: P extends keyof Replacements ? Replacements[P] : T[P];
};
/** Like `Partial` but deep */
export type DeepPartial = T extends object ? T extends Date ? T : {
[P in keyof T]?: DeepPartial;
} : T;
/** Like `Required` but deep */
export type RequiredDeep = T extends object ? T extends Date ? T : {
[P in keyof T]-?: RequiredDeep;
} : T;
/** Selects only public members of a class */
export type Public = {
[K in keyof T]: T[K];
};
/** Shortened `Record` where keys are always strings */
export type Dict = Record;
type TupleSplit = Acc['length'] extends N ? [Acc, T] : T extends readonly [infer Head, ...infer Tail] ? TupleSplit : [Acc, []];
/** Skips the first N elements of a tuple */
export type SkipFirst = TupleSplit[1];
/**
* Calls `bind` on function saving original function type
* @param func function to bind
* @param thisArg `this` argument
* @returns bound function
*/
export declare function typedBind(func: T, thisArg: any): T;
export {};