-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpand.ts
52 lines (45 loc) · 1.19 KB
/
expand.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// deno-lint-ignore-file ban-types
export interface SimplifyOptions {
deep?: boolean;
}
type Flatten<
AnyType,
Options extends SimplifyOptions = {},
> = Options["deep"] extends true ? { [KeyType in keyof AnyType]: Expand<AnyType[KeyType], Options> }
: { [KeyType in keyof AnyType]: AnyType[KeyType] };
/**
* Unrolls the `...` type displays in an IDE.
*/
export type Expand<
AnyType,
Options extends SimplifyOptions = {},
> = Flatten<AnyType> extends AnyType ? Flatten<AnyType, Options>
: AnyType;
/**
* Unrolls the `...` type displays in an IDE.
*
* This is an alias for {@linkcode Expand}
*/
export type Simplify<T> = Expand<T>;
/**
* Unrolls the `...` type displays in an IDE.
*
* This is an alias for {@linkcode Expand}
*/
export type Preview<T> = Expand<T>;
/**
* Unrolls the `...` type displays in an IDE recursively.
*/
export type ExpandAll<T> = Expand<T, { deep: true }>;
/**
* Unrolls the `...` type displays in an IDE recursively.
*
* This is an alias for {@linkcode ExpandAll}
*/
export type SimplifyAll<T> = ExpandAll<T>;
/**
* Unrolls the `...` type displays in an IDE.
*
* This is an alias for {@linkcode ExpandAll}
*/
export type PreviewAll<T> = ExpandAll<T>;