ts-gems 3.12.0 → 4.0.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/README.md +114 -2
- package/docs/api/combine.md +48 -0
- package/docs/api/dto.md +115 -0
- package/docs/api/helpers.md +97 -0
- package/docs/api/logical.md +48 -0
- package/docs/api/mutable.md +164 -0
- package/docs/api/non-nullable.md +68 -0
- package/docs/api/nullish.md +66 -0
- package/docs/api/omit-never.md +62 -0
- package/docs/api/omit-undefined.md +60 -0
- package/docs/api/omit.md +99 -0
- package/docs/api/opaque.md +56 -0
- package/docs/api/partial.md +135 -0
- package/docs/api/pick.md +115 -0
- package/docs/api/readonly.md +150 -0
- package/docs/api/required.md +146 -0
- package/docs/api/type-check.md +246 -0
- package/docs/api/types.md +238 -0
- package/docs/api.md +113 -0
- package/docs/logo.svg +43 -0
- package/lib/dto.d.ts +14 -12
- package/lib/helpers.d.ts +16 -15
- package/lib/mutable.d.ts +15 -17
- package/lib/non-nullable.d.ts +31 -23
- package/lib/nullish.d.ts +15 -11
- package/lib/omit-never.d.ts +15 -11
- package/lib/omit-undefined.d.ts +12 -10
- package/lib/omit.d.ts +37 -28
- package/lib/partial.d.ts +12 -11
- package/lib/pick.d.ts +46 -38
- package/lib/readonly.d.ts +91 -77
- package/lib/required.d.ts +91 -75
- package/lib/type-check.d.ts +10 -9
- package/package.json +17 -15
package/lib/omit-never.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IfNoDeepValue } from './helpers.js';
|
|
2
|
-
import { IfNever } from './type-check.js';
|
|
2
|
+
import { IfNever, IfTuple } from './type-check.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OmitNever<T> is a type that omits all properties with a value of type "never".
|
|
@@ -41,14 +41,18 @@ export type DeepOmitNever<T> = {
|
|
|
41
41
|
* Omit all "never" and "undefined" properties in T deeply including arrays
|
|
42
42
|
*/
|
|
43
43
|
export type DeeperOmitNever<T> = {
|
|
44
|
-
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]: IfTuple<
|
|
45
|
+
NonNullable<T[K]>
|
|
46
|
+
> extends true // Leave fixed-length tuples untouched
|
|
47
|
+
? T[K]
|
|
48
|
+
: NonNullable<
|
|
49
|
+
// Deep process arrays
|
|
50
|
+
T[K]
|
|
51
|
+
> extends readonly (infer U)[]
|
|
52
|
+
? DeeperOmitNever<U>[]
|
|
53
|
+
: // Do not deep process No-Deep values
|
|
54
|
+
IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
55
|
+
? T[K]
|
|
56
|
+
: // Deep process objects
|
|
57
|
+
DeeperOmitNever<NonNullable<T[K]>>;
|
|
54
58
|
};
|
package/lib/omit-undefined.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IfNoDeepValue } from './helpers.js';
|
|
2
|
-
import { IfNever } from './type-check.js';
|
|
2
|
+
import { IfNever, IfTuple } from './type-check.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OmitUndefined<T> is a type that omits all properties with a value of type "undefined".
|
|
@@ -25,13 +25,15 @@ export type DeepOmitUndefined<T> = {
|
|
|
25
25
|
* Omit all "never" and "undefined" properties in T deeply including arrays
|
|
26
26
|
*/
|
|
27
27
|
export type DeeperOmitUndefined<T> = {
|
|
28
|
-
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]:
|
|
29
|
-
T[K]
|
|
30
|
-
> extends
|
|
31
|
-
?
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]: IfTuple<
|
|
29
|
+
NonNullable<T[K]>
|
|
30
|
+
> extends true // Leave fixed-length tuples untouched
|
|
31
|
+
? T[K]
|
|
32
|
+
: NonNullable<T[K]> extends readonly (infer U)[] // Deep process arrays
|
|
33
|
+
? DeeperOmitUndefined<U>[]
|
|
34
|
+
: // Do not deep process No-Deep values
|
|
35
|
+
IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
36
|
+
? T[K]
|
|
37
|
+
: // Deep process objects
|
|
38
|
+
DeeperOmitUndefined<NonNullable<T[K]>>;
|
|
37
39
|
};
|
package/lib/omit.d.ts
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import { IfNoDeepValue } from './helpers.js';
|
|
2
2
|
import { Or } from './logical.js';
|
|
3
|
-
import { IfFunction, IfNever } from './type-check.js';
|
|
3
|
+
import { IfFunction, IfNever, IfTuple } from './type-check.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Construct a type with the properties of T except for those in type K,
|
|
7
7
|
* while preserving strict type checking.
|
|
8
8
|
*/
|
|
9
9
|
export type StrictOmit<T, X extends keyof T> = {
|
|
10
|
-
[
|
|
10
|
+
[
|
|
11
|
+
K in keyof T as Or<
|
|
12
|
+
// Omit never keys
|
|
13
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
14
|
+
// Omit X
|
|
15
|
+
K extends X ? true : false
|
|
16
|
+
> extends true
|
|
17
|
+
? never
|
|
18
|
+
: K
|
|
19
|
+
]: T[K];
|
|
11
20
|
};
|
|
12
21
|
|
|
13
22
|
/**
|
|
14
23
|
* Omit all function properties in T
|
|
15
24
|
*/
|
|
16
25
|
export type OmitFunctions<T> = {
|
|
17
|
-
[
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
[
|
|
27
|
+
K in keyof T as Or<
|
|
28
|
+
// Omit never keys
|
|
29
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
30
|
+
// Omit functions
|
|
31
|
+
IfFunction<NonNullable<T[K]>>
|
|
32
|
+
> extends true
|
|
33
|
+
? never
|
|
34
|
+
: K
|
|
35
|
+
]: T[K];
|
|
25
36
|
};
|
|
26
37
|
|
|
27
38
|
/**
|
|
@@ -38,11 +49,9 @@ export type OmitTypes<T, X> = {
|
|
|
38
49
|
* Omit all function properties in T
|
|
39
50
|
*/
|
|
40
51
|
export type DeepOmitTypes<T, X> = {
|
|
41
|
-
[
|
|
42
|
-
Exclude<T[K], undefined | X>,
|
|
43
|
-
|
|
44
|
-
K
|
|
45
|
-
>]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
52
|
+
[
|
|
53
|
+
K in keyof T as IfNever<Exclude<T[K], undefined | X>, never, K>
|
|
54
|
+
]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
46
55
|
? Exclude<T[K], X>
|
|
47
56
|
: // Deep process objects
|
|
48
57
|
DeepOmitTypes<NonNullable<T[K]>, X>;
|
|
@@ -52,17 +61,17 @@ export type DeepOmitTypes<T, X> = {
|
|
|
52
61
|
* Omit all function properties in T deeply including arrays
|
|
53
62
|
*/
|
|
54
63
|
export type DeeperOmitTypes<T, X> = {
|
|
55
|
-
[K in keyof T as IfNever<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
K
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined | X>, never, K>]: IfTuple<
|
|
65
|
+
NonNullable<T[K]>
|
|
66
|
+
> extends true // Leave fixed-length tuples untouched
|
|
67
|
+
? Exclude<T[K], X>
|
|
68
|
+
: NonNullable<
|
|
69
|
+
// Deep process arrays // Do not deep process No-Deep values
|
|
70
|
+
T[K]
|
|
71
|
+
> extends readonly (infer U)[]
|
|
72
|
+
? DeeperOmitTypes<U, X>[]
|
|
73
|
+
: IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
74
|
+
? Exclude<T[K], X>
|
|
75
|
+
: // Deep process objects
|
|
76
|
+
DeeperOmitTypes<NonNullable<T[K]>, X>;
|
|
68
77
|
};
|
package/lib/partial.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
OmitRequired,
|
|
8
8
|
PickRequired,
|
|
9
9
|
} from './required.js';
|
|
10
|
-
import { IfNever } from './type-check.js';
|
|
10
|
+
import { IfNever, IfTuple } from './type-check.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Marks given keys as optional
|
|
@@ -32,16 +32,17 @@ export type DeepPartial<T> = {
|
|
|
32
32
|
* Partial but deeply including arrays
|
|
33
33
|
*/
|
|
34
34
|
export type DeeperPartial<T> = {
|
|
35
|
-
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]?:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]?: IfTuple<
|
|
36
|
+
NonNullable<T[K]>
|
|
37
|
+
> extends true // Leave fixed-length tuples untouched
|
|
38
|
+
? T[K]
|
|
39
|
+
: NonNullable<T[K]> extends readonly (infer U)[] // Deep process arrays
|
|
40
|
+
? DeeperPartial<U>[]
|
|
41
|
+
: // Do not deep process No-Deep values
|
|
42
|
+
IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
43
|
+
? T[K]
|
|
44
|
+
: // Deep process objects
|
|
45
|
+
DeeperPartial<NonNullable<T[K]>>;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
/**
|
package/lib/pick.d.ts
CHANGED
|
@@ -13,62 +13,70 @@ import {
|
|
|
13
13
|
* while preserving strict type checking.
|
|
14
14
|
*/
|
|
15
15
|
export type StrictPick<T, X extends keyof T> = {
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
[
|
|
17
|
+
K in keyof T as Or<
|
|
18
|
+
// Omit never keys
|
|
19
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
20
|
+
// Omit X
|
|
21
|
+
K extends X ? false : true
|
|
22
|
+
> extends true
|
|
23
|
+
? never
|
|
24
|
+
: K
|
|
25
|
+
]: T[K];
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Pick all function properties in T
|
|
28
30
|
*/
|
|
29
31
|
export type PickFunctions<T> = {
|
|
30
|
-
[
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
[
|
|
33
|
+
K in keyof T as Or<
|
|
34
|
+
// Omit never keys
|
|
35
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
36
|
+
// Omit non functions
|
|
37
|
+
IfFunction<NonNullable<T[K]>, false, true>
|
|
38
|
+
> extends true
|
|
39
|
+
? never
|
|
40
|
+
: K
|
|
41
|
+
]: T[K];
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* Pick all function properties in T
|
|
42
46
|
*/
|
|
43
47
|
export type PickTypes<T, X> = {
|
|
44
|
-
[
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
[
|
|
49
|
+
K in keyof T as Or<
|
|
50
|
+
// Omit never keys
|
|
51
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
52
|
+
// Omit types which not exists in X
|
|
53
|
+
T[K] extends X ? false : X extends T[K] ? false : true
|
|
54
|
+
> extends true
|
|
55
|
+
? never
|
|
56
|
+
: K
|
|
57
|
+
]: T[K];
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
/**
|
|
55
61
|
* Pick all function properties in T
|
|
56
62
|
*/
|
|
57
63
|
export type StrictPickTypes<T, X> = {
|
|
58
|
-
[
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
[
|
|
65
|
+
K in keyof T as Or<
|
|
66
|
+
// Omit never keys
|
|
67
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
68
|
+
// Omit unknown
|
|
69
|
+
IfUnknown<T[K]>,
|
|
70
|
+
// Omit any
|
|
71
|
+
IfAny<T[K]>,
|
|
72
|
+
// Omit {}
|
|
73
|
+
IfEmptyObject<T[K]>,
|
|
74
|
+
// Omit types which not exists in X
|
|
75
|
+
T[K] extends X ? false : X extends T[K] ? false : true
|
|
76
|
+
> extends true
|
|
77
|
+
? never
|
|
78
|
+
: K
|
|
79
|
+
]: T[K];
|
|
72
80
|
};
|
|
73
81
|
|
|
74
82
|
/**
|
package/lib/readonly.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IfNoDeepValue } from './helpers.js';
|
|
2
2
|
import { Or } from './logical.js';
|
|
3
|
-
import { IfEquals, IfNever } from './type-check.js';
|
|
3
|
+
import { IfEquals, IfNever, IfTuple } from './type-check.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Marks given keys as readonly
|
|
@@ -12,11 +12,9 @@ export type ReadonlySome<T, K extends keyof T> = Readonly<Pick<T, K>> &
|
|
|
12
12
|
* Make all properties in T readonly deeply
|
|
13
13
|
*/
|
|
14
14
|
export type DeepReadonly<T> = {
|
|
15
|
-
readonly [
|
|
16
|
-
Exclude<T[K], undefined>,
|
|
17
|
-
|
|
18
|
-
K
|
|
19
|
-
>]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
15
|
+
readonly [
|
|
16
|
+
K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>
|
|
17
|
+
]: IfNoDeepValue<Exclude<T[K], undefined>> extends true // Do not deep process No-Deep values
|
|
20
18
|
? T[K]
|
|
21
19
|
: // Deep process objects
|
|
22
20
|
DeepReadonly<Exclude<T[K], undefined>>;
|
|
@@ -26,17 +24,17 @@ export type DeepReadonly<T> = {
|
|
|
26
24
|
* Make all properties in T readonly deeply
|
|
27
25
|
*/
|
|
28
26
|
export type DeeperReadonly<T> = {
|
|
29
|
-
readonly [
|
|
30
|
-
Exclude<T[K], undefined>,
|
|
31
|
-
|
|
32
|
-
K
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
readonly [
|
|
28
|
+
K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>
|
|
29
|
+
]: IfTuple<NonNullable<T[K]>> extends true // Leave fixed-length tuples untouched
|
|
30
|
+
? T[K]
|
|
31
|
+
: NonNullable<T[K]> extends readonly (infer U)[] // Deep process arrays
|
|
32
|
+
? DeeperReadonly<U>[]
|
|
33
|
+
: // Do not deep process No-Deep values
|
|
34
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
35
|
+
? T[K]
|
|
36
|
+
: // Deep process objects
|
|
37
|
+
DeeperReadonly<Exclude<T[K], undefined>>;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
/**
|
|
@@ -48,42 +46,48 @@ export type ReadonlyKeys<T> = keyof PickReadonly<T>;
|
|
|
48
46
|
* Pick all readonly properties in T
|
|
49
47
|
*/
|
|
50
48
|
export type PickReadonly<T> = {
|
|
51
|
-
[
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
[
|
|
50
|
+
K in keyof T as Or<
|
|
51
|
+
// Omit never keys
|
|
52
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
53
|
+
// Omit required
|
|
54
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
55
|
+
> extends true
|
|
56
|
+
? never
|
|
57
|
+
: K
|
|
58
|
+
]: T[K];
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Omit all readonly properties in T
|
|
63
63
|
*/
|
|
64
64
|
export type OmitReadonly<T> = {
|
|
65
|
-
[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
[
|
|
66
|
+
K in keyof T as Or<
|
|
67
|
+
// Omit never keys
|
|
68
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
69
|
+
// Omit required
|
|
70
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
71
|
+
> extends true
|
|
72
|
+
? never
|
|
73
|
+
: K
|
|
74
|
+
]: T[K];
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Pick all readonly properties in T deeply
|
|
77
79
|
*/
|
|
78
80
|
export type DeepPickReadonly<T> = {
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
[
|
|
82
|
+
K in keyof T as Or<
|
|
83
|
+
// Omit never keys
|
|
84
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
85
|
+
// Omit required
|
|
86
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
87
|
+
> extends true
|
|
88
|
+
? never
|
|
89
|
+
: K
|
|
90
|
+
]: IfNoDeepValue<NonNullable<T[K]>> extends true // Do not deep process No-Deep values
|
|
87
91
|
? T[K]
|
|
88
92
|
: // Deep process objects
|
|
89
93
|
DeepPickReadonly<NonNullable<T[K]>>;
|
|
@@ -93,14 +97,16 @@ export type DeepPickReadonly<T> = {
|
|
|
93
97
|
* Pick all readonly properties in T deeply
|
|
94
98
|
*/
|
|
95
99
|
export type DeepOmitReadonly<T> = {
|
|
96
|
-
[
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
[
|
|
101
|
+
K in keyof T as Or<
|
|
102
|
+
// Omit never keys
|
|
103
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
104
|
+
// Omit required
|
|
105
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
106
|
+
> extends true
|
|
107
|
+
? never
|
|
108
|
+
: K
|
|
109
|
+
]: IfNoDeepValue<NonNullable<T[K]>> extends true // Do not deep process No-Deep values
|
|
104
110
|
? T[K]
|
|
105
111
|
: // Deep process objects
|
|
106
112
|
DeepOmitReadonly<NonNullable<T[K]>>;
|
|
@@ -110,38 +116,46 @@ export type DeepOmitReadonly<T> = {
|
|
|
110
116
|
* Pick all readonly properties in T deeply including arrays
|
|
111
117
|
*/
|
|
112
118
|
export type DeeperPickReadonly<T> = {
|
|
113
|
-
[
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
[
|
|
120
|
+
K in keyof T as Or<
|
|
121
|
+
// Omit never keys
|
|
122
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
123
|
+
// Omit required
|
|
124
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, false, true>
|
|
125
|
+
> extends true
|
|
126
|
+
? never
|
|
127
|
+
: K
|
|
128
|
+
]: IfTuple<NonNullable<T[K]>> extends true // Leave fixed-length tuples untouched
|
|
129
|
+
? T[K]
|
|
130
|
+
: NonNullable<T[K]> extends readonly (infer U)[] // Deep process arrays
|
|
131
|
+
? DeeperPickReadonly<U>[]
|
|
132
|
+
: // Do not deep process No-Deep values
|
|
133
|
+
IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
134
|
+
? T[K]
|
|
135
|
+
: // Deep process objects
|
|
136
|
+
DeeperPickReadonly<NonNullable<T[K]>>;
|
|
127
137
|
};
|
|
128
138
|
|
|
129
139
|
/**
|
|
130
140
|
* Pick all readonly properties in T deeply including arrays
|
|
131
141
|
*/
|
|
132
142
|
export type DeeperOmitReadonly<T> = {
|
|
133
|
-
[
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
[
|
|
144
|
+
K in keyof T as Or<
|
|
145
|
+
// Omit never keys
|
|
146
|
+
IfNever<Exclude<T[K], undefined>>,
|
|
147
|
+
// Omit required
|
|
148
|
+
IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }>
|
|
149
|
+
> extends true
|
|
150
|
+
? never
|
|
151
|
+
: K
|
|
152
|
+
]: IfTuple<NonNullable<T[K]>> extends true // Leave fixed-length tuples untouched
|
|
153
|
+
? T[K]
|
|
154
|
+
: NonNullable<T[K]> extends readonly (infer U)[] // Deep process arrays
|
|
155
|
+
? DeeperOmitReadonly<U>[]
|
|
156
|
+
: // Do not deep process No-Deep values
|
|
157
|
+
IfNoDeepValue<NonNullable<T[K]>> extends true
|
|
158
|
+
? T[K]
|
|
159
|
+
: // Deep process objects
|
|
160
|
+
DeeperOmitReadonly<NonNullable<T[K]>>;
|
|
147
161
|
};
|