ts-gems 3.7.0 → 3.8.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/non-nullable.d.ts +16 -5
- package/package.json +1 -1
package/lib/non-nullable.d.ts
CHANGED
|
@@ -4,7 +4,18 @@ import { IfNever, IfNull } from './type-check.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Exclude null and undefined from T deeply
|
|
6
6
|
*/
|
|
7
|
-
export type
|
|
7
|
+
export type UnNullish<T> = {
|
|
8
|
+
[K in keyof T as IfNever<
|
|
9
|
+
Exclude<T[K], undefined>,
|
|
10
|
+
never,
|
|
11
|
+
IfNull<Exclude<T[K], undefined>, never, K>
|
|
12
|
+
>]: NonNullable<T[K]>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Exclude null and undefined from T deeply
|
|
17
|
+
*/
|
|
18
|
+
export type DeepUnNullish<T> = {
|
|
8
19
|
[K in keyof T as IfNever<
|
|
9
20
|
Exclude<T[K], undefined>,
|
|
10
21
|
never,
|
|
@@ -15,22 +26,22 @@ export type DeepNonNullable<T> = {
|
|
|
15
26
|
> extends true
|
|
16
27
|
? NonNullable<T[K]>
|
|
17
28
|
: // Deep process objects
|
|
18
|
-
|
|
29
|
+
DeepUnNullish<NonNullable<T[K]>>;
|
|
19
30
|
};
|
|
20
31
|
|
|
21
32
|
/**
|
|
22
33
|
* Exclude null and undefined from T deeply including arrays
|
|
23
34
|
*/
|
|
24
|
-
export type
|
|
35
|
+
export type DeeperUnNullish<T> = {
|
|
25
36
|
[K in keyof T as IfNever<
|
|
26
37
|
Exclude<T[K], undefined>,
|
|
27
38
|
never,
|
|
28
39
|
IfNull<Exclude<T[K], undefined>, never, K>
|
|
29
40
|
>]: NonNullable<Exclude<T[K], undefined>> extends (infer U)[]
|
|
30
|
-
?
|
|
41
|
+
? DeeperUnNullish<U>[]
|
|
31
42
|
: // Do not deep process No-Deep values
|
|
32
43
|
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
33
44
|
? NonNullable<T[K]>
|
|
34
45
|
: // Deep process objects
|
|
35
|
-
|
|
46
|
+
DeeperUnNullish<NonNullable<T[K]>>;
|
|
36
47
|
};
|