ts-gems 3.8.0 → 3.10.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/dto.d.ts +4 -4
- package/lib/index.d.ts +1 -0
- package/lib/omit-never.d.ts +1 -1
- package/lib/omit-undefined.d.ts +39 -0
- package/package.json +1 -1
package/lib/dto.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IfNoDeepValue } from './helpers.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DeeperNullish } from './nullish.js';
|
|
3
|
+
import { DeeperPartial } from './partial.js';
|
|
4
4
|
import { IfNever } from './type-check.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -21,5 +21,5 @@ export type DTO<T> = {
|
|
|
21
21
|
DTO<Exclude<T[K], undefined | null>>;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export type PartialDTO<T> =
|
|
25
|
-
export type PatchDTO<T> =
|
|
24
|
+
export type PartialDTO<T> = DeeperPartial<DTO<T>>;
|
|
25
|
+
export type PatchDTO<T> = DeeperNullish<DTO<T>>;
|
package/lib/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type * from './non-nullable';
|
|
|
14
14
|
export type * from './nullish';
|
|
15
15
|
export type * from './omit';
|
|
16
16
|
export type * from './omit-never';
|
|
17
|
+
export type * from './omit-undefined';
|
|
17
18
|
export type * from './opaque';
|
|
18
19
|
export type * from './partial';
|
|
19
20
|
export type * from './pick';
|
package/lib/omit-never.d.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IfNoDeepValue } from './helpers.js';
|
|
2
|
+
import { IfNever } from './type-check.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* OmitUndefined<T> is a type that omits all properties with a value of type "undefined".
|
|
6
|
+
*/
|
|
7
|
+
export type OmitUndefined<T> = {
|
|
8
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]: T[K];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Omit all "never" and "undefined" properties in T deeply
|
|
13
|
+
*/
|
|
14
|
+
export type DeepOmitUndefined<T> = {
|
|
15
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]: IfNoDeepValue<
|
|
16
|
+
// Do not deep process No-Deep values
|
|
17
|
+
Exclude<T[K], undefined>
|
|
18
|
+
> extends true
|
|
19
|
+
? T[K]
|
|
20
|
+
: // Deep process objects
|
|
21
|
+
DeepOmitUndefined<Exclude<T[K], undefined>>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Omit all "never" and "undefined" properties in T deeply including arrays
|
|
26
|
+
*/
|
|
27
|
+
export type DeeperOmitUndefined<T> = {
|
|
28
|
+
[K in keyof T as IfNever<Exclude<T[K], undefined>, never, K>]: Exclude<
|
|
29
|
+
// Deep process arrays
|
|
30
|
+
T[K],
|
|
31
|
+
undefined
|
|
32
|
+
> extends (infer U)[]
|
|
33
|
+
? DeeperOmitUndefined<U>[]
|
|
34
|
+
: // Do not deep process No-Deep values
|
|
35
|
+
IfNoDeepValue<Exclude<T[K], undefined>> extends true
|
|
36
|
+
? T[K]
|
|
37
|
+
: // Deep process objects
|
|
38
|
+
DeeperOmitUndefined<Exclude<T[K], undefined>>;
|
|
39
|
+
};
|