ts-gems 1.2.0 → 1.5.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.
@@ -103,4 +103,4 @@ type _DeepNullish<T> =
103
103
  : T extends WeakSet<infer U> ? WeakSet<DeepNullish<U>>
104
104
  : IfTuple<T> extends true ? { [K in OptionalKeys<T>]?: DeepNullish<T[K]> }
105
105
  : T extends (infer U)[] ? DeepNullish<U>[] | null | undefined
106
- : { [P in keyof T]: DeepNullish<T[P]>| null | undefined };
106
+ : { [P in keyof T]: DeepNullish<Exclude<T[P], undefined>> | null | undefined };
@@ -1,5 +1,5 @@
1
- import {Builtin} from './common';
2
- import {IfTuple} from './type-check';
1
+ import {Builtin, Type} from './common';
2
+ import {IfClass, IfTuple} from './type-check';
3
3
  import {JsonKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, WritableKeys} from './keys';
4
4
 
5
5
  /**
@@ -17,7 +17,7 @@ type _DeepPickOptional<T, K extends keyof T = OptionalKeys<T>> =
17
17
  : T extends WeakSet<infer U> ? WeakSet<DeepPickOptional<U>>
18
18
  : IfTuple<T> extends true ? { [K in OptionalKeys<T>]?: DeepPickOptional<T[K]> }
19
19
  : T extends (infer U)[] ? DeepPickOptional<U>[]
20
- : { [P in K]: DeepPickOptional<Exclude<T[P], undefined>> };
20
+ : { [P in K]?: DeepPickOptional<Exclude<T[P], undefined>> };
21
21
 
22
22
  /**
23
23
  * Pick all required properties in T deeply
@@ -67,8 +67,9 @@ type _DeepPickWritable<T, K extends keyof T = WritableKeys<T>> =
67
67
  : T extends ReadonlySet<infer U> ? ReadonlySet<DeepPickWritable<U>>
68
68
  : T extends WeakSet<infer U> ? WeakSet<DeepPickWritable<U>>
69
69
  : IfTuple<T> extends true ? { [K in OptionalKeys<T>]?: DeepPickWritable<T[K]> }
70
- : T extends (infer U)[] ? DeepPickWritable<U>[]
71
- : { [P in K]: DeepPickWritable<Exclude<T[P], undefined>> }
70
+ : IfClass<T> extends true ? DeepPickWritable<Type<T>>
71
+ : T extends (infer U)[] ? DeepPickWritable<U>[]
72
+ : { [P in K]: DeepPickWritable<Exclude<T[P], undefined>> }
72
73
 
73
74
  /**
74
75
  * Pick all JSON friendly properties in T deeply
@@ -69,13 +69,14 @@ export type IfPrimitiveOrAny<T, Y = true, N = false> =
69
69
  * Returns Y if typeof T is JSON like, N otherwise
70
70
  */
71
71
  export type IfJson<T, Y = true, N = false> =
72
- IfNull<T> extends true ? Y :
73
- IfNever<T> extends true ? N :
74
- T extends Function ? N :
75
- T extends symbol ? N :
76
- IfUndefined<T> extends true ? N :
77
- T extends (infer U)[] ? IfJson<U> extends true ? Y : N
78
- : Y;
72
+ IfAny<T> extends true ? Y :
73
+ IfNull<T> extends true ? Y :
74
+ IfNever<T> extends true ? N :
75
+ T extends Function ? N :
76
+ T extends symbol ? N :
77
+ IfUndefined<T> extends true ? N :
78
+ T extends (infer U)[] ? IfJson<U> extends true ? Y : N
79
+ : Y;
79
80
 
80
81
  export type IfJsonOrAny<T, Y = true, N = false> =
81
82
  IfAny<T> extends true ? Y : IfJson<T, Y, N>;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "lodash",
13
13
  "underscore"
14
14
  ],
15
- "version": "1.2.0",
15
+ "version": "1.5.0",
16
16
  "types": "lib/index.d.ts",
17
17
  "repository": "git@github.com:panates/ts-gems.git",
18
18
  "author": "Eray Hanoglu <e.hanoglu@panates.com>",