ts-type 2.1.10 → 3.0.2
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/CHANGELOG.md +72 -0
- package/README.md +43 -9
- package/docs/01-base-types.md +218 -0
- package/docs/02-built-in-types.md +200 -0
- package/docs/03-function-types.md +156 -0
- package/docs/04-promise-types.md +166 -0
- package/docs/05-array-tuple-types.md +159 -0
- package/docs/06-object-record-types.md +234 -0
- package/docs/07-string-number-types.md +325 -0
- package/docs/08-logic-types.md +154 -0
- package/docs/README.md +155 -0
- package/index.js +0 -2
- package/lib/_build-in.d.ts +68 -13
- package/lib/_build-in.js +7 -2
- package/lib/_build-in.js.map +1 -1
- package/lib/generic.d.ts +35 -2
- package/lib/generic.js.map +1 -1
- package/lib/helper/array/readonly.d.ts +18 -2
- package/lib/helper/array/readonly.js.map +1 -1
- package/lib/helper/filter.d.ts +72 -14
- package/lib/helper/filter.js.map +1 -1
- package/lib/helper/infer.d.ts +21 -2
- package/lib/helper/infer.js.map +1 -1
- package/lib/helper/intersection.d.ts +4 -1
- package/lib/helper/intersection.js.map +1 -1
- package/lib/helper/key-value.d.ts +99 -9
- package/lib/helper/key-value.js +5 -1
- package/lib/helper/key-value.js.map +1 -1
- package/lib/helper/number.d.ts +27 -4
- package/lib/helper/number.js.map +1 -1
- package/lib/helper/overwrite.d.ts +5 -1
- package/lib/helper/overwrite.js.map +1 -1
- package/lib/helper/promise.d.ts +11 -0
- package/lib/helper/{unpacked.js → promise.js} +1 -1
- package/lib/helper/promise.js.map +1 -0
- package/lib/helper/readonly.d.ts +124 -12
- package/lib/helper/readonly.js.map +1 -1
- package/lib/helper/record/enum.d.ts +50 -3
- package/lib/helper/record/enum.js +7 -0
- package/lib/helper/record/enum.js.map +1 -1
- package/lib/helper/record/member.d.ts +33 -3
- package/lib/helper/record/member.js +7 -0
- package/lib/helper/record/member.js.map +1 -1
- package/lib/helper/record/omit-index.d.ts +52 -3
- package/lib/helper/record/omit-index.js +7 -1
- package/lib/helper/record/omit-index.js.map +1 -1
- package/lib/helper/record/partial.d.ts +29 -2
- package/lib/helper/record/partial.js +7 -0
- package/lib/helper/record/partial.js.map +1 -1
- package/lib/helper/record/pick-one.d.ts +9 -0
- package/lib/{type/bluebird.js → helper/record/pick-one.js} +1 -4
- package/lib/helper/record/pick-one.js.map +1 -0
- package/lib/helper/record/pick-type.d.ts +16 -16
- package/lib/helper/record.d.ts +61 -10
- package/lib/helper/record.js +7 -1
- package/lib/helper/record.js.map +1 -1
- package/lib/helper/string/infer.d.ts +60 -0
- package/lib/helper/string/infer.js +10 -0
- package/lib/helper/string/infer.js.map +1 -0
- package/lib/helper/string/literal-string.d.ts +31 -4
- package/lib/helper/string/literal-string.js +7 -0
- package/lib/helper/string/literal-string.js.map +1 -1
- package/lib/helper/string.d.ts +64 -6
- package/lib/helper/string.js +7 -0
- package/lib/helper/string.js.map +1 -1
- package/lib/helper/tuple.d.ts +16 -3
- package/lib/helper/tuple.js +7 -0
- package/lib/helper/tuple.js.map +1 -1
- package/lib/helper/typeof.d.ts +36 -3
- package/lib/helper/typeof.js +6 -0
- package/lib/helper/typeof.js.map +1 -1
- package/lib/helper.d.ts +26 -11
- package/lib/helper.js.map +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.js +0 -2
- package/lib/internal/filter.d.ts +7 -0
- package/lib/internal/filter.js +7 -0
- package/lib/internal/filter.js.map +1 -1
- package/lib/internal/logic/string-literal.d.ts +37 -4
- package/lib/internal/logic/string-literal.js +7 -0
- package/lib/internal/logic/string-literal.js.map +1 -1
- package/lib/logic/any.d.ts +35 -2
- package/lib/logic/any.js +9 -0
- package/lib/logic/any.js.map +1 -1
- package/lib/logic/never.d.ts +23 -1
- package/lib/logic/never.js +7 -0
- package/lib/logic/never.js.map +1 -1
- package/lib/logic/record/empty.d.ts +1 -1
- package/lib/logic/union/index.d.ts +41 -0
- package/lib/logic/union/index.js +10 -0
- package/lib/logic/union/index.js.map +1 -0
- package/lib/type/base.d.ts +86 -10
- package/lib/type/base.js +5 -1
- package/lib/type/base.js.map +1 -1
- package/lib/type/iterator.d.ts +25 -0
- package/lib/type/iterator.js +10 -0
- package/lib/type/iterator.js.map +1 -0
- package/lib/type/promise.d.ts +63 -3
- package/lib/type/promise.js +6 -0
- package/lib/type/promise.js.map +1 -1
- package/lib/type/proxy.d.ts +20 -3
- package/lib/type/proxy.js +5 -1
- package/lib/type/proxy.js.map +1 -1
- package/lib/type/record/empty.d.ts +26 -2
- package/lib/type/record/empty.js +9 -0
- package/lib/type/record/empty.js.map +1 -1
- package/lib/type/record/enum.d.ts +65 -1
- package/lib/type/record/enum.js +7 -0
- package/lib/type/record/enum.js.map +1 -1
- package/lib/type/record/partial.d.ts +31 -2
- package/lib/type/record/partial.js +7 -0
- package/lib/type/record/partial.js.map +1 -1
- package/lib/type/record/readonly.d.ts +33 -1
- package/lib/type/record/readonly.js +7 -0
- package/lib/type/record/readonly.js.map +1 -1
- package/lib/type/record.d.ts +157 -35
- package/lib/type/record.js +6 -0
- package/lib/type/record.js.map +1 -1
- package/lib/type/tuple/empty.d.ts +16 -1
- package/lib/type/tuple/empty.js +7 -0
- package/lib/type/tuple/empty.js.map +1 -1
- package/package.json +48 -15
- package/ts-toolbelt.js +0 -2
- package/lib/helper/unpacked.d.ts +0 -13
- package/lib/helper/unpacked.js.map +0 -1
- package/lib/type/bluebird.d.ts +0 -19
- package/lib/type/bluebird.js.map +0 -1
- package/tsconfig.check.json +0 -17
- package/tsconfig.check.tsbuildinfo +0 -1
- package/tsconfig.json.tpl +0 -3
- package/tsconfig.tsbuildinfo +0 -3148
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partial.js","sourceRoot":"","sources":["partial.ts"],"names":[],"mappings":"","sourcesContent":["\nexport type ITSPartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\nexport type ITSRequireRecord<K extends keyof any, T> = {\n\t[P in K]-?: T;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"partial.js","sourceRoot":"","sources":["partial.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG","sourcesContent":["/**\n * 記錄部分類型工具\n * Record Partial Type Utilities\n * \n * 提供可選和必填記錄類型的工具\n * Provides optional and required record type utilities\n */\n\n/**\n * 可選的記錄類型\n * Optional record type\n * \n * 類似 Partial,但使用指定的鍵集合\n * Similar to Partial, but uses a specified key set\n * \n * @example\n * type PartialUser = ITSPartialRecord<'name' | 'age', string>;\n * // type PartialUser = { name?: string; age?: string; }\n */\nexport type ITSPartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\n/**\n * 必填的記錄類型\n * Required record type\n * \n * 類似 Required,但使用指定的鍵集合\n * Similar to Required, but uses a specified key set\n * \n * @example\n * type RequiredUser = ITSRequireRecord<'name' | 'age', string>;\n * // type RequiredUser = { name: string; age: string; }\n */\nexport type ITSRequireRecord<K extends keyof any, T> = {\n\t[P in K]-?: T;\n};\n"]}
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 記錄唯讀類型工具
|
|
3
|
+
* Record Readonly Type Utilities
|
|
4
|
+
*
|
|
5
|
+
* 提供唯讀和可讀寫記錄類型的工具
|
|
6
|
+
* Provides readonly and writable record type utilities
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 唯讀記錄類型
|
|
10
|
+
* Readonly record type
|
|
11
|
+
*
|
|
12
|
+
* 將指定鍵集合的所有屬性設為唯讀
|
|
13
|
+
* Makes all properties of the specified key set readonly
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* type ReadonlyUser = ITSReadonlyRecord<'name' | 'age', string>;
|
|
17
|
+
* // type ReadonlyUser = { readonly name: string; readonly age: string; }
|
|
18
|
+
*/
|
|
19
|
+
export type ITSReadonlyRecord<K extends keyof any, T> = {
|
|
2
20
|
readonly [P in K]: T;
|
|
3
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* 可讀寫記錄類型
|
|
24
|
+
* Writable record type
|
|
25
|
+
*
|
|
26
|
+
* 將指定鍵集合的所有屬性設為可讀寫(移除 readonly)
|
|
27
|
+
* Makes all properties of the specified key set writable (removes readonly)
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* type WritableUser = ITSWriteableRecord<'name' | 'age', string>;
|
|
31
|
+
* // type WritableUser = { name: string; age: string; }
|
|
32
|
+
*/
|
|
33
|
+
export type ITSWriteableRecord<K extends keyof any, T> = {
|
|
34
|
+
-readonly [P in K]: T;
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readonly.js","sourceRoot":"","sources":["readonly.ts"],"names":[],"mappings":"","sourcesContent":["\nexport type ITSReadonlyRecord<K extends keyof any, T> = {\n\treadonly [P in K]: T;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"readonly.js","sourceRoot":"","sources":["readonly.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG","sourcesContent":["/**\n * 記錄唯讀類型工具\n * Record Readonly Type Utilities\n * \n * 提供唯讀和可讀寫記錄類型的工具\n * Provides readonly and writable record type utilities\n */\n\n/**\n * 唯讀記錄類型\n * Readonly record type\n * \n * 將指定鍵集合的所有屬性設為唯讀\n * Makes all properties of the specified key set readonly\n * \n * @example\n * type ReadonlyUser = ITSReadonlyRecord<'name' | 'age', string>;\n * // type ReadonlyUser = { readonly name: string; readonly age: string; }\n */\nexport type ITSReadonlyRecord<K extends keyof any, T> = {\n\treadonly [P in K]: T;\n};\n\n/**\n * 可讀寫記錄類型\n * Writable record type\n * \n * 將指定鍵集合的所有屬性設為可讀寫(移除 readonly)\n * Makes all properties of the specified key set writable (removes readonly)\n * \n * @example\n * type WritableUser = ITSWriteableRecord<'name' | 'age', string>;\n * // type WritableUser = { name: string; age: string; }\n */\nexport type ITSWriteableRecord<K extends keyof any, T> = {\n\t-readonly [P in K]: T;\n};\n"]}
|
package/lib/type/record.d.ts
CHANGED
|
@@ -1,87 +1,209 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* 記錄(Record)類型操作工具
|
|
3
|
+
* Record Type Manipulation Utilities
|
|
4
|
+
*
|
|
5
|
+
* 提供物件類型選擇、覆寫、合併等操作
|
|
6
|
+
* Provides object type selection, overwrite, merge and other operations
|
|
7
|
+
*
|
|
2
8
|
* Created by user on 2019/6/11.
|
|
3
9
|
*/
|
|
4
|
-
import { ITSKeyofBothDiff, ITSKeyofBothSame, ITSKeyofDiff, ITSKeyofSame } from '../helper/filter';
|
|
5
|
-
export { ITSRequireRecord, ITSPartialRecord } from '../type/record/partial';
|
|
10
|
+
import type { ITSKeyofBothDiff, ITSKeyofBothSame, ITSKeyofDiff, ITSKeyofSame } from '../helper/filter';
|
|
11
|
+
export type { ITSRequireRecord, ITSPartialRecord } from '../type/record/partial';
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
13
|
+
* 取得兩個鍵集合的差異(已棄用)
|
|
14
|
+
* Get the difference between two key sets (deprecated)
|
|
15
|
+
*
|
|
16
|
+
* @deprecated 請使用 ITSKeyofDiff 取代 / Please use ITSKeyofDiff instead
|
|
8
17
|
*/
|
|
9
|
-
export
|
|
18
|
+
export type ITSDiff<T extends keyof any, U extends keyof any> = ({
|
|
10
19
|
[P in T]: P;
|
|
11
20
|
} & {
|
|
12
21
|
[P in U]: never;
|
|
13
22
|
} & {
|
|
14
23
|
[x: string]: never;
|
|
15
24
|
})[T];
|
|
16
|
-
export declare type ITSPickSame<T, U> = Pick<T, ITSKeyofSame<T, U>>;
|
|
17
|
-
export declare type ITSPickDiff<T, U> = Pick<T, ITSKeyofDiff<T, U>>;
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
26
|
+
* 選擇 T 中與 U 相同的鍵
|
|
27
|
+
* Pick keys from T that are the same as U
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* type A = { a: 1; b: 2; };
|
|
31
|
+
* type B = { a: 3; c: 4; };
|
|
32
|
+
* type Result = ITSPickSame<A, B>;
|
|
33
|
+
* // type Result = { a: 1 }
|
|
34
|
+
*/
|
|
35
|
+
export type ITSPickSame<T, U> = Pick<T, ITSKeyofSame<T, U>>;
|
|
36
|
+
/**
|
|
37
|
+
* 選擇 T 中與 U 不同的鍵
|
|
38
|
+
* Pick keys from T that are different from U
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* type A = { a: 1; b: 2; };
|
|
42
|
+
* type B = { a: 3; c: 4; };
|
|
43
|
+
* type Result = ITSPickDiff<A, B>;
|
|
44
|
+
* // type Result = { b: 2 }
|
|
20
45
|
*/
|
|
21
|
-
export
|
|
46
|
+
export type ITSPickDiff<T, U> = Pick<T, ITSKeyofDiff<T, U>>;
|
|
22
47
|
/**
|
|
23
|
-
*
|
|
48
|
+
* 選擇 T 與 U 中同時存在的鍵
|
|
49
|
+
* Pick keys that exist in both T and U
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* type A = { a: 1; b: 2; };
|
|
53
|
+
* type B = { a: 3; c: 4; };
|
|
54
|
+
* type Result = ITSPickBothSame<A, B>;
|
|
55
|
+
* // type Result = { a: 1 }
|
|
24
56
|
*/
|
|
25
|
-
export
|
|
26
|
-
export declare type ITSPickBoth<T, U, K extends ITSKeyofBothSame<T, U> = ITSKeyofBothSame<T, U>> = Pick<T & U, K>;
|
|
57
|
+
export type ITSPickBothSame<T, U> = Pick<T & U, ITSKeyofBothSame<T, U>>;
|
|
27
58
|
/**
|
|
59
|
+
* 選擇 T 與 U 中不同時存在的鍵
|
|
60
|
+
* Pick keys that do not exist in both T and U
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* type A = { a: 1; b: 2; };
|
|
64
|
+
* type B = { a: 3; c: 4; };
|
|
65
|
+
* type Result = ITSPickBothDiff<A, B>;
|
|
66
|
+
* // type Result = { b: 2; c: 4 }
|
|
67
|
+
*/
|
|
68
|
+
export type ITSPickBothDiff<T, U> = Pick<T & U, ITSKeyofBothDiff<T, U>>;
|
|
69
|
+
/**
|
|
70
|
+
* 選擇指定鍵集合 K(必須是 T 與 U 中同時存在的鍵)
|
|
71
|
+
* Pick a specified key set K (must be keys that exist in both T and U)
|
|
72
|
+
*/
|
|
73
|
+
export type ITSPickBoth<T, U, K extends ITSKeyofBothSame<T, U> = ITSKeyofBothSame<T, U>> = Pick<T & U, K>;
|
|
74
|
+
/**
|
|
75
|
+
* 取得物件成員的類型
|
|
76
|
+
* Get the type of an object member
|
|
77
|
+
*
|
|
28
78
|
* @see https://stackoverflow.com/questions/49198713/override-the-properties-of-an-interface-in-typescript
|
|
29
79
|
*/
|
|
30
|
-
export
|
|
80
|
+
export type ITSPickMember<T, K extends keyof T> = T[K];
|
|
31
81
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
82
|
+
* 排除指定鍵(已棄用)
|
|
83
|
+
* Exclude specified keys (deprecated)
|
|
84
|
+
*
|
|
85
|
+
* @deprecated 請使用 Omit 取代 / Please use Omit instead
|
|
34
86
|
*/
|
|
35
|
-
export
|
|
87
|
+
export type ITSPickNot<T, K extends keyof T> = Omit<T, K>;
|
|
36
88
|
/**
|
|
89
|
+
* 覆寫物件類型的屬性
|
|
90
|
+
* Overwrite properties of an object type
|
|
91
|
+
*
|
|
92
|
+
* 用 U 中的屬性覆寫 T 中的同名屬性
|
|
93
|
+
* Overwrites properties in T with the same name from U
|
|
94
|
+
*
|
|
37
95
|
* @see https://stackoverflow.com/questions/49198713/override-the-properties-of-an-interface-in-typescript
|
|
38
96
|
*
|
|
39
97
|
* @example
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
98
|
+
* interface A1 { s: string }
|
|
99
|
+
* type A2 = ITSOverwrite<A1, { s: number }>;
|
|
100
|
+
* // type A2 = { s: number }
|
|
43
101
|
*/
|
|
44
|
-
export
|
|
102
|
+
export type ITSOverwrite<T, U> = Omit<T, keyof U> & U;
|
|
45
103
|
/**
|
|
104
|
+
* 合併兩個物件類型,處理衝突屬性
|
|
105
|
+
* Merge two object types, handling conflicting properties
|
|
106
|
+
*
|
|
107
|
+
* 對於 T 與 U 中同時存在的鍵,取兩者的聯集類型
|
|
108
|
+
* For keys that exist in both T and U, takes the union type of both
|
|
109
|
+
*
|
|
46
110
|
* @example
|
|
47
111
|
* type Test1 = { id: number, code: string }
|
|
48
112
|
* type Test2 = { id: string, code: number }
|
|
49
113
|
* type Test3 = ITSMergeBoth<Test1, Test2>
|
|
50
|
-
*
|
|
114
|
+
* // type Test3 = { id: string | number; code: string | number }
|
|
51
115
|
* @see https://github.com/microsoft/TypeScript/issues/35627
|
|
52
116
|
*/
|
|
53
|
-
export
|
|
117
|
+
export type ITSMergeBoth<T, U> = ITSPickBothDiff<T, U> & Pick<T | U, ITSKeyofBothSame<T, U>>;
|
|
54
118
|
/**
|
|
55
|
-
*
|
|
119
|
+
* 選擇指定鍵並設為必填
|
|
120
|
+
* Pick specified keys and mark as Required
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* interface User { name?: string; age?: number; email?: string; }
|
|
124
|
+
* type RequiredName = ITSRequiredPick<User, 'name'>;
|
|
125
|
+
* // type RequiredName = { name: string; age?: number; email?: string; }
|
|
56
126
|
*/
|
|
57
|
-
export
|
|
127
|
+
export type ITSRequiredPick<T, K extends keyof T = keyof T> = {
|
|
58
128
|
[P in K]-?: T[P];
|
|
59
129
|
};
|
|
60
130
|
/**
|
|
61
|
-
*
|
|
131
|
+
* 選擇指定鍵並設為可選
|
|
132
|
+
* Pick specified keys and mark as Partial
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* interface User { name: string; age: number; email: string; }
|
|
136
|
+
* type PartialName = ITSPartialPick<User, 'name'>;
|
|
137
|
+
* // type PartialName = { name?: string; age: number; email: string; }
|
|
62
138
|
*/
|
|
63
|
-
export
|
|
139
|
+
export type ITSPartialPick<T, K extends keyof T = keyof T> = {
|
|
64
140
|
[P in K]?: T[P];
|
|
65
141
|
};
|
|
66
142
|
/**
|
|
67
|
-
*
|
|
143
|
+
* 複製類型並將指定鍵RK設為必填,其他鍵Pk設為可選
|
|
144
|
+
* Clone a type and mark specified keys as Required, other keys as Partial
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* interface User { name: string; age: number; email: string; }
|
|
148
|
+
* type Result = ITSPickExtra<User, 'name', 'email'>;
|
|
149
|
+
* // type Result = { name: string; } & { age?: number; email?: string; }
|
|
150
|
+
*/
|
|
151
|
+
export type ITSPickExtra<T, RK extends keyof T, PK extends Exclude<keyof T, RK> = Exclude<keyof T, RK>> = ITSRequiredPick<T, RK> & ITSPartialPick<T, PK>;
|
|
152
|
+
/**
|
|
153
|
+
* 複製類型並將指定鍵Pk設為可選,其他鍵Rk設為必填(與 ITSPickExtra 相反)
|
|
154
|
+
* Clone a type and mark specified keys as Partial, other keys as Required (opposite of ITSPickExtra)
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* interface User { name: string; age: number; email: string; }
|
|
158
|
+
* type Result = ITSPickExtra2<User, 'name', 'email'>;
|
|
159
|
+
* // type Result = { name?: string; } & { age: number; email: string; }
|
|
160
|
+
*/
|
|
161
|
+
export type ITSPickExtra2<T, PK extends keyof T, RK extends Exclude<keyof T, PK> = Exclude<keyof T, PK>> = ITSRequiredPick<T, RK> & ITSPartialPick<T, PK>;
|
|
162
|
+
/**
|
|
163
|
+
* 保留指定鍵為必填,其他鍵不變
|
|
164
|
+
* Keep specified keys as Required, other keys unchanged
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* interface User { name: string; age: number; email: string; }
|
|
168
|
+
* type Result = ITSRequiredWith<User, 'name'>;
|
|
169
|
+
* // type Result = { name: string; age: number; email: string; }
|
|
68
170
|
*/
|
|
69
|
-
export
|
|
171
|
+
export type ITSRequiredWith<T, K extends keyof T> = Omit<T, K> & ITSRequiredPick<T, K>;
|
|
70
172
|
/**
|
|
71
|
-
*
|
|
173
|
+
* 保留指定鍵為可選,其他鍵不變
|
|
174
|
+
* Keep specified keys as Partial, other keys unchanged
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* interface User { name: string; age: number; email: string; }
|
|
178
|
+
* type Result = ITSPartialWith<User, 'name'>;
|
|
179
|
+
* // type Result = { name?: string; age: number; email: string; }
|
|
72
180
|
*/
|
|
73
|
-
export
|
|
74
|
-
export declare type ITSRequiredWith<T, K extends keyof T> = Omit<T, K> & ITSRequiredPick<T, K>;
|
|
75
|
-
export declare type ITSPartialWith<T, K extends keyof T> = Omit<T, K> & ITSPartialPick<T, K>;
|
|
181
|
+
export type ITSPartialWith<T, K extends keyof T> = Omit<T, K> & ITSPartialPick<T, K>;
|
|
76
182
|
/**
|
|
77
|
-
*
|
|
183
|
+
* 確保物件至少具有指定的鍵集合中的一個
|
|
184
|
+
* Ensure the object has at least one of the specified key sets
|
|
185
|
+
*
|
|
186
|
+
* @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* interface User { name?: string; age?: number; }
|
|
190
|
+
* type AtLeastOne = ITSRequireAtLeastOne<User, 'name' | 'age'>;
|
|
191
|
+
* // 需要至少提供 name 或 age 其中一個
|
|
78
192
|
*/
|
|
79
|
-
export
|
|
193
|
+
export type ITSRequireAtLeastOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> & {
|
|
80
194
|
[K in Keys]-?: ITSRequiredPick<T, K> & ITSPartialPick<T, Exclude<Keys, K>>;
|
|
81
195
|
}[Keys];
|
|
82
196
|
/**
|
|
83
|
-
*
|
|
197
|
+
* 確保物件只能具有指定的鍵集合中的其中一個(互斥)
|
|
198
|
+
* Ensure the object can only have exactly one of the specified key sets (mutually exclusive)
|
|
199
|
+
*
|
|
200
|
+
* @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* interface User { name?: string; age?: number; }
|
|
204
|
+
* type OnlyOne = ITSRequireOnlyOne<User, 'name' | 'age'>;
|
|
205
|
+
* // 只能提供 name 或 age 其中一個,不能同時提供
|
|
84
206
|
*/
|
|
85
|
-
export
|
|
207
|
+
export type ITSRequireOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> & {
|
|
86
208
|
[K in Keys]-?: ITSRequiredPick<T, K> & Partial<Record<Exclude<Keys, K>, never>>;
|
|
87
209
|
}[Keys];
|
package/lib/type/record.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
+
* 記錄(Record)類型操作工具
|
|
4
|
+
* Record Type Manipulation Utilities
|
|
5
|
+
*
|
|
6
|
+
* 提供物件類型選擇、覆寫、合併等操作
|
|
7
|
+
* Provides object type selection, overwrite, merge and other operations
|
|
8
|
+
*
|
|
3
9
|
* Created by user on 2019/6/11.
|
|
4
10
|
*/
|
|
5
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/type/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["record.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["record.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG","sourcesContent":["/**\n * 記錄(Record)類型操作工具\n * Record Type Manipulation Utilities\n * \n * 提供物件類型選擇、覆寫、合併等操作\n * Provides object type selection, overwrite, merge and other operations\n * \n * Created by user on 2019/6/11.\n */\n\nimport type { ITSKeyofBothDiff, ITSKeyofBothSame, ITSKeyofDiff, ITSKeyofSame } from '../helper/filter';\n\nexport type { ITSRequireRecord, ITSPartialRecord } from '../type/record/partial';\n\n/**\n * 取得兩個鍵集合的差異(已棄用)\n * Get the difference between two key sets (deprecated)\n * \n * @deprecated 請使用 ITSKeyofDiff 取代 / Please use ITSKeyofDiff instead\n */\nexport type ITSDiff<T extends keyof any, U extends keyof any> = (\n\t{ [P in T]: P }\n\t&\n\t{ [P in U]: never }\n\t&\n\t{ [x: string]: never }\n\t)[T];\n\n/**\n * 選擇 T 中與 U 相同的鍵\n * Pick keys from T that are the same as U\n * \n * @example\n * type A = { a: 1; b: 2; };\n * type B = { a: 3; c: 4; };\n * type Result = ITSPickSame<A, B>;\n * // type Result = { a: 1 }\n */\nexport type ITSPickSame<T, U> = Pick<T, ITSKeyofSame<T, U>>;\n\n/**\n * 選擇 T 中與 U 不同的鍵\n * Pick keys from T that are different from U\n * \n * @example\n * type A = { a: 1; b: 2; };\n * type B = { a: 3; c: 4; };\n * type Result = ITSPickDiff<A, B>;\n * // type Result = { b: 2 }\n */\nexport type ITSPickDiff<T, U> = Pick<T, ITSKeyofDiff<T, U>>;\n\n/**\n * 選擇 T 與 U 中同時存在的鍵\n * Pick keys that exist in both T and U\n * \n * @example\n * type A = { a: 1; b: 2; };\n * type B = { a: 3; c: 4; };\n * type Result = ITSPickBothSame<A, B>;\n * // type Result = { a: 1 }\n */\nexport type ITSPickBothSame<T, U> = Pick<T & U, ITSKeyofBothSame<T, U>>;\n\n/**\n * 選擇 T 與 U 中不同時存在的鍵\n * Pick keys that do not exist in both T and U\n * \n * @example\n * type A = { a: 1; b: 2; };\n * type B = { a: 3; c: 4; };\n * type Result = ITSPickBothDiff<A, B>;\n * // type Result = { b: 2; c: 4 }\n */\nexport type ITSPickBothDiff<T, U> = Pick<T & U, ITSKeyofBothDiff<T, U>>;\n\n/**\n * 選擇指定鍵集合 K(必須是 T 與 U 中同時存在的鍵)\n * Pick a specified key set K (must be keys that exist in both T and U)\n */\nexport type ITSPickBoth<T, U, K extends ITSKeyofBothSame<T, U> = ITSKeyofBothSame<T, U>> = Pick<T & U, K>;\n\n/**\n * 取得物件成員的類型\n * Get the type of an object member\n * \n * @see https://stackoverflow.com/questions/49198713/override-the-properties-of-an-interface-in-typescript\n */\nexport type ITSPickMember<T, K extends keyof T> = T[K];\n\n/**\n * 排除指定鍵(已棄用)\n * Exclude specified keys (deprecated)\n * \n * @deprecated 請使用 Omit 取代 / Please use Omit instead\n */\nexport type ITSPickNot<T, K extends keyof T> = Omit<T, K>;\n\n/**\n * 覆寫物件類型的屬性\n * Overwrite properties of an object type\n * \n * 用 U 中的屬性覆寫 T 中的同名屬性\n * Overwrites properties in T with the same name from U\n * \n * @see https://stackoverflow.com/questions/49198713/override-the-properties-of-an-interface-in-typescript\n * \n * @example\n * interface A1 { s: string }\n * type A2 = ITSOverwrite<A1, { s: number }>;\n * // type A2 = { s: number }\n */\nexport type ITSOverwrite<T, U> = Omit<T, keyof U> & U;\n\n/**\n * 合併兩個物件類型,處理衝突屬性\n * Merge two object types, handling conflicting properties\n * \n * 對於 T 與 U 中同時存在的鍵,取兩者的聯集類型\n * For keys that exist in both T and U, takes the union type of both\n * \n * @example\n * type Test1 = { id: number, code: string }\n * type Test2 = { id: string, code: number }\n * type Test3 = ITSMergeBoth<Test1, Test2>\n * // type Test3 = { id: string | number; code: string | number }\n * @see https://github.com/microsoft/TypeScript/issues/35627\n */\nexport type ITSMergeBoth<T, U> = ITSPickBothDiff<T, U> & Pick<T | U, ITSKeyofBothSame<T, U>>;\n\n/**\n * 選擇指定鍵並設為必填\n * Pick specified keys and mark as Required\n * \n * @example\n * interface User { name?: string; age?: number; email?: string; }\n * type RequiredName = ITSRequiredPick<User, 'name'>;\n * // type RequiredName = { name: string; age?: number; email?: string; }\n */\nexport type ITSRequiredPick<T, K extends keyof T = keyof T> = {\n\t[P in K]-?: T[P];\n};\n\n/**\n * 選擇指定鍵並設為可選\n * Pick specified keys and mark as Partial\n * \n * @example\n * interface User { name: string; age: number; email: string; }\n * type PartialName = ITSPartialPick<User, 'name'>;\n * // type PartialName = { name?: string; age: number; email: string; }\n */\nexport type ITSPartialPick<T, K extends keyof T = keyof T> = {\n\t[P in K]?: T[P];\n};\n\n/**\n * 複製類型並將指定鍵RK設為必填,其他鍵Pk設為可選\n * Clone a type and mark specified keys as Required, other keys as Partial\n * \n * @example\n * interface User { name: string; age: number; email: string; }\n * type Result = ITSPickExtra<User, 'name', 'email'>;\n * // type Result = { name: string; } & { age?: number; email?: string; }\n */\nexport type ITSPickExtra<T, RK extends keyof T, PK extends Exclude<keyof T, RK> = Exclude<keyof T, RK>> =\n\tITSRequiredPick<T, RK>\n\t& ITSPartialPick<T, PK>;\n\n/**\n * 複製類型並將指定鍵Pk設為可選,其他鍵Rk設為必填(與 ITSPickExtra 相反)\n * Clone a type and mark specified keys as Partial, other keys as Required (opposite of ITSPickExtra)\n * \n * @example\n * interface User { name: string; age: number; email: string; }\n * type Result = ITSPickExtra2<User, 'name', 'email'>;\n * // type Result = { name?: string; } & { age: number; email: string; }\n */\nexport type ITSPickExtra2<T, PK extends keyof T, RK extends Exclude<keyof T, PK> = Exclude<keyof T, PK>> =\n\tITSRequiredPick<T, RK>\n\t& ITSPartialPick<T, PK>;\n\n/**\n * 保留指定鍵為必填,其他鍵不變\n * Keep specified keys as Required, other keys unchanged\n * \n * @example\n * interface User { name: string; age: number; email: string; }\n * type Result = ITSRequiredWith<User, 'name'>;\n * // type Result = { name: string; age: number; email: string; }\n */\nexport type ITSRequiredWith<T, K extends keyof T> = Omit<T, K> & ITSRequiredPick<T, K>;\n\n/**\n * 保留指定鍵為可選,其他鍵不變\n * Keep specified keys as Partial, other keys unchanged\n * \n * @example\n * interface User { name: string; age: number; email: string; }\n * type Result = ITSPartialWith<User, 'name'>;\n * // type Result = { name?: string; age: number; email: string; }\n */\nexport type ITSPartialWith<T, K extends keyof T> = Omit<T, K> & ITSPartialPick<T, K>;\n\n/**\n * 確保物件至少具有指定的鍵集合中的一個\n * Ensure the object has at least one of the specified key sets\n * \n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist\n * \n * @example\n * interface User { name?: string; age?: number; }\n * type AtLeastOne = ITSRequireAtLeastOne<User, 'name' | 'age'>;\n * // 需要至少提供 name 或 age 其中一個\n */\nexport type ITSRequireAtLeastOne<T, Keys extends keyof T = keyof T> =\n\tOmit<T, Keys>\n\t& {\n\t[K in Keys]-?: ITSRequiredPick<T, K>\n\t& ITSPartialPick<T, Exclude<Keys, K>>\n}[Keys];\n\n/**\n * 確保物件只能具有指定的鍵集合中的其中一個(互斥)\n * Ensure the object can only have exactly one of the specified key sets (mutually exclusive)\n * \n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist\n * \n * @example\n * interface User { name?: string; age?: number; }\n * type OnlyOne = ITSRequireOnlyOne<User, 'name' | 'age'>;\n * // 只能提供 name 或 age 其中一個,不能同時提供\n */\nexport type ITSRequireOnlyOne<T, Keys extends keyof T = keyof T> =\n\tOmit<T, Keys>\n\t& {\n\t[K in Keys]-?: ITSRequiredPick<T, K>\n\t& Partial<Record<Exclude<Keys, K>, never>>\n}[Keys];\n"]}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 空元組類型
|
|
3
|
+
* Empty Tuple Type
|
|
4
|
+
*
|
|
5
|
+
* 提供空元組相關的類型定義
|
|
6
|
+
* Provides empty tuple-related type definitions
|
|
7
|
+
*/
|
|
1
8
|
import { ITSArrayListMaybeReadonly } from '../base';
|
|
2
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 空元組類型
|
|
11
|
+
* Empty tuple type
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* type Empty = ITSEmptyTuple;
|
|
15
|
+
* // type Empty = [] | readonly []
|
|
16
|
+
*/
|
|
17
|
+
export type ITSEmptyTuple = ITSArrayListMaybeReadonly<never>;
|
package/lib/type/tuple/empty.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty.js","sourceRoot":"","sources":["empty.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"empty.js","sourceRoot":"","sources":["empty.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG","sourcesContent":["/**\n * 空元組類型\n * Empty Tuple Type\n * \n * 提供空元組相關的類型定義\n * Provides empty tuple-related type definitions\n */\n\nimport { ITSArrayListMaybeReadonly } from '../base';\n\n/**\n * 空元組類型\n * Empty tuple type\n * \n * @example\n * type Empty = ITSEmptyTuple;\n * // type Empty = [] | readonly []\n */\nexport type ITSEmptyTuple = ITSArrayListMaybeReadonly<never>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-type",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": "TypeScript 類型工具庫:提供豐富的類型操作工具和重新導出的內建類型 / TypeScript type utility library: provides rich type manipulation utilities and re-exported built-in types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".d.ts",
|
|
7
7
|
"@types",
|
|
@@ -23,9 +23,21 @@
|
|
|
23
23
|
"typescript",
|
|
24
24
|
"typing",
|
|
25
25
|
"typings",
|
|
26
|
-
"type-
|
|
26
|
+
"type-helper",
|
|
27
27
|
"toolbox",
|
|
28
|
-
"toolbelt"
|
|
28
|
+
"toolbelt",
|
|
29
|
+
"utility",
|
|
30
|
+
"utilities",
|
|
31
|
+
"type-utilities",
|
|
32
|
+
"type-manipulation",
|
|
33
|
+
"advanced-types",
|
|
34
|
+
"type-transform",
|
|
35
|
+
"type-inference",
|
|
36
|
+
"generic-types",
|
|
37
|
+
"type-safe",
|
|
38
|
+
"bilingual",
|
|
39
|
+
"chinese",
|
|
40
|
+
"english"
|
|
29
41
|
],
|
|
30
42
|
"homepage": "https://github.com/bluelovers/ws-ts-type/tree/master/packages/ts-type#readme",
|
|
31
43
|
"bugs": {
|
|
@@ -33,7 +45,8 @@
|
|
|
33
45
|
},
|
|
34
46
|
"repository": {
|
|
35
47
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/bluelovers/ws-ts-type.git"
|
|
48
|
+
"url": "git+https://github.com/bluelovers/ws-ts-type.git",
|
|
49
|
+
"directory": "packages/ts-type"
|
|
37
50
|
},
|
|
38
51
|
"license": "ISC",
|
|
39
52
|
"author": "",
|
|
@@ -43,26 +56,46 @@
|
|
|
43
56
|
"test": "test"
|
|
44
57
|
},
|
|
45
58
|
"scripts": {
|
|
59
|
+
"coverage": "yarn run test -- --coverage",
|
|
46
60
|
"pretest": "yarn run build",
|
|
47
|
-
"test": "yarn run ts:check",
|
|
61
|
+
"test": "yarn run ts:check && yarn run test:tsd",
|
|
62
|
+
"test:jest": "jest --passWithNoTests",
|
|
63
|
+
"test:jest:coverage": "node --run test:jest -- --coverage",
|
|
64
|
+
"test:jest:snapshot": "yarn run test:jest -- -u",
|
|
65
|
+
"test:snapshot": "yarn run test -- -u",
|
|
66
|
+
"test:tsd": "tsd",
|
|
48
67
|
"build": "yarn run build-lib-toc",
|
|
49
|
-
"build-lib-toc": "
|
|
50
|
-
"build:toc": "tsc
|
|
68
|
+
"build-lib-toc": "ts-node ./test/script/toc && yarn run build:toc",
|
|
69
|
+
"build:toc": "tsc --skipLibCheck & echo build:toc",
|
|
51
70
|
"preversion": "yarn run test && yarn run postpublish:git:commit",
|
|
52
71
|
"prepublishOnly": "echo prepublishOnly",
|
|
53
72
|
"postpublish:git:commit": "git commit -m \"build(release): publish\" ./lib/index.d.ts & echo postpublish:git:commit",
|
|
54
|
-
"ncu": "
|
|
55
|
-
"sort-package-json": "
|
|
56
|
-
"ts:check": "tsc
|
|
73
|
+
"ncu": "yarn-tool ncu -u",
|
|
74
|
+
"sort-package-json": "yarn-tool sort",
|
|
75
|
+
"ts:check": "tsc -p tsconfig.check.json --emitDeclarationOnly --skipLibCheck",
|
|
76
|
+
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
77
|
+
},
|
|
78
|
+
"tsd": {
|
|
79
|
+
"compilerOptions": {
|
|
80
|
+
"skipLibCheck": true,
|
|
81
|
+
"emitDeclarationOnly": true,
|
|
82
|
+
"noUnusedParameters": false,
|
|
83
|
+
"allowUnusedLabels": true,
|
|
84
|
+
"noUnusedLocals": false,
|
|
85
|
+
"noPropertyAccessFromIndexSignature": false
|
|
86
|
+
},
|
|
87
|
+
"directory": "test/spec",
|
|
88
|
+
"testFiles": [
|
|
89
|
+
"test/spec/**/*.ts"
|
|
90
|
+
]
|
|
57
91
|
},
|
|
58
92
|
"dependencies": {
|
|
59
|
-
"
|
|
93
|
+
"@types/node": "*",
|
|
94
|
+
"tslib": ">=2",
|
|
60
95
|
"typedarray-dts": "^1.0.0"
|
|
61
96
|
},
|
|
62
97
|
"peerDependencies": {
|
|
63
|
-
"@types/bluebird": "*",
|
|
64
|
-
"@types/node": "*",
|
|
65
98
|
"ts-toolbelt": "^9.6.0"
|
|
66
99
|
},
|
|
67
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "57f82cba146cfef0d0f3f138e5ec736cd17f040d"
|
|
68
101
|
}
|
package/ts-toolbelt.js
CHANGED
package/lib/helper/unpacked.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* for Iterator IteratorResult
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
|
|
6
|
-
*/
|
|
7
|
-
import { ITSMapLike, ITSResolvable, ITSTypeFunction } from '../generic';
|
|
8
|
-
export declare type ITSUnpackedReturnType<T extends (...args: any[]) => any> = ITSUnpacked<ReturnType<T>>;
|
|
9
|
-
export declare type ITSUnpacked<T> = T extends ITSMapLike<any, infer U> ? U : T extends (infer U)[] ? U : T extends ArrayLike<infer U> ? U : T extends Iterator<infer U> ? U : T extends IteratorResult<infer U> ? U : T extends ITSTypeFunction<infer U> ? U : T extends ITSResolvable<infer U> ? U : T;
|
|
10
|
-
export declare type ITSUnpackedPromiseLike<T> = T extends ITSResolvable<infer U> ? U : T;
|
|
11
|
-
export declare type ITSUnpackedIteratorLike<T extends Iterator<any> | IteratorResult<any>> = T extends Iterator<infer U> ? ITSUnpacked<U> : T extends IteratorResult<infer U> ? ITSUnpacked<U> : T;
|
|
12
|
-
export declare type ITSUnpackedArrayLike<T extends ArrayLike<any> | any[]> = T extends (infer U)[] ? ITSUnpacked<U> : T extends readonly (infer U)[] ? ITSUnpacked<U> : T extends ArrayLike<infer U> ? ITSUnpacked<U> : T;
|
|
13
|
-
export declare type ITSUnpackedThisFunction<T extends (...args: any[]) => any> = T extends (this: infer R, ...args: any[]) => any ? R : unknown;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpacked.js","sourceRoot":"","sources":["unpacked.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * for Iterator IteratorResult\n */\n/**\n * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html\n */\nimport { ITSMapLike, ITSResolvable, ITSTypeFunction } from '../generic';\n\nexport type ITSUnpackedReturnType<T extends (...args: any[]) => any> =\n\tITSUnpacked<ReturnType<T>>\n//\tT extends ITSTypeFunction<infer R>\n//\t\t? ITSUnpacked<R>\n//\t\t: T\n\t;\nexport type ITSUnpacked<T> =\n\tT extends ITSMapLike<any, infer U> ? U :\n\t\tT extends (infer U)[] ? U :\n\t\t\tT extends ArrayLike<infer U> ? U :\n\t\t\t\tT extends Iterator<infer U> ? U :\n\t\t\t\t\tT extends IteratorResult<infer U> ? U :\n\t\t\t\t\t\tT extends ITSTypeFunction<infer U> ? U :\n\t\t\t\t\t\t\tT extends ITSResolvable<infer U> ? U :\n\t\t\t\t\t\t\t\t//T extends Promise<infer U> ? U :\n\t\t\t\t\t\t\t\tT\n\t;\nexport type ITSUnpackedPromiseLike<T> =\n\tT extends ITSResolvable<infer U> ? U :\n\t\tT\n\t;\nexport type ITSUnpackedIteratorLike<T extends Iterator<any> | IteratorResult<any>> =\n\tT extends Iterator<infer U> ? ITSUnpacked<U> :\n\t\tT extends IteratorResult<infer U> ? ITSUnpacked<U> :\n\t\t\tT\n\t;\nexport type ITSUnpackedArrayLike<T extends ArrayLike<any> | any[]> =\n\tT extends (infer U)[] ? ITSUnpacked<U> :\n\t\tT extends readonly (infer U)[] ? ITSUnpacked<U> :\n\t\t\tT extends ArrayLike<infer U> ? ITSUnpacked<U> :\n\t\t\t\tT\n\t;\n\nexport type ITSUnpackedThisFunction<T extends (...args: any[]) => any> =\n\tT extends (this: infer R, ...args: any[]) => any\n\t\t? R\n\t\t: unknown;\n"]}
|
package/lib/type/bluebird.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by user on 2019/5/17.
|
|
3
|
-
*/
|
|
4
|
-
import Bluebird from 'bluebird';
|
|
5
|
-
import { ITSUnpackedReturnType, ITSKeyOfRecordExtractToKey, ITSUnpackedPromiseLike, ITSAnyFunction } from '..';
|
|
6
|
-
export declare type IBluebird<T> = Bluebird<T>;
|
|
7
|
-
export declare type ITSBluebird<T> = Bluebird<T>;
|
|
8
|
-
export declare type ITSWrapFunctionBluebird<T extends (...args: any[]) => any> = (...args: Parameters<T>) => IBluebird<ITSUnpackedReturnType<T>>;
|
|
9
|
-
export declare type ITSBluebirdPromisifyAll<T extends {
|
|
10
|
-
[p: string | symbol]: ITSAnyFunction;
|
|
11
|
-
}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {
|
|
12
|
-
[P in K]: (...argv: Parameters<T[P]>) => IBluebird<ITSUnpackedPromiseLike<ReturnType<T[P]>>>;
|
|
13
|
-
};
|
|
14
|
-
export declare type ITSPromisifyAll<T extends {
|
|
15
|
-
[p: string | symbol]: ITSAnyFunction;
|
|
16
|
-
}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {
|
|
17
|
-
[P in K]: (...argv: Parameters<T[P]>) => Promise<ITSUnpackedPromiseLike<ReturnType<T[P]>>>;
|
|
18
|
-
};
|
|
19
|
-
export declare type ITSResultArrayToBluebirdInspection<T> = T extends [infer T1, infer T2, infer T3, infer T4, infer T5] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>, Bluebird.Inspection<T5>] : T extends [infer T1, infer T2, infer T3, infer T4] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>] : T extends [infer T1, infer T2, infer T3] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>] : T extends [infer T1, infer T2] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>] : T extends [infer T1] ? [Bluebird.Inspection<T1>] : T extends (infer R)[] ? Bluebird.Inspection<R>[] : never;
|
package/lib/type/bluebird.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bluebird.js","sourceRoot":"","sources":["bluebird.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Created by user on 2019/5/17.\n */\n\nimport Bluebird from 'bluebird';\nimport { ITSUnpackedReturnType, ITSKeyOfRecordExtractToKey, ITSUnpackedPromiseLike, ITSAnyFunction } from '..';\n\nexport type IBluebird<T> = Bluebird<T>;\nexport type ITSBluebird<T> = Bluebird<T>;\n\nexport type ITSWrapFunctionBluebird<T extends (...args: any[]) => any> =\n\t(...args: Parameters<T>) => IBluebird<ITSUnpackedReturnType<T>>;\n\nexport type ITSBluebirdPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => IBluebird<ITSUnpackedPromiseLike<ReturnType<T[P]>>>\n}\n\nexport type ITSPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => Promise<ITSUnpackedPromiseLike<ReturnType<T[P]>>>\n}\n\nexport type ITSResultArrayToBluebirdInspection<T> = T extends [infer T1, infer T2, infer T3, infer T4, infer T5] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>, Bluebird.Inspection<T5>] : T extends [infer T1, infer T2, infer T3, infer T4] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>] : T extends [infer T1, infer T2, infer T3] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>] : T extends [infer T1, infer T2] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>] : T extends [infer T1] ? [Bluebird.Inspection<T1>] : T extends (infer R)[] ? Bluebird.Inspection<R>[] : never;\n"]}
|
package/tsconfig.check.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@bluelovers/tsconfig/esm/mapfile.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"skipLibCheck": true,
|
|
5
|
-
"noEmit": true,
|
|
6
|
-
"declaration": false
|
|
7
|
-
},
|
|
8
|
-
"exclude": [
|
|
9
|
-
"node_modules",
|
|
10
|
-
"./node_modules",
|
|
11
|
-
"./node_modules/*",
|
|
12
|
-
"**/node_modules/*",
|
|
13
|
-
"**/test/script/*",
|
|
14
|
-
"**/test/demo/*",
|
|
15
|
-
"**/test/temp/*"
|
|
16
|
-
]
|
|
17
|
-
}
|