File tree Expand file tree Collapse file tree 1 file changed +0
-16
lines changed Expand file tree Collapse file tree 1 file changed +0
-16
lines changed Original file line number Diff line number Diff line change @@ -6,35 +6,19 @@ export type Promish<T> = T | Promise<T>;
66/**
77 * Recursively flattens the nested structure of an object type, transforming
88 * each property to its resolved (non-nested) type.
9- *
10- * @example
11- * ```ts
12- * type Example = { a: { b: { c: string } } };
13- * type FlatExample = FlatType<Example>; // { a: { b: { c: string } } }
14- * ```
159 */
1610export type FlatType < T > = T extends Record < PropertyKey , unknown >
1711 ? { [ K in keyof T ] : FlatType < T [ K ] > }
1812 : T ;
1913
2014/**
2115 * Extracts the first type in a tuple type.
22- *
23- * @example
24- * ```ts
25- * type First = FirstType<[string, number, boolean]>; // string
26- * ```
2716 */
2817export type FirstType < T extends unknown [ ] > = T extends [ infer F , ...infer _ ] ? F
2918 : never ;
3019
3120/**
3221 * Extracts the last type in a tuple type.
33- *
34- * @example
35- * ```ts
36- * type Last = LastType<[string, number, boolean]>; // boolean
37- * ```
3822 */
3923export type LastType < T extends unknown [ ] > = T extends [ ...infer _ , infer L ] ? L
4024 : never ;
You can’t perform that action at this time.
0 commit comments