@pawover/kit 0.0.0-beta.45 → 0.0.0-beta.50

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