type-plus 7.4.0 → 7.6.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/README.md +81 -92
- package/cjs/array/array.entries.d.ts +4 -3
- package/cjs/array/array.entries.d.ts.map +1 -1
- package/cjs/array/array_index.d.ts +4 -1
- package/cjs/array/array_index.d.ts.map +1 -1
- package/cjs/array/array_plus.common_prop_keys.d.ts +27 -0
- package/cjs/array/array_plus.common_prop_keys.d.ts.map +1 -0
- package/cjs/array/array_plus.common_prop_keys.js +3 -0
- package/cjs/array/array_plus.common_prop_keys.js.map +1 -0
- package/cjs/array/array_plus.d.ts +6 -3
- package/cjs/array/array_plus.d.ts.map +1 -1
- package/cjs/array/array_plus.drop_match.d.ts +4 -0
- package/cjs/array/array_plus.drop_match.d.ts.map +1 -0
- package/cjs/array/array_plus.drop_match.js +3 -0
- package/cjs/array/array_plus.drop_match.js.map +1 -0
- package/cjs/array/array_plus.element_match.d.ts +44 -0
- package/cjs/array/array_plus.element_match.d.ts.map +1 -0
- package/cjs/array/array_plus.element_match.js +3 -0
- package/cjs/array/array_plus.element_match.js.map +1 -0
- package/cjs/array/array_plus.find.d.ts +57 -0
- package/cjs/array/array_plus.find.d.ts.map +1 -0
- package/cjs/array/array_plus.find.js +3 -0
- package/cjs/array/array_plus.find.js.map +1 -0
- package/cjs/array/array_plus.split_at.d.ts +20 -15
- package/cjs/array/array_plus.split_at.d.ts.map +1 -1
- package/cjs/array/find_first.d.ts +62 -0
- package/cjs/array/find_first.d.ts.map +1 -0
- package/cjs/array/{array.find.js → find_first.js} +1 -1
- package/cjs/array/find_first.js.map +1 -0
- package/cjs/array/head.d.ts +18 -6
- package/cjs/array/head.d.ts.map +1 -1
- package/cjs/array/last.d.ts +17 -6
- package/cjs/array/last.d.ts.map +1 -1
- package/cjs/assertion/assert_type.d.ts +4 -1
- package/cjs/assertion/assert_type.d.ts.map +1 -1
- package/cjs/assertion/assert_type.js.map +1 -1
- package/cjs/index.d.ts +5 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/never/never_type.d.ts +11 -0
- package/cjs/never/never_type.d.ts.map +1 -1
- package/cjs/object/index.d.ts +0 -1
- package/cjs/object/index.d.ts.map +1 -1
- package/cjs/object/index.js.map +1 -1
- package/cjs/testing/test_type.d.ts +277 -276
- package/cjs/testing/test_type.d.ts.map +1 -1
- package/cjs/testing/test_type.js.map +1 -1
- package/cjs/tuple/common_prop_keys.d.ts +15 -10
- package/cjs/tuple/common_prop_keys.d.ts.map +1 -1
- package/cjs/tuple/drop.d.ts +45 -26
- package/cjs/tuple/drop.d.ts.map +1 -1
- package/cjs/tuple/drop.js.map +1 -1
- package/cjs/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.js +3 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.js.map +1 -0
- package/cjs/tuple/tuple_plus.d.ts +3 -0
- package/cjs/tuple/tuple_plus.d.ts.map +1 -1
- package/cjs/tuple/tuple_plus.drop_match.d.ts +6 -0
- package/cjs/tuple/tuple_plus.drop_match.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.drop_match.js +3 -0
- package/cjs/tuple/tuple_plus.drop_match.js.map +1 -0
- package/cjs/tuple/tuple_plus.filter.d.ts +2 -2
- package/cjs/tuple/tuple_plus.find.d.ts +64 -0
- package/cjs/tuple/tuple_plus.find.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.find.js +3 -0
- package/cjs/tuple/tuple_plus.find.js.map +1 -0
- package/cjs/tuple/tuple_plus.pad_start.d.ts +7 -6
- package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- package/cjs/tuple/tuple_type.d.ts +41 -23
- package/cjs/tuple/tuple_type.d.ts.map +1 -1
- package/cjs/union/union.d.ts +33 -0
- package/cjs/union/union.d.ts.map +1 -0
- package/cjs/union/union.js +3 -0
- package/cjs/union/union.js.map +1 -0
- package/cjs/unknown/unknown_type.d.ts +12 -0
- package/cjs/unknown/unknown_type.d.ts.map +1 -1
- package/cjs/utils/options.d.ts +10 -0
- package/cjs/utils/options.d.ts.map +1 -0
- package/cjs/utils/options.js +3 -0
- package/cjs/utils/options.js.map +1 -0
- package/esm/array/array.entries.d.ts +4 -3
- package/esm/array/array.entries.d.ts.map +1 -1
- package/esm/array/array_index.d.ts +4 -1
- package/esm/array/array_index.d.ts.map +1 -1
- package/esm/array/array_plus.common_prop_keys.d.ts +27 -0
- package/esm/array/array_plus.common_prop_keys.d.ts.map +1 -0
- package/esm/array/array_plus.common_prop_keys.js +2 -0
- package/esm/array/array_plus.common_prop_keys.js.map +1 -0
- package/esm/array/array_plus.d.ts +6 -3
- package/esm/array/array_plus.d.ts.map +1 -1
- package/esm/array/array_plus.drop_match.d.ts +4 -0
- package/esm/array/array_plus.drop_match.d.ts.map +1 -0
- package/esm/array/array_plus.drop_match.js +2 -0
- package/esm/array/array_plus.drop_match.js.map +1 -0
- package/esm/array/array_plus.element_match.d.ts +44 -0
- package/esm/array/array_plus.element_match.d.ts.map +1 -0
- package/esm/array/array_plus.element_match.js +2 -0
- package/esm/array/array_plus.element_match.js.map +1 -0
- package/esm/array/array_plus.find.d.ts +57 -0
- package/esm/array/array_plus.find.d.ts.map +1 -0
- package/esm/array/array_plus.find.js +2 -0
- package/esm/array/array_plus.find.js.map +1 -0
- package/esm/array/array_plus.split_at.d.ts +20 -15
- package/esm/array/array_plus.split_at.d.ts.map +1 -1
- package/esm/array/find_first.d.ts +62 -0
- package/esm/array/find_first.d.ts.map +1 -0
- package/esm/array/find_first.js +2 -0
- package/esm/array/find_first.js.map +1 -0
- package/esm/array/head.d.ts +18 -6
- package/esm/array/head.d.ts.map +1 -1
- package/esm/array/last.d.ts +17 -6
- package/esm/array/last.d.ts.map +1 -1
- package/esm/assertion/assert_type.d.ts +4 -1
- package/esm/assertion/assert_type.d.ts.map +1 -1
- package/esm/assertion/assert_type.js.map +1 -1
- package/esm/index.d.ts +5 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/never/never_type.d.ts +11 -0
- package/esm/never/never_type.d.ts.map +1 -1
- package/esm/object/index.d.ts +0 -1
- package/esm/object/index.d.ts.map +1 -1
- package/esm/object/index.js.map +1 -1
- package/esm/testing/test_type.d.ts +277 -276
- package/esm/testing/test_type.d.ts.map +1 -1
- package/esm/testing/test_type.js.map +1 -1
- package/esm/tuple/common_prop_keys.d.ts +15 -10
- package/esm/tuple/common_prop_keys.d.ts.map +1 -1
- package/esm/tuple/drop.d.ts +45 -26
- package/esm/tuple/drop.d.ts.map +1 -1
- package/esm/tuple/drop.js.map +1 -1
- package/esm/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
- package/esm/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.common_prop_keys.js +2 -0
- package/esm/tuple/tuple_plus.common_prop_keys.js.map +1 -0
- package/esm/tuple/tuple_plus.d.ts +3 -0
- package/esm/tuple/tuple_plus.d.ts.map +1 -1
- package/esm/tuple/tuple_plus.drop_match.d.ts +6 -0
- package/esm/tuple/tuple_plus.drop_match.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.drop_match.js +2 -0
- package/esm/tuple/tuple_plus.drop_match.js.map +1 -0
- package/esm/tuple/tuple_plus.filter.d.ts +2 -2
- package/esm/tuple/tuple_plus.find.d.ts +64 -0
- package/esm/tuple/tuple_plus.find.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.find.js +2 -0
- package/esm/tuple/tuple_plus.find.js.map +1 -0
- package/esm/tuple/tuple_plus.pad_start.d.ts +7 -6
- package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- package/esm/tuple/tuple_type.d.ts +41 -23
- package/esm/tuple/tuple_type.d.ts.map +1 -1
- package/esm/union/union.d.ts +33 -0
- package/esm/union/union.d.ts.map +1 -0
- package/esm/union/union.js +2 -0
- package/esm/union/union.js.map +1 -0
- package/esm/unknown/unknown_type.d.ts +12 -0
- package/esm/unknown/unknown_type.d.ts.map +1 -1
- package/esm/utils/options.d.ts +10 -0
- package/esm/utils/options.d.ts.map +1 -0
- package/esm/utils/options.js +2 -0
- package/esm/utils/options.js.map +1 -0
- package/package.json +12 -1
- package/ts/array/array.entries.ts +4 -2
- package/ts/array/array_index.ts +33 -23
- package/ts/array/array_plus.common_prop_keys.ts +35 -0
- package/ts/array/array_plus.drop_match.ts +16 -0
- package/ts/array/array_plus.element_match.ts +61 -0
- package/ts/array/array_plus.find.ts +71 -0
- package/ts/array/array_plus.split_at.ts +52 -23
- package/ts/array/array_plus.ts +6 -3
- package/ts/array/find_first.ts +71 -0
- package/ts/array/head.ts +28 -6
- package/ts/array/last.ts +26 -6
- package/ts/array/readme.md +152 -32
- package/ts/assertion/assert_type.ts +4 -1
- package/ts/assertion/readme.md +3 -2
- package/ts/index.ts +5 -5
- package/ts/never/never_type.ts +13 -0
- package/ts/object/index.ts +0 -1
- package/ts/testing/test_type.ts +279 -277
- package/ts/tuple/common_prop_keys.ts +18 -32
- package/ts/tuple/drop.ts +61 -60
- package/ts/tuple/readme.md +178 -39
- package/ts/tuple/tuple_plus.common_prop_keys.ts +47 -0
- package/ts/tuple/tuple_plus.drop_match.ts +20 -0
- package/ts/tuple/tuple_plus.filter.ts +2 -2
- package/ts/tuple/tuple_plus.find.ts +88 -0
- package/ts/tuple/tuple_plus.pad_start.ts +28 -25
- package/ts/tuple/tuple_plus.ts +3 -0
- package/ts/tuple/tuple_type.ts +67 -25
- package/ts/union/readme.md +81 -0
- package/ts/union/union.ts +37 -0
- package/ts/unknown/unknown_type.ts +13 -0
- package/ts/utils/options.ts +10 -0
- package/cjs/array/array.find.d.ts +0 -23
- package/cjs/array/array.find.d.ts.map +0 -1
- package/cjs/array/array.find.js.map +0 -1
- package/esm/array/array.find.d.ts +0 -23
- package/esm/array/array.find.d.ts.map +0 -1
- package/esm/array/array.find.js +0 -2
- package/esm/array/array.find.js.map +0 -1
- package/ts/array/array.find.ts +0 -34
|
@@ -22,214 +22,282 @@ import type { IsTuple } from '../tuple/tuple_type.js';
|
|
|
22
22
|
import type { IsUndefined } from '../undefined/undefined_type.js';
|
|
23
23
|
import type { IsUnknown } from '../unknown/unknown_type.js';
|
|
24
24
|
import type { IsVoid } from '../void/void_type.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
25
|
+
export declare namespace testType {
|
|
26
|
+
interface TestType {
|
|
27
|
+
/**
|
|
28
|
+
* Check if type `A` is equal to type `B` and `C`.
|
|
29
|
+
*
|
|
30
|
+
* @return `expected` as `A` for type inspection.
|
|
31
|
+
*/
|
|
32
|
+
equal<A, B, C>(expected: IsEqual<A, B> & IsEqual<A, C>): A;
|
|
33
|
+
/**
|
|
34
|
+
* Check if type `A` is equal to type `B`.
|
|
35
|
+
*
|
|
36
|
+
* @return `expected` as `A` for type inspection.
|
|
37
|
+
*/
|
|
38
|
+
equal<A, B>(expected: IsEqual<A, B>): A;
|
|
39
|
+
/**
|
|
40
|
+
* Check if `A` can assign to `B`.
|
|
41
|
+
*
|
|
42
|
+
* If `A` is a union,
|
|
43
|
+
* the check is distributive.
|
|
44
|
+
*
|
|
45
|
+
* Meaning the result can be `boolean`,
|
|
46
|
+
* meaning both `true` and `false` will pass.
|
|
47
|
+
*
|
|
48
|
+
* If you want to avoid the distributivity,
|
|
49
|
+
* use `testType.strictCanAssign()` instead.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* testType.canAssign<123, number> // true
|
|
54
|
+
*
|
|
55
|
+
* testType.canAssign<number | string, number> // boolean
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @return `expected` as `A` for type inspection.
|
|
59
|
+
*/
|
|
60
|
+
canAssign<A, B>(expected: CanAssign<A, B>): A;
|
|
61
|
+
/**
|
|
62
|
+
* Check if `A` can fully assign to `B`.
|
|
63
|
+
*
|
|
64
|
+
* This checks all branches in an union `A` are assignable to `B`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* testType.strictCanAssign<number | string, number | string> // true
|
|
69
|
+
*
|
|
70
|
+
* testType.strictCanAssign<number | string, number> // false
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @return `expected` as `A` for type inspection.
|
|
74
|
+
*/
|
|
75
|
+
strictCanAssign<A, B>(expected: StrictCanAssign<A, B>): A;
|
|
76
|
+
/**
|
|
77
|
+
* Check if type `T` is exactly `any`.
|
|
78
|
+
*
|
|
79
|
+
* @return `expected` as `T` for type inspection.
|
|
80
|
+
*/
|
|
81
|
+
any<T>(expected: IsAny<T>): T;
|
|
82
|
+
/**
|
|
83
|
+
* Check if type `T` is exactly `array`.
|
|
84
|
+
*
|
|
85
|
+
* @return `expected` as `T` for type inspection.
|
|
86
|
+
*/
|
|
87
|
+
array<T>(expected: IsArray<T>): T;
|
|
88
|
+
/**
|
|
89
|
+
* Check if type `T` is exactly `bigint`.
|
|
90
|
+
*
|
|
91
|
+
* @return `expected` as `T` for type inspection.
|
|
92
|
+
*/
|
|
93
|
+
strictBigint<T>(expected: IsStrictBigint<T>): T;
|
|
94
|
+
/**
|
|
95
|
+
* Check if type `T` is `bigint` or bigint literals.
|
|
96
|
+
*
|
|
97
|
+
* @return `expected` as `T` for type inspection.
|
|
98
|
+
*/
|
|
99
|
+
bigint<T>(expected: IsBigint<T>): T;
|
|
100
|
+
/**
|
|
101
|
+
* Check if type `T` is exactly `boolean`.
|
|
102
|
+
*
|
|
103
|
+
* @return `expected` as `T` for type inspection.
|
|
104
|
+
*/
|
|
105
|
+
strictBoolean<T>(expected: IsStrictBoolean<T>): T;
|
|
106
|
+
/**
|
|
107
|
+
* Check if type `T` is `boolean` and boolean literals.
|
|
108
|
+
*
|
|
109
|
+
* @return `expected` as `T` for type inspection.
|
|
110
|
+
*/
|
|
111
|
+
boolean<T>(expected: IsBoolean<T>): T;
|
|
112
|
+
/**
|
|
113
|
+
* Check if type `T` is exactly `true`.
|
|
114
|
+
*
|
|
115
|
+
* @return `expected` as `T` for type inspection.
|
|
116
|
+
*/
|
|
117
|
+
true<T>(expected: IsTrue<T>): T;
|
|
118
|
+
/**
|
|
119
|
+
* Check if type `T` is exactly `false`.
|
|
120
|
+
*
|
|
121
|
+
* @return `expected` as `T` for type inspection.
|
|
122
|
+
*/
|
|
123
|
+
false<T>(expected: IsFalse<T>): T;
|
|
124
|
+
/**
|
|
125
|
+
* Check if type `T` is exactly `boolean`.
|
|
126
|
+
*
|
|
127
|
+
* @return `expected` as `T` for type inspection.
|
|
128
|
+
*/
|
|
129
|
+
strictFunction<T>(expected: IsStrictFunction<T>): T;
|
|
130
|
+
/**
|
|
131
|
+
* Check if type `T` is `boolean` and boolean literals.
|
|
132
|
+
*
|
|
133
|
+
* @return `expected` as `T` for type inspection.
|
|
134
|
+
*/
|
|
135
|
+
function<T>(expected: IsFunction<T>): T;
|
|
136
|
+
/**
|
|
137
|
+
* Check if type `T` is exactly `never`.
|
|
138
|
+
*
|
|
139
|
+
* @return `expected` as `T` for type inspection.
|
|
140
|
+
*/
|
|
141
|
+
never<T>(expected: IsNever<T>): T;
|
|
142
|
+
/**
|
|
143
|
+
* Check if type `T` is exactly `null`.
|
|
144
|
+
*
|
|
145
|
+
* @return `expected` as `T` for type inspection.
|
|
146
|
+
*/
|
|
147
|
+
null<T>(expected: IsNull<T>): T;
|
|
148
|
+
/**
|
|
149
|
+
* Check if type `T` is exactly `number`.
|
|
150
|
+
*
|
|
151
|
+
* @return `expected` as `T` for type inspection.
|
|
152
|
+
*/
|
|
153
|
+
strictNumber<T>(expected: IsStrictNumber<T>): T;
|
|
154
|
+
/**
|
|
155
|
+
* Check if type `T` is `number` or number literals.
|
|
156
|
+
*
|
|
157
|
+
* @return `expected` as `T` for type inspection.
|
|
158
|
+
*/
|
|
159
|
+
number<T>(expected: IsNumber<T>): T;
|
|
160
|
+
/**
|
|
161
|
+
* Check if type `T` is `object`.
|
|
162
|
+
*
|
|
163
|
+
* Note that `Function`, `Array`, and *tuple* are also `object`.
|
|
164
|
+
*
|
|
165
|
+
* @return `expected` as `T` for type inspection.
|
|
166
|
+
*/
|
|
167
|
+
object<T>(expected: IsObject<T>): T;
|
|
168
|
+
/**
|
|
169
|
+
* Check if type `T` is exactly `string`.
|
|
170
|
+
*
|
|
171
|
+
* @return `expected` as `T` for type inspection.
|
|
172
|
+
*/
|
|
173
|
+
strictString<T>(expected: IsStrictString<T>): T;
|
|
174
|
+
/**
|
|
175
|
+
* Check if type `T` is `string` or string literals.
|
|
176
|
+
*
|
|
177
|
+
* @return `expected` as `T` for type inspection.
|
|
178
|
+
*/
|
|
179
|
+
string<T>(expected: IsString<T>): T;
|
|
180
|
+
/**
|
|
181
|
+
* Check if type `T` is a `symbol`.
|
|
182
|
+
*
|
|
183
|
+
* @return `expected` as `T` for type inspection.
|
|
184
|
+
*/
|
|
185
|
+
symbol<T>(expected: IsSymbol<T>): T;
|
|
186
|
+
/**
|
|
187
|
+
* Check if type `T` is a *tuple*.
|
|
188
|
+
*
|
|
189
|
+
* @return `expected` as `T` for type inspection.
|
|
190
|
+
*/
|
|
191
|
+
tuple<T>(expected: IsTuple<T>): T;
|
|
192
|
+
/**
|
|
193
|
+
* Check if type `T` is exactly `undefined`.
|
|
194
|
+
*
|
|
195
|
+
* @return `expected` as `T` for type inspection.
|
|
196
|
+
*/
|
|
197
|
+
undefined<T>(expected: IsUndefined<T>): T;
|
|
198
|
+
/**
|
|
199
|
+
* Check if type `T` is exactly `unknown`.
|
|
200
|
+
*
|
|
201
|
+
* @return `expected` as `T` for type inspection.
|
|
202
|
+
*/
|
|
203
|
+
unknown<T>(expected: IsUnknown<T>): T;
|
|
204
|
+
/**
|
|
205
|
+
* Check if type `T` is exactly `void`.
|
|
206
|
+
*
|
|
207
|
+
* @return `expected` as `T` for type inspection.
|
|
208
|
+
*/
|
|
209
|
+
void<T>(expected: IsVoid<T>): T;
|
|
210
|
+
/**
|
|
211
|
+
* A quick way to inspect a type.
|
|
212
|
+
*
|
|
213
|
+
* The handler receives a `InspectedType` object.
|
|
214
|
+
* It contains `value` which is typed to `T`,
|
|
215
|
+
* and many other properties to inspect the behavior of `T`.
|
|
216
|
+
*
|
|
217
|
+
* The handler is not being call,
|
|
218
|
+
* it is use to hold the type in value for inspection.
|
|
219
|
+
*
|
|
220
|
+
* 🧪 *testing*
|
|
221
|
+
* 🦴 *utilities*
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* testType.inspect<SomeType>(t => {
|
|
226
|
+
* type T = typeof t.value // resolve and inspect the type `T`
|
|
227
|
+
* t.extend_boolean // result of `T extends boolean`
|
|
228
|
+
* })
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* After trying out the type, remove the line.
|
|
232
|
+
*/
|
|
233
|
+
inspect<T>(handler: (t: InspectedType<T>) => unknown): T;
|
|
234
|
+
}
|
|
235
|
+
type InspectedType<T> = {
|
|
236
|
+
type: T;
|
|
237
|
+
extends<R>(): T extends R ? true : false;
|
|
238
|
+
extends_any: T extends any ? true : false;
|
|
239
|
+
extends_unknown: T extends unknown ? true : false;
|
|
240
|
+
extends_void: T extends void ? true : false;
|
|
241
|
+
extends_never: T extends never ? true : false;
|
|
242
|
+
extends_undefined: T extends undefined ? true : false;
|
|
243
|
+
extends_null: T extends null ? true : false;
|
|
244
|
+
extends_boolean: T extends boolean ? true : false;
|
|
245
|
+
extends_true: T extends true ? true : false;
|
|
246
|
+
extends_false: T extends false ? true : false;
|
|
247
|
+
extends_number: T extends number ? true : false;
|
|
248
|
+
extends_1: T extends 1 ? true : false;
|
|
249
|
+
extends_bigint: T extends bigint ? true : false;
|
|
250
|
+
extends_1n: T extends 1n ? true : false;
|
|
251
|
+
extends_string: T extends string ? true : false;
|
|
252
|
+
extends_a: T extends 'a' ? true : false;
|
|
253
|
+
extends_symbol: T extends symbol ? true : false;
|
|
254
|
+
extends_object: T extends object ? true : false;
|
|
255
|
+
extends_function: T extends Function ? true : false;
|
|
256
|
+
extends_array_unknown: T extends unknown[] ? true : false;
|
|
257
|
+
extends_tuple_empty: T extends [] ? true : false;
|
|
258
|
+
union<R>(): T | R;
|
|
259
|
+
union_any: T | any;
|
|
260
|
+
union_unknown: T | unknown;
|
|
261
|
+
union_void: T | void;
|
|
262
|
+
union_never: T | never;
|
|
263
|
+
union_undefined: T | undefined;
|
|
264
|
+
union_null: T | null;
|
|
265
|
+
union_boolean: T | boolean;
|
|
266
|
+
union_true: T | true;
|
|
267
|
+
union_false: T | false;
|
|
268
|
+
union_number: T | number;
|
|
269
|
+
union_1: T | 1;
|
|
270
|
+
union_bigint: T | bigint;
|
|
271
|
+
union_1n: T | 1n;
|
|
272
|
+
union_string: T | string;
|
|
273
|
+
union_a: T | 'a';
|
|
274
|
+
union_symbol: T | symbol;
|
|
275
|
+
union_object: T | object;
|
|
276
|
+
union_function: T | Function;
|
|
277
|
+
union_array_unknown: T | unknown[];
|
|
278
|
+
union_tuple_empty: T | [];
|
|
279
|
+
intersect<R>(): T & R;
|
|
280
|
+
intersect_any: T & any;
|
|
281
|
+
intersect_unknown: T & unknown;
|
|
282
|
+
intersect_void: T & void;
|
|
283
|
+
intersect_never: T & never;
|
|
284
|
+
intersect_undefined: T & undefined;
|
|
285
|
+
intersect_null: T & null;
|
|
286
|
+
intersect_boolean: T & boolean;
|
|
287
|
+
intersect_true: T & true;
|
|
288
|
+
intersect_false: T & false;
|
|
289
|
+
intersect_number: T & number;
|
|
290
|
+
intersect_1: T & 1;
|
|
291
|
+
intersect_bigint: T & bigint;
|
|
292
|
+
intersect_1n: T & 1n;
|
|
293
|
+
intersect_string: T & string;
|
|
294
|
+
intersect_a: T & 'a';
|
|
295
|
+
intersect_symbol: T & symbol;
|
|
296
|
+
intersect_object: T & object;
|
|
297
|
+
intersect_function: T & Function;
|
|
298
|
+
intersect_array_unknown: T & unknown[];
|
|
299
|
+
intersect_tuple_empty: T & [];
|
|
300
|
+
};
|
|
233
301
|
}
|
|
234
302
|
/**
|
|
235
303
|
* Test utilities for types.
|
|
@@ -238,72 +306,5 @@ interface TestType {
|
|
|
238
306
|
* The return value is the input `expected` parameter asserted as the first type parameter,
|
|
239
307
|
* so that the type can be further inspected.
|
|
240
308
|
*/
|
|
241
|
-
export declare const testType: TestType;
|
|
242
|
-
export type InspectedType<T> = {
|
|
243
|
-
type: T;
|
|
244
|
-
extends<R>(): T extends R ? true : false;
|
|
245
|
-
extends_any: T extends any ? true : false;
|
|
246
|
-
extends_unknown: T extends unknown ? true : false;
|
|
247
|
-
extends_void: T extends void ? true : false;
|
|
248
|
-
extends_never: T extends never ? true : false;
|
|
249
|
-
extends_undefined: T extends undefined ? true : false;
|
|
250
|
-
extends_null: T extends null ? true : false;
|
|
251
|
-
extends_boolean: T extends boolean ? true : false;
|
|
252
|
-
extends_true: T extends true ? true : false;
|
|
253
|
-
extends_false: T extends false ? true : false;
|
|
254
|
-
extends_number: T extends number ? true : false;
|
|
255
|
-
extends_1: T extends 1 ? true : false;
|
|
256
|
-
extends_bigint: T extends bigint ? true : false;
|
|
257
|
-
extends_1n: T extends 1n ? true : false;
|
|
258
|
-
extends_string: T extends string ? true : false;
|
|
259
|
-
extends_a: T extends 'a' ? true : false;
|
|
260
|
-
extends_symbol: T extends symbol ? true : false;
|
|
261
|
-
extends_object: T extends object ? true : false;
|
|
262
|
-
extends_function: T extends Function ? true : false;
|
|
263
|
-
extends_array_unknown: T extends unknown[] ? true : false;
|
|
264
|
-
extends_tuple_empty: T extends [] ? true : false;
|
|
265
|
-
union<R>(): T | R;
|
|
266
|
-
union_any: T | any;
|
|
267
|
-
union_unknown: T | unknown;
|
|
268
|
-
union_void: T | void;
|
|
269
|
-
union_never: T | never;
|
|
270
|
-
union_undefined: T | undefined;
|
|
271
|
-
union_null: T | null;
|
|
272
|
-
union_boolean: T | boolean;
|
|
273
|
-
union_true: T | true;
|
|
274
|
-
union_false: T | false;
|
|
275
|
-
union_number: T | number;
|
|
276
|
-
union_1: T | 1;
|
|
277
|
-
union_bigint: T | bigint;
|
|
278
|
-
union_1n: T | 1n;
|
|
279
|
-
union_string: T | string;
|
|
280
|
-
union_a: T | 'a';
|
|
281
|
-
union_symbol: T | symbol;
|
|
282
|
-
union_object: T | object;
|
|
283
|
-
union_function: T | Function;
|
|
284
|
-
union_array_unknown: T | unknown[];
|
|
285
|
-
union_tuple_empty: T | [];
|
|
286
|
-
intersect<R>(): T & R;
|
|
287
|
-
intersect_any: T & any;
|
|
288
|
-
intersect_unknown: T & unknown;
|
|
289
|
-
intersect_void: T & void;
|
|
290
|
-
intersect_never: T & never;
|
|
291
|
-
intersect_undefined: T & undefined;
|
|
292
|
-
intersect_null: T & null;
|
|
293
|
-
intersect_boolean: T & boolean;
|
|
294
|
-
intersect_true: T & true;
|
|
295
|
-
intersect_false: T & false;
|
|
296
|
-
intersect_number: T & number;
|
|
297
|
-
intersect_1: T & 1;
|
|
298
|
-
intersect_bigint: T & bigint;
|
|
299
|
-
intersect_1n: T & 1n;
|
|
300
|
-
intersect_string: T & string;
|
|
301
|
-
intersect_a: T & 'a';
|
|
302
|
-
intersect_symbol: T & symbol;
|
|
303
|
-
intersect_object: T & object;
|
|
304
|
-
intersect_function: T & Function;
|
|
305
|
-
intersect_array_unknown: T & unknown[];
|
|
306
|
-
intersect_tuple_empty: T & [];
|
|
307
|
-
};
|
|
308
|
-
export {};
|
|
309
|
+
export declare const testType: testType.TestType;
|
|
309
310
|
//# sourceMappingURL=test_type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_type.d.ts","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAA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C7B,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;QACnB,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC;QAC7B,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC;QACrB,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC;QAC7B,WAAW,EAAE,CAAC,GAAG,GAAG,CAAC;QACrB,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC;QAC7B,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC;QAC7B,kBAAkB,EAAE,CAAC,GAAG,QAAQ,CAAC;QACjC,uBAAuB,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC;QACvC,qBAAqB,EAAE,CAAC,GAAG,EAAE,CAAA;KAC7B,CAAA;CACD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,mBAInB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_type.js","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test_type.js","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":";;;AAiTA;;;;;;GAMG;AACU,QAAA,QAAQ,GAAG,IAAI,KAAK,CAAC,EAAuB,EAAE;IAC1D,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS;QAC5B,OAAO,CAAC,QAAiB,EAAE,EAAE,CAAC,QAAQ,CAAA;IACvC,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonPropKeys as ArrayCommonPropKeys } from '../array/array_plus.common_prop_keys.js';
|
|
2
2
|
import type { KeyTypes } from '../object/KeyTypes.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CommonPropKeys as TupleCommonPropKeys } from './tuple_plus.common_prop_keys.js';
|
|
4
4
|
/**
|
|
5
5
|
* ⚗️ *transform*
|
|
6
|
+
* 🔢 *customization*
|
|
6
7
|
*
|
|
7
|
-
* Gets the common property keys of the elements in tuple `T`.
|
|
8
|
+
* Gets the common property keys of the elements in tuple or array `T`.
|
|
8
9
|
*
|
|
10
|
+
* @example
|
|
9
11
|
* ```ts
|
|
10
12
|
* import { CommonPropKeys } from 'type-plus'
|
|
11
13
|
*
|
|
12
14
|
* type R = CommonPropKeys<[{ a: number }, { b: number }]> // never
|
|
13
15
|
* type R = CommonPropKeys<[{ a: number, c: 1 }, { b: number, c: 2 }]> // 'c'
|
|
14
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* @typeParam Options['caseNever'] Return type when `T` is `never`.
|
|
19
|
+
* Default to `never`.
|
|
15
20
|
*/
|
|
16
|
-
export type CommonPropKeys<T extends Record<KeyTypes, unknown>[],
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
export type CommonPropKeys<T extends Record<KeyTypes, unknown>[], Options extends CommonPropKeys.Options = CommonPropKeys.DefaultOptions> = number extends T['length'] ? ArrayCommonPropKeys<T> : TupleCommonPropKeys<T, Options>;
|
|
22
|
+
export declare namespace CommonPropKeys {
|
|
23
|
+
interface Options extends TupleCommonPropKeys.Options {
|
|
24
|
+
}
|
|
25
|
+
interface DefaultOptions extends TupleCommonPropKeys.DefaultOptions {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
23
28
|
/**
|
|
24
29
|
* Gets the common property keys of the elements in `A`.
|
|
25
30
|
*
|