notform 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +10 -23
- package/dist/index.d.ts +218 -2862
- package/dist/index.js +197 -120
- package/package.json +2 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,2731 +1,15 @@
|
|
|
1
1
|
import * as _$vue from "vue";
|
|
2
|
-
import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
import { ComputedRef, MaybeRefOrGetter, Raw, Ref, useAttrs } from "vue";
|
|
3
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
import { Get, PartialDeep, Paths as Paths$1 } from "type-fest";
|
|
4
5
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/primitive.d.ts
|
|
6
|
-
/**
|
|
7
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
8
|
-
|
|
9
|
-
@category Type
|
|
10
|
-
*/
|
|
11
|
-
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/characters.d.ts
|
|
14
|
-
/**
|
|
15
|
-
Matches any digit as a string ('0'-'9').
|
|
16
|
-
|
|
17
|
-
@example
|
|
18
|
-
```
|
|
19
|
-
import type {DigitCharacter} from 'type-fest';
|
|
20
|
-
|
|
21
|
-
const a: DigitCharacter = '0'; // Valid
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
const b: DigitCharacter = 0; // Invalid
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
@category Type
|
|
27
|
-
*/
|
|
28
|
-
type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-any.d.ts
|
|
31
|
-
/**
|
|
32
|
-
Returns a boolean for whether the given type is `any`.
|
|
33
|
-
|
|
34
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
35
|
-
|
|
36
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
37
|
-
|
|
38
|
-
@example
|
|
39
|
-
```
|
|
40
|
-
import type {IsAny} from 'type-fest';
|
|
41
|
-
|
|
42
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
43
|
-
const anyObject: any = {a: 1, b: 2};
|
|
44
|
-
|
|
45
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
46
|
-
return object[key];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const typedA = get(typedObject, 'a');
|
|
50
|
-
//=> 1
|
|
51
|
-
|
|
52
|
-
const anyA = get(anyObject, 'a');
|
|
53
|
-
//=> any
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
@category Type Guard
|
|
57
|
-
@category Utilities
|
|
58
|
-
*/
|
|
59
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
62
|
-
/**
|
|
63
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
64
|
-
|
|
65
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
66
|
-
|
|
67
|
-
@example
|
|
68
|
-
```
|
|
69
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
70
|
-
|
|
71
|
-
type User = {
|
|
72
|
-
name: string;
|
|
73
|
-
surname: string;
|
|
74
|
-
|
|
75
|
-
luckyNumber?: number;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
type Admin = {
|
|
79
|
-
name: string;
|
|
80
|
-
surname?: string;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
84
|
-
//=> true
|
|
85
|
-
|
|
86
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
87
|
-
//=> false
|
|
88
|
-
|
|
89
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
90
|
-
//=> boolean
|
|
91
|
-
|
|
92
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
93
|
-
//=> false
|
|
94
|
-
|
|
95
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
96
|
-
//=> boolean
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
@category Type Guard
|
|
100
|
-
@category Utilities
|
|
101
|
-
*/
|
|
102
|
-
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
105
|
-
/**
|
|
106
|
-
Extract all optional keys from the given type.
|
|
107
|
-
|
|
108
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
109
|
-
|
|
110
|
-
@example
|
|
111
|
-
```
|
|
112
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
113
|
-
|
|
114
|
-
type User = {
|
|
115
|
-
name: string;
|
|
116
|
-
surname: string;
|
|
117
|
-
|
|
118
|
-
luckyNumber?: number;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
122
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
123
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const update1: UpdateOperation<User> = {
|
|
127
|
-
name: 'Alice',
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const update2: UpdateOperation<User> = {
|
|
131
|
-
name: 'Bob',
|
|
132
|
-
luckyNumber: REMOVE_FIELD,
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
@category Utilities
|
|
137
|
-
*/
|
|
138
|
-
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
139
|
-
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
140
|
-
: never;
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
143
|
-
/**
|
|
144
|
-
Extract all required keys from the given type.
|
|
145
|
-
|
|
146
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
147
|
-
|
|
148
|
-
@example
|
|
149
|
-
```
|
|
150
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
151
|
-
|
|
152
|
-
declare function createValidation<
|
|
153
|
-
Entity extends object,
|
|
154
|
-
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
155
|
-
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
156
|
-
|
|
157
|
-
type User = {
|
|
158
|
-
name: string;
|
|
159
|
-
surname: string;
|
|
160
|
-
luckyNumber?: number;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
164
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
165
|
-
|
|
166
|
-
// @ts-expect-error
|
|
167
|
-
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
168
|
-
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
@category Utilities
|
|
172
|
-
*/
|
|
173
|
-
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
174
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-never.d.ts
|
|
177
|
-
/**
|
|
178
|
-
Returns a boolean for whether the given type is `never`.
|
|
179
|
-
|
|
180
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
181
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
182
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
183
|
-
|
|
184
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
185
|
-
|
|
186
|
-
@example
|
|
187
|
-
```
|
|
188
|
-
import type {IsNever, And} from 'type-fest';
|
|
189
|
-
|
|
190
|
-
type A = IsNever<never>;
|
|
191
|
-
//=> true
|
|
192
|
-
|
|
193
|
-
type B = IsNever<any>;
|
|
194
|
-
//=> false
|
|
195
|
-
|
|
196
|
-
type C = IsNever<unknown>;
|
|
197
|
-
//=> false
|
|
198
|
-
|
|
199
|
-
type D = IsNever<never[]>;
|
|
200
|
-
//=> false
|
|
201
|
-
|
|
202
|
-
type E = IsNever<object>;
|
|
203
|
-
//=> false
|
|
204
|
-
|
|
205
|
-
type F = IsNever<string>;
|
|
206
|
-
//=> false
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
@example
|
|
210
|
-
```
|
|
211
|
-
import type {IsNever} from 'type-fest';
|
|
212
|
-
|
|
213
|
-
type IsTrue<T> = T extends true ? true : false;
|
|
214
|
-
|
|
215
|
-
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
216
|
-
type A = IsTrue<never>;
|
|
217
|
-
//=> never
|
|
218
|
-
|
|
219
|
-
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
220
|
-
type IsTrueFixed<T> =
|
|
221
|
-
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
222
|
-
|
|
223
|
-
type B = IsTrueFixed<never>;
|
|
224
|
-
//=> false
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
@category Type Guard
|
|
228
|
-
@category Utilities
|
|
229
|
-
*/
|
|
230
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/if.d.ts
|
|
233
|
-
/**
|
|
234
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
235
|
-
|
|
236
|
-
Use-cases:
|
|
237
|
-
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
238
|
-
|
|
239
|
-
Note:
|
|
240
|
-
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
241
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
242
|
-
|
|
243
|
-
@example
|
|
244
|
-
```
|
|
245
|
-
import type {If} from 'type-fest';
|
|
246
|
-
|
|
247
|
-
type A = If<true, 'yes', 'no'>;
|
|
248
|
-
//=> 'yes'
|
|
249
|
-
|
|
250
|
-
type B = If<false, 'yes', 'no'>;
|
|
251
|
-
//=> 'no'
|
|
252
|
-
|
|
253
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
254
|
-
//=> 'yes' | 'no'
|
|
255
|
-
|
|
256
|
-
type D = If<any, 'yes', 'no'>;
|
|
257
|
-
//=> 'yes' | 'no'
|
|
258
|
-
|
|
259
|
-
type E = If<never, 'yes', 'no'>;
|
|
260
|
-
//=> 'no'
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
@example
|
|
264
|
-
```
|
|
265
|
-
import type {If, IsAny, IsNever} from 'type-fest';
|
|
266
|
-
|
|
267
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
268
|
-
//=> 'not any'
|
|
269
|
-
|
|
270
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
271
|
-
//=> 'is never'
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
@example
|
|
275
|
-
```
|
|
276
|
-
import type {If, IsEqual} from 'type-fest';
|
|
277
|
-
|
|
278
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
279
|
-
|
|
280
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
281
|
-
//=> 'equal'
|
|
282
|
-
|
|
283
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
284
|
-
//=> 'not equal'
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
288
|
-
|
|
289
|
-
@example
|
|
290
|
-
```
|
|
291
|
-
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
292
|
-
|
|
293
|
-
type HundredZeroes = StringRepeat<'0', 100>;
|
|
294
|
-
|
|
295
|
-
// The following implementation is not tail recursive
|
|
296
|
-
type Includes<S extends string, Char extends string> =
|
|
297
|
-
S extends `${infer First}${infer Rest}`
|
|
298
|
-
? If<IsEqual<First, Char>,
|
|
299
|
-
'found',
|
|
300
|
-
Includes<Rest, Char>>
|
|
301
|
-
: 'not found';
|
|
302
|
-
|
|
303
|
-
// Hence, instantiations with long strings will fail
|
|
304
|
-
// @ts-expect-error
|
|
305
|
-
type Fails = Includes<HundredZeroes, '1'>;
|
|
306
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
307
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
308
|
-
|
|
309
|
-
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
310
|
-
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
311
|
-
S extends `${infer First}${infer Rest}`
|
|
312
|
-
? IsEqual<First, Char> extends true
|
|
313
|
-
? 'found'
|
|
314
|
-
: IncludesWithoutIf<Rest, Char>
|
|
315
|
-
: 'not found';
|
|
316
|
-
|
|
317
|
-
// Now, instantiations with long strings will work
|
|
318
|
-
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
319
|
-
//=> 'not found'
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
@category Type Guard
|
|
323
|
-
@category Utilities
|
|
324
|
-
*/
|
|
325
|
-
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
326
|
-
//#endregion
|
|
327
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
328
|
-
/**
|
|
329
|
-
Represents an array with `unknown` value.
|
|
330
|
-
|
|
331
|
-
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
332
|
-
|
|
333
|
-
@example
|
|
334
|
-
```
|
|
335
|
-
import type {UnknownArray} from 'type-fest';
|
|
336
|
-
|
|
337
|
-
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
338
|
-
|
|
339
|
-
type A = IsArray<['foo']>;
|
|
340
|
-
//=> true
|
|
341
|
-
|
|
342
|
-
type B = IsArray<readonly number[]>;
|
|
343
|
-
//=> true
|
|
344
|
-
|
|
345
|
-
type C = IsArray<string>;
|
|
346
|
-
//=> false
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
@category Type
|
|
350
|
-
@category Array
|
|
351
|
-
*/
|
|
352
|
-
type UnknownArray = readonly unknown[];
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/type.d.ts
|
|
355
|
-
/**
|
|
356
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
357
|
-
*/
|
|
358
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
359
|
-
/**
|
|
360
|
-
Matches non-recursive types.
|
|
361
|
-
*/
|
|
362
|
-
type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown) | Promise<unknown>;
|
|
363
|
-
/**
|
|
364
|
-
Matches maps, sets, or arrays.
|
|
365
|
-
*/
|
|
366
|
-
type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray;
|
|
367
|
-
/**
|
|
368
|
-
Test if the given function has multiple call signatures.
|
|
369
|
-
|
|
370
|
-
Needed to handle the case of a single call signature with properties.
|
|
371
|
-
|
|
372
|
-
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
373
|
-
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
374
|
-
*/
|
|
375
|
-
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
376
|
-
(...arguments_: infer A): unknown;
|
|
377
|
-
(...arguments_: infer B): unknown;
|
|
378
|
-
} ? B extends A ? A extends B ? false : true : true : false;
|
|
379
|
-
/**
|
|
380
|
-
Returns a boolean for whether A is false.
|
|
381
|
-
|
|
382
|
-
@example
|
|
383
|
-
```
|
|
384
|
-
type A = Not<true>;
|
|
385
|
-
//=> false
|
|
386
|
-
|
|
387
|
-
type B = Not<false>;
|
|
388
|
-
//=> true
|
|
389
|
-
```
|
|
390
|
-
*/
|
|
391
|
-
type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
|
|
392
|
-
/**
|
|
393
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
394
|
-
|
|
395
|
-
@example
|
|
396
|
-
```
|
|
397
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
398
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
399
|
-
//=> 'VALID'
|
|
400
|
-
|
|
401
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
402
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
403
|
-
//=> 'IS_ANY'
|
|
404
|
-
|
|
405
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
406
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
407
|
-
//=> 'IS_NEVER'
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
|
|
411
|
-
|
|
412
|
-
@example
|
|
413
|
-
```ts
|
|
414
|
-
import type {StringRepeat} from 'type-fest';
|
|
415
|
-
|
|
416
|
-
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
417
|
-
|
|
418
|
-
// The following implementation is not tail recursive
|
|
419
|
-
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
420
|
-
|
|
421
|
-
// Hence, instantiations with long strings will fail
|
|
422
|
-
// @ts-expect-error
|
|
423
|
-
type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
424
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
425
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
426
|
-
|
|
427
|
-
// To fix this, move the recursion into a helper type
|
|
428
|
-
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
|
|
429
|
-
|
|
430
|
-
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
431
|
-
|
|
432
|
-
type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
433
|
-
//=> ''
|
|
434
|
-
```
|
|
435
|
-
*/
|
|
436
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
|
|
437
|
-
/**
|
|
438
|
-
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
439
|
-
*/
|
|
440
|
-
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
441
|
-
//#endregion
|
|
442
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/array.d.ts
|
|
443
|
-
/**
|
|
444
|
-
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
|
|
445
|
-
|
|
446
|
-
@example
|
|
447
|
-
```
|
|
448
|
-
type A = CollapseRestElement<[string, string, ...number[]]>;
|
|
449
|
-
//=> [string, string, number]
|
|
450
|
-
|
|
451
|
-
type B = CollapseRestElement<[...string[], number, number]>;
|
|
452
|
-
//=> [string, number, number]
|
|
453
|
-
|
|
454
|
-
type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
|
|
455
|
-
//=> [string, string, number | bigint]
|
|
456
|
-
|
|
457
|
-
type D = CollapseRestElement<[string, number]>;
|
|
458
|
-
//=> [string, number]
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
|
|
462
|
-
|
|
463
|
-
@example
|
|
464
|
-
```
|
|
465
|
-
// `exactOptionalPropertyTypes` enabled
|
|
466
|
-
type A = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
467
|
-
//=> [string, string, number]
|
|
468
|
-
|
|
469
|
-
// `exactOptionalPropertyTypes` disabled
|
|
470
|
-
type B = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
471
|
-
//=> [string | undefined, string | undefined, number]
|
|
472
|
-
```
|
|
473
|
-
*/
|
|
474
|
-
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
|
|
475
|
-
type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
|
|
476
|
-
? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
|
|
477
|
-
// or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
478
|
-
? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
|
|
479
|
-
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
480
|
-
: TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
|
|
481
|
-
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
482
|
-
: never; // Should never happen
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/numeric.d.ts
|
|
485
|
-
type _Numeric = number | bigint;
|
|
486
|
-
type Zero = 0 | 0n;
|
|
487
|
-
/**
|
|
488
|
-
Matches the hidden `Infinity` type.
|
|
489
|
-
|
|
490
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
491
|
-
|
|
492
|
-
@see {@link NegativeInfinity}
|
|
493
|
-
|
|
494
|
-
@category Numeric
|
|
495
|
-
*/
|
|
496
|
-
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
497
|
-
// eslint-disable-next-line no-loss-of-precision
|
|
498
|
-
type PositiveInfinity = 1e999;
|
|
499
|
-
/**
|
|
500
|
-
Matches the hidden `-Infinity` type.
|
|
501
|
-
|
|
502
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
503
|
-
|
|
504
|
-
@see {@link PositiveInfinity}
|
|
505
|
-
|
|
506
|
-
@category Numeric
|
|
507
|
-
*/
|
|
508
|
-
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
509
|
-
// eslint-disable-next-line no-loss-of-precision
|
|
510
|
-
type NegativeInfinity = -1e999;
|
|
511
|
-
/**
|
|
512
|
-
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
513
|
-
|
|
514
|
-
Use-case: Validating and documenting parameters.
|
|
515
|
-
|
|
516
|
-
@see {@link NegativeInteger}
|
|
517
|
-
@see {@link NonNegative}
|
|
518
|
-
|
|
519
|
-
@category Numeric
|
|
520
|
-
*/
|
|
521
|
-
type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
|
|
522
|
-
/**
|
|
523
|
-
Returns a boolean for whether the given number is a negative number.
|
|
524
|
-
|
|
525
|
-
@see {@link Negative}
|
|
526
|
-
|
|
527
|
-
@example
|
|
528
|
-
```
|
|
529
|
-
import type {IsNegative} from 'type-fest';
|
|
530
|
-
|
|
531
|
-
type ShouldBeFalse = IsNegative<1>;
|
|
532
|
-
type ShouldBeTrue = IsNegative<-1>;
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
@category Numeric
|
|
536
|
-
*/
|
|
537
|
-
type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
|
|
540
|
-
declare const tag: unique symbol;
|
|
541
|
-
//#endregion
|
|
542
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tagged.d.ts
|
|
543
|
-
// eslint-disable-next-line type-fest/require-exported-types
|
|
544
|
-
type TagContainer<Token> = {
|
|
545
|
-
readonly [tag]: Token;
|
|
546
|
-
};
|
|
547
|
-
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
|
|
548
|
-
/**
|
|
549
|
-
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
|
|
550
|
-
|
|
551
|
-
A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
|
|
552
|
-
|
|
553
|
-
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
554
|
-
|
|
555
|
-
A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
|
|
556
|
-
|
|
557
|
-
A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
|
|
558
|
-
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
|
|
559
|
-
- `A` contains at least all the tags `B` has;
|
|
560
|
-
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
|
|
561
|
-
|
|
562
|
-
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
563
|
-
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
564
|
-
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
|
|
565
|
-
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
|
|
566
|
-
|
|
567
|
-
@example
|
|
568
|
-
```
|
|
569
|
-
import type {Tagged} from 'type-fest';
|
|
570
|
-
|
|
571
|
-
type AccountNumber = Tagged<number, 'AccountNumber'>;
|
|
572
|
-
type AccountBalance = Tagged<number, 'AccountBalance'>;
|
|
573
|
-
|
|
574
|
-
function createAccountNumber(): AccountNumber {
|
|
575
|
-
// As you can see, casting from a `number` (the underlying type being tagged) is allowed.
|
|
576
|
-
return 2 as AccountNumber;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
580
|
-
|
|
581
|
-
// This will compile successfully.
|
|
582
|
-
getMoneyForAccount(createAccountNumber());
|
|
583
|
-
|
|
584
|
-
// But this won't, because it has to be explicitly passed as an `AccountNumber` type!
|
|
585
|
-
// Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
|
|
586
|
-
// @ts-expect-error
|
|
587
|
-
getMoneyForAccount(2);
|
|
588
|
-
|
|
589
|
-
// You can also use tagged values like their underlying, untagged type.
|
|
590
|
-
// I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
|
|
591
|
-
// In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
|
|
592
|
-
const accountNumber = createAccountNumber() + 2;
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
@example
|
|
596
|
-
```
|
|
597
|
-
import type {Tagged} from 'type-fest';
|
|
598
|
-
|
|
599
|
-
// You can apply multiple tags to a type by using `Tagged` repeatedly.
|
|
600
|
-
type Url = Tagged<string, 'URL'>;
|
|
601
|
-
type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
|
|
602
|
-
|
|
603
|
-
// You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
|
|
604
|
-
type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
@category Type
|
|
608
|
-
*/
|
|
609
|
-
type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
|
|
610
|
-
/**
|
|
611
|
-
Revert a tagged type back to its original type by removing all tags.
|
|
612
|
-
|
|
613
|
-
Why is this necessary?
|
|
614
|
-
|
|
615
|
-
1. Use a `Tagged` type as object keys
|
|
616
|
-
2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
|
|
617
|
-
|
|
618
|
-
@example
|
|
619
|
-
```
|
|
620
|
-
import type {Tagged, UnwrapTagged} from 'type-fest';
|
|
621
|
-
|
|
622
|
-
type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
|
|
623
|
-
|
|
624
|
-
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
|
|
625
|
-
SAVINGS: 99,
|
|
626
|
-
CHECKING: 0.1,
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
// Without UnwrapTagged, the following expression would throw a type error.
|
|
630
|
-
const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
|
|
631
|
-
|
|
632
|
-
// Attempting to pass a non-Tagged type to UnwrapTagged will raise a type error.
|
|
633
|
-
// @ts-expect-error
|
|
634
|
-
type WontWork = UnwrapTagged<string>;
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
@category Type
|
|
638
|
-
*/
|
|
639
|
-
type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
|
|
640
|
-
type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
|
|
641
|
-
/**
|
|
642
|
-
Note: The `Opaque` type is deprecated in favor of `Tagged`.
|
|
643
|
-
|
|
644
|
-
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
|
|
645
|
-
|
|
646
|
-
The generic type parameters can be anything.
|
|
647
|
-
|
|
648
|
-
Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
|
|
649
|
-
|
|
650
|
-
Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
|
|
651
|
-
|
|
652
|
-
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
653
|
-
|
|
654
|
-
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
655
|
-
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
656
|
-
- [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
|
|
657
|
-
- [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
|
|
658
|
-
|
|
659
|
-
@example
|
|
660
|
-
```
|
|
661
|
-
import type {Opaque} from 'type-fest';
|
|
662
|
-
|
|
663
|
-
type AccountNumber = Opaque<number, 'AccountNumber'>;
|
|
664
|
-
type AccountBalance = Opaque<number, 'AccountBalance'>;
|
|
665
|
-
|
|
666
|
-
// The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
|
|
667
|
-
type ThingOne = Opaque<string>;
|
|
668
|
-
type ThingTwo = Opaque<string>;
|
|
669
|
-
|
|
670
|
-
// To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
|
|
671
|
-
// To avoid this behaviour, you would instead pass the "Token" parameter, like so.
|
|
672
|
-
type NewThingOne = Opaque<string, 'ThingOne'>;
|
|
673
|
-
type NewThingTwo = Opaque<string, 'ThingTwo'>;
|
|
674
|
-
|
|
675
|
-
// Now they're completely separate types, so the following will fail to compile.
|
|
676
|
-
function createNewThingOne(): NewThingOne {
|
|
677
|
-
// As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
|
|
678
|
-
return 'new thing one' as NewThingOne;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// This will fail to compile, as they are fundamentally different types.
|
|
682
|
-
// @ts-expect-error
|
|
683
|
-
const thingTwo = createNewThingOne() as NewThingTwo;
|
|
684
|
-
|
|
685
|
-
// Here's another example of opaque typing.
|
|
686
|
-
function createAccountNumber(): AccountNumber {
|
|
687
|
-
return 2 as AccountNumber;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
691
|
-
|
|
692
|
-
// This will compile successfully.
|
|
693
|
-
getMoneyForAccount(createAccountNumber());
|
|
694
|
-
|
|
695
|
-
// But this won't, because it has to be explicitly passed as an `AccountNumber` type.
|
|
696
|
-
// @ts-expect-error
|
|
697
|
-
getMoneyForAccount(2);
|
|
698
|
-
|
|
699
|
-
// You can use opaque values like they aren't opaque too.
|
|
700
|
-
const accountNumber = createAccountNumber();
|
|
701
|
-
|
|
702
|
-
// This will compile successfully.
|
|
703
|
-
const newAccountNumber = accountNumber + 2;
|
|
704
|
-
|
|
705
|
-
// As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
|
|
706
|
-
type Person = {
|
|
707
|
-
id: Opaque<number, Person>;
|
|
708
|
-
name: string;
|
|
709
|
-
};
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
@category Type
|
|
713
|
-
@deprecated Use {@link Tagged} instead
|
|
714
|
-
*/
|
|
715
|
-
//#endregion
|
|
716
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-literal.d.ts
|
|
717
|
-
/**
|
|
718
|
-
Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
719
|
-
|
|
720
|
-
Useful for:
|
|
721
|
-
- providing strongly-typed string manipulation functions
|
|
722
|
-
- constraining strings to be a string literal
|
|
723
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
724
|
-
|
|
725
|
-
The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
726
|
-
|
|
727
|
-
@example
|
|
728
|
-
```
|
|
729
|
-
import type {IsStringLiteral} from 'type-fest';
|
|
730
|
-
|
|
731
|
-
type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
|
|
732
|
-
|
|
733
|
-
// https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
|
|
734
|
-
function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
|
|
735
|
-
return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
const output = capitalize('hello, world!');
|
|
739
|
-
//=> 'Hello, world!'
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
@example
|
|
743
|
-
```
|
|
744
|
-
// String types with infinite set of possible values return `false`.
|
|
745
|
-
|
|
746
|
-
import type {IsStringLiteral} from 'type-fest';
|
|
747
|
-
|
|
748
|
-
type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
|
|
749
|
-
//=> false
|
|
750
|
-
|
|
751
|
-
type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
|
|
752
|
-
//=> false
|
|
753
|
-
|
|
754
|
-
// This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
|
|
755
|
-
|
|
756
|
-
type Length<S extends string, Counter extends never[] = []> =
|
|
757
|
-
IsStringLiteral<S> extends false
|
|
758
|
-
? number // return `number` for infinite string types
|
|
759
|
-
: S extends `${string}${infer Tail}`
|
|
760
|
-
? Length<Tail, [...Counter, never]>
|
|
761
|
-
: Counter['length'];
|
|
762
|
-
|
|
763
|
-
type L1 = Length<Lowercase<string>>;
|
|
764
|
-
//=> number
|
|
765
|
-
|
|
766
|
-
type L2 = Length<`${number}`>;
|
|
767
|
-
//=> number
|
|
768
|
-
```
|
|
769
|
-
|
|
770
|
-
@category Type Guard
|
|
771
|
-
@category Utilities
|
|
772
|
-
*/
|
|
773
|
-
type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
|
|
774
|
-
type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
|
|
775
|
-
// and since `{}` extends index signatures, the result becomes `false`.
|
|
776
|
-
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
777
|
-
//#endregion
|
|
778
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tuple-of.d.ts
|
|
779
|
-
/**
|
|
780
|
-
Create a tuple type of the specified length with elements of the specified type.
|
|
781
|
-
|
|
782
|
-
@example
|
|
783
|
-
```
|
|
784
|
-
import type {TupleOf} from 'type-fest';
|
|
785
|
-
|
|
786
|
-
type RGB = TupleOf<3, number>;
|
|
787
|
-
//=> [number, number, number]
|
|
788
|
-
|
|
789
|
-
type Line = TupleOf<2, {x: number; y: number}>;
|
|
790
|
-
//=> [{x: number; y: number}, {x: number; y: number}]
|
|
791
|
-
|
|
792
|
-
type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
|
|
793
|
-
//=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
|
|
794
|
-
```
|
|
795
|
-
|
|
796
|
-
@example
|
|
797
|
-
```
|
|
798
|
-
import type {TupleOf} from 'type-fest';
|
|
799
|
-
|
|
800
|
-
type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
|
|
801
|
-
|
|
802
|
-
type ZeroToFour = Range<0, 5>;
|
|
803
|
-
//=> '0' | '1' | '2' | '3' | '4'
|
|
804
|
-
|
|
805
|
-
type ThreeToEight = Range<3, 9>;
|
|
806
|
-
//=> '5' | '3' | '4' | '6' | '7' | '8'
|
|
807
|
-
```
|
|
808
|
-
|
|
809
|
-
Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
|
|
810
|
-
|
|
811
|
-
@example
|
|
812
|
-
```
|
|
813
|
-
import type {TupleOf} from 'type-fest';
|
|
814
|
-
|
|
815
|
-
type StringArray = TupleOf<number, string>;
|
|
816
|
-
//=> string[]
|
|
817
|
-
```
|
|
818
|
-
|
|
819
|
-
Note: If the type for elements is not specified, it will default to `unknown`.
|
|
820
|
-
|
|
821
|
-
@example
|
|
822
|
-
```
|
|
823
|
-
import type {TupleOf} from 'type-fest';
|
|
824
|
-
|
|
825
|
-
type UnknownTriplet = TupleOf<3>;
|
|
826
|
-
//=> [unknown, unknown, unknown]
|
|
827
|
-
```
|
|
828
|
-
|
|
829
|
-
Note: If the specified length is negative, the result will be an empty tuple.
|
|
830
|
-
|
|
831
|
-
@example
|
|
832
|
-
```
|
|
833
|
-
import type {TupleOf} from 'type-fest';
|
|
834
|
-
|
|
835
|
-
type EmptyTuple = TupleOf<-3, string>;
|
|
836
|
-
//=> []
|
|
837
|
-
```
|
|
838
|
-
|
|
839
|
-
Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
|
|
840
|
-
|
|
841
|
-
@category Array
|
|
842
|
-
*/
|
|
843
|
-
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill, []>, Fill[], []>;
|
|
844
|
-
type _TupleOf<L extends number, Fill, Accumulator extends UnknownArray> = number extends L ? Fill[] : L extends Accumulator['length'] ? Accumulator : _TupleOf<L, Fill, [...Accumulator, Fill]>;
|
|
845
|
-
//#endregion
|
|
846
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/string.d.ts
|
|
847
|
-
/**
|
|
848
|
-
Return a string representation of the given string or number.
|
|
849
|
-
|
|
850
|
-
Note: This type is not the return type of the `.toString()` function.
|
|
851
|
-
*/
|
|
852
|
-
type ToString<T> = T extends string | number ? `${T}` : never;
|
|
853
|
-
/**
|
|
854
|
-
Converts a numeric string to a number.
|
|
855
|
-
|
|
856
|
-
@example
|
|
857
|
-
```
|
|
858
|
-
type PositiveInt = StringToNumber<'1234'>;
|
|
859
|
-
//=> 1234
|
|
860
|
-
|
|
861
|
-
type NegativeInt = StringToNumber<'-1234'>;
|
|
862
|
-
//=> -1234
|
|
863
|
-
|
|
864
|
-
type PositiveFloat = StringToNumber<'1234.56'>;
|
|
865
|
-
//=> 1234.56
|
|
866
|
-
|
|
867
|
-
type NegativeFloat = StringToNumber<'-1234.56'>;
|
|
868
|
-
//=> -1234.56
|
|
869
|
-
|
|
870
|
-
type PositiveInfinity = StringToNumber<'Infinity'>;
|
|
871
|
-
//=> Infinity
|
|
872
|
-
|
|
873
|
-
type NegativeInfinity = StringToNumber<'-Infinity'>;
|
|
874
|
-
//=> -Infinity
|
|
875
|
-
```
|
|
876
|
-
|
|
877
|
-
@category String
|
|
878
|
-
@category Numeric
|
|
879
|
-
@category Template literal
|
|
880
|
-
*/
|
|
881
|
-
type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends 'Infinity' ? PositiveInfinity : S extends '-Infinity' ? NegativeInfinity : never;
|
|
882
|
-
/**
|
|
883
|
-
Returns an array of the characters of the string.
|
|
884
|
-
|
|
885
|
-
@example
|
|
886
|
-
```
|
|
887
|
-
type A = StringToArray<'abcde'>;
|
|
888
|
-
//=> ['a', 'b', 'c', 'd', 'e']
|
|
889
|
-
|
|
890
|
-
type B = StringToArray<string>;
|
|
891
|
-
//=> never
|
|
892
|
-
```
|
|
893
|
-
|
|
894
|
-
@category String
|
|
895
|
-
*/
|
|
896
|
-
type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [...Result, F]> : Result;
|
|
897
|
-
/**
|
|
898
|
-
Returns the length of the given string.
|
|
899
|
-
|
|
900
|
-
@example
|
|
901
|
-
```
|
|
902
|
-
type A = StringLength<'abcde'>;
|
|
903
|
-
//=> 5
|
|
904
|
-
|
|
905
|
-
type B = StringLength<string>;
|
|
906
|
-
//=> never
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
@category String
|
|
910
|
-
@category Template literal
|
|
911
|
-
*/
|
|
912
|
-
type StringLength<S extends string> = string extends S ? never : StringToArray<S>['length'];
|
|
913
|
-
/**
|
|
914
|
-
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
|
|
915
|
-
|
|
916
|
-
@example
|
|
917
|
-
```
|
|
918
|
-
type A = SameLengthPositiveNumericStringGt<'50', '10'>;
|
|
919
|
-
//=> true
|
|
920
|
-
|
|
921
|
-
type B = SameLengthPositiveNumericStringGt<'10', '10'>;
|
|
922
|
-
//=> false
|
|
923
|
-
```
|
|
924
|
-
*/
|
|
925
|
-
type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
|
|
926
|
-
type NumericString = '0123456789';
|
|
927
|
-
/**
|
|
928
|
-
Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
|
|
929
|
-
|
|
930
|
-
@example
|
|
931
|
-
```
|
|
932
|
-
type A = PositiveNumericStringGt<'500', '1'>;
|
|
933
|
-
//=> true
|
|
934
|
-
|
|
935
|
-
type B = PositiveNumericStringGt<'1', '1'>;
|
|
936
|
-
//=> false
|
|
937
|
-
|
|
938
|
-
type C = PositiveNumericStringGt<'1', '500'>;
|
|
939
|
-
//=> false
|
|
940
|
-
```
|
|
941
|
-
*/
|
|
942
|
-
type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [TupleOf<StringLength<A>, 0>, TupleOf<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain['length'] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
|
|
943
|
-
/**
|
|
944
|
-
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
|
|
945
|
-
|
|
946
|
-
@example
|
|
947
|
-
```
|
|
948
|
-
type A = PositiveNumericCharacterGt<'5', '1'>;
|
|
949
|
-
//=> true
|
|
950
|
-
|
|
951
|
-
type B = PositiveNumericCharacterGt<'1', '1'>;
|
|
952
|
-
//=> false
|
|
953
|
-
```
|
|
954
|
-
*/
|
|
955
|
-
type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
|
|
956
|
-
//#endregion
|
|
957
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/numeric.d.ts
|
|
958
|
-
/**
|
|
959
|
-
Returns the absolute value of a given value.
|
|
960
|
-
|
|
961
|
-
@example
|
|
962
|
-
```
|
|
963
|
-
type A = NumberAbsolute<-1>;
|
|
964
|
-
//=> 1
|
|
965
|
-
|
|
966
|
-
type B = NumberAbsolute<1>;
|
|
967
|
-
//=> 1
|
|
968
|
-
|
|
969
|
-
type C = NumberAbsolute<NegativeInfinity>;
|
|
970
|
-
//=> PositiveInfinity
|
|
971
|
-
```
|
|
972
|
-
*/
|
|
973
|
-
type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
|
|
974
|
-
/**
|
|
975
|
-
Check whether the given type is a number or a number string.
|
|
976
|
-
|
|
977
|
-
Supports floating-point as a string.
|
|
978
|
-
|
|
979
|
-
@example
|
|
980
|
-
```
|
|
981
|
-
type A = IsNumberLike<'1'>;
|
|
982
|
-
//=> true
|
|
983
|
-
|
|
984
|
-
type B = IsNumberLike<'-1.1'>;
|
|
985
|
-
//=> true
|
|
986
|
-
|
|
987
|
-
type C = IsNumberLike<'5e-20'>;
|
|
988
|
-
//=> true
|
|
989
|
-
|
|
990
|
-
type D = IsNumberLike<1>;
|
|
991
|
-
//=> true
|
|
992
|
-
|
|
993
|
-
type E = IsNumberLike<'a'>;
|
|
994
|
-
//=> false
|
|
995
|
-
*/
|
|
996
|
-
type IsNumberLike<N> = IfNotAnyOrNever<N, N extends number | `${number}` ? true : false, boolean, false>;
|
|
997
|
-
/**
|
|
998
|
-
Returns the number with reversed sign.
|
|
999
|
-
|
|
1000
|
-
@example
|
|
1001
|
-
```
|
|
1002
|
-
type A = ReverseSign<-1>;
|
|
1003
|
-
//=> 1
|
|
1004
|
-
|
|
1005
|
-
type B = ReverseSign<1>;
|
|
1006
|
-
//=> -1
|
|
1007
|
-
|
|
1008
|
-
type C = ReverseSign<NegativeInfinity>;
|
|
1009
|
-
//=> PositiveInfinity
|
|
1010
|
-
|
|
1011
|
-
type D = ReverseSign<PositiveInfinity>;
|
|
1012
|
-
//=> NegativeInfinity
|
|
1013
|
-
```
|
|
1014
|
-
*/
|
|
1015
|
-
type ReverseSign<N extends number> = // Handle edge cases
|
|
1016
|
-
N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends NegativeInfinity ? PositiveInfinity : // Handle negative numbers
|
|
1017
|
-
`${N}` extends `-${infer P extends number}` ? P // Handle positive numbers
|
|
1018
|
-
: `-${N}` extends `${infer R extends number}` ? R : never;
|
|
1019
|
-
//#endregion
|
|
1020
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/simplify.d.ts
|
|
1021
|
-
/**
|
|
1022
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
1023
|
-
|
|
1024
|
-
@example
|
|
1025
|
-
```
|
|
1026
|
-
import type {Simplify} from 'type-fest';
|
|
1027
|
-
|
|
1028
|
-
type PositionProps = {
|
|
1029
|
-
top: number;
|
|
1030
|
-
left: number;
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
|
-
type SizeProps = {
|
|
1034
|
-
width: number;
|
|
1035
|
-
height: number;
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
1039
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
1040
|
-
```
|
|
1041
|
-
|
|
1042
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
1043
|
-
|
|
1044
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
1045
|
-
|
|
1046
|
-
@example
|
|
1047
|
-
```
|
|
1048
|
-
import type {Simplify} from 'type-fest';
|
|
1049
|
-
|
|
1050
|
-
interface SomeInterface {
|
|
1051
|
-
foo: number;
|
|
1052
|
-
bar?: string;
|
|
1053
|
-
baz: number | undefined;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
type SomeType = {
|
|
1057
|
-
foo: number;
|
|
1058
|
-
bar?: string;
|
|
1059
|
-
baz: number | undefined;
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
1063
|
-
const someType: SomeType = literal;
|
|
1064
|
-
const someInterface: SomeInterface = literal;
|
|
1065
|
-
|
|
1066
|
-
declare function fn(object: Record<string, unknown>): void;
|
|
1067
|
-
|
|
1068
|
-
fn(literal); // Good: literal object type is sealed
|
|
1069
|
-
fn(someType); // Good: type is sealed
|
|
1070
|
-
// @ts-expect-error
|
|
1071
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
1072
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
1076
|
-
@see {@link SimplifyDeep}
|
|
1077
|
-
@category Object
|
|
1078
|
-
*/
|
|
1079
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
1080
|
-
//#endregion
|
|
1081
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-equal.d.ts
|
|
1082
|
-
/**
|
|
1083
|
-
Returns a boolean for whether the two given types are equal.
|
|
1084
|
-
|
|
1085
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
1086
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
1087
|
-
|
|
1088
|
-
Use-cases:
|
|
1089
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1090
|
-
|
|
1091
|
-
@example
|
|
1092
|
-
```
|
|
1093
|
-
import type {IsEqual} from 'type-fest';
|
|
1094
|
-
|
|
1095
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
1096
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
1097
|
-
type Includes<Value extends readonly any[], Item> =
|
|
1098
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
1099
|
-
? IsEqual<Value[0], Item> extends true
|
|
1100
|
-
? true
|
|
1101
|
-
: Includes<rest, Item>
|
|
1102
|
-
: false;
|
|
1103
|
-
```
|
|
1104
|
-
|
|
1105
|
-
@category Type Guard
|
|
1106
|
-
@category Utilities
|
|
1107
|
-
*/
|
|
1108
|
-
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
1109
|
-
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
1110
|
-
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
1111
|
-
//#endregion
|
|
1112
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
1113
|
-
/**
|
|
1114
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
1115
|
-
|
|
1116
|
-
This is the counterpart of `PickIndexSignature`.
|
|
1117
|
-
|
|
1118
|
-
Use-cases:
|
|
1119
|
-
- Remove overly permissive signatures from third-party types.
|
|
1120
|
-
|
|
1121
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
1122
|
-
|
|
1123
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
1124
|
-
|
|
1125
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
1126
|
-
|
|
1127
|
-
```
|
|
1128
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
1129
|
-
|
|
1130
|
-
// @ts-expect-error
|
|
1131
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
1132
|
-
// TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
1133
|
-
```
|
|
1134
|
-
|
|
1135
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
1136
|
-
|
|
1137
|
-
```
|
|
1138
|
-
type Indexed = {} extends Record<string, unknown>
|
|
1139
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1140
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
1141
|
-
|
|
1142
|
-
type IndexedResult = Indexed;
|
|
1143
|
-
//=> '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1144
|
-
|
|
1145
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
1146
|
-
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
1147
|
-
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
1148
|
-
|
|
1149
|
-
type KeyedResult = Keyed;
|
|
1150
|
-
//=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
1151
|
-
```
|
|
1152
|
-
|
|
1153
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
1154
|
-
|
|
1155
|
-
```
|
|
1156
|
-
type OmitIndexSignature<ObjectType> = {
|
|
1157
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
1158
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
1159
|
-
};
|
|
1160
|
-
```
|
|
1161
|
-
|
|
1162
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
1163
|
-
|
|
1164
|
-
```
|
|
1165
|
-
type OmitIndexSignature<ObjectType> = {
|
|
1166
|
-
[KeyType in keyof ObjectType
|
|
1167
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
1168
|
-
as {} extends Record<KeyType, unknown>
|
|
1169
|
-
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
1170
|
-
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
1171
|
-
]: ObjectType[KeyType];
|
|
1172
|
-
};
|
|
1173
|
-
```
|
|
1174
|
-
|
|
1175
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
1176
|
-
|
|
1177
|
-
@example
|
|
1178
|
-
```
|
|
1179
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
1180
|
-
|
|
1181
|
-
type Example = {
|
|
1182
|
-
// These index signatures will be removed.
|
|
1183
|
-
[x: string]: any;
|
|
1184
|
-
[x: number]: any;
|
|
1185
|
-
[x: symbol]: any;
|
|
1186
|
-
[x: `head-${string}`]: string;
|
|
1187
|
-
[x: `${string}-tail`]: string;
|
|
1188
|
-
[x: `head-${string}-tail`]: string;
|
|
1189
|
-
[x: `${bigint}`]: string;
|
|
1190
|
-
[x: `embedded-${number}`]: string;
|
|
1191
|
-
|
|
1192
|
-
// These explicitly defined keys will remain.
|
|
1193
|
-
foo: 'bar';
|
|
1194
|
-
qux?: 'baz';
|
|
1195
|
-
};
|
|
1196
|
-
|
|
1197
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
1198
|
-
//=> {foo: 'bar'; qux?: 'baz'}
|
|
1199
|
-
```
|
|
1200
|
-
|
|
1201
|
-
@see {@link PickIndexSignature}
|
|
1202
|
-
@category Object
|
|
1203
|
-
*/
|
|
1204
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
1205
|
-
//#endregion
|
|
1206
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
1207
|
-
/**
|
|
1208
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1209
|
-
|
|
1210
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
1211
|
-
|
|
1212
|
-
@example
|
|
1213
|
-
```
|
|
1214
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
1215
|
-
|
|
1216
|
-
declare const symbolKey: unique symbol;
|
|
1217
|
-
|
|
1218
|
-
type Example = {
|
|
1219
|
-
// These index signatures will remain.
|
|
1220
|
-
[x: string]: unknown;
|
|
1221
|
-
[x: number]: unknown;
|
|
1222
|
-
[x: symbol]: unknown;
|
|
1223
|
-
[x: `head-${string}`]: string;
|
|
1224
|
-
[x: `${string}-tail`]: string;
|
|
1225
|
-
[x: `head-${string}-tail`]: string;
|
|
1226
|
-
[x: `${bigint}`]: string;
|
|
1227
|
-
[x: `embedded-${number}`]: string;
|
|
1228
|
-
|
|
1229
|
-
// These explicitly defined keys will be removed.
|
|
1230
|
-
['kebab-case-key']: string;
|
|
1231
|
-
[symbolKey]: string;
|
|
1232
|
-
foo: 'bar';
|
|
1233
|
-
qux?: 'baz';
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
1237
|
-
// {
|
|
1238
|
-
// [x: string]: unknown;
|
|
1239
|
-
// [x: number]: unknown;
|
|
1240
|
-
// [x: symbol]: unknown;
|
|
1241
|
-
// [x: `head-${string}`]: string;
|
|
1242
|
-
// [x: `${string}-tail`]: string;
|
|
1243
|
-
// [x: `head-${string}-tail`]: string;
|
|
1244
|
-
// [x: `${bigint}`]: string;
|
|
1245
|
-
// [x: `embedded-${number}`]: string;
|
|
1246
|
-
// }
|
|
1247
|
-
```
|
|
1248
|
-
|
|
1249
|
-
@see {@link OmitIndexSignature}
|
|
1250
|
-
@category Object
|
|
1251
|
-
*/
|
|
1252
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
1253
|
-
//#endregion
|
|
1254
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/merge.d.ts
|
|
1255
|
-
// Merges two objects without worrying about index signatures.
|
|
1256
|
-
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
1257
|
-
/**
|
|
1258
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
1259
|
-
|
|
1260
|
-
This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
|
|
1261
|
-
|
|
1262
|
-
@example
|
|
1263
|
-
```
|
|
1264
|
-
import type {Merge} from 'type-fest';
|
|
1265
|
-
|
|
1266
|
-
type Foo = {
|
|
1267
|
-
a: string;
|
|
1268
|
-
b: number;
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
type Bar = {
|
|
1272
|
-
a: number; // Conflicts with Foo['a']
|
|
1273
|
-
c: boolean;
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
// With `&`, `a` becomes `string & number` which is `never`. Not what you want.
|
|
1277
|
-
type WithIntersection = (Foo & Bar)['a'];
|
|
1278
|
-
//=> never
|
|
1279
|
-
|
|
1280
|
-
// With `Merge`, `a` is cleanly overridden to `number`.
|
|
1281
|
-
type WithMerge = Merge<Foo, Bar>['a'];
|
|
1282
|
-
//=> number
|
|
1283
|
-
```
|
|
1284
|
-
|
|
1285
|
-
@example
|
|
1286
|
-
```
|
|
1287
|
-
import type {Merge} from 'type-fest';
|
|
1288
|
-
|
|
1289
|
-
type Foo = {
|
|
1290
|
-
[x: string]: unknown;
|
|
1291
|
-
[x: number]: unknown;
|
|
1292
|
-
foo: string;
|
|
1293
|
-
bar: symbol;
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
type Bar = {
|
|
1297
|
-
[x: number]: number;
|
|
1298
|
-
[x: symbol]: unknown;
|
|
1299
|
-
bar: Date;
|
|
1300
|
-
baz: boolean;
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
1304
|
-
//=> {
|
|
1305
|
-
// [x: string]: unknown;
|
|
1306
|
-
// [x: number]: number;
|
|
1307
|
-
// [x: symbol]: unknown;
|
|
1308
|
-
// foo: string;
|
|
1309
|
-
// bar: Date;
|
|
1310
|
-
// baz: boolean;
|
|
1311
|
-
// }
|
|
1312
|
-
```
|
|
1313
|
-
|
|
1314
|
-
Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
|
|
1315
|
-
|
|
1316
|
-
@see {@link ObjectMerge}
|
|
1317
|
-
@category Object
|
|
1318
|
-
*/
|
|
1319
|
-
type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
|
|
1320
|
-
? Source extends unknown // For distributing `Source`
|
|
1321
|
-
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
1322
|
-
: never;
|
|
1323
|
-
// Should never happen
|
|
1324
|
-
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
1325
|
-
//#endregion
|
|
1326
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/object.d.ts
|
|
1327
|
-
/**
|
|
1328
|
-
Merges user specified options with default options.
|
|
1329
|
-
|
|
1330
|
-
@example
|
|
1331
|
-
```
|
|
1332
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1333
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1334
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
1335
|
-
|
|
1336
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1337
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
1338
|
-
```
|
|
1339
|
-
|
|
1340
|
-
@example
|
|
1341
|
-
```
|
|
1342
|
-
// Complains if default values are not provided for optional options
|
|
1343
|
-
|
|
1344
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1345
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
1346
|
-
type SpecifiedOptions = {};
|
|
1347
|
-
|
|
1348
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1349
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1350
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
1351
|
-
```
|
|
1352
|
-
|
|
1353
|
-
@example
|
|
1354
|
-
```
|
|
1355
|
-
// Complains if an option's default type does not conform to the expected type
|
|
1356
|
-
|
|
1357
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1358
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
1359
|
-
type SpecifiedOptions = {};
|
|
1360
|
-
|
|
1361
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1362
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1363
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1364
|
-
```
|
|
1365
|
-
|
|
1366
|
-
@example
|
|
1367
|
-
```
|
|
1368
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
1369
|
-
|
|
1370
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1371
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1372
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
1373
|
-
|
|
1374
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1375
|
-
// ~~~~~~~~~~~~~~~~
|
|
1376
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1377
|
-
```
|
|
1378
|
-
*/
|
|
1379
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
1380
|
-
// `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
1381
|
-
/**
|
|
1382
|
-
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
1383
|
-
|
|
1384
|
-
Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
|
|
1385
|
-
|
|
1386
|
-
Use-case: For collapsing unions created using {@link LiteralUnion}.
|
|
1387
|
-
|
|
1388
|
-
@example
|
|
1389
|
-
```
|
|
1390
|
-
import type {LiteralUnion} from 'type-fest';
|
|
1391
|
-
|
|
1392
|
-
type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
|
|
1393
|
-
//=> string
|
|
1394
|
-
|
|
1395
|
-
type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
|
|
1396
|
-
//=> number
|
|
1397
|
-
|
|
1398
|
-
type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
|
|
1399
|
-
//=> `on${string}`
|
|
1400
|
-
|
|
1401
|
-
type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
|
|
1402
|
-
//=> 'click' | 'change' | `on${string}`
|
|
1403
|
-
|
|
1404
|
-
type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
|
|
1405
|
-
//=> string | null | undefined
|
|
1406
|
-
```
|
|
1407
|
-
*/
|
|
1408
|
-
type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
|
|
1409
|
-
//#endregion
|
|
1410
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/some-extend.d.ts
|
|
1411
|
-
/**
|
|
1412
|
-
@see {@link SomeExtend}
|
|
1413
|
-
*/
|
|
1414
|
-
type SomeExtendOptions = {
|
|
1415
|
-
/**
|
|
1416
|
-
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1417
|
-
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1418
|
-
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1419
|
-
@default true
|
|
1420
|
-
@example
|
|
1421
|
-
```
|
|
1422
|
-
import type {SomeExtend} from 'type-fest';
|
|
1423
|
-
type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
|
|
1424
|
-
//=> false
|
|
1425
|
-
type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
|
|
1426
|
-
//=> true
|
|
1427
|
-
type C = SomeExtend<[1, never], never, {strictNever: true}>;
|
|
1428
|
-
//=> true
|
|
1429
|
-
type D = SomeExtend<[1, never], never, {strictNever: false}>;
|
|
1430
|
-
//=> true
|
|
1431
|
-
type E = SomeExtend<[never], any, {strictNever: true}>;
|
|
1432
|
-
//=> true
|
|
1433
|
-
type F = SomeExtend<[never], any, {strictNever: false}>;
|
|
1434
|
-
//=> true
|
|
1435
|
-
```
|
|
1436
|
-
*/
|
|
1437
|
-
strictNever?: boolean;
|
|
1438
|
-
};
|
|
1439
|
-
type DefaultSomeExtendOptions = {
|
|
1440
|
-
strictNever: true;
|
|
1441
|
-
};
|
|
1442
|
-
/**
|
|
1443
|
-
Returns a boolean for whether some element in an array type extends another type.
|
|
1444
|
-
|
|
1445
|
-
@example
|
|
1446
|
-
```
|
|
1447
|
-
import type {SomeExtend} from 'type-fest';
|
|
1448
|
-
|
|
1449
|
-
type A = SomeExtend<['1', '2', 3], number>;
|
|
1450
|
-
//=> true
|
|
1451
|
-
|
|
1452
|
-
type B = SomeExtend<[1, 2, 3], string>;
|
|
1453
|
-
//=> false
|
|
1454
|
-
|
|
1455
|
-
type C = SomeExtend<[string, number | string], number>;
|
|
1456
|
-
//=> boolean
|
|
1457
|
-
|
|
1458
|
-
type D = SomeExtend<[true, boolean, true], false>;
|
|
1459
|
-
//=> boolean
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1463
|
-
|
|
1464
|
-
```
|
|
1465
|
-
// @exactOptionalPropertyTypes: true
|
|
1466
|
-
import type {SomeExtend} from 'type-fest';
|
|
1467
|
-
|
|
1468
|
-
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1469
|
-
//=> true
|
|
1470
|
-
```
|
|
1471
|
-
|
|
1472
|
-
```
|
|
1473
|
-
// @exactOptionalPropertyTypes: false
|
|
1474
|
-
import type {SomeExtend} from 'type-fest';
|
|
1475
|
-
|
|
1476
|
-
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1477
|
-
//=> boolean
|
|
1478
|
-
|
|
1479
|
-
type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
|
|
1480
|
-
//=> true
|
|
1481
|
-
```
|
|
1482
|
-
|
|
1483
|
-
@see {@link SomeExtendOptions}
|
|
1484
|
-
|
|
1485
|
-
@category Utilities
|
|
1486
|
-
@category Array
|
|
1487
|
-
*/
|
|
1488
|
-
type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
|
|
1489
|
-
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
1490
|
-
? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
|
|
1491
|
-
//#endregion
|
|
1492
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or-all.d.ts
|
|
1493
|
-
/**
|
|
1494
|
-
Returns a boolean for whether any of the given elements is `true`.
|
|
1495
|
-
|
|
1496
|
-
Use-cases:
|
|
1497
|
-
- Check if at least one condition in a list of booleans is met.
|
|
1498
|
-
|
|
1499
|
-
@example
|
|
1500
|
-
```
|
|
1501
|
-
import type {OrAll} from 'type-fest';
|
|
1502
|
-
|
|
1503
|
-
type FFT = OrAll<[false, false, true]>;
|
|
1504
|
-
//=> true
|
|
1505
|
-
|
|
1506
|
-
type FFF = OrAll<[false, false, false]>;
|
|
1507
|
-
//=> false
|
|
1508
|
-
```
|
|
1509
|
-
|
|
1510
|
-
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1511
|
-
For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1512
|
-
|
|
1513
|
-
@example
|
|
1514
|
-
```
|
|
1515
|
-
import type {OrAll} from 'type-fest';
|
|
1516
|
-
|
|
1517
|
-
type A = OrAll<[false, boolean]>;
|
|
1518
|
-
//=> boolean
|
|
1519
|
-
|
|
1520
|
-
type B = OrAll<[true, boolean]>;
|
|
1521
|
-
//=> true
|
|
1522
|
-
```
|
|
1523
|
-
|
|
1524
|
-
Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
|
|
1525
|
-
|
|
1526
|
-
@example
|
|
1527
|
-
```
|
|
1528
|
-
import type {OrAll} from 'type-fest';
|
|
1529
|
-
|
|
1530
|
-
type A = OrAll<[never, never, true]>;
|
|
1531
|
-
//=> true
|
|
1532
|
-
|
|
1533
|
-
type B = OrAll<[never, never, false]>;
|
|
1534
|
-
//=> false
|
|
1535
|
-
|
|
1536
|
-
type C = OrAll<[never, never, never]>;
|
|
1537
|
-
//=> false
|
|
1538
|
-
|
|
1539
|
-
type D = OrAll<[never, never, boolean]>;
|
|
1540
|
-
//=> boolean
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
|
|
1544
|
-
|
|
1545
|
-
@example
|
|
1546
|
-
```
|
|
1547
|
-
import type {OrAll} from 'type-fest';
|
|
1548
|
-
|
|
1549
|
-
type A = OrAll<[false, any]>;
|
|
1550
|
-
//=> boolean
|
|
1551
|
-
|
|
1552
|
-
type B = OrAll<[true, any]>;
|
|
1553
|
-
//=> true
|
|
1554
|
-
```
|
|
1555
|
-
|
|
1556
|
-
Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
|
|
1557
|
-
|
|
1558
|
-
@see {@link Or}
|
|
1559
|
-
@see {@link AndAll}
|
|
1560
|
-
*/
|
|
1561
|
-
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
1562
|
-
//#endregion
|
|
1563
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or.d.ts
|
|
1564
|
-
/**
|
|
1565
|
-
Returns a boolean for whether either of two given types is true.
|
|
1566
|
-
|
|
1567
|
-
Use-case: Constructing complex conditional types where at least one condition must be satisfied.
|
|
1568
|
-
|
|
1569
|
-
@example
|
|
1570
|
-
```
|
|
1571
|
-
import type {Or} from 'type-fest';
|
|
1572
|
-
|
|
1573
|
-
type TT = Or<true, true>;
|
|
1574
|
-
//=> true
|
|
1575
|
-
|
|
1576
|
-
type TF = Or<true, false>;
|
|
1577
|
-
//=> true
|
|
1578
|
-
|
|
1579
|
-
type FT = Or<false, true>;
|
|
1580
|
-
//=> true
|
|
1581
|
-
|
|
1582
|
-
type FF = Or<false, false>;
|
|
1583
|
-
//=> false
|
|
1584
|
-
```
|
|
1585
|
-
|
|
1586
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1587
|
-
For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1588
|
-
|
|
1589
|
-
@example
|
|
1590
|
-
```
|
|
1591
|
-
import type {Or} from 'type-fest';
|
|
1592
|
-
|
|
1593
|
-
type A = Or<false, boolean>;
|
|
1594
|
-
//=> boolean
|
|
1595
|
-
|
|
1596
|
-
type B = Or<boolean, false>;
|
|
1597
|
-
//=> boolean
|
|
1598
|
-
|
|
1599
|
-
type C = Or<true, boolean>;
|
|
1600
|
-
//=> true
|
|
1601
|
-
|
|
1602
|
-
type D = Or<boolean, true>;
|
|
1603
|
-
//=> true
|
|
1604
|
-
|
|
1605
|
-
type E = Or<boolean, boolean>;
|
|
1606
|
-
//=> boolean
|
|
1607
|
-
```
|
|
1608
|
-
|
|
1609
|
-
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
1610
|
-
|
|
1611
|
-
@example
|
|
1612
|
-
```
|
|
1613
|
-
import type {Or} from 'type-fest';
|
|
1614
|
-
|
|
1615
|
-
type A = Or<true, never>;
|
|
1616
|
-
//=> true
|
|
1617
|
-
|
|
1618
|
-
type B = Or<never, true>;
|
|
1619
|
-
//=> true
|
|
1620
|
-
|
|
1621
|
-
type C = Or<false, never>;
|
|
1622
|
-
//=> false
|
|
1623
|
-
|
|
1624
|
-
type D = Or<never, false>;
|
|
1625
|
-
//=> false
|
|
1626
|
-
|
|
1627
|
-
type E = Or<boolean, never>;
|
|
1628
|
-
//=> boolean
|
|
1629
|
-
|
|
1630
|
-
type F = Or<never, boolean>;
|
|
1631
|
-
//=> boolean
|
|
1632
|
-
|
|
1633
|
-
type G = Or<never, never>;
|
|
1634
|
-
//=> false
|
|
1635
|
-
```
|
|
1636
|
-
|
|
1637
|
-
@see {@link OrAll}
|
|
1638
|
-
@see {@link And}
|
|
1639
|
-
@see {@link Xor}
|
|
1640
|
-
*/
|
|
1641
|
-
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
1642
|
-
//#endregion
|
|
1643
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/all-extend.d.ts
|
|
1644
|
-
/**
|
|
1645
|
-
@see {@link AllExtend}
|
|
1646
|
-
*/
|
|
1647
|
-
type AllExtendOptions = {
|
|
1648
|
-
/**
|
|
1649
|
-
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1650
|
-
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1651
|
-
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1652
|
-
@default true
|
|
1653
|
-
@example
|
|
1654
|
-
```
|
|
1655
|
-
import type {AllExtend} from 'type-fest';
|
|
1656
|
-
type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
|
|
1657
|
-
//=> false
|
|
1658
|
-
type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
|
|
1659
|
-
//=> true
|
|
1660
|
-
type C = AllExtend<[never, never], never, {strictNever: true}>;
|
|
1661
|
-
//=> true
|
|
1662
|
-
type D = AllExtend<[never, never], never, {strictNever: false}>;
|
|
1663
|
-
//=> true
|
|
1664
|
-
type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
|
|
1665
|
-
//=> true
|
|
1666
|
-
type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
|
|
1667
|
-
//=> true
|
|
1668
|
-
type G = AllExtend<[never, 1], never, {strictNever: true}>;
|
|
1669
|
-
//=> false
|
|
1670
|
-
type H = AllExtend<[never, 1], never, {strictNever: false}>;
|
|
1671
|
-
//=> false
|
|
1672
|
-
```
|
|
1673
|
-
*/
|
|
1674
|
-
strictNever?: boolean;
|
|
1675
|
-
};
|
|
1676
|
-
type DefaultAllExtendOptions = {
|
|
1677
|
-
strictNever: true;
|
|
1678
|
-
};
|
|
1679
|
-
/**
|
|
1680
|
-
Returns a boolean for whether every element in an array type extends another type.
|
|
1681
|
-
|
|
1682
|
-
@example
|
|
1683
|
-
```
|
|
1684
|
-
import type {AllExtend} from 'type-fest';
|
|
1685
|
-
|
|
1686
|
-
type A = AllExtend<[1, 2, 3], number>;
|
|
1687
|
-
//=> true
|
|
1688
|
-
|
|
1689
|
-
type B = AllExtend<[1, 2, '3'], number>;
|
|
1690
|
-
//=> false
|
|
1691
|
-
|
|
1692
|
-
type C = AllExtend<[number, number | string], number>;
|
|
1693
|
-
//=> boolean
|
|
1694
|
-
|
|
1695
|
-
type D = AllExtend<[true, boolean, true], true>;
|
|
1696
|
-
//=> boolean
|
|
1697
|
-
```
|
|
1698
|
-
|
|
1699
|
-
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1700
|
-
|
|
1701
|
-
```
|
|
1702
|
-
// @exactOptionalPropertyTypes: true
|
|
1703
|
-
import type {AllExtend} from 'type-fest';
|
|
1704
|
-
|
|
1705
|
-
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1706
|
-
//=> true
|
|
1707
|
-
```
|
|
1708
|
-
|
|
1709
|
-
```
|
|
1710
|
-
// @exactOptionalPropertyTypes: false
|
|
1711
|
-
import type {AllExtend} from 'type-fest';
|
|
1712
|
-
|
|
1713
|
-
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1714
|
-
//=> boolean
|
|
1715
|
-
|
|
1716
|
-
type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
1717
|
-
//=> true
|
|
1718
|
-
```
|
|
1719
|
-
|
|
1720
|
-
@see {@link AllExtendOptions}
|
|
1721
|
-
|
|
1722
|
-
@category Utilities
|
|
1723
|
-
@category Array
|
|
1724
|
-
*/
|
|
1725
|
-
type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
|
|
1726
|
-
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
1727
|
-
? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
|
|
1728
|
-
//#endregion
|
|
1729
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/and-all.d.ts
|
|
1730
|
-
/**
|
|
1731
|
-
Returns a boolean for whether all of the given elements are `true`.
|
|
1732
|
-
|
|
1733
|
-
Use-cases:
|
|
1734
|
-
- Check if all conditions in a list of booleans are met.
|
|
1735
|
-
|
|
1736
|
-
@example
|
|
1737
|
-
```
|
|
1738
|
-
import type {AndAll} from 'type-fest';
|
|
1739
|
-
|
|
1740
|
-
type TTT = AndAll<[true, true, true]>;
|
|
1741
|
-
//=> true
|
|
1742
|
-
|
|
1743
|
-
type TTF = AndAll<[true, true, false]>;
|
|
1744
|
-
//=> false
|
|
1745
|
-
|
|
1746
|
-
type TFT = AndAll<[true, false, true]>;
|
|
1747
|
-
//=> false
|
|
1748
|
-
```
|
|
1749
|
-
|
|
1750
|
-
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1751
|
-
For example, `AndAll<[true, boolean]>` expands to `AndAll<[true, true]> | AndAll<[true, false]>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1752
|
-
|
|
1753
|
-
@example
|
|
1754
|
-
```
|
|
1755
|
-
import type {AndAll} from 'type-fest';
|
|
1756
|
-
|
|
1757
|
-
type A = AndAll<[true, boolean]>;
|
|
1758
|
-
//=> boolean
|
|
1759
|
-
|
|
1760
|
-
type B = AndAll<[false, boolean]>;
|
|
1761
|
-
//=> false
|
|
1762
|
-
```
|
|
1763
|
-
|
|
1764
|
-
Note: If any of the elements is `never`, the result becomes `false`.
|
|
1765
|
-
|
|
1766
|
-
@example
|
|
1767
|
-
```
|
|
1768
|
-
import type {AndAll} from 'type-fest';
|
|
1769
|
-
|
|
1770
|
-
type A = AndAll<[true, true, never]>;
|
|
1771
|
-
//=> false
|
|
1772
|
-
|
|
1773
|
-
type B = AndAll<[false, never, never]>;
|
|
1774
|
-
//=> false
|
|
1775
|
-
|
|
1776
|
-
type C = AndAll<[never, never, never]>;
|
|
1777
|
-
//=> false
|
|
1778
|
-
|
|
1779
|
-
type D = AndAll<[boolean, true, never]>;
|
|
1780
|
-
//=> false
|
|
1781
|
-
```
|
|
1782
|
-
|
|
1783
|
-
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
|
|
1784
|
-
|
|
1785
|
-
@example
|
|
1786
|
-
```
|
|
1787
|
-
import type {AndAll} from 'type-fest';
|
|
1788
|
-
|
|
1789
|
-
type A = AndAll<[false, any]>;
|
|
1790
|
-
//=> false
|
|
1791
|
-
|
|
1792
|
-
type B = AndAll<[true, any]>;
|
|
1793
|
-
//=> boolean
|
|
1794
|
-
```
|
|
1795
|
-
|
|
1796
|
-
Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](https://en.wikipedia.org/wiki/Logical_conjunction#:~:text=In%20keeping%20with%20the%20concept%20of%20vacuous%20truth%2C%20when%20conjunction%20is%20defined%20as%20an%20operator%20or%20function%20of%20arbitrary%20arity%2C%20the%20empty%20conjunction%20(AND%2Ding%20over%20an%20empty%20set%20of%20operands)%20is%20often%20defined%20as%20having%20the%20result%20true.), i.e., there are no `false` elements in an empty tuple.
|
|
1797
|
-
|
|
1798
|
-
@see {@link And}
|
|
1799
|
-
@see {@link OrAll}
|
|
1800
|
-
*/
|
|
1801
|
-
type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
|
|
1802
|
-
//#endregion
|
|
1803
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/and.d.ts
|
|
1804
|
-
/**
|
|
1805
|
-
Returns a boolean for whether two given types are both true.
|
|
1806
|
-
|
|
1807
|
-
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
1808
|
-
|
|
1809
|
-
@example
|
|
1810
|
-
```
|
|
1811
|
-
import type {And} from 'type-fest';
|
|
1812
|
-
|
|
1813
|
-
type TT = And<true, true>;
|
|
1814
|
-
//=> true
|
|
1815
|
-
|
|
1816
|
-
type TF = And<true, false>;
|
|
1817
|
-
//=> false
|
|
1818
|
-
|
|
1819
|
-
type FT = And<false, true>;
|
|
1820
|
-
//=> false
|
|
1821
|
-
|
|
1822
|
-
type FF = And<false, false>;
|
|
1823
|
-
//=> false
|
|
1824
|
-
```
|
|
1825
|
-
|
|
1826
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1827
|
-
For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1828
|
-
|
|
1829
|
-
@example
|
|
1830
|
-
```
|
|
1831
|
-
import type {And} from 'type-fest';
|
|
1832
|
-
|
|
1833
|
-
type A = And<true, boolean>;
|
|
1834
|
-
//=> boolean
|
|
1835
|
-
|
|
1836
|
-
type B = And<boolean, true>;
|
|
1837
|
-
//=> boolean
|
|
1838
|
-
|
|
1839
|
-
type C = And<false, boolean>;
|
|
1840
|
-
//=> false
|
|
1841
|
-
|
|
1842
|
-
type D = And<boolean, false>;
|
|
1843
|
-
//=> false
|
|
1844
|
-
|
|
1845
|
-
type E = And<boolean, boolean>;
|
|
1846
|
-
//=> boolean
|
|
1847
|
-
```
|
|
1848
|
-
|
|
1849
|
-
Note: If either of the types is `never`, the result becomes `false`.
|
|
1850
|
-
|
|
1851
|
-
@example
|
|
1852
|
-
```
|
|
1853
|
-
import type {And} from 'type-fest';
|
|
1854
|
-
|
|
1855
|
-
type A = And<true, never>;
|
|
1856
|
-
//=> false
|
|
1857
|
-
|
|
1858
|
-
type B = And<never, true>;
|
|
1859
|
-
//=> false
|
|
1860
|
-
|
|
1861
|
-
type C = And<false, never>;
|
|
1862
|
-
//=> false
|
|
1863
|
-
|
|
1864
|
-
type D = And<never, false>;
|
|
1865
|
-
//=> false
|
|
1866
|
-
|
|
1867
|
-
type E = And<boolean, never>;
|
|
1868
|
-
//=> false
|
|
1869
|
-
|
|
1870
|
-
type F = And<never, boolean>;
|
|
1871
|
-
//=> false
|
|
1872
|
-
|
|
1873
|
-
type G = And<never, never>;
|
|
1874
|
-
//=> false
|
|
1875
|
-
```
|
|
1876
|
-
|
|
1877
|
-
@see {@link AndAll}
|
|
1878
|
-
@see {@link Or}
|
|
1879
|
-
@see {@link Xor}
|
|
1880
|
-
*/
|
|
1881
|
-
type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
|
|
1882
|
-
//#endregion
|
|
1883
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/greater-than.d.ts
|
|
1884
|
-
/**
|
|
1885
|
-
Returns a boolean for whether a given number is greater than another number.
|
|
1886
|
-
|
|
1887
|
-
@example
|
|
1888
|
-
```
|
|
1889
|
-
import type {GreaterThan} from 'type-fest';
|
|
1890
|
-
|
|
1891
|
-
type A = GreaterThan<1, -5>;
|
|
1892
|
-
//=> true
|
|
1893
|
-
|
|
1894
|
-
type B = GreaterThan<1, 1>;
|
|
1895
|
-
//=> false
|
|
1896
|
-
|
|
1897
|
-
type C = GreaterThan<1, 5>;
|
|
1898
|
-
//=> false
|
|
1899
|
-
```
|
|
1900
|
-
|
|
1901
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
1902
|
-
|
|
1903
|
-
@example
|
|
1904
|
-
```
|
|
1905
|
-
import type {GreaterThan} from 'type-fest';
|
|
1906
|
-
|
|
1907
|
-
type A = GreaterThan<number, 1>;
|
|
1908
|
-
//=> boolean
|
|
1909
|
-
|
|
1910
|
-
type B = GreaterThan<1, number>;
|
|
1911
|
-
//=> boolean
|
|
1912
|
-
|
|
1913
|
-
type C = GreaterThan<number, number>;
|
|
1914
|
-
//=> boolean
|
|
1915
|
-
```
|
|
1916
|
-
|
|
1917
|
-
@example
|
|
1918
|
-
```
|
|
1919
|
-
import type {GreaterThan} from 'type-fest';
|
|
1920
|
-
|
|
1921
|
-
// Use `GreaterThan` to constrain a function parameter to positive numbers.
|
|
1922
|
-
declare function setPositive<N extends number>(value: GreaterThan<N, 0> extends true ? N : never): void;
|
|
1923
|
-
|
|
1924
|
-
setPositive(1); // ✅ Allowed
|
|
1925
|
-
setPositive(2); // ✅ Allowed
|
|
1926
|
-
|
|
1927
|
-
// @ts-expect-error
|
|
1928
|
-
setPositive(0);
|
|
1929
|
-
|
|
1930
|
-
// @ts-expect-error
|
|
1931
|
-
setPositive(-1);
|
|
1932
|
-
```
|
|
1933
|
-
*/
|
|
1934
|
-
type GreaterThan<A extends number, B extends number> = A extends number // For distributing `A`
|
|
1935
|
-
? B extends number // For distributing `B`
|
|
1936
|
-
? number extends A | B ? boolean : [IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>, IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`> : never : never : never // Should never happen
|
|
1937
|
-
: never;
|
|
1938
|
-
//#endregion
|
|
1939
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
|
|
1940
|
-
/**
|
|
1941
|
-
Returns a boolean for whether a given number is greater than or equal to another number.
|
|
1942
|
-
|
|
1943
|
-
@example
|
|
1944
|
-
```
|
|
1945
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1946
|
-
|
|
1947
|
-
type A = GreaterThanOrEqual<1, -5>;
|
|
1948
|
-
//=> true
|
|
1949
|
-
|
|
1950
|
-
type B = GreaterThanOrEqual<1, 1>;
|
|
1951
|
-
//=> true
|
|
1952
|
-
|
|
1953
|
-
type C = GreaterThanOrEqual<1, 5>;
|
|
1954
|
-
//=> false
|
|
1955
|
-
```
|
|
1956
|
-
|
|
1957
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
1958
|
-
|
|
1959
|
-
@example
|
|
1960
|
-
```
|
|
1961
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1962
|
-
|
|
1963
|
-
type A = GreaterThanOrEqual<number, 1>;
|
|
1964
|
-
//=> boolean
|
|
1965
|
-
|
|
1966
|
-
type B = GreaterThanOrEqual<1, number>;
|
|
1967
|
-
//=> boolean
|
|
1968
|
-
|
|
1969
|
-
type C = GreaterThanOrEqual<number, number>;
|
|
1970
|
-
//=> boolean
|
|
1971
|
-
```
|
|
1972
|
-
|
|
1973
|
-
@example
|
|
1974
|
-
```
|
|
1975
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1976
|
-
|
|
1977
|
-
// Use `GreaterThanOrEqual` to constrain a function parameter to non-negative numbers.
|
|
1978
|
-
declare function setNonNegative<N extends number>(value: GreaterThanOrEqual<N, 0> extends true ? N : never): void;
|
|
1979
|
-
|
|
1980
|
-
setNonNegative(0); // ✅ Allowed
|
|
1981
|
-
setNonNegative(1); // ✅ Allowed
|
|
1982
|
-
|
|
1983
|
-
// @ts-expect-error
|
|
1984
|
-
setNonNegative(-1);
|
|
1985
|
-
|
|
1986
|
-
// @ts-expect-error
|
|
1987
|
-
setNonNegative(-2);
|
|
1988
|
-
```
|
|
1989
|
-
*/
|
|
1990
|
-
type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? boolean : A extends number // For distributing `A`
|
|
1991
|
-
? B extends number // For distributing `B`
|
|
1992
|
-
? A extends B ? true : GreaterThan<A, B> : never // Should never happen
|
|
1993
|
-
: never;
|
|
1994
|
-
//#endregion
|
|
1995
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/less-than.d.ts
|
|
1996
|
-
/**
|
|
1997
|
-
Returns a boolean for whether a given number is less than another number.
|
|
1998
|
-
|
|
1999
|
-
@example
|
|
2000
|
-
```
|
|
2001
|
-
import type {LessThan} from 'type-fest';
|
|
2002
|
-
|
|
2003
|
-
type A = LessThan<1, -5>;
|
|
2004
|
-
//=> false
|
|
2005
|
-
|
|
2006
|
-
type B = LessThan<1, 1>;
|
|
2007
|
-
//=> false
|
|
2008
|
-
|
|
2009
|
-
type C = LessThan<1, 5>;
|
|
2010
|
-
//=> true
|
|
2011
|
-
```
|
|
2012
|
-
|
|
2013
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
2014
|
-
|
|
2015
|
-
@example
|
|
2016
|
-
```
|
|
2017
|
-
import type {LessThan} from 'type-fest';
|
|
2018
|
-
|
|
2019
|
-
type A = LessThan<number, 1>;
|
|
2020
|
-
//=> boolean
|
|
2021
|
-
|
|
2022
|
-
type B = LessThan<1, number>;
|
|
2023
|
-
//=> boolean
|
|
2024
|
-
|
|
2025
|
-
type C = LessThan<number, number>;
|
|
2026
|
-
//=> boolean
|
|
2027
|
-
```
|
|
2028
|
-
|
|
2029
|
-
@example
|
|
2030
|
-
```
|
|
2031
|
-
import type {LessThan} from 'type-fest';
|
|
2032
|
-
|
|
2033
|
-
// Use `LessThan` to constrain a function parameter to negative numbers.
|
|
2034
|
-
declare function setNegative<N extends number>(value: LessThan<N, 0> extends true ? N : never): void;
|
|
2035
|
-
|
|
2036
|
-
setNegative(-1); // ✅ Allowed
|
|
2037
|
-
setNegative(-2); // ✅ Allowed
|
|
2038
|
-
|
|
2039
|
-
// @ts-expect-error
|
|
2040
|
-
setNegative(0);
|
|
2041
|
-
|
|
2042
|
-
// @ts-expect-error
|
|
2043
|
-
setNegative(1);
|
|
2044
|
-
```
|
|
2045
|
-
*/
|
|
2046
|
-
type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
|
|
2047
|
-
//#endregion
|
|
2048
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/tuple.d.ts
|
|
2049
|
-
// Should never happen
|
|
2050
|
-
/**
|
|
2051
|
-
Returns the maximum value from a tuple of integers.
|
|
2052
|
-
|
|
2053
|
-
Note:
|
|
2054
|
-
- Float numbers are not supported.
|
|
2055
|
-
|
|
2056
|
-
@example
|
|
2057
|
-
```
|
|
2058
|
-
type A = TupleMax<[1, 2, 5, 3]>;
|
|
2059
|
-
//=> 5
|
|
2060
|
-
|
|
2061
|
-
type B = TupleMax<[1, 2, 5, 3, 99, -1]>;
|
|
2062
|
-
//=> 99
|
|
2063
|
-
```
|
|
2064
|
-
*/
|
|
2065
|
-
type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? GreaterThan<F, Result> extends true ? TupleMax<R, F> : TupleMax<R, Result> : Result;
|
|
2066
|
-
//#endregion
|
|
2067
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
2068
|
-
/**
|
|
2069
|
-
@see {@link PartialDeep}
|
|
2070
|
-
*/
|
|
2071
|
-
type PartialDeepOptions = {
|
|
2072
|
-
/**
|
|
2073
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
2074
|
-
@default false
|
|
2075
|
-
*/
|
|
2076
|
-
readonly recurseIntoArrays?: boolean;
|
|
2077
|
-
/**
|
|
2078
|
-
Allows `undefined` values in non-tuple arrays.
|
|
2079
|
-
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
2080
|
-
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
2081
|
-
@default false
|
|
2082
|
-
@example
|
|
2083
|
-
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
2084
|
-
```
|
|
2085
|
-
import type {PartialDeep} from 'type-fest';
|
|
2086
|
-
type Settings = {
|
|
2087
|
-
languages: string[];
|
|
2088
|
-
};
|
|
2089
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
2090
|
-
partialSettings.languages = [undefined]; // OK
|
|
2091
|
-
```
|
|
2092
|
-
*/
|
|
2093
|
-
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
2094
|
-
};
|
|
2095
|
-
type DefaultPartialDeepOptions = {
|
|
2096
|
-
recurseIntoArrays: false;
|
|
2097
|
-
allowUndefinedInNonTupleArrays: false;
|
|
2098
|
-
};
|
|
2099
|
-
/**
|
|
2100
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
2101
|
-
|
|
2102
|
-
Use-cases:
|
|
2103
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
2104
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
2105
|
-
|
|
2106
|
-
@example
|
|
2107
|
-
```
|
|
2108
|
-
import type {PartialDeep} from 'type-fest';
|
|
2109
|
-
|
|
2110
|
-
let settings = {
|
|
2111
|
-
textEditor: {
|
|
2112
|
-
fontSize: 14,
|
|
2113
|
-
fontColor: '#000000',
|
|
2114
|
-
fontWeight: 400,
|
|
2115
|
-
},
|
|
2116
|
-
autocomplete: false,
|
|
2117
|
-
autosave: true,
|
|
2118
|
-
};
|
|
2119
|
-
|
|
2120
|
-
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
2121
|
-
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
2122
|
-
);
|
|
2123
|
-
|
|
2124
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
2125
|
-
```
|
|
2126
|
-
|
|
2127
|
-
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
2128
|
-
|
|
2129
|
-
```
|
|
2130
|
-
import type {PartialDeep} from 'type-fest';
|
|
2131
|
-
|
|
2132
|
-
type Shape = {
|
|
2133
|
-
dimensions: [number, number];
|
|
2134
|
-
};
|
|
2135
|
-
|
|
2136
|
-
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
2137
|
-
dimensions: [], // OK
|
|
2138
|
-
};
|
|
2139
|
-
|
|
2140
|
-
partialShape.dimensions = [15]; // OK
|
|
2141
|
-
```
|
|
2142
|
-
|
|
2143
|
-
@see {@link PartialDeepOptions}
|
|
2144
|
-
|
|
2145
|
-
@category Object
|
|
2146
|
-
@category Array
|
|
2147
|
-
@category Set
|
|
2148
|
-
@category Map
|
|
2149
|
-
*/
|
|
2150
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
2151
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T // For functions with no properties
|
|
2152
|
-
: HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
2153
|
-
? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
2154
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
2155
|
-
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
|
|
2156
|
-
: T // If they don't opt into array testing, just use the original type
|
|
2157
|
-
: PartialObjectDeep<T, Options> : unknown;
|
|
2158
|
-
/**
|
|
2159
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
2160
|
-
*/
|
|
2161
|
-
type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
2162
|
-
/**
|
|
2163
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
2164
|
-
*/
|
|
2165
|
-
type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
2166
|
-
/**
|
|
2167
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
2168
|
-
*/
|
|
2169
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
2170
|
-
/**
|
|
2171
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
2172
|
-
*/
|
|
2173
|
-
type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
2174
|
-
/**
|
|
2175
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
2176
|
-
*/
|
|
2177
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
|
|
2178
|
-
//#endregion
|
|
2179
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/subtract.d.ts
|
|
2180
|
-
/**
|
|
2181
|
-
Returns the difference between two numbers.
|
|
2182
|
-
|
|
2183
|
-
Note:
|
|
2184
|
-
- A or B can only support `-999` ~ `999`.
|
|
2185
|
-
|
|
2186
|
-
@example
|
|
2187
|
-
```
|
|
2188
|
-
import type {Subtract, PositiveInfinity} from 'type-fest';
|
|
2189
|
-
|
|
2190
|
-
type A = Subtract<333, 222>;
|
|
2191
|
-
//=> 111
|
|
2192
|
-
|
|
2193
|
-
type B = Subtract<111, -222>;
|
|
2194
|
-
//=> 333
|
|
2195
|
-
|
|
2196
|
-
type C = Subtract<-111, 222>;
|
|
2197
|
-
//=> -333
|
|
2198
|
-
|
|
2199
|
-
type D = Subtract<18, 96>;
|
|
2200
|
-
//=> -78
|
|
2201
|
-
|
|
2202
|
-
type E = Subtract<PositiveInfinity, 9999>;
|
|
2203
|
-
//=> Infinity
|
|
2204
|
-
|
|
2205
|
-
type F = Subtract<PositiveInfinity, PositiveInfinity>;
|
|
2206
|
-
//=> number
|
|
2207
|
-
```
|
|
2208
|
-
|
|
2209
|
-
@category Numeric
|
|
2210
|
-
*/
|
|
2211
|
-
// TODO: Support big integer.
|
|
2212
|
-
type Subtract<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
|
|
2213
|
-
number extends A | B ? number // Handle cases when A and B are both +/- infinity
|
|
2214
|
-
: A extends B & (PositiveInfinity | NegativeInfinity) ? number // Handle cases when A is - infinity or B is + infinity
|
|
2215
|
-
: A extends NegativeInfinity ? NegativeInfinity : B extends PositiveInfinity ? NegativeInfinity // Handle cases when A is + infinity or B is - infinity
|
|
2216
|
-
: A extends PositiveInfinity ? PositiveInfinity : B extends NegativeInfinity ? PositiveInfinity // Handle case when numbers are equal to each other
|
|
2217
|
-
: A extends B ? 0 // Handle cases when A or B is 0
|
|
2218
|
-
: A extends 0 ? ReverseSign<B> : B extends 0 ? A // Handle remaining regular cases
|
|
2219
|
-
: SubtractPostChecks<A, B>;
|
|
2220
|
-
/**
|
|
2221
|
-
Subtracts two numbers A and B, such that they are not equal and neither of them are 0, +/- infinity or the `number` type
|
|
2222
|
-
*/
|
|
2223
|
-
type SubtractPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] ? SubtractPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we subtract the absolute values and then reverse the sign
|
|
2224
|
-
? ReverseSign<SubtractPositives<NumberAbsolute<A>, NumberAbsolute<B>>> // When the signs are different we can add the absolute values and then reverse the sign if A < B
|
|
2225
|
-
: [...TupleOf<NumberAbsolute<A>>, ...TupleOf<NumberAbsolute<B>>] extends infer R extends unknown[] ? LessThan<A, B> extends true ? ReverseSign<R['length']> : R['length'] : never;
|
|
2226
|
-
/**
|
|
2227
|
-
Subtracts two positive numbers.
|
|
2228
|
-
*/
|
|
2229
|
-
type SubtractPositives<A extends number, B extends number> = LessThan<A, B> extends true // When A < B we can reverse the result of B - A
|
|
2230
|
-
? ReverseSign<SubtractIfAGreaterThanB<B, A>> : SubtractIfAGreaterThanB<A, B>;
|
|
2231
|
-
/**
|
|
2232
|
-
Subtracts two positive numbers A and B such that A > B.
|
|
2233
|
-
*/
|
|
2234
|
-
type SubtractIfAGreaterThanB<A extends number, B extends number> = // This is where we always want to end up and do the actual subtraction
|
|
2235
|
-
TupleOf<A> extends [...TupleOf<B>, ...infer R] ? R['length'] : never;
|
|
2236
|
-
//#endregion
|
|
2237
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/sum.d.ts
|
|
2238
|
-
/**
|
|
2239
|
-
Returns the sum of two numbers.
|
|
2240
|
-
|
|
2241
|
-
Note:
|
|
2242
|
-
- A or B can only support `-999` ~ `999`.
|
|
2243
|
-
|
|
2244
|
-
@example
|
|
2245
|
-
```
|
|
2246
|
-
import type {Sum, PositiveInfinity, NegativeInfinity} from 'type-fest';
|
|
2247
|
-
|
|
2248
|
-
type A = Sum<111, 222>;
|
|
2249
|
-
//=> 333
|
|
2250
|
-
|
|
2251
|
-
type B = Sum<-111, 222>;
|
|
2252
|
-
//=> 111
|
|
2253
|
-
|
|
2254
|
-
type C = Sum<111, -222>;
|
|
2255
|
-
//=> -111
|
|
2256
|
-
|
|
2257
|
-
type D = Sum<PositiveInfinity, -9999>;
|
|
2258
|
-
//=> Infinity
|
|
2259
|
-
|
|
2260
|
-
type E = Sum<PositiveInfinity, NegativeInfinity>;
|
|
2261
|
-
//=> number
|
|
2262
|
-
```
|
|
2263
|
-
|
|
2264
|
-
@category Numeric
|
|
2265
|
-
*/
|
|
2266
|
-
// TODO: Support big integer.
|
|
2267
|
-
type Sum<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
|
|
2268
|
-
number extends A | B ? number // Handle cases when A and B are both +/- infinity
|
|
2269
|
-
: A extends B & (PositiveInfinity | NegativeInfinity) ? A // A or B could be used here as they are equal
|
|
2270
|
-
// Handle cases when A and B are opposite infinities
|
|
2271
|
-
: A | B extends PositiveInfinity | NegativeInfinity ? number // Handle cases when A is +/- infinity
|
|
2272
|
-
: A extends PositiveInfinity | NegativeInfinity ? A // Handle cases when B is +/- infinity
|
|
2273
|
-
: B extends PositiveInfinity | NegativeInfinity ? B // Handle cases when A or B is 0 or it's the same number with different signs
|
|
2274
|
-
: A extends 0 ? B : B extends 0 ? A : A extends ReverseSign<B> ? 0 // Handle remaining regular cases
|
|
2275
|
-
: SumPostChecks<A, B>;
|
|
2276
|
-
/**
|
|
2277
|
-
Adds two numbers A and B, such that they are not equal with different signs and neither of them are 0, +/- infinity or the `number` type
|
|
2278
|
-
*/
|
|
2279
|
-
type SumPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] // When both numbers are positive we can add them together
|
|
2280
|
-
? SumPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we add the absolute values and then reverse the sign
|
|
2281
|
-
? ReverseSign<SumPositives<NumberAbsolute<A>, NumberAbsolute<B>>> // When the signs are different we can subtract the absolute values, remove the sign
|
|
2282
|
-
// and then reverse the sign if the larger absolute value is negative
|
|
2283
|
-
: NumberAbsolute<Subtract<NumberAbsolute<A>, NumberAbsolute<B>>> extends infer Result extends number ? TupleMax<[NumberAbsolute<A>, NumberAbsolute<B>]> extends infer Max_ extends number ? Max_ extends A | B // The larger absolute value is positive, so the result is positive
|
|
2284
|
-
? Result // The larger absolute value is negative, so the result is negative
|
|
2285
|
-
: ReverseSign<Result> : never : never;
|
|
2286
|
-
/**
|
|
2287
|
-
Adds two positive numbers.
|
|
2288
|
-
*/
|
|
2289
|
-
type SumPositives<A extends number, B extends number> = [...TupleOf<A>, ...TupleOf<B>]['length'] extends infer Result extends number ? Result : never;
|
|
2290
|
-
//#endregion
|
|
2291
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/paths.d.ts
|
|
2292
|
-
/**
|
|
2293
|
-
Paths options.
|
|
2294
|
-
|
|
2295
|
-
@see {@link Paths}
|
|
2296
|
-
*/
|
|
2297
|
-
type PathsOptions = {
|
|
2298
|
-
/**
|
|
2299
|
-
The maximum depth to recurse when searching for paths. Range: 0 ~ 10.
|
|
2300
|
-
@default 5
|
|
2301
|
-
*/
|
|
2302
|
-
maxRecursionDepth?: number;
|
|
2303
|
-
/**
|
|
2304
|
-
Use bracket notation for array indices and numeric object keys.
|
|
2305
|
-
@default false
|
|
2306
|
-
@example
|
|
2307
|
-
```
|
|
2308
|
-
import type {Paths} from 'type-fest';
|
|
2309
|
-
type ArrayExample = {
|
|
2310
|
-
array: ['foo'];
|
|
2311
|
-
};
|
|
2312
|
-
type A = Paths<ArrayExample, {bracketNotation: false}>;
|
|
2313
|
-
//=> 'array' | 'array.0'
|
|
2314
|
-
type B = Paths<ArrayExample, {bracketNotation: true}>;
|
|
2315
|
-
//=> 'array' | 'array[0]'
|
|
2316
|
-
```
|
|
2317
|
-
@example
|
|
2318
|
-
```
|
|
2319
|
-
import type {Paths} from 'type-fest';
|
|
2320
|
-
type NumberKeyExample = {
|
|
2321
|
-
1: ['foo'];
|
|
2322
|
-
};
|
|
2323
|
-
type A = Paths<NumberKeyExample, {bracketNotation: false}>;
|
|
2324
|
-
//=> 1 | '1' | '1.0'
|
|
2325
|
-
type B = Paths<NumberKeyExample, {bracketNotation: true}>;
|
|
2326
|
-
//=> '[1]' | '[1][0]'
|
|
2327
|
-
```
|
|
2328
|
-
*/
|
|
2329
|
-
bracketNotation?: boolean;
|
|
2330
|
-
/**
|
|
2331
|
-
Only include leaf paths in the output.
|
|
2332
|
-
@default false
|
|
2333
|
-
@example
|
|
2334
|
-
```
|
|
2335
|
-
import type {Paths} from 'type-fest';
|
|
2336
|
-
type Post = {
|
|
2337
|
-
id: number;
|
|
2338
|
-
author: {
|
|
2339
|
-
id: number;
|
|
2340
|
-
name: {
|
|
2341
|
-
first: string;
|
|
2342
|
-
last: string;
|
|
2343
|
-
};
|
|
2344
|
-
};
|
|
2345
|
-
};
|
|
2346
|
-
type AllPaths = Paths<Post, {leavesOnly: false}>;
|
|
2347
|
-
//=> 'id' | 'author' | 'author.id' | 'author.name' | 'author.name.first' | 'author.name.last'
|
|
2348
|
-
type LeafPaths = Paths<Post, {leavesOnly: true}>;
|
|
2349
|
-
//=> 'id' | 'author.id' | 'author.name.first' | 'author.name.last'
|
|
2350
|
-
```
|
|
2351
|
-
@example
|
|
2352
|
-
```
|
|
2353
|
-
import type {Paths} from 'type-fest';
|
|
2354
|
-
type ArrayExample = {
|
|
2355
|
-
array: Array<{foo: string}>;
|
|
2356
|
-
tuple: [string, {bar: string}];
|
|
2357
|
-
};
|
|
2358
|
-
type AllPaths = Paths<ArrayExample, {leavesOnly: false}>;
|
|
2359
|
-
//=> 'array' | 'tuple' | `array.${number}` | `array.${number}.foo` | 'tuple.0' | 'tuple.1' | 'tuple.1.bar'
|
|
2360
|
-
type LeafPaths = Paths<ArrayExample, {leavesOnly: true}>;
|
|
2361
|
-
//=> `array.${number}.foo` | 'tuple.0' | 'tuple.1.bar'
|
|
2362
|
-
```
|
|
2363
|
-
*/
|
|
2364
|
-
leavesOnly?: boolean;
|
|
2365
|
-
/**
|
|
2366
|
-
Only include paths at the specified depth. By default all paths up to {@link PathsOptions.maxRecursionDepth | `maxRecursionDepth`} are included.
|
|
2367
|
-
Note: Depth starts at `0` for root properties.
|
|
2368
|
-
@default number
|
|
2369
|
-
@example
|
|
2370
|
-
```
|
|
2371
|
-
import type {Paths} from 'type-fest';
|
|
2372
|
-
type Post = {
|
|
2373
|
-
id: number;
|
|
2374
|
-
author: {
|
|
2375
|
-
id: number;
|
|
2376
|
-
name: {
|
|
2377
|
-
first: string;
|
|
2378
|
-
last: string;
|
|
2379
|
-
};
|
|
2380
|
-
};
|
|
2381
|
-
};
|
|
2382
|
-
type DepthZero = Paths<Post, {depth: 0}>;
|
|
2383
|
-
//=> 'id' | 'author'
|
|
2384
|
-
type DepthOne = Paths<Post, {depth: 1}>;
|
|
2385
|
-
//=> 'author.id' | 'author.name'
|
|
2386
|
-
type DepthTwo = Paths<Post, {depth: 2}>;
|
|
2387
|
-
//=> 'author.name.first' | 'author.name.last'
|
|
2388
|
-
type LeavesAtDepthOne = Paths<Post, {leavesOnly: true; depth: 1}>;
|
|
2389
|
-
//=> 'author.id'
|
|
2390
|
-
```
|
|
2391
|
-
*/
|
|
2392
|
-
depth?: number;
|
|
2393
|
-
};
|
|
2394
|
-
type DefaultPathsOptions = {
|
|
2395
|
-
maxRecursionDepth: 5;
|
|
2396
|
-
bracketNotation: false;
|
|
2397
|
-
leavesOnly: false;
|
|
2398
|
-
depth: number;
|
|
2399
|
-
};
|
|
2400
|
-
/**
|
|
2401
|
-
Generate a union of all possible paths to properties in the given object.
|
|
2402
|
-
|
|
2403
|
-
It also works with arrays.
|
|
2404
|
-
|
|
2405
|
-
Use-case: You want a type-safe way to access deeply nested properties in an object.
|
|
2406
|
-
|
|
2407
|
-
@example
|
|
2408
|
-
```
|
|
2409
|
-
import type {Paths} from 'type-fest';
|
|
2410
|
-
|
|
2411
|
-
type Project = {
|
|
2412
|
-
filename: string;
|
|
2413
|
-
listA: string[];
|
|
2414
|
-
listB: [{filename: string}];
|
|
2415
|
-
folder: {
|
|
2416
|
-
subfolder: {
|
|
2417
|
-
filename: string;
|
|
2418
|
-
};
|
|
2419
|
-
};
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
type ProjectPaths = Paths<Project>;
|
|
2423
|
-
//=> 'filename' | 'listA' | 'listB' | 'folder' | `listA.${number}` | 'listB.0' | 'listB.0.filename' | 'folder.subfolder' | 'folder.subfolder.filename'
|
|
2424
|
-
|
|
2425
|
-
declare function open<Path extends ProjectPaths>(path: Path): void;
|
|
2426
|
-
|
|
2427
|
-
open('filename'); // Pass
|
|
2428
|
-
open('folder.subfolder'); // Pass
|
|
2429
|
-
open('folder.subfolder.filename'); // Pass
|
|
2430
|
-
// @ts-expect-error
|
|
2431
|
-
open('foo'); // TypeError
|
|
2432
|
-
|
|
2433
|
-
// Also works with arrays
|
|
2434
|
-
open('listA.1'); // Pass
|
|
2435
|
-
open('listB.0'); // Pass
|
|
2436
|
-
// @ts-expect-error
|
|
2437
|
-
open('listB.1'); // TypeError. Because listB only has one element.
|
|
2438
|
-
```
|
|
2439
|
-
|
|
2440
|
-
@category Object
|
|
2441
|
-
@category Array
|
|
2442
|
-
*/
|
|
2443
|
-
type Paths$1<T, Options extends PathsOptions = {}> = _Paths<T, ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, Options>>;
|
|
2444
|
-
type _Paths<T, Options extends Required<PathsOptions>, CurrentDepth extends number = 0> = T extends NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray> ? never : IsAny<T> extends true ? never : T extends object ? InternalPaths<Required<T>, Options, CurrentDepth> : never;
|
|
2445
|
-
type InternalPaths<T, Options extends Required<PathsOptions>, CurrentDepth extends number> = { [Key in keyof T]: Key extends string | number // Limit `Key` to `string | number`
|
|
2446
|
-
? (And<Options['bracketNotation'], IsNumberLike<Key>> extends true ? `[${Key}]` : CurrentDepth extends 0 // Return both `Key` and `ToString<Key>` because for number keys, like `1`, both `1` and `'1'` are valid keys.
|
|
2447
|
-
? Key | ToString<Key> : `.${(Key | ToString<Key>)}`) extends infer TransformedKey extends string | number ? ((Options['leavesOnly'] extends true ? Options['maxRecursionDepth'] extends CurrentDepth ? TransformedKey : IsNever<T[Key]> extends true ? TransformedKey : T[Key] extends infer Value // For distributing `T[Key]`
|
|
2448
|
-
? (Value extends readonly [] | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray> ? TransformedKey : IsNever<keyof Value> extends true // Check for empty object & `unknown`, because `keyof unknown` is `never`.
|
|
2449
|
-
? TransformedKey : never) : never // Should never happen
|
|
2450
|
-
: TransformedKey) extends infer _TransformedKey // If `depth` is provided, the condition becomes truthy only when it matches `CurrentDepth`.
|
|
2451
|
-
// Otherwise, since `depth` defaults to `number`, the condition is always truthy, returning paths at all depths.
|
|
2452
|
-
? CurrentDepth extends Options['depth'] ? _TransformedKey : never : never) // Recursively generate paths for the current key
|
|
2453
|
-
| (GreaterThan<Options['maxRecursionDepth'], CurrentDepth> extends true // Limit the depth to prevent infinite recursion
|
|
2454
|
-
? `${TransformedKey}${_Paths<T[Key], Options, Sum<CurrentDepth, 1>> & (string | number)}` : never) : never : never }[keyof T & (T extends UnknownArray ? number : unknown)];
|
|
2455
|
-
//#endregion
|
|
2456
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/literal-union.d.ts
|
|
2457
|
-
type _LiteralStringUnion<T> = LiteralUnion<T, string>;
|
|
2458
|
-
/**
|
|
2459
|
-
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
2460
|
-
|
|
2461
|
-
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
2462
|
-
|
|
2463
|
-
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
2464
|
-
|
|
2465
|
-
@example
|
|
2466
|
-
```
|
|
2467
|
-
import type {LiteralUnion} from 'type-fest';
|
|
2468
|
-
|
|
2469
|
-
// Before
|
|
2470
|
-
|
|
2471
|
-
type Pet = 'dog' | 'cat' | string;
|
|
2472
|
-
|
|
2473
|
-
const petWithoutAutocomplete: Pet = '';
|
|
2474
|
-
// Start typing in your TypeScript-enabled IDE.
|
|
2475
|
-
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
2476
|
-
|
|
2477
|
-
// After
|
|
2478
|
-
|
|
2479
|
-
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
2480
|
-
|
|
2481
|
-
const petWithAutoComplete: Pet2 = '';
|
|
2482
|
-
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
2483
|
-
```
|
|
2484
|
-
|
|
2485
|
-
@category Type
|
|
2486
|
-
*/
|
|
2487
|
-
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
2488
|
-
//#endregion
|
|
2489
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/key-as-string.d.ts
|
|
2490
|
-
/**
|
|
2491
|
-
Get keys of the given type as strings.
|
|
2492
|
-
|
|
2493
|
-
Number keys are converted to strings.
|
|
2494
|
-
|
|
2495
|
-
Use-cases:
|
|
2496
|
-
- Get string keys from a type which may have number keys.
|
|
2497
|
-
- Makes it possible to index using strings retrieved from template types.
|
|
2498
|
-
|
|
2499
|
-
@example
|
|
2500
|
-
```
|
|
2501
|
-
import type {KeyAsString} from 'type-fest';
|
|
2502
|
-
|
|
2503
|
-
type Foo = {
|
|
2504
|
-
1: number;
|
|
2505
|
-
stringKey: string;
|
|
2506
|
-
};
|
|
2507
|
-
|
|
2508
|
-
type StringKeysOfFoo = KeyAsString<Foo>;
|
|
2509
|
-
//=> 'stringKey' | '1'
|
|
2510
|
-
```
|
|
2511
|
-
|
|
2512
|
-
@category Object
|
|
2513
|
-
*/
|
|
2514
|
-
type KeyAsString<BaseType> = `${Extract<keyof BaseType, string | number>}`;
|
|
2515
|
-
//#endregion
|
|
2516
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/split.d.ts
|
|
2517
|
-
/**
|
|
2518
|
-
Split options.
|
|
2519
|
-
|
|
2520
|
-
@see {@link Split}
|
|
2521
|
-
*/
|
|
2522
|
-
type SplitOptions = {
|
|
2523
|
-
/**
|
|
2524
|
-
When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
|
|
2525
|
-
@default true
|
|
2526
|
-
@example
|
|
2527
|
-
```ts
|
|
2528
|
-
import type {Split} from 'type-fest';
|
|
2529
|
-
type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
|
|
2530
|
-
//=> ['foo', string, 'bar']
|
|
2531
|
-
type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
|
|
2532
|
-
//=> string[]
|
|
2533
|
-
type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
|
|
2534
|
-
//=> ['foo', 'r', 'z']
|
|
2535
|
-
type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
|
|
2536
|
-
//=> string[]
|
|
2537
|
-
```
|
|
2538
|
-
*/
|
|
2539
|
-
strictLiteralChecks?: boolean;
|
|
2540
|
-
};
|
|
2541
|
-
type DefaultSplitOptions = {
|
|
2542
|
-
strictLiteralChecks: true;
|
|
2543
|
-
};
|
|
2544
|
-
/**
|
|
2545
|
-
Represents an array of strings split using a given character or character set.
|
|
2546
|
-
|
|
2547
|
-
Use-case: Defining the return type of a method like `String.prototype.split`.
|
|
2548
|
-
|
|
2549
|
-
@example
|
|
2550
|
-
```
|
|
2551
|
-
import type {Split} from 'type-fest';
|
|
2552
|
-
|
|
2553
|
-
declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
|
|
2554
|
-
|
|
2555
|
-
type Item = 'foo' | 'bar' | 'baz' | 'waldo';
|
|
2556
|
-
const items = 'foo,bar,baz,waldo';
|
|
2557
|
-
const array: Item[] = split(items, ',');
|
|
2558
|
-
```
|
|
2559
|
-
|
|
2560
|
-
@see {@link SplitOptions}
|
|
2561
|
-
|
|
2562
|
-
@category String
|
|
2563
|
-
@category Template literal
|
|
2564
|
-
*/
|
|
2565
|
-
type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
|
|
2566
|
-
type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
|
|
2567
|
-
? Delimiter extends string // For distributing `Delimiter`
|
|
2568
|
-
// If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
|
|
2569
|
-
? Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S] // Otherwise, return `string[]`
|
|
2570
|
-
: string[] : never // Should never happen
|
|
2571
|
-
: never; // Should never happen
|
|
2572
|
-
//#endregion
|
|
2573
|
-
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/get.d.ts
|
|
2574
|
-
type GetOptions = {
|
|
2575
|
-
/**
|
|
2576
|
-
Include `undefined` in the return type when accessing properties.
|
|
2577
|
-
Setting this to `false` is not recommended.
|
|
2578
|
-
@default true
|
|
2579
|
-
*/
|
|
2580
|
-
strict?: boolean;
|
|
2581
|
-
};
|
|
2582
|
-
type DefaultGetOptions = {
|
|
2583
|
-
strict: true;
|
|
2584
|
-
};
|
|
2585
|
-
/**
|
|
2586
|
-
Like the `Get` type but receives an array of strings as a path parameter.
|
|
2587
|
-
*/
|
|
2588
|
-
type GetWithPath<BaseType, Keys, Options extends Required<GetOptions>> = Keys extends readonly [] ? BaseType : Keys extends readonly [infer Head, ...infer Tail] ? GetWithPath<PropertyOf<BaseType, Extract<Head, string>, Options>, Extract<Tail, string[]>, Options> : never;
|
|
2589
|
-
/**
|
|
2590
|
-
Adds `undefined` to `Type` if `strict` is enabled.
|
|
2591
|
-
*/
|
|
2592
|
-
type Strictify<Type, Options extends Required<GetOptions>> = Options['strict'] extends false ? Type : (Type | undefined);
|
|
2593
|
-
/**
|
|
2594
|
-
If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
|
|
2595
|
-
|
|
2596
|
-
Known limitations:
|
|
2597
|
-
- Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
|
|
2598
|
-
*/
|
|
2599
|
-
type StrictPropertyOf<BaseType, Key extends keyof BaseType, Options extends Required<GetOptions>> = Record<string, any> extends BaseType ? string extends keyof BaseType ? Strictify<BaseType[Key], Options> // Record<string, any>
|
|
2600
|
-
: BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
|
|
2601
|
-
: BaseType[Key];
|
|
2602
|
-
/**
|
|
2603
|
-
Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
|
|
2604
|
-
|
|
2605
|
-
@example
|
|
2606
|
-
```
|
|
2607
|
-
type A = ToPath<'foo.bar.baz'>;
|
|
2608
|
-
//=> ['foo', 'bar', 'baz']
|
|
2609
|
-
|
|
2610
|
-
type B = ToPath<'foo[0].bar.baz'>;
|
|
2611
|
-
//=> ['foo', '0', 'bar', 'baz']
|
|
2612
|
-
```
|
|
2613
|
-
*/
|
|
2614
|
-
type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, '.', {
|
|
2615
|
-
strictLiteralChecks: false;
|
|
2616
|
-
}>;
|
|
2617
|
-
/**
|
|
2618
|
-
Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -> `foo.0.bar`.
|
|
2619
|
-
*/
|
|
2620
|
-
type FixPathSquareBrackets<Path extends string> = Path extends `[${infer Head}]${infer Tail}` ? Tail extends `[${string}` ? `${Head}.${FixPathSquareBrackets<Tail>}` : `${Head}${FixPathSquareBrackets<Tail>}` : Path extends `${infer Head}[${infer Middle}]${infer Tail}` ? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}` : Path;
|
|
2621
|
-
/**
|
|
2622
|
-
Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
|
|
2623
|
-
|
|
2624
|
-
@example
|
|
2625
|
-
```
|
|
2626
|
-
type A = ConsistsOnlyOf<'aaa', 'a'>; //=> true
|
|
2627
|
-
type B = ConsistsOnlyOf<'ababab', 'ab'>; //=> true
|
|
2628
|
-
type C = ConsistsOnlyOf<'aBa', 'a'>; //=> false
|
|
2629
|
-
type D = ConsistsOnlyOf<'', 'a'>; //=> true
|
|
2630
|
-
```
|
|
2631
|
-
*/
|
|
2632
|
-
type ConsistsOnlyOf<LongString extends string, Substring extends string> = LongString extends '' ? true : LongString extends `${Substring}${infer Tail}` ? ConsistsOnlyOf<Tail, Substring> : false;
|
|
2633
|
-
/**
|
|
2634
|
-
Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
|
|
2635
|
-
|
|
2636
|
-
@example
|
|
2637
|
-
```
|
|
2638
|
-
type WithNumbers = {foo: string; 0: boolean};
|
|
2639
|
-
type WithStrings = WithStringKeys<WithNumbers>;
|
|
2640
|
-
|
|
2641
|
-
type WithNumbersKeys = keyof WithNumbers;
|
|
2642
|
-
//=> 'foo' | 0
|
|
2643
|
-
type WithStringsKeys = keyof WithStrings;
|
|
2644
|
-
//=> 'foo' | '0'
|
|
2645
|
-
```
|
|
2646
|
-
*/
|
|
2647
|
-
type WithStringKeys<BaseType> = { [Key in KeyAsString<BaseType>]: UncheckedIndex<BaseType, Key> };
|
|
2648
|
-
/**
|
|
2649
|
-
Perform a `T[U]` operation if `T` supports indexing.
|
|
2650
|
-
*/
|
|
2651
|
-
type UncheckedIndex<T, U extends string | number> = [T] extends [Record<string | number, any>] ? T[U] : never;
|
|
2652
|
-
/**
|
|
2653
|
-
Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
|
|
2654
|
-
|
|
2655
|
-
Note:
|
|
2656
|
-
- Returns `unknown` if `Key` is not a property of `BaseType`, since TypeScript uses structural typing, and it cannot be guaranteed that extra properties unknown to the type system will exist at runtime.
|
|
2657
|
-
- Returns `undefined` from nullish values, to match the behaviour of most deep-key libraries like `lodash`, `dot-prop`, etc.
|
|
2658
|
-
*/
|
|
2659
|
-
type PropertyOf<BaseType, Key extends string, Options extends Required<GetOptions>> = BaseType extends null | undefined ? undefined : Key extends keyof BaseType ? StrictPropertyOf<BaseType, Key, Options> // Handle arrays and tuples
|
|
2660
|
-
: BaseType extends readonly unknown[] ? Key extends `${number}` // For arrays with unknown length (regular arrays)
|
|
2661
|
-
? number extends BaseType['length'] ? Strictify<BaseType[number], Options> // For tuples: check if the index is valid
|
|
2662
|
-
: Key extends keyof BaseType ? Strictify<BaseType[Key & keyof BaseType], Options> // Out-of-bounds access for tuples
|
|
2663
|
-
: unknown // Non-numeric string key for arrays/tuples
|
|
2664
|
-
: unknown // Handle array-like objects
|
|
2665
|
-
: BaseType extends {
|
|
2666
|
-
[n: number]: infer Item;
|
|
2667
|
-
length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
|
|
2668
|
-
} ? (ConsistsOnlyOf<Key, DigitCharacter> extends true ? Strictify<Item, Options> : unknown) : Key extends keyof WithStringKeys<BaseType> ? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options> : unknown; // This works by first splitting the path based on `.` and `[...]` characters into a tuple of string keys. Then it recursively uses the head key to get the next property of the current object, until there are no keys left. Number keys extract the item type from arrays, or are converted to strings to extract types from tuples and dictionaries with number keys.
|
|
2669
|
-
/**
|
|
2670
|
-
Get a deeply-nested property from an object using a key path, like Lodash's `.get()` function.
|
|
2671
|
-
|
|
2672
|
-
Use-case: Retrieve a property from deep inside an API response or some other complex object.
|
|
2673
|
-
|
|
2674
|
-
@example
|
|
2675
|
-
```
|
|
2676
|
-
import type {Get} from 'type-fest';
|
|
2677
|
-
|
|
2678
|
-
declare function get<BaseType, const Path extends string | readonly string[]>(object: BaseType, path: Path): Get<BaseType, Path>;
|
|
2679
|
-
|
|
2680
|
-
type ApiResponse = {
|
|
2681
|
-
hits: {
|
|
2682
|
-
hits: Array<{
|
|
2683
|
-
_id: string;
|
|
2684
|
-
_source: {
|
|
2685
|
-
name: Array<{
|
|
2686
|
-
given: string[];
|
|
2687
|
-
family: string;
|
|
2688
|
-
}>;
|
|
2689
|
-
birthDate: string;
|
|
2690
|
-
};
|
|
2691
|
-
}>;
|
|
2692
|
-
};
|
|
2693
|
-
};
|
|
2694
|
-
|
|
2695
|
-
const getName = (apiResponse: ApiResponse) => get(apiResponse, 'hits.hits[0]._source.name');
|
|
2696
|
-
//=> (apiResponse: ApiResponse) => {
|
|
2697
|
-
// given: string[];
|
|
2698
|
-
// family: string;
|
|
2699
|
-
// }[] | undefined
|
|
2700
|
-
|
|
2701
|
-
// Path also supports a readonly array of strings
|
|
2702
|
-
const getNameWithPathArray = (apiResponse: ApiResponse) => get(apiResponse, ['hits', 'hits', '0', '_source', 'name']);
|
|
2703
|
-
//=> (apiResponse: ApiResponse) => {
|
|
2704
|
-
// given: string[];
|
|
2705
|
-
// family: string;
|
|
2706
|
-
// }[] | undefined
|
|
2707
|
-
|
|
2708
|
-
// Non-strict mode:
|
|
2709
|
-
type A = Get<string[], '3', {strict: false}>;
|
|
2710
|
-
//=> string
|
|
2711
|
-
|
|
2712
|
-
type B = Get<Record<string, string>, 'foo', {strict: true}>;
|
|
2713
|
-
//=> string | undefined
|
|
2714
|
-
```
|
|
2715
|
-
|
|
2716
|
-
@category Object
|
|
2717
|
-
@category Array
|
|
2718
|
-
@category Template literal
|
|
2719
|
-
*/
|
|
2720
|
-
type Get<BaseType, Path extends readonly string[] | _LiteralStringUnion<ToString<Paths$1<BaseType, {
|
|
2721
|
-
bracketNotation: false;
|
|
2722
|
-
maxRecursionDepth: 2;
|
|
2723
|
-
}> | Paths$1<BaseType, {
|
|
2724
|
-
bracketNotation: true;
|
|
2725
|
-
maxRecursionDepth: 2;
|
|
2726
|
-
}>>>, Options extends GetOptions = {}> = GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, ApplyDefaultOptions<GetOptions, DefaultGetOptions, Options>>;
|
|
2727
|
-
//#endregion
|
|
2728
6
|
//#region src/types/shared.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The validation mode determines when validation occurs.
|
|
9
|
+
* - `lazy`: Validates on blur or submission.
|
|
10
|
+
* - `eager`: Validates on blur, then on every change if an error exists.
|
|
11
|
+
*/
|
|
12
|
+
type ValidationMode = 'eager' | 'lazy';
|
|
2729
13
|
/**
|
|
2730
14
|
* Interaction events that can trigger a validation check for a field.
|
|
2731
15
|
* - onBlur: Trigger validation when the field loses focus.
|
|
@@ -2787,6 +71,11 @@ type UseNotFormConfig<TSchema extends ObjectSchema> = {
|
|
|
2787
71
|
* @default { onBlur: true, onChange: true, onInput: true }
|
|
2788
72
|
*/
|
|
2789
73
|
validateOn?: Partial<Record<ValidationTrigger, boolean>>;
|
|
74
|
+
/**
|
|
75
|
+
* The validation mode of the form.
|
|
76
|
+
* @default { eager: true }
|
|
77
|
+
*/
|
|
78
|
+
validationMode?: Partial<Record<ValidationMode, boolean>>;
|
|
2790
79
|
/**
|
|
2791
80
|
* Callback triggered when form validation passes and the form is submitted.
|
|
2792
81
|
* @param values The validated output data from the schema.
|
|
@@ -2796,221 +85,288 @@ type UseNotFormConfig<TSchema extends ObjectSchema> = {
|
|
|
2796
85
|
//#endregion
|
|
2797
86
|
//#region src/types/not-form.d.ts
|
|
2798
87
|
/**
|
|
2799
|
-
* The
|
|
2800
|
-
* @template TSchema The validation schema type derived from ObjectSchema
|
|
88
|
+
* The complete state and API of a form instance returned by `useNotForm`.
|
|
89
|
+
* @template TSchema The validation schema type derived from `ObjectSchema`.
|
|
2801
90
|
*/
|
|
2802
|
-
type NotFormInstance<TSchema extends ObjectSchema> = {
|
|
2803
|
-
/**
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
* @example
|
|
2808
|
-
* const { values, submit, instance } = useNotForm({ schema, onSubmit })
|
|
2809
|
-
* // <NotForm :form="instance" />
|
|
2810
|
-
*/
|
|
2811
|
-
instance: NotFormInstance<TSchema>; /** The initial values the form was created or last reset with */
|
|
2812
|
-
readonly initialValues: UseNotFormConfig<TSchema>['initialValues']; /** The initial errors the form was created or last reset with */
|
|
2813
|
-
readonly initialErrors: UseNotFormConfig<TSchema>['initialErrors'];
|
|
91
|
+
type NotFormInstance<TSchema extends ObjectSchema> = Raw<{
|
|
92
|
+
/** The values the form was initialised or last reset with. */readonly initialValues: UseNotFormConfig<TSchema>['initialValues']; /** The errors the form was initialised or last reset with. */
|
|
93
|
+
readonly initialErrors: UseNotFormConfig<TSchema>['initialErrors']; /** The resolved validation triggers for this form. */
|
|
94
|
+
readonly validateOn: Required<NonNullable<UseNotFormConfig<TSchema>['validateOn']>>; /** The resolved validation mode for this form. */
|
|
95
|
+
readonly validationMode: Required<NonNullable<UseNotFormConfig<TSchema>['validationMode']>>;
|
|
2814
96
|
/**
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
97
|
+
* Deeply reactive object of field values.
|
|
98
|
+
*
|
|
99
|
+
* Access directly — no `.value` needed:
|
|
100
|
+
* ```ts
|
|
101
|
+
* form.values.email
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* Use with `v-model` for two-way binding:
|
|
105
|
+
* ```vue
|
|
106
|
+
* <input v-model="form.values.email" />
|
|
107
|
+
* ```
|
|
2817
108
|
*/
|
|
2818
|
-
|
|
2819
|
-
values: Ref<StandardSchemaV1.InferInput<TSchema>>;
|
|
109
|
+
values: StandardSchemaV1.InferInput<TSchema>;
|
|
2820
110
|
/**
|
|
2821
|
-
*
|
|
2822
|
-
*
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
111
|
+
* Sets a field value by dot-separated path.
|
|
112
|
+
*
|
|
113
|
+
* Useful for deeply nested paths or custom inputs that do not use `v-model`.
|
|
114
|
+
* Does **not** trigger validation — the field's event handlers are responsible for that.
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* form.setValue('address.city', 'Lagos')
|
|
118
|
+
* ```
|
|
2825
119
|
*/
|
|
2826
120
|
setValue: <const TPath extends Paths<StandardSchemaV1.InferInput<TSchema>>>(path: TPath, value: Get<StandardSchemaV1.InferInput<TSchema>, TPath, {
|
|
2827
121
|
strict: false;
|
|
2828
122
|
}>) => void;
|
|
2829
123
|
/**
|
|
2830
|
-
*
|
|
2831
|
-
*
|
|
2832
|
-
* @param values Partial object of field paths to new values.
|
|
124
|
+
* The set of field paths the user has interacted with.
|
|
125
|
+
* Populated for all paths when the form is submitted.
|
|
2833
126
|
*/
|
|
2834
|
-
|
|
2835
|
-
touchedFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>; /** Whether any field in the form has been touched */
|
|
127
|
+
touchedFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>; /** Whether any field has been touched. */
|
|
2836
128
|
isTouched: ComputedRef<boolean>;
|
|
2837
129
|
/**
|
|
2838
|
-
* Marks a
|
|
2839
|
-
*
|
|
2840
|
-
*/
|
|
2841
|
-
touchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
|
|
2842
|
-
/**
|
|
2843
|
-
* Marks a specific field as not touched.
|
|
2844
|
-
* @param path Dot-separated path to the field.
|
|
130
|
+
* Marks a field as touched.
|
|
131
|
+
* Typically called automatically by the field's `onBlur` handler.
|
|
2845
132
|
*/
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
unTouchAllFields: () => void; /** Reactive set of field paths that have been dirtied */
|
|
2849
|
-
dirtyFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>; /** Whether any field in the form has been dirtied */
|
|
133
|
+
touchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** The set of field paths whose current value differs from the initial value. */
|
|
134
|
+
dirtyFields: Set<Paths<StandardSchemaV1.InferInput<TSchema>>>; /** Whether any field value differs from its initial value. */
|
|
2850
135
|
isDirty: ComputedRef<boolean>;
|
|
2851
136
|
/**
|
|
2852
|
-
* Marks a
|
|
2853
|
-
*
|
|
2854
|
-
*/
|
|
2855
|
-
dirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
|
|
2856
|
-
/**
|
|
2857
|
-
* Marks a specific field as not dirty.
|
|
2858
|
-
* @param path Dot-separated path to the field.
|
|
137
|
+
* Marks a field as dirty.
|
|
138
|
+
* Typically called automatically when a field value changes.
|
|
2859
139
|
*/
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
unDirtyAllFields: () => void; /** The raw issues from the last validation */
|
|
2863
|
-
errors: Ref<StandardSchemaV1.Issue[]>;
|
|
140
|
+
dirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** The raw validation issues produced by the last validation run. */
|
|
141
|
+
errors: StandardSchemaV1.Issue[];
|
|
2864
142
|
/**
|
|
2865
|
-
* A flat
|
|
2866
|
-
*
|
|
143
|
+
* A flat map of field path to its first error message.
|
|
144
|
+
*
|
|
145
|
+
* Convenient for direct template access without calling `getFieldErrors`:
|
|
146
|
+
* ```vue
|
|
147
|
+
* <p>{{ form.errorsMap['address.city'] }}</p>
|
|
148
|
+
* ```
|
|
2867
149
|
*/
|
|
2868
150
|
errorsMap: ComputedRef<Partial<Record<Paths<StandardSchemaV1.InferInput<TSchema>>, string>>>;
|
|
2869
151
|
/**
|
|
2870
|
-
*
|
|
2871
|
-
*
|
|
2872
|
-
*/
|
|
2873
|
-
setError: (error: StandardSchemaV1.Issue) => void;
|
|
2874
|
-
/**
|
|
2875
|
-
* Replaces all current errors with the provided issues.
|
|
2876
|
-
* @param errors The new set of issues.
|
|
152
|
+
* Replaces an existing error for the same path, or appends it if none exists.
|
|
153
|
+
* Useful for setting server-side errors after submission.
|
|
2877
154
|
*/
|
|
2878
|
-
|
|
155
|
+
setError: (error: StandardSchemaV1.Issue) => void; /** Replaces all current errors with the provided issues. */
|
|
156
|
+
setErrors: (errors: StandardSchemaV1.Issue[]) => void; /** Removes all active validation errors. */
|
|
2879
157
|
clearErrors: () => void;
|
|
2880
158
|
/**
|
|
2881
159
|
* Returns all validation issues for a specific field path.
|
|
2882
|
-
*
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* form.getFieldErrors('address.city')
|
|
163
|
+
* ```
|
|
2883
164
|
*/
|
|
2884
|
-
getFieldErrors: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => StandardSchemaV1.Issue[]; /** Whether
|
|
165
|
+
getFieldErrors: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => StandardSchemaV1.Issue[]; /** Whether a validation run is currently in progress. */
|
|
2885
166
|
isValidating: Ref<boolean>;
|
|
2886
167
|
/**
|
|
2887
168
|
* Validates the entire form against the schema.
|
|
2888
|
-
*
|
|
169
|
+
* Replaces all current errors with the result.
|
|
2889
170
|
*/
|
|
2890
171
|
validate: () => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
2891
172
|
/**
|
|
2892
|
-
* Validates a
|
|
2893
|
-
* Only replaces errors for that field
|
|
2894
|
-
* @param path Dot-separated path to the field.
|
|
2895
|
-
* @returns A promise resolving to the validation result.
|
|
173
|
+
* Validates a single field against the schema.
|
|
174
|
+
* Only replaces errors for that field — all other fields are left untouched.
|
|
2896
175
|
*/
|
|
2897
|
-
validateField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>; /** Whether the form
|
|
2898
|
-
isValid: ComputedRef<boolean>; /** Whether the form is currently
|
|
176
|
+
validateField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>; /** Whether the form currently has no validation errors. */
|
|
177
|
+
isValid: ComputedRef<boolean>; /** Whether the form is currently running its submit handler. */
|
|
2899
178
|
isSubmitting: Ref<boolean>;
|
|
2900
179
|
/**
|
|
2901
|
-
* Validates and
|
|
2902
|
-
*
|
|
2903
|
-
*
|
|
2904
|
-
*
|
|
180
|
+
* Validates the form and runs `onSubmit` if it passes.
|
|
181
|
+
*
|
|
182
|
+
* Marks all fields as touched and dirty before validating so all errors surface.
|
|
183
|
+
* If validation fails, submission is aborted.
|
|
184
|
+
* Bind to the native form's `@submit` event:
|
|
185
|
+
*
|
|
186
|
+
* ```vue
|
|
187
|
+
* <form @submit="form.submit">
|
|
188
|
+
* ```
|
|
2905
189
|
*/
|
|
2906
190
|
submit: (event: Event) => Promise<void>;
|
|
2907
191
|
/**
|
|
2908
|
-
* Resets the form to its initial or provided
|
|
2909
|
-
*
|
|
2910
|
-
* If
|
|
2911
|
-
*
|
|
2912
|
-
*
|
|
192
|
+
* Resets the form to its initial state, or to new values and errors if provided.
|
|
193
|
+
*
|
|
194
|
+
* Clears all touched and dirty tracking. If `values` or `errors` are passed,
|
|
195
|
+
* they replace the stored baseline so subsequent resets return to the new state.
|
|
196
|
+
*
|
|
197
|
+
* ```ts
|
|
198
|
+
* // Reset to original initial values
|
|
199
|
+
* form.reset()
|
|
200
|
+
*
|
|
201
|
+
* // Reset to new values (becomes the new baseline)
|
|
202
|
+
* form.reset({ name: 'Jane' })
|
|
203
|
+
* ```
|
|
2913
204
|
*/
|
|
2914
205
|
reset: (values?: DeepPartial<StandardSchemaV1.InferInput<TSchema>>, errors?: StandardSchemaV1.Issue[]) => void;
|
|
206
|
+
}>;
|
|
207
|
+
/** Props for the `NotForm` component. */
|
|
208
|
+
type NotFormProps = {
|
|
209
|
+
/** The form instance to provide to all descendant `NotField` components. */form: NotFormInstance<any>;
|
|
2915
210
|
};
|
|
2916
|
-
/**
|
|
2917
|
-
* Props for the NotForm component
|
|
2918
|
-
* @template TSchema The validation schema type derived from ObjectSchema.
|
|
2919
|
-
*/
|
|
2920
|
-
type NotFormProps<TSchema extends ObjectSchema> = {
|
|
2921
|
-
/** The form instance to use */instance: NotFormInstance<TSchema>;
|
|
2922
|
-
};
|
|
211
|
+
/** Slots for the `NotForm` component. */
|
|
2923
212
|
type NotFormSlots = {
|
|
2924
|
-
|
|
213
|
+
default: [];
|
|
2925
214
|
};
|
|
2926
215
|
//#endregion
|
|
2927
216
|
//#region src/composables/use-not-form.d.ts
|
|
2928
217
|
declare function useNotForm<TSchema extends ObjectSchema>(config: UseNotFormConfig<TSchema>): NotFormInstance<TSchema>;
|
|
2929
218
|
//#endregion
|
|
2930
219
|
//#region src/components/not-form.vue.d.ts
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
}>) => _$vue.VNode & {
|
|
2940
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
220
|
+
type __VLS_Slots$1 = NotFormSlots;
|
|
221
|
+
declare const __VLS_base$1: _$vue.DefineComponent<NotFormProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotFormProps> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
222
|
+
declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
223
|
+
declare const _default$1: typeof __VLS_export$2;
|
|
224
|
+
type __VLS_WithSlots$1<T, S> = T & {
|
|
225
|
+
new (): {
|
|
226
|
+
$slots: S;
|
|
227
|
+
};
|
|
2941
228
|
};
|
|
2942
|
-
declare const _default$1: typeof __VLS_export$1;
|
|
2943
|
-
type __VLS_PrettifyLocal$1<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
2944
229
|
//#endregion
|
|
2945
230
|
//#region src/types/not-field.d.ts
|
|
2946
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* Native DOM event handlers exposed by a field.
|
|
233
|
+
* Spread onto a native input or bind individually to custom components.
|
|
234
|
+
*
|
|
235
|
+
* ```vue
|
|
236
|
+
* <!-- spread -->
|
|
237
|
+
* <input v-bind="events" />
|
|
238
|
+
*
|
|
239
|
+
* <!-- individual -->
|
|
240
|
+
* <CustomCombobox @focusout="onBlur" @pick="onChange" />
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
2947
243
|
type NotFieldEvents = {
|
|
2948
|
-
/** Triggered when the field loses focus */onBlur: () => void; /** Triggered on every keystroke or value change */
|
|
2949
|
-
onInput: () => void; /** Triggered when the field value is committed */
|
|
2950
|
-
onChange: () => void; /** Triggered when the field gains focus */
|
|
244
|
+
/** Triggered when the field loses focus. */onBlur: () => void; /** Triggered on every keystroke or value change. */
|
|
245
|
+
onInput: () => void; /** Triggered when the field value is committed. */
|
|
246
|
+
onChange: () => void; /** Triggered when the field gains focus. */
|
|
2951
247
|
onFocus: () => void;
|
|
2952
248
|
};
|
|
2953
|
-
/**
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
249
|
+
/** Props for the `NotField` component. */
|
|
250
|
+
type NotFieldProps = {
|
|
251
|
+
/** Dot-separated path to this field within the form values. */path: string;
|
|
252
|
+
/**
|
|
253
|
+
* Explicit form instance override.
|
|
254
|
+
* Takes priority over the instance provided by a `NotForm` ancestor.
|
|
255
|
+
* Required when using `NotField` outside of a `NotForm` (singleton fields).
|
|
256
|
+
*
|
|
257
|
+
* ```vue
|
|
258
|
+
* <NotField :form="form" path="email" v-slot="{ events }">
|
|
259
|
+
* <input v-bind="events" />
|
|
260
|
+
* </NotField>
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
form?: NotFormInstance<any>;
|
|
2961
264
|
/**
|
|
2962
265
|
* Per-field validation trigger overrides.
|
|
2963
|
-
* Merged over the form-wide validateOn
|
|
266
|
+
* Merged over the form-wide `validateOn` — only the keys you specify are overridden.
|
|
267
|
+
*
|
|
268
|
+
* ```vue
|
|
269
|
+
* <!-- form validates on blur only, but this field also validates on every input -->
|
|
270
|
+
* <NotField :validateOn="{ onInput: true }" path="username" />
|
|
271
|
+
* ```
|
|
2964
272
|
*/
|
|
2965
273
|
validateOn?: Partial<Record<ValidationTrigger, boolean>>;
|
|
2966
274
|
};
|
|
2967
275
|
/**
|
|
2968
|
-
*
|
|
2969
|
-
* @template TSchema The validation schema type derived from ObjectSchema
|
|
2970
|
-
* @template TPath The dot-separated path to the field within the form state.
|
|
276
|
+
* Everything available inside the `NotField` default slot.
|
|
277
|
+
* @template TSchema The validation schema type derived from `ObjectSchema`.
|
|
2971
278
|
*/
|
|
2972
|
-
type
|
|
2973
|
-
/** The dot-separated path to
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
279
|
+
type NotFieldSlotProps<TSchema extends ObjectSchema> = {
|
|
280
|
+
/** The dot-separated path to this field. */path: string;
|
|
281
|
+
/**
|
|
282
|
+
* The current value of this field — read-only snapshot for display purposes.
|
|
283
|
+
* Do not mutate directly or use with `v-model`.
|
|
284
|
+
* For two-way binding use `v-model="form.values.fieldName"` instead.
|
|
285
|
+
*/
|
|
286
|
+
value: any; /** All validation issues for this field from the last validation run. */
|
|
287
|
+
errors: StandardSchemaV1.Issue[]; /** Whether this field currently has no validation errors. */
|
|
288
|
+
isValid: boolean; /** Whether the user has interacted with this field, or the form has been submitted. */
|
|
289
|
+
isTouched: boolean; /** Whether this field's current value differs from its initial value. */
|
|
290
|
+
isDirty: boolean; /** Whether an async validator is currently running for this field. */
|
|
291
|
+
isValidating: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Manually triggers validation for this field.
|
|
294
|
+
* Useful for custom inputs that manage their own interaction events.
|
|
295
|
+
*/
|
|
296
|
+
validate: () => ReturnType<NotFormInstance<TSchema>['validateField']>;
|
|
2982
297
|
/**
|
|
2983
298
|
* All event handlers combined — spread directly onto native inputs.
|
|
2984
|
-
*
|
|
299
|
+
*
|
|
300
|
+
* ```vue
|
|
301
|
+
* <input v-bind="events" />
|
|
302
|
+
* ```
|
|
2985
303
|
*/
|
|
2986
|
-
events: NotFieldEvents; /** Triggered when the field loses focus */
|
|
2987
|
-
onBlur: NotFieldEvents['onBlur']; /** Triggered on every keystroke or value change */
|
|
2988
|
-
onInput: NotFieldEvents['onInput']; /** Triggered when the field value is committed */
|
|
2989
|
-
onChange: NotFieldEvents['onChange']; /** Triggered when the field gains focus */
|
|
304
|
+
events: NotFieldEvents; /** Triggered when the field loses focus. */
|
|
305
|
+
onBlur: NotFieldEvents['onBlur']; /** Triggered on every keystroke or value change. */
|
|
306
|
+
onInput: NotFieldEvents['onInput']; /** Triggered when the field value is committed. */
|
|
307
|
+
onChange: NotFieldEvents['onChange']; /** Triggered when the field gains focus. */
|
|
2990
308
|
onFocus: NotFieldEvents['onFocus'];
|
|
2991
309
|
};
|
|
2992
310
|
/**
|
|
2993
|
-
* Slots for the NotField component
|
|
2994
|
-
* @template TSchema The validation schema type derived from ObjectSchema
|
|
2995
|
-
* @template TPath The dot-separated path to the field within the form state.
|
|
311
|
+
* Slots for the `NotField` component.
|
|
312
|
+
* @template TSchema The validation schema type derived from `ObjectSchema`.
|
|
2996
313
|
*/
|
|
2997
|
-
type NotFieldSlots<TSchema extends ObjectSchema
|
|
2998
|
-
/** The default slot receives the full field
|
|
314
|
+
type NotFieldSlots<TSchema extends ObjectSchema> = {
|
|
315
|
+
/** The default slot receives the full field state and event handlers. */default: (props: NotFieldSlotProps<TSchema>) => [];
|
|
2999
316
|
};
|
|
3000
317
|
//#endregion
|
|
3001
318
|
//#region src/components/not-field.vue.d.ts
|
|
3002
|
-
declare const __VLS_export: <TSchema extends ObjectSchema
|
|
3003
|
-
props: _$vue.PublicProps & __VLS_PrettifyLocal<NotFieldProps
|
|
319
|
+
declare const __VLS_export$1: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
320
|
+
props: _$vue.PublicProps & __VLS_PrettifyLocal<NotFieldProps> & (typeof globalThis extends {
|
|
3004
321
|
__VLS_PROPS_FALLBACK: infer P;
|
|
3005
322
|
} ? P : {});
|
|
3006
323
|
expose: (exposed: {}) => void;
|
|
3007
324
|
attrs: any;
|
|
3008
|
-
slots: NotFieldSlots<TSchema
|
|
325
|
+
slots: NotFieldSlots<TSchema>;
|
|
3009
326
|
emit: {};
|
|
3010
327
|
}>) => _$vue.VNode & {
|
|
3011
328
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
3012
329
|
};
|
|
3013
|
-
declare const _default: typeof __VLS_export;
|
|
330
|
+
declare const _default: typeof __VLS_export$1;
|
|
3014
331
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
3015
332
|
//#endregion
|
|
3016
|
-
|
|
333
|
+
//#region src/types/not-message.d.ts
|
|
334
|
+
/** Props for the `NotMessage` component. */
|
|
335
|
+
type NotMessageProps = {
|
|
336
|
+
/** The name/path of the field whose error message should be displayed */path: string; /** HTML Tag `NotMessage` should render as - default is `span`. */
|
|
337
|
+
as?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Explicit form instance override.
|
|
340
|
+
* Takes priority over the instance provided by a `NotForm` ancestor.
|
|
341
|
+
* Required when using `NotMessage` outside of a `NotForm` (singleton fields).
|
|
342
|
+
*
|
|
343
|
+
* ```vue
|
|
344
|
+
* <NotMessage :form="form" path="email" />
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
form?: NotFormInstance<any>;
|
|
348
|
+
};
|
|
349
|
+
/** Everything available inside the `NotMessage` default slot. */
|
|
350
|
+
type NotMessageSlotProps = {
|
|
351
|
+
/** The first active validation error message for the specified field */message?: string; /** Attributes passed to the `NotMessage` component */
|
|
352
|
+
attributes?: ReturnType<typeof useAttrs>;
|
|
353
|
+
};
|
|
354
|
+
/** Slots for the `NotMessage` component. */
|
|
355
|
+
type NotMessageSlots = {
|
|
356
|
+
/** The default slot receives the error message context for custom rendering */default: (props: NotMessageSlotProps) => [];
|
|
357
|
+
};
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/components/not-message.vue.d.ts
|
|
360
|
+
type __VLS_Slots = NotMessageSlots;
|
|
361
|
+
declare const __VLS_base: _$vue.DefineComponent<NotMessageProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotMessageProps> & Readonly<{}>, {
|
|
362
|
+
as: string;
|
|
363
|
+
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
364
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
365
|
+
declare const _default$2: typeof __VLS_export;
|
|
366
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
367
|
+
new (): {
|
|
368
|
+
$slots: S;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
//#endregion
|
|
372
|
+
export { ArraySchema, DeepPartial, _default as NotField, NotFieldEvents, NotFieldProps, NotFieldSlotProps, NotFieldSlots, _default$1 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, _default$2 as NotMessage, NotMessageProps, NotMessageSlotProps, NotMessageSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationMode, ValidationTrigger, useNotForm };
|