@germondai/ts-utils 0.1.0 → 0.1.1
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/dist/types.d.ts +22 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,28 @@ export type DeepReadonly<T> = {
|
|
|
18
18
|
export type Nullable<T> = T | null;
|
|
19
19
|
/** Makes a type nullable or undefined */
|
|
20
20
|
export type Maybe<T> = T | null | undefined;
|
|
21
|
+
/** Makes a type promise or not */
|
|
22
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
23
|
+
/** Makes all properties of a type nullable */
|
|
24
|
+
export type NullableProperties<T> = {
|
|
25
|
+
[K in keyof T]: T[K] | null;
|
|
26
|
+
};
|
|
27
|
+
/** Makes all properties of a type optional */
|
|
28
|
+
export type OptionalProperties<T> = {
|
|
29
|
+
[K in keyof T]?: T[K];
|
|
30
|
+
};
|
|
31
|
+
/** Makes all properties of a type required */
|
|
32
|
+
export type RequiredProperties<T> = {
|
|
33
|
+
[K in keyof T]-?: T[K];
|
|
34
|
+
};
|
|
35
|
+
/** Extracts the keys of a type that are optional */
|
|
36
|
+
export type OptionalKeys<T> = {
|
|
37
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
38
|
+
}[keyof T];
|
|
39
|
+
/** Extracts the keys of a type that are required */
|
|
40
|
+
export type RequiredKeys<T> = {
|
|
41
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
42
|
+
}[keyof T];
|
|
21
43
|
/** Recursively removes null and undefined from all properties */
|
|
22
44
|
export type NonNullableDeep<T> = {
|
|
23
45
|
[K in keyof T]: T[K] extends object ? NonNullableDeep<NonNullable<T[K]>> : NonNullable<T[K]>;
|