1 | import type {NonRecursiveType, StringToNumber} from './internal';
|
2 | import type {Paths} from './paths';
|
3 | import type {SimplifyDeep} from './simplify-deep';
|
4 | import type {UnknownArray} from './unknown-array';
|
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 | export type SetRequiredDeep<BaseType, KeyPaths extends Paths<BaseType>> =
|
36 | BaseType extends NonRecursiveType
|
37 | ? BaseType
|
38 | : SimplifyDeep<(
|
39 | BaseType extends UnknownArray
|
40 | ? {}
|
41 | : {[K in keyof BaseType as K extends (KeyPaths | StringToNumber<KeyPaths & string>) ? K : never]-?: BaseType[K]}
|
42 | ) & {
|
43 | [K in keyof BaseType]: Extract<KeyPaths, `${K & (string | number)}.${string}`> extends never
|
44 | ? BaseType[K]
|
45 | : SetRequiredDeep<BaseType[K], KeyPaths extends `${K & (string | number)}.${infer Rest extends Paths<BaseType[K]>}` ? Rest : never>
|
46 | }>;
|