-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
35 lines (26 loc) · 1.17 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
declare global {
type DiffKeys<T, U> = {
[K in keyof T]: K extends keyof U ? never : K;
}[keyof T];
type Diff<T, U> = Pick<T & U, DiffKeys<T, U> | DiffKeys<U, T>>;
type DeepPartial<T> = {
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
};
type Callable<T extends any = any, A extends any[] = any[]> = (...args: A) => T;
type ResolveType<T extends Callable> = ReturnType<T> extends Promise<infer U> ? U : ReturnType<T>;
type Asynchronize<T extends Callable> = ReturnType<T> extends Promise<any>
? T
: (ReturnType<T> extends (AsyncIterableIterator<infer U> | IterableIterator<infer U>)
? (...args: Parameters<T>) => AsyncIterableIterator<U>
: (...args: Parameters<T>) => Promise<ReturnType<T>>
);
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
type FunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? K : never
}[keyof T];
type NonFunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? never : K
}[keyof T];
}
export { };