UNPKG

1.43 kBTypeScriptView Raw
1export declare type Id<T> = {
2 [K in keyof T]: T[K];
3} & {};
4export declare type WithRequiredProp<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
5export declare type Override<T1, T2> = T2 extends any ? Omit<T1, keyof T2> & T2 : never;
6export declare function assertCast<T>(v: any): asserts v is T;
7export declare function safeAssign<T extends object>(target: T, ...args: Array<Partial<NoInfer<T>>>): void;
8/**
9 * Convert a Union type `(A|B)` to an intersection type `(A&B)`
10 */
11export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
12export declare type NonOptionalKeys<T> = {
13 [K in keyof T]-?: undefined extends T[K] ? never : K;
14}[keyof T];
15export declare type HasRequiredProps<T, True, False> = NonOptionalKeys<T> extends never ? False : True;
16export declare type OptionalIfAllPropsOptional<T> = HasRequiredProps<T, T, T | never>;
17export declare type NoInfer<T> = [T][T extends any ? 0 : never];
18export declare type UnwrapPromise<T> = T extends PromiseLike<infer V> ? V : T;
19export declare type MaybePromise<T> = T | PromiseLike<T>;
20export declare type OmitFromUnion<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
21export declare type IsAny<T, True, False = never> = true | false extends (T extends never ? true : false) ? True : False;
22export declare type CastAny<T, CastTo> = IsAny<T, CastTo, T>;