@metajoy/config 1.0.2 → 1.0.3

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