@pastable/typings
Version:
29 lines (28 loc) • 1.49 kB
TypeScript
export declare type PrimitiveValue = string | number | boolean;
export declare type Primitive = PrimitiveValue | Array<PrimitiveValue>;
export declare type ObjectLiteral<T = any> = Record<string, T>;
export declare type JSONValue = PrimitiveValue | JSONObject | JSONArray;
export interface JSONObject {
[x: string]: JSONValue;
}
export interface JSONArray extends Array<JSONValue> {
}
export declare type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise<infer U> ? U : T;
export declare type CType<T = any> = new (...args: any[]) => T;
export declare type AnyFunction<Return = any, Args = any> = (...args: Args[]) => Return;
export declare type FunctionArguments<T extends Function> = T extends (...args: infer R) => any ? R : never;
export declare type ArrayUnion<T extends Readonly<string[]>> = T[number];
/**
* Same as Partial<T> but goes deeper and makes Partial<T> all its properties and sub-properties.
`*/
declare type DP<T> = {
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
};
export declare type DeepPartial<T> = {
[P in keyof T]?: T[P] | DP<T>;
};
export declare type NonUndefined<A> = A extends undefined ? never : A;
export declare type NonFunctionKeys<T extends object> = {
[K in keyof T]-?: NonUndefined<T[K]> extends Function ? never : K;
}[keyof T];
export {};