@pawover/kit 0.0.0-beta.4 → 0.0.0-beta.41

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.
Files changed (40) hide show
  1. package/dist/enums-BL6w5-mS.js +148 -0
  2. package/dist/enums-BL6w5-mS.js.map +1 -0
  3. package/dist/enums.d.ts +2 -25
  4. package/dist/enums.js +2 -24
  5. package/dist/except-MacUK44u.d.ts +971 -0
  6. package/dist/except-MacUK44u.d.ts.map +1 -0
  7. package/dist/hooks-alova.d.ts +22 -13
  8. package/dist/hooks-alova.d.ts.map +1 -1
  9. package/dist/hooks-alova.js +54 -24
  10. package/dist/hooks-alova.js.map +1 -1
  11. package/dist/hooks-react.d.ts +82 -42
  12. package/dist/hooks-react.d.ts.map +1 -1
  13. package/dist/hooks-react.js +83 -260
  14. package/dist/hooks-react.js.map +1 -1
  15. package/dist/index-Bn_PNnsM.d.ts +212 -0
  16. package/dist/index-Bn_PNnsM.d.ts.map +1 -0
  17. package/dist/index-DBPmnr4a.d.ts +21 -0
  18. package/dist/index-DBPmnr4a.d.ts.map +1 -0
  19. package/dist/index.d.ts +1958 -1029
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -1430
  22. package/dist/patches-fetchEventSource.d.ts +2 -721
  23. package/dist/patches-fetchEventSource.d.ts.map +1 -1
  24. package/dist/patches-fetchEventSource.js +1 -114
  25. package/dist/patches-fetchEventSource.js.map +1 -1
  26. package/dist/utils-_dtCs-qa.js +2004 -0
  27. package/dist/utils-_dtCs-qa.js.map +1 -0
  28. package/dist/value-of-DUmTbnuw.d.ts +26 -0
  29. package/dist/value-of-DUmTbnuw.d.ts.map +1 -0
  30. package/dist/vite.d.ts.map +1 -1
  31. package/dist/vite.js.map +1 -1
  32. package/dist/zod.d.ts +8 -1
  33. package/dist/zod.d.ts.map +1 -1
  34. package/dist/zod.js +13 -1
  35. package/dist/zod.js.map +1 -1
  36. package/metadata.json +31 -9
  37. package/package.json +31 -23
  38. package/dist/enums.d.ts.map +0 -1
  39. package/dist/enums.js.map +0 -1
  40. package/dist/index.js.map +0 -1
