ts-gems 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/combine.d.ts +4 -4
- package/lib/dto.d.ts +11 -7
- package/lib/helpers.d.ts +25 -16
- package/lib/index.cjs +16 -0
- package/lib/index.d.ts +61 -15
- package/lib/index.mjs +16 -0
- package/lib/logical.d.ts +26 -14
- package/lib/mutable.d.ts +23 -18
- package/lib/nullish.d.ts +18 -15
- package/lib/omit-never.d.ts +17 -13
- package/lib/omit.d.ts +30 -20
- package/lib/opaque.ts +1 -1
- package/lib/partial.d.ts +19 -17
- package/lib/pick.d.ts +45 -46
- package/lib/readonly.d.ts +87 -83
- package/lib/required.d.ts +89 -83
- package/lib/type-check.d.ts +110 -70
- package/lib/types.d.ts +38 -19
- package/package.json +15 -6
- package/lib/index.js +0 -0
package/lib/pick.d.ts
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
1
1
|
import { Or } from './logical.js';
|
|
2
2
|
import { OmitFunctions } from './omit';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IfAny,
|
|
5
|
+
IfEmptyObject,
|
|
6
|
+
IfFunction,
|
|
7
|
+
IfNever,
|
|
8
|
+
IfUnknown,
|
|
9
|
+
} from './type-check';
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* From T, pick a set of properties whose keys are in the union K,
|
|
7
13
|
* while preserving strict type checking.
|
|
8
14
|
*/
|
|
9
15
|
export type StrictPick<T, X extends keyof T> = {
|
|
10
|
-
[K in keyof T as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
[K in keyof T as Or<
|
|
17
|
+
// Omit never keys
|
|
18
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
19
|
+
// Omit X
|
|
20
|
+
K extends X ? false : true
|
|
21
|
+
> extends true
|
|
22
|
+
? never
|
|
23
|
+
: K]: T[K];
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
/**
|
|
21
27
|
* Pick all function properties in T
|
|
22
28
|
*/
|
|
23
29
|
export type PickFunctions<T> = {
|
|
24
|
-
[K in keyof T as
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
[K in keyof T as Or<
|
|
31
|
+
// Omit never keys
|
|
32
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
33
|
+
// Omit non functions
|
|
34
|
+
IfFunction<Exclude<T[K], undefined>, false, true>
|
|
35
|
+
> extends true
|
|
36
|
+
? never
|
|
37
|
+
: K]: T[K];
|
|
32
38
|
};
|
|
33
39
|
|
|
34
|
-
|
|
35
40
|
/**
|
|
36
41
|
* Pick all function properties in T
|
|
37
42
|
*/
|
|
38
43
|
export type PickTypes<T, X> = {
|
|
39
|
-
[K in keyof T as
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)]: T[K]
|
|
44
|
+
[K in keyof T as Or<
|
|
45
|
+
// Omit never keys
|
|
46
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
47
|
+
// Omit types which not exists in X
|
|
48
|
+
T[K] extends X ? false : X extends T[K] ? false : true
|
|
49
|
+
> extends true
|
|
50
|
+
? never
|
|
51
|
+
: K]: T[K];
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
|
|
51
54
|
/**
|
|
52
55
|
* Pick all function properties in T
|
|
53
56
|
*/
|
|
54
57
|
export type StrictPickTypes<T, X> = {
|
|
55
|
-
[K in keyof T as
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)]: T[K]
|
|
58
|
+
[K in keyof T as Or<
|
|
59
|
+
// Omit never keys
|
|
60
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
61
|
+
// Omit unknown
|
|
62
|
+
IfUnknown<T[K]>,
|
|
63
|
+
// Omit any
|
|
64
|
+
IfAny<T[K]>,
|
|
65
|
+
// Omit {}
|
|
66
|
+
IfEmptyObject<T[K]>,
|
|
67
|
+
// Omit types which not exists in X
|
|
68
|
+
T[K] extends X ? false : X extends T[K] ? false : true
|
|
69
|
+
> extends true
|
|
70
|
+
? never
|
|
71
|
+
: K]: T[K];
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
|
|
73
74
|
/**
|
|
74
75
|
* @desc Returns Function keys of an object
|
|
75
76
|
*/
|
|
@@ -80,7 +81,6 @@ export type FunctionKeys<T> = keyof PickFunctions<T>;
|
|
|
80
81
|
*/
|
|
81
82
|
export type NonFunctionKeys<T> = keyof OmitFunctions<T>;
|
|
82
83
|
|
|
83
|
-
|
|
84
84
|
/**
|
|
85
85
|
* @desc Returns keys that match given type
|
|
86
86
|
*/
|
|
@@ -90,4 +90,3 @@ export type KeysOfTypes<T, X> = keyof PickTypes<T, X>;
|
|
|
90
90
|
* @desc Returns keys that equals given type
|
|
91
91
|
*/
|
|
92
92
|
export type StrictKeysOfTypes<T, X> = keyof StrictPickTypes<T, X>;
|
|
93
|
-
|
package/lib/readonly.d.ts
CHANGED
|
@@ -5,33 +5,40 @@ import { IfEquals, IfNever } from './type-check';
|
|
|
5
5
|
/**
|
|
6
6
|
* Marks given keys as readonly
|
|
7
7
|
*/
|
|
8
|
-
export type ReadonlySome<T, K extends keyof T> = Readonly<Pick<T, K>> &
|
|
8
|
+
export type ReadonlySome<T, K extends keyof T> = Readonly<Pick<T, K>> &
|
|
9
|
+
Omit<T, K>;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Make all properties in T readonly deeply
|
|
12
13
|
*/
|
|
13
14
|
export type DeepReadonly<T> = {
|
|
14
|
-
readonly [K in keyof T as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
readonly [K in keyof T as IfNever<
|
|
16
|
+
Exclude<T[K], undefined>,
|
|
17
|
+
never,
|
|
18
|
+
K
|
|
19
|
+
>]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
20
|
+
? T[K]
|
|
21
|
+
: // Deep process objects
|
|
22
|
+
DeepReadonly<Exclude<T[K], undefined>>;
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Make all properties in T readonly deeply
|
|
23
27
|
*/
|
|
24
28
|
export type DeeperReadonly<T> = {
|
|
25
|
-
readonly [K in keyof T as
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
readonly [K in keyof T as IfNever<
|
|
30
|
+
Exclude<T[K], undefined>,
|
|
31
|
+
never,
|
|
32
|
+
K
|
|
33
|
+
>]: Exclude<T[K], undefined> extends (infer U)[] // Deep process arrays
|
|
34
|
+
? DeeperReadonly<U>[]
|
|
35
|
+
: // Do not deep process No-Deep values
|
|
36
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
37
|
+
? T[K]
|
|
38
|
+
: // Deep process objects
|
|
39
|
+
DeeperReadonly<Exclude<T[K], undefined>>;
|
|
32
40
|
};
|
|
33
41
|
|
|
34
|
-
|
|
35
42
|
/**
|
|
36
43
|
* Returns readonly keys of an object
|
|
37
44
|
*/
|
|
@@ -41,103 +48,100 @@ export type ReadonlyKeys<T> = keyof PickReadonly<T>;
|
|
|
41
48
|
* Pick all readonly properties in T
|
|
42
49
|
*/
|
|
43
50
|
export type PickReadonly<T> = {
|
|
44
|
-
[K in keyof T as
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
[K in keyof T as Or<
|
|
52
|
+
// Omit never keys
|
|
53
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
54
|
+
// Omit required
|
|
55
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
56
|
+
> extends true
|
|
57
|
+
? never
|
|
58
|
+
: K]: T[K];
|
|
52
59
|
};
|
|
53
60
|
|
|
54
61
|
/**
|
|
55
62
|
* Omit all readonly properties in T
|
|
56
63
|
*/
|
|
57
64
|
export type OmitReadonly<T> = {
|
|
58
|
-
[K in keyof T as
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
[K in keyof T as Or<
|
|
66
|
+
// Omit never keys
|
|
67
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
68
|
+
// Omit required
|
|
69
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
70
|
+
> extends true
|
|
71
|
+
? never
|
|
72
|
+
: K]: T[K];
|
|
66
73
|
};
|
|
67
74
|
|
|
68
|
-
|
|
69
75
|
/**
|
|
70
76
|
* Pick all readonly properties in T deeply
|
|
71
77
|
*/
|
|
72
78
|
export type DeepPickReadonly<T> = {
|
|
73
|
-
[K in keyof T as
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
: DeepPickReadonly<Exclude<T[K], undefined>>
|
|
79
|
+
[K in keyof T as Or<
|
|
80
|
+
// Omit never keys
|
|
81
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
82
|
+
// Omit required
|
|
83
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
84
|
+
> extends true
|
|
85
|
+
? never
|
|
86
|
+
: K]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
87
|
+
? T[K]
|
|
88
|
+
: // Deep process objects
|
|
89
|
+
DeepPickReadonly<Exclude<T[K], undefined>>;
|
|
85
90
|
};
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
93
|
* Pick all readonly properties in T deeply
|
|
89
94
|
*/
|
|
90
95
|
export type DeepOmitReadonly<T> = {
|
|
91
|
-
[K in keyof T as
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
: DeepOmitReadonly<Exclude<T[K], undefined>>
|
|
96
|
+
[K in keyof T as Or<
|
|
97
|
+
// Omit never keys
|
|
98
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
99
|
+
// Omit required
|
|
100
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
101
|
+
> extends true
|
|
102
|
+
? never
|
|
103
|
+
: K]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
104
|
+
? T[K]
|
|
105
|
+
: // Deep process objects
|
|
106
|
+
DeepOmitReadonly<Exclude<T[K], undefined>>;
|
|
103
107
|
};
|
|
104
108
|
|
|
105
109
|
/**
|
|
106
110
|
* Pick all readonly properties in T deeply including arrays
|
|
107
111
|
*/
|
|
108
112
|
export type DeeperPickReadonly<T> = {
|
|
109
|
-
[K in keyof T as
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
[K in keyof T as Or<
|
|
114
|
+
// Omit never keys
|
|
115
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
116
|
+
// Omit required
|
|
117
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
118
|
+
> extends true
|
|
119
|
+
? never
|
|
120
|
+
: K]: Exclude<T[K], undefined> extends (infer U)[] // Deep process arrays
|
|
121
|
+
? DeeperPickReadonly<U>[]
|
|
122
|
+
: // Do not deep process No-Deep values
|
|
123
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
124
|
+
? T[K]
|
|
125
|
+
: // Deep process objects
|
|
126
|
+
DeeperPickReadonly<Exclude<T[K], undefined>>;
|
|
123
127
|
};
|
|
124
128
|
|
|
125
129
|
/**
|
|
126
130
|
* Pick all readonly properties in T deeply including arrays
|
|
127
131
|
*/
|
|
128
132
|
export type DeeperOmitReadonly<T> = {
|
|
129
|
-
[K in keyof T as
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
[K in keyof T as Or<
|
|
134
|
+
// Omit never keys
|
|
135
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
136
|
+
// Omit required
|
|
137
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
138
|
+
> extends true
|
|
139
|
+
? never
|
|
140
|
+
: K]: Exclude<T[K], undefined> extends (infer U)[] // Deep process arrays
|
|
141
|
+
? DeeperOmitReadonly<U>[]
|
|
142
|
+
: // Do not deep process No-Deep values
|
|
143
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
144
|
+
? T[K]
|
|
145
|
+
: // Deep process objects
|
|
146
|
+
DeeperOmitReadonly<Exclude<T[K], undefined>>;
|
|
143
147
|
};
|
package/lib/required.d.ts
CHANGED
|
@@ -6,31 +6,40 @@ import { IfEquals, IfNever } from './type-check';
|
|
|
6
6
|
/**
|
|
7
7
|
* Marks given keys as required
|
|
8
8
|
*/
|
|
9
|
-
export type RequiredSome<T, K extends keyof T> = OmitTypes<
|
|
9
|
+
export type RequiredSome<T, K extends keyof T> = OmitTypes<
|
|
10
|
+
Required<Pick<T, K>>,
|
|
11
|
+
null
|
|
12
|
+
> &
|
|
13
|
+
Omit<T, K>;
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* Make all properties in T required deeply
|
|
13
17
|
*/
|
|
14
18
|
export type DeepRequired<T> = {
|
|
15
|
-
[K in keyof T as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
[K in keyof T as IfNever<
|
|
20
|
+
Exclude<T[K], undefined>,
|
|
21
|
+
never,
|
|
22
|
+
K
|
|
23
|
+
>]-?: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
24
|
+
? Exclude<T[K], undefined>
|
|
25
|
+
: // Deep process objects
|
|
26
|
+
DeepRequired<Exclude<T[K], undefined>>;
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
|
|
23
29
|
/**
|
|
24
30
|
* Make all properties in T required deeply including arrays
|
|
25
31
|
*/
|
|
26
32
|
export type DeeperRequired<T> = {
|
|
27
|
-
[K in keyof T as
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]-?: Exclude< // Deep process arrays
|
|
34
|
+
T[K],
|
|
35
|
+
undefined
|
|
36
|
+
> extends (infer U)[]
|
|
37
|
+
? DeeperRequired<U>[]
|
|
38
|
+
: // Do not deep process No-Deep values
|
|
39
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
40
|
+
? Exclude<T[K], undefined>
|
|
41
|
+
: // Deep process objects
|
|
42
|
+
DeepRequired<Exclude<T[K], undefined>>;
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
/**
|
|
@@ -39,107 +48,104 @@ export type DeeperRequired<T> = {
|
|
|
39
48
|
*/
|
|
40
49
|
export type RequiredKeys<T> = keyof PickRequired<T>;
|
|
41
50
|
|
|
42
|
-
|
|
43
51
|
/**
|
|
44
52
|
* Pick all required properties in T
|
|
45
53
|
*/
|
|
46
54
|
export type PickRequired<T> = {
|
|
47
|
-
[K in keyof T as
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
[K in keyof T as Or<
|
|
56
|
+
// Omit never keys
|
|
57
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
58
|
+
// Omit optional
|
|
59
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]?: T[K] }>
|
|
60
|
+
> extends true
|
|
61
|
+
? never
|
|
62
|
+
: K]: T[K];
|
|
55
63
|
};
|
|
56
64
|
|
|
57
65
|
/**
|
|
58
66
|
* Pick all required properties in T
|
|
59
67
|
*/
|
|
60
68
|
export type OmitRequired<T> = {
|
|
61
|
-
[K in keyof T as
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
[K in keyof T as Or<
|
|
70
|
+
// Omit never keys
|
|
71
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
72
|
+
// Omit optional
|
|
73
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]?: T[K] }, false, true>
|
|
74
|
+
> extends true
|
|
75
|
+
? never
|
|
76
|
+
: K]: T[K];
|
|
69
77
|
};
|
|
70
78
|
|
|
71
79
|
/**
|
|
72
80
|
* Pick all required properties in T deeply
|
|
73
81
|
*/
|
|
74
82
|
export type DeepPickRequired<T> = {
|
|
75
|
-
[K in keyof T as
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
: DeepPickRequired<Exclude<T[K], undefined>>
|
|
83
|
+
[K in keyof T as Or<
|
|
84
|
+
// Omit never keys
|
|
85
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
86
|
+
// Omit optional
|
|
87
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]?: T[K] }>
|
|
88
|
+
> extends true
|
|
89
|
+
? never
|
|
90
|
+
: K]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
91
|
+
? T[K]
|
|
92
|
+
: // Deep process objects
|
|
93
|
+
DeepPickRequired<Exclude<T[K], undefined>>;
|
|
87
94
|
};
|
|
88
95
|
|
|
89
96
|
/**
|
|
90
97
|
* Omit all required properties in T deeply
|
|
91
98
|
*/
|
|
92
99
|
export type DeepOmitRequired<T> = {
|
|
93
|
-
[K in keyof T as
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
: DeepOmitRequired<Exclude<T[K], undefined>>
|
|
100
|
+
[K in keyof T as Or<
|
|
101
|
+
// Omit never keys
|
|
102
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
103
|
+
// Omit required
|
|
104
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]-?: T[K] }>
|
|
105
|
+
> extends true
|
|
106
|
+
? never
|
|
107
|
+
: K]?: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
108
|
+
? T[K]
|
|
109
|
+
: // Deep process objects
|
|
110
|
+
DeepOmitRequired<Exclude<T[K], undefined>>;
|
|
105
111
|
};
|
|
106
112
|
|
|
107
113
|
/**
|
|
108
114
|
* Pick all required properties in T deeply including arrays
|
|
109
115
|
*/
|
|
110
116
|
export type DeeperPickRequired<T> = {
|
|
111
|
-
[K in keyof T as
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
[K in keyof T as Or<
|
|
118
|
+
// Omit never keys
|
|
119
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
120
|
+
// Omit required
|
|
121
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]?: T[K] }>
|
|
122
|
+
> extends true
|
|
123
|
+
? never
|
|
124
|
+
: K]: Exclude<T[K], undefined> extends (infer U)[] // Deep process arrays
|
|
125
|
+
? DeeperPickRequired<U>[]
|
|
126
|
+
: // Do not deep process No-Deep values
|
|
127
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
128
|
+
? T[K]
|
|
129
|
+
: // Deep process objects
|
|
130
|
+
DeeperPickRequired<Exclude<T[K], undefined>>;
|
|
125
131
|
};
|
|
126
132
|
|
|
127
133
|
/**
|
|
128
134
|
* Omit all required properties in T deeply including arrays
|
|
129
135
|
*/
|
|
130
136
|
export type DeeperOmitRequired<T> = {
|
|
131
|
-
[K in keyof T as
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
[K in keyof T as Or<
|
|
138
|
+
// Omit never keys
|
|
139
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
140
|
+
// Omit required
|
|
141
|
+
IfEquals<{ [Q in K]: T[K] }, { [Q in K]-?: T[K] }>
|
|
142
|
+
> extends true
|
|
143
|
+
? never
|
|
144
|
+
: K]: Exclude<T[K], undefined> extends (infer U)[] // Deep process arrays
|
|
145
|
+
? DeeperOmitRequired<U>[]
|
|
146
|
+
: // Do not deep process No-Deep values
|
|
147
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
148
|
+
? T[K]
|
|
149
|
+
: // Deep process objects
|
|
150
|
+
DeeperOmitRequired<Exclude<T[K], undefined>>;
|
|
145
151
|
};
|