ts-gems 3.6.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/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,47 @@
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 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> = {
19
+ [K in keyof T as IfNever<
20
+ Exclude<T[K], undefined>,
21
+ never,
22
+ IfNull<Exclude<T[K], undefined>, never, K>
23
+ >]: IfNoDeepValue<
24
+ // Do not deep process No-Deep values
25
+ Exclude<T[K], undefined>
26
+ > extends true
27
+ ? NonNullable<T[K]>
28
+ : // Deep process objects
29
+ DeepUnNullish<NonNullable<T[K]>>;
30
+ };
31
+
32
+ /**
33
+ * Exclude null and undefined from T deeply including arrays
34
+ */
35
+ export type DeeperUnNullish<T> = {
36
+ [K in keyof T as IfNever<
37
+ Exclude<T[K], undefined>,
38
+ never,
39
+ IfNull<Exclude<T[K], undefined>, never, K>
40
+ >]: NonNullable<Exclude<T[K], undefined>> extends (infer U)[]
41
+ ? DeeperUnNullish<U>[]
42
+ : // Do not deep process No-Deep values
43
+ IfNoDeepValue<Exclude<T[K], undefined>> extends true
44
+ ? NonNullable<T[K]>
45
+ : // Deep process objects
46
+ DeeperUnNullish<NonNullable<T[K]>>;
47
+ };
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.6.0",
4
+ "version": "3.8.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.6",
32
+ "husky": "^9.1.7",
33
33
  "jest": "^29.7.0",
34
- "prettier": "^3.3.3",
34
+ "prettier": "^3.4.0",
35
35
  "ts-jest": "^29.2.5",
36
- "typescript": "^5.6.3"
36
+ "typescript": "^5.7.2"
37
37
  },
38
38
  "files": [
39
39
  "LICENSE",