@@ -0,0 +1,971 @@
1
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/union-to-intersection.d.ts
2
+ /**
3
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
4
+
5
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
6
+
7
+ @example
8
+ ```
9
+ import type {UnionToIntersection} from 'type-fest';
10
+
11
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
12
+
13
+ type Intersection = UnionToIntersection<Union>;
14
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
15
+ ```
16
+
17
+ @category Type
18
+ */
19
+ type UnionToIntersection<Union> = (
20
+ // `extends unknown` is always going to be the case and is used to convert the
21
+ // `Union` into a [distributive conditional
22
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
23
+ Union extends unknown
24
+ // The union type is used as the only argument to a function since the union
25
+ // of function arguments is an intersection.
26
+ ? (distributedUnion: Union) => void
27
+ // This won't happen.
28
+ : never
29
+ // Infer the `Intersection` type since TypeScript represents the positional
30
+ // arguments of unions of functions as an intersection of the union.
31
+ ) extends ((mergedIntersection: infer Intersection) => void)
32
+ // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
33
+ ? Intersection & Union : never;
34
+ //#endregion
35
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/keys-of-union.d.ts
36
+ /**
37
+ Create a union of all keys from a given type, even those exclusive to specific union members.
38
+
39
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
40
+
41
+ @link https://stackoverflow.com/a/49402091
42
+
43
+ @example
44
+ ```
45
+ import type {KeysOfUnion} from 'type-fest';
46
+
47
+ type A = {
48
+ common: string;
49
+ a: number;
50
+ };
51
+
52
+ type B = {
53
+ common: string;
54
+ b: string;
55
+ };
56
+
57
+ type C = {
58
+ common: string;
59
+ c: boolean;
60
+ };
61
+
62
+ type Union = A | B | C;
63
+
64
+ type CommonKeys = keyof Union;
65
+ //=> 'common'
66
+
67
+ type AllKeys = KeysOfUnion<Union>;
68
+ //=> 'common' | 'a' | 'b' | 'c'
69
+ ```
70
+
71
+ @category Object
72
+ */
73
+ type KeysOfUnion<ObjectType> =
74
+ // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
75
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
76
+ //#endregion
77
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-any.d.ts
78
+ /**
79
+ Returns a boolean for whether the given type is `any`.
80
+
81
+ @link https://stackoverflow.com/a/49928360/1490091
82
+
83
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
84
+
85
+ @example
86
+ ```
87
+ import type {IsAny} from 'type-fest';
88
+
89
+ const typedObject = {a: 1, b: 2} as const;
90
+ const anyObject: any = {a: 1, b: 2};
91
+
92
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
93
+ return object[key];
94
+ }
95
+
96
+ const typedA = get(typedObject, 'a');
97
+ //=> 1
98
+
99
+ const anyA = get(anyObject, 'a');
100
+ //=> any
101
+ ```
102
+
103
+ @category Type Guard
104
+ @category Utilities
105
+ */
106
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
107
+ //#endregion
108
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-optional-key-of.d.ts
109
+ /**
110
+ Returns a boolean for whether the given key is an optional key of type.
111
+
112
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
113
+
114
+ @example
115
+ ```
116
+ import type {IsOptionalKeyOf} from 'type-fest';
117
+
118
+ type User = {
119
+ name: string;
120
+ surname: string;
121
+
122
+ luckyNumber?: number;
123
+ };
124
+
125
+ type Admin = {
126
+ name: string;
127
+ surname?: string;
128
+ };
129
+
130
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
131
+ //=> true
132
+
133
+ type T2 = IsOptionalKeyOf<User, 'name'>;
134
+ //=> false
135
+
136
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
137
+ //=> boolean
138
+
139
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
140
+ //=> false
141
+
142
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
143
+ //=> boolean
144
+ ```
145
+
146
+ @category Type Guard
147
+ @category Utilities
148
+ */
149
+ type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
150
+ //#endregion
151
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/optional-keys-of.d.ts
152
+ /**
153
+ Extract all optional keys from the given type.
154
+
155
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
156
+
157
+ @example
158
+ ```
159
+ import type {OptionalKeysOf, Except} from 'type-fest';
160
+
161
+ type User = {
162
+ name: string;
163
+ surname: string;
164
+
165
+ luckyNumber?: number;
166
+ };
167
+
168
+ const REMOVE_FIELD = Symbol('remove field symbol');
169
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
170
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
171
+ };
172
+
173
+ const update1: UpdateOperation<User> = {
174
+ name: 'Alice',
175
+ };
176
+
177
+ const update2: UpdateOperation<User> = {
178
+ name: 'Bob',
179
+ luckyNumber: REMOVE_FIELD,
180
+ };
181
+ ```
182
+
183
+ @category Utilities
184
+ */
185
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
186
+ ? (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`
187
+ : never;
188
+ //#endregion
189
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/required-keys-of.d.ts
190
+ /**
191
+ Extract all required keys from the given type.
192
+
193
+ 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...
194
+
195
+ @example
196
+ ```
197
+ import type {RequiredKeysOf} from 'type-fest';
198
+
199
+ declare function createValidation<
200
+ Entity extends object,
201
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
202
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
203
+
204
+ type User = {
205
+ name: string;
206
+ surname: string;
207
+ luckyNumber?: number;
208
+ };
209
+
210
+ const validator1 = createValidation<User>('name', value => value.length < 25);
211
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
212
+
213
+ // @ts-expect-error
214
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
215
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
216
+ ```
217
+
218
+ @category Utilities
219
+ */
220
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
221
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
222
+ //#endregion
223
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-never.d.ts
224
+ /**
225
+ Returns a boolean for whether the given type is `never`.
226
+
227
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
228
+ @link https://stackoverflow.com/a/53984913/10292952
229
+ @link https://www.zhenghao.io/posts/ts-never
230
+
231
+ Useful in type utilities, such as checking if something does not occur.
232
+
233
+ @example
234
+ ```
235
+ import type {IsNever, And} from 'type-fest';
236
+
237
+ type A = IsNever<never>;
238
+ //=> true
239
+
240
+ type B = IsNever<any>;
241
+ //=> false
242
+
243
+ type C = IsNever<unknown>;
244
+ //=> false
245
+
246
+ type D = IsNever<never[]>;
247
+ //=> false
248
+
249
+ type E = IsNever<object>;
250
+ //=> false
251
+
252
+ type F = IsNever<string>;
253
+ //=> false
254
+ ```
255
+
256
+ @example
257
+ ```
258
+ import type {IsNever} from 'type-fest';
259
+
260
+ type IsTrue<T> = T extends true ? true : false;
261
+
262
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
263
+ type A = IsTrue<never>;
264
+ //=> never
265
+
266
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
267
+ type IsTrueFixed<T> =
268
+ IsNever<T> extends true ? false : T extends true ? true : false;
269
+
270
+ type B = IsTrueFixed<never>;
271
+ //=> false
272
+ ```
273
+
274
+ @category Type Guard
275
+ @category Utilities
276
+ */
277
+ type IsNever<T> = [T] extends [never] ? true : false;
278
+ //#endregion
279
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/if.d.ts
280
+ /**
281
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
282
+
283
+ Use-cases:
284
+ - 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'>`.
285
+
286
+ Note:
287
+ - 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'`.
288
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
289
+
290
+ @example
291
+ ```
292
+ import type {If} from 'type-fest';
293
+
294
+ type A = If<true, 'yes', 'no'>;
295
+ //=> 'yes'
296
+
297
+ type B = If<false, 'yes', 'no'>;
298
+ //=> 'no'
299
+
300
+ type C = If<boolean, 'yes', 'no'>;
301
+ //=> 'yes' | 'no'
302
+
303
+ type D = If<any, 'yes', 'no'>;
304
+ //=> 'yes' | 'no'
305
+
306
+ type E = If<never, 'yes', 'no'>;
307
+ //=> 'no'
308
+ ```
309
+
310
+ @example
311
+ ```
312
+ import type {If, IsAny, IsNever} from 'type-fest';
313
+
314
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
315
+ //=> 'not any'
316
+
317
+ type B = If<IsNever<never>, 'is never', 'not never'>;
318
+ //=> 'is never'
319
+ ```
320
+
321
+ @example
322
+ ```
323
+ import type {If, IsEqual} from 'type-fest';
324
+
325
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
326
+
327
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
328
+ //=> 'equal'
329
+
330
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
331
+ //=> 'not equal'
332
+ ```
333
+
334
+ 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:
335
+
336
+ @example
337
+ ```
338
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
339
+
340
+ type HundredZeroes = StringRepeat<'0', 100>;
341
+
342
+ // The following implementation is not tail recursive
343
+ type Includes<S extends string, Char extends string> =
344
+ S extends `${infer First}${infer Rest}`
345
+ ? If<IsEqual<First, Char>,
346
+ 'found',
347
+ Includes<Rest, Char>>
348
+ : 'not found';
349
+
350
+ // Hence, instantiations with long strings will fail
351
+ // @ts-expect-error
352
+ type Fails = Includes<HundredZeroes, '1'>;
353
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354
+ // Error: Type instantiation is excessively deep and possibly infinite.
355
+
356
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
357
+ type IncludesWithoutIf<S extends string, Char extends string> =
358
+ S extends `${infer First}${infer Rest}`
359
+ ? IsEqual<First, Char> extends true
360
+ ? 'found'
361
+ : IncludesWithoutIf<Rest, Char>
362
+ : 'not found';
363
+
364
+ // Now, instantiations with long strings will work
365
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
366
+ //=> 'not found'
367
+ ```
368
+
369
+ @category Type Guard
370
+ @category Utilities
371
+ */
372
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
373
+ //#endregion
374
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/unknown-array.d.ts
375
+ /**
376
+ Represents an array with `unknown` value.
377
+
378
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
379
+
380
+ @example
381
+ ```
382
+ import type {UnknownArray} from 'type-fest';
383
+
384
+ type IsArray<T> = T extends UnknownArray ? true : false;
385
+
386
+ type A = IsArray<['foo']>;
387
+ //=> true
388
+
389
+ type B = IsArray<readonly number[]>;
390
+ //=> true
391
+
392
+ type C = IsArray<string>;
393
+ //=> false
394
+ ```
395
+
396
+ @category Type
397
+ @category Array
398
+ */
399
+ type UnknownArray = readonly unknown[];
400
+ //#endregion
401
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/internal/type.d.ts
402
+ /**
403
+ Returns a boolean for whether A is false.
404
+
405
+ @example
406
+ ```
407
+ type A = Not<true>;
408
+ //=> false
409
+
410
+ type B = Not<false>;
411
+ //=> true
412
+ ```
413
+ */
414
+ type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
415
+ /**
416
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
417
+
418
+ @example
419
+ ```
420
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
421
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
422
+ //=> 'VALID'
423
+
424
+ // When `T` is `any` => Returns `IfAny` branch
425
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
426
+ //=> 'IS_ANY'
427
+
428
+ // When `T` is `never` => Returns `IfNever` branch
429
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
430
+ //=> 'IS_NEVER'
431
+ ```
432
+
433
+ 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:
434
+
435
+ @example
436
+ ```ts
437
+ import type {StringRepeat} from 'type-fest';
438
+
439
+ type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
440
+
441
+ // The following implementation is not tail recursive
442
+ type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
443
+
444
+ // Hence, instantiations with long strings will fail
445
+ // @ts-expect-error
446
+ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
447
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
448
+ // Error: Type instantiation is excessively deep and possibly infinite.
449
+
450
+ // To fix this, move the recursion into a helper type
451
+ type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
452
+
453
+ type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
454
+
455
+ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
456
+ //=> ''
457
+ ```
458
+ */
459
+ type IfNotAnyOrNever<T, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever$1>>;
460
+ /**
461
+ Indicates the value of `exactOptionalPropertyTypes` compiler option.
462
+ */
463
+ type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
464
+ //#endregion
465
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/simplify.d.ts
466
+ /**
467
+ 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.
468
+
469
+ @example
470
+ ```
471
+ import type {Simplify} from 'type-fest';
472
+
473
+ type PositionProps = {
474
+ top: number;
475
+ left: number;
476
+ };
477
+
478
+ type SizeProps = {
479
+ width: number;
480
+ height: number;
481
+ };
482
+
483
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
484
+ type Props = Simplify<PositionProps & SizeProps>;
485
+ ```
486
+
487
+ 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.
488
+
489
+ 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`.
490
+
491
+ @example
492
+ ```
493
+ import type {Simplify} from 'type-fest';
494
+
495
+ interface SomeInterface {
496
+ foo: number;
497
+ bar?: string;
498
+ baz: number | undefined;
499
+ }
500
+
501
+ type SomeType = {
502
+ foo: number;
503
+ bar?: string;
504
+ baz: number | undefined;
505
+ };
506
+
507
+ const literal = {foo: 123, bar: 'hello', baz: 456};
508
+ const someType: SomeType = literal;
509
+ const someInterface: SomeInterface = literal;
510
+
511
+ declare function fn(object: Record<string, unknown>): void;
512
+
513
+ fn(literal); // Good: literal object type is sealed
514
+ fn(someType); // Good: type is sealed
515
+ // @ts-expect-error
516
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
517
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
518
+ ```
519
+
520
+ @link https://github.com/microsoft/TypeScript/issues/15300
521
+ @see {@link SimplifyDeep}
522
+ @category Object
523
+ */
524
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
525
+ //#endregion
526
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-equal.d.ts
527
+ /**
528
+ Returns a boolean for whether the two given types are equal.
529
+
530
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
531
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
532
+
533
+ Use-cases:
534
+ - If you want to make a conditional branch based on the result of a comparison of two types.
535
+
536
+ @example
537
+ ```
538
+ import type {IsEqual} from 'type-fest';
539
+
540
+ // This type returns a boolean for whether the given array includes the given item.
541
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
542
+ type Includes<Value extends readonly any[], Item> =
543
+ Value extends readonly [Value[0], ...infer rest]
544
+ ? IsEqual<Value[0], Item> extends true
545
+ ? true
546
+ : Includes<rest, Item>
547
+ : false;
548
+ ```
549
+
550
+ @category Type Guard
551
+ @category Utilities
552
+ */
553
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
554
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
555
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
556
+ //#endregion
557
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/omit-index-signature.d.ts
558
+ /**
559
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
560
+
561
+ This is the counterpart of `PickIndexSignature`.
562
+
563
+ Use-cases:
564
+ - Remove overly permissive signatures from third-party types.
565
+
566
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
567
+
568
+ 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>`.
569
+
570
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
571
+
572
+ ```
573
+ const indexed: Record<string, unknown> = {}; // Allowed
574
+
575
+ // @ts-expect-error
576
+ const keyed: Record<'foo', unknown> = {}; // Error
577
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
578
+ ```
579
+
580
+ 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:
581
+
582
+ ```
583
+ type Indexed = {} extends Record<string, unknown>
584
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
585
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
586
+
587
+ type IndexedResult = Indexed;
588
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
589
+
590
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
591
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
592
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
593
+
594
+ type KeyedResult = Keyed;
595
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
596
+ ```
597
+
598
+ 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`...
599
+
600
+ ```
601
+ type OmitIndexSignature<ObjectType> = {
602
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
603
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
604
+ };
605
+ ```
606
+
607
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
608
+
609
+ ```
610
+ type OmitIndexSignature<ObjectType> = {
611
+ [KeyType in keyof ObjectType
612
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
613
+ as {} extends Record<KeyType, unknown>
614
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
615
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
616
+ ]: ObjectType[KeyType];
617
+ };
618
+ ```
619
+
620
+ 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.
621
+
622
+ @example
623
+ ```
624
+ import type {OmitIndexSignature} from 'type-fest';
625
+
626
+ type Example = {
627
+ // These index signatures will be removed.
628
+ [x: string]: any;
629
+ [x: number]: any;
630
+ [x: symbol]: any;
631
+ [x: `head-${string}`]: string;
632
+ [x: `${string}-tail`]: string;
633
+ [x: `head-${string}-tail`]: string;
634
+ [x: `${bigint}`]: string;
635
+ [x: `embedded-${number}`]: string;
636
+
637
+ // These explicitly defined keys will remain.
638
+ foo: 'bar';
639
+ qux?: 'baz';
640
+ };
641
+
642
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
643
+ //=> {foo: 'bar'; qux?: 'baz'}
644
+ ```
645
+
646
+ @see {@link PickIndexSignature}
647
+ @category Object
648
+ */
649
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
650
+ //#endregion
651
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/pick-index-signature.d.ts
652
+ /**
653
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
654
+
655
+ This is the counterpart of `OmitIndexSignature`.
656
+
657
+ @example
658
+ ```
659
+ import type {PickIndexSignature} from 'type-fest';
660
+
661
+ declare const symbolKey: unique symbol;
662
+
663
+ type Example = {
664
+ // These index signatures will remain.
665
+ [x: string]: unknown;
666
+ [x: number]: unknown;
667
+ [x: symbol]: unknown;
668
+ [x: `head-${string}`]: string;
669
+ [x: `${string}-tail`]: string;
670
+ [x: `head-${string}-tail`]: string;
671
+ [x: `${bigint}`]: string;
672
+ [x: `embedded-${number}`]: string;
673
+
674
+ // These explicitly defined keys will be removed.
675
+ ['kebab-case-key']: string;
676
+ [symbolKey]: string;
677
+ foo: 'bar';
678
+ qux?: 'baz';
679
+ };
680
+
681
+ type ExampleIndexSignature = PickIndexSignature<Example>;
682
+ // {
683
+ // [x: string]: unknown;
684
+ // [x: number]: unknown;
685
+ // [x: symbol]: unknown;
686
+ // [x: `head-${string}`]: string;
687
+ // [x: `${string}-tail`]: string;
688
+ // [x: `head-${string}-tail`]: string;
689
+ // [x: `${bigint}`]: string;
690
+ // [x: `embedded-${number}`]: string;
691
+ // }
692
+ ```
693
+
694
+ @see {@link OmitIndexSignature}
695
+ @category Object
696
+ */
697
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
698
+ //#endregion
699
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/merge.d.ts
700
+ // Merges two objects without worrying about index signatures.
701
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
702
+
703
+ /**
704
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
705
+
706
+ @example
707
+ ```
708
+ import type {Merge} from 'type-fest';
709
+
710
+ type Foo = {
711
+ [x: string]: unknown;
712
+ [x: number]: unknown;
713
+ foo: string;
714
+ bar: symbol;
715
+ };
716
+
717
+ type Bar = {
718
+ [x: number]: number;
719
+ [x: symbol]: unknown;
720
+ bar: Date;
721
+ baz: boolean;
722
+ };
723
+
724
+ export type FooBar = Merge<Foo, Bar>;
725
+ //=> {
726
+ // [x: string]: unknown;
727
+ // [x: number]: number;
728
+ // [x: symbol]: unknown;
729
+ // foo: string;
730
+ // bar: Date;
731
+ // baz: boolean;
732
+ // }
733
+ ```
734
+
735
+ 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.
736
+
737
+ @see {@link ObjectMerge}
738
+ @category Object
739
+ */
740
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
741
+ ? Source extends unknown // For distributing `Source`
742
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
743
+ : never;
744
+ // Should never happen
745
+
746
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
747
+ //#endregion
748
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/internal/object.d.ts
749
+ /**
750
+ Works similar to the built-in `Pick` utility type, except for the following differences:
751
+ - Distributes over union types and allows picking keys from any member of the union type.
752
+ - Primitives types are returned as-is.
753
+ - Picks all keys if `Keys` is `any`.
754
+ - Doesn't pick `number` from a `string` index signature.
755
+
756
+ @example
757
+ ```
758
+ type ImageUpload = {
759
+ url: string;
760
+ size: number;
761
+ thumbnailUrl: string;
762
+ };
763
+
764
+ type VideoUpload = {
765
+ url: string;
766
+ duration: number;
767
+ encodingFormat: string;
768
+ };
769
+
770
+ // Distributes over union types and allows picking keys from any member of the union type
771
+ type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
772
+ //=> {url: string; size: number} | {url: string; duration: number}
773
+
774
+ // Primitive types are returned as-is
775
+ type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
776
+ //=> string | number
777
+
778
+ // Picks all keys if `Keys` is `any`
779
+ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
780
+ //=> {a: 1; b: 2} | {c: 3}
781
+
782
+ // Doesn't pick `number` from a `string` index signature
783
+ type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
784
+ //=> {}
785
+ */
786
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
787
+ /**
788
+ Merges user specified options with default options.
789
+
790
+ @example
791
+ ```
792
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
793
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
794
+ type SpecifiedOptions = {leavesOnly: true};
795
+
796
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
797
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
798
+ ```
799
+
800
+ @example
801
+ ```
802
+ // Complains if default values are not provided for optional options
803
+
804
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
805
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
806
+ type SpecifiedOptions = {};
807
+
808
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
809
+ // ~~~~~~~~~~~~~~~~~~~
810
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
811
+ ```
812
+
813
+ @example
814
+ ```
815
+ // Complains if an option's default type does not conform to the expected type
816
+
817
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
818
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
819
+ type SpecifiedOptions = {};
820
+
821
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
822
+ // ~~~~~~~~~~~~~~~~~~~
823
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
824
+ ```
825
+
826
+ @example
827
+ ```
828
+ // Complains if an option's specified type does not conform to the expected type
829
+
830
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
831
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
832
+ type SpecifiedOptions = {leavesOnly: 'yes'};
833
+
834
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
835
+ // ~~~~~~~~~~~~~~~~
836
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
837
+ ```
838
+ */
839
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
840
+ // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
841
+
842
+ /**
843
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
844
+
845
+ 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>`.
846
+
847
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
848
+
849
+ @example
850
+ ```
851
+ import type {LiteralUnion} from 'type-fest';
852
+
853
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
854
+ //=> string
855
+
856
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
857
+ //=> number
858
+
859
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
860
+ //=> `on${string}`
861
+
862
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
863
+ //=> 'click' | 'change' | `on${string}`
864
+
865
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
866
+ //=> string | null | undefined
867
+ ```
868
+ */
869
+ type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
870
+ //#endregion
871
+ //#region node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/except.d.ts
872
+ /**
873
+ Filter out keys from an object.
874
+
875
+ Returns `never` if `Exclude` is strictly equal to `Key`.
876
+ Returns `never` if `Key` extends `Exclude`.
877
+ Returns `Key` otherwise.
878
+
879
+ @example
880
+ ```
881
+ type Filtered = Filter<'foo', 'foo'>;
882
+ //=> never
883
+ ```
884
+
885
+ @example
886
+ ```
887
+ type Filtered = Filter<'bar', string>;
888
+ //=> never
889
+ ```
890
+
891
+ @example
892
+ ```
893
+ type Filtered = Filter<'bar', 'foo'>;
894
+ //=> 'bar'
895
+ ```
896
+
897
+ @see {Except}
898
+ */
899
+ type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
900
+ type ExceptOptions = {
901
+ /**
902
+ Disallow assigning non-specified properties.
903
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
904
+ @default false
905
+ */
906
+ requireExactProps?: boolean;
907
+ };
908
+ type DefaultExceptOptions = {
909
+ requireExactProps: false;
910
+ };
911
+
912
+ /**
913
+ Create a type from an object type without certain keys.
914
+
915
+ We recommend setting the `requireExactProps` option to `true`.
916
+
917
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
918
+
919
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
920
+
921
+ @example
922
+ ```
923
+ import type {Except} from 'type-fest';
924
+
925
+ type Foo = {
926
+ a: number;
927
+ b: string;
928
+ };
929
+
930
+ type FooWithoutA = Except<Foo, 'a'>;
931
+ //=> {b: string}
932
+
933
+ // @ts-expect-error
934
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
935
+ // errors: 'a' does not exist in type '{ b: string; }'
936
+
937
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
938
+ //=> {a: number} & Partial<Record<'b', never>>
939
+
940
+ // @ts-expect-error
941
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
942
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
943
+
944
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
945
+
946
+ // Consider the following example:
947
+
948
+ type UserData = {
949
+ [metadata: string]: string;
950
+ email: string;
951
+ name: string;
952
+ role: 'admin' | 'user';
953
+ };
954
+
955
+ // `Omit` clearly doesn't behave as expected in this case:
956
+ type PostPayload = Omit<UserData, 'email'>;
957
+ //=> {[x: string]: string; [x: number]: string}
958
+
959
+ // In situations like this, `Except` works better.
960
+ // It simply removes the `email` key while preserving all the other keys.
961
+ type PostPayloadFixed = Except<UserData, 'email'>;
962
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
963
+ ```
964
+
965
+ @category Object
966
+ */
967
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
968
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
969
+ //#endregion
970
+ export { Simplify as a, Not as c, IsNever as d, OptionalKeysOf as f, HomomorphicPick as i, UnknownArray as l, UnionToIntersection as m, ApplyDefaultOptions as n, IfNotAnyOrNever as o, IsAny as p, CollapseLiterals as r, IsExactOptionalPropertyTypesEnabled as s, Except as t, If as u };
971
+ //# sourceMappingURL=except-MacUK44u.d.ts.map