1 | import {Primitive} from './basic';
|
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 | export type ReadonlyDeep<T> = T extends Primitive | ((...arguments: any[]) => unknown)
|
33 | ? T
|
34 | : T extends ReadonlyMap<infer KeyType, infer ValueType>
|
35 | ? ReadonlyMapDeep<KeyType, ValueType>
|
36 | : T extends ReadonlySet<infer ItemType>
|
37 | ? ReadonlySetDeep<ItemType>
|
38 | : T extends object
|
39 | ? ReadonlyObjectDeep<T>
|
40 | : unknown;
|
41 |
|
42 | /**
|
43 | Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
|
44 | */
|
45 | interface ReadonlyMapDeep<KeyType, ValueType>
|
46 | extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>> {}
|
47 |
|
48 | /**
|
49 | Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
|
50 | */
|
51 | interface ReadonlySetDeep<ItemType>
|
52 | extends ReadonlySet<ReadonlyDeep<ItemType>> {}
|
53 |
|
54 | /**
|
55 | Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
|
56 | */
|
57 | type ReadonlyObjectDeep<ObjectType extends object> = {
|
58 | readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
|
59 | };
|
60 |
|
\ | No newline at end of file |