ts-gems 3.6.0 → 3.7.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/index.d.ts +1 -0
- package/lib/non-nullable.d.ts +36 -0
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type * from './dto';
|
|
|
10
10
|
export type * from './helpers';
|
|
11
11
|
export type * from './logical';
|
|
12
12
|
export type * from './mutable';
|
|
13
|
+
export type * from './non-nullable';
|
|
13
14
|
export type * from './nullish';
|
|
14
15
|
export type * from './omit';
|
|
15
16
|
export type * from './omit-never';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IfNoDeepValue } from './helpers.js';
|
|
2
|
+
import { IfNever, IfNull } from './type-check.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Exclude null and undefined from T deeply
|
|
6
|
+
*/
|
|
7
|
+
export type DeepNonNullable<T> = {
|
|
8
|
+
[K in keyof T as IfNever<
|
|
9
|
+
Exclude<T[K], undefined>,
|
|
10
|
+
never,
|
|
11
|
+
IfNull<Exclude<T[K], undefined>, never, K>
|
|
12
|
+
>]: IfNoDeepValue<
|
|
13
|
+
// Do not deep process No-Deep values
|
|
14
|
+
Exclude<T[K], undefined>
|
|
15
|
+
> extends true
|
|
16
|
+
? NonNullable<T[K]>
|
|
17
|
+
: // Deep process objects
|
|
18
|
+
DeepNonNullable<NonNullable<T[K]>>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Exclude null and undefined from T deeply including arrays
|
|
23
|
+
*/
|
|
24
|
+
export type DeeperNonNullable<T> = {
|
|
25
|
+
[K in keyof T as IfNever<
|
|
26
|
+
Exclude<T[K], undefined>,
|
|
27
|
+
never,
|
|
28
|
+
IfNull<Exclude<T[K], undefined>, never, K>
|
|
29
|
+
>]: NonNullable<Exclude<T[K], undefined>> extends (infer U)[]
|
|
30
|
+
? DeeperNonNullable<U>[]
|
|
31
|
+
: // Do not deep process No-Deep values
|
|
32
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
33
|
+
? NonNullable<T[K]>
|
|
34
|
+
: // Deep process objects
|
|
35
|
+
DeeperNonNullable<NonNullable<T[K]>>;
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-gems",
|
|
3
3
|
"description": "Valuable typing extensions for TypeScript",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "./lib/index.mjs",
|
|
7
7
|
"main": "./lib/index.cjs",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@panates/eslint-config-ts": "^1.0.21",
|
|
30
30
|
"@panates/tsconfig": "^1.0.21",
|
|
31
31
|
"@types/jest": "^29.5.14",
|
|
32
|
-
"husky": "^9.1.
|
|
32
|
+
"husky": "^9.1.7",
|
|
33
33
|
"jest": "^29.7.0",
|
|
34
|
-
"prettier": "^3.
|
|
34
|
+
"prettier": "^3.4.0",
|
|
35
35
|
"ts-jest": "^29.2.5",
|
|
36
|
-
"typescript": "^5.
|
|
36
|
+
"typescript": "^5.7.2"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"LICENSE",
|