js-dev-tool 1.2.0 → 1.2.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/basic-types.d.ts +26 -0
- package/package.json +1 -1
package/basic-types.d.ts
CHANGED
|
@@ -73,8 +73,34 @@ type Writable<T> = {
|
|
|
73
73
|
type InterfaceType<T> = {
|
|
74
74
|
[P in keyof T]: T[P];
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* combine intersection(s)
|
|
78
|
+
*/
|
|
76
79
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
77
80
|
type Constructor<T> = new (...args: any[]) => T;
|
|
81
|
+
/**
|
|
82
|
+
* mark a specific property as `required`
|
|
83
|
+
*
|
|
84
|
+
* + About `Merge` parameter - Accepts values of `1` or `0`.
|
|
85
|
+
* - If it is **1**, the types are displayed concatenated.
|
|
86
|
+
* - If it is **0**, the types are displayed separated by "&".
|
|
87
|
+
*/
|
|
88
|
+
type RequireThese<T, K extends keyof T, Merge extends 1 | 0 = 0> =
|
|
89
|
+
Merge extends 1 ? Prettify<
|
|
90
|
+
T & Required<Pick<T, K>>
|
|
91
|
+
> : T & Required<Pick<T, K>>;
|
|
92
|
+
/**
|
|
93
|
+
* pick any `property` as excludes
|
|
94
|
+
*/
|
|
95
|
+
type ExcludePick<T, K extends keyof T> = Exclude<Pick<T, K>, T>;
|
|
96
|
+
/**
|
|
97
|
+
* pick any `property` as required
|
|
98
|
+
*/
|
|
99
|
+
type RequiredPick<T, K extends keyof T> = Required<Pick<T, K>>;
|
|
100
|
+
/**
|
|
101
|
+
* pick any `property` as partial
|
|
102
|
+
*/
|
|
103
|
+
type PartialPick<T, K extends keyof T> = Partial<Pick<T, K>>;
|
|
78
104
|
type PickProperties<P, T> = { [K in keyof T]-?: T[K] extends P ? K : never }[keyof T];
|
|
79
105
|
type PickNumberProperties<T> = PickProperties<number, T>;
|
|
80
106
|
type PickStringProperties<T> = PickProperties<string, T>;
|