@esposter/shared 2.16.0 → 2.18.2
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.ts +152 -110
- package/dist/index.js +223 -211
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare class NotInitializedError<T$1 extends string = string> extends Error {
|
|
|
29
29
|
//#region src/models/router/RoutePath.d.ts
|
|
30
30
|
declare const RoutePath: {
|
|
31
31
|
readonly About: "/about";
|
|
32
|
+
readonly Achievements: "/achievements";
|
|
32
33
|
readonly Anime: "/anime";
|
|
33
34
|
readonly Calendar: "/calendar";
|
|
34
35
|
readonly Clicker: "/clicker";
|
|
@@ -57,7 +58,7 @@ declare const RoutePath: {
|
|
|
57
58
|
};
|
|
58
59
|
type RoutePath = typeof RoutePath;
|
|
59
60
|
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
61
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/primitive.d.ts
|
|
61
62
|
/**
|
|
62
63
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
63
64
|
|
|
@@ -65,7 +66,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
65
66
|
*/
|
|
66
67
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
67
68
|
//#endregion
|
|
68
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
69
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/basic.d.ts
|
|
69
70
|
/**
|
|
70
71
|
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
71
72
|
|
|
@@ -76,7 +77,7 @@ type Class<T$1, Arguments extends unknown[] = any[]> = {
|
|
|
76
77
|
new (...arguments_: Arguments): T$1;
|
|
77
78
|
};
|
|
78
79
|
//#endregion
|
|
79
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
80
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-any.d.ts
|
|
80
81
|
/**
|
|
81
82
|
Returns a boolean for whether the given type is `any`.
|
|
82
83
|
|
|
@@ -91,8 +92,8 @@ import type {IsAny} from 'type-fest';
|
|
|
91
92
|
const typedObject = {a: 1, b: 2} as const;
|
|
92
93
|
const anyObject: any = {a: 1, b: 2};
|
|
93
94
|
|
|
94
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
95
|
-
return
|
|
95
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
96
|
+
return object[key];
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
const typedA = get(typedObject, 'a');
|
|
@@ -107,7 +108,7 @@ const anyA = get(anyObject, 'a');
|
|
|
107
108
|
*/
|
|
108
109
|
type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
|
|
109
110
|
//#endregion
|
|
110
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
111
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
111
112
|
/**
|
|
112
113
|
Returns a boolean for whether the given key is an optional key of type.
|
|
113
114
|
|
|
@@ -117,17 +118,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
117
118
|
```
|
|
118
119
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
type User = {
|
|
121
122
|
name: string;
|
|
122
123
|
surname: string;
|
|
123
124
|
|
|
124
125
|
luckyNumber?: number;
|
|
125
|
-
}
|
|
126
|
+
};
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
type Admin = {
|
|
128
129
|
name: string;
|
|
129
130
|
surname?: string;
|
|
130
|
-
}
|
|
131
|
+
};
|
|
131
132
|
|
|
132
133
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
133
134
|
//=> true
|
|
@@ -150,7 +151,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
150
151
|
*/
|
|
151
152
|
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;
|
|
152
153
|
//#endregion
|
|
153
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
154
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
154
155
|
/**
|
|
155
156
|
Extract all optional keys from the given type.
|
|
156
157
|
|
|
@@ -160,12 +161,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
160
161
|
```
|
|
161
162
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
162
163
|
|
|
163
|
-
|
|
164
|
+
type User = {
|
|
164
165
|
name: string;
|
|
165
166
|
surname: string;
|
|
166
167
|
|
|
167
168
|
luckyNumber?: number;
|
|
168
|
-
}
|
|
169
|
+
};
|
|
169
170
|
|
|
170
171
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
171
172
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -173,12 +174,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
173
174
|
};
|
|
174
175
|
|
|
175
176
|
const update1: UpdateOperation<User> = {
|
|
176
|
-
name: 'Alice'
|
|
177
|
+
name: 'Alice',
|
|
177
178
|
};
|
|
178
179
|
|
|
179
180
|
const update2: UpdateOperation<User> = {
|
|
180
181
|
name: 'Bob',
|
|
181
|
-
luckyNumber: REMOVE_FIELD
|
|
182
|
+
luckyNumber: REMOVE_FIELD,
|
|
182
183
|
};
|
|
183
184
|
```
|
|
184
185
|
|
|
@@ -188,7 +189,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
188
189
|
? (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`
|
|
189
190
|
: never;
|
|
190
191
|
//#endregion
|
|
191
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
192
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/required-keys-of.d.ts
|
|
192
193
|
/**
|
|
193
194
|
Extract all required keys from the given type.
|
|
194
195
|
|
|
@@ -198,17 +199,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
198
199
|
```
|
|
199
200
|
import type {RequiredKeysOf} from 'type-fest';
|
|
200
201
|
|
|
201
|
-
declare function createValidation<
|
|
202
|
+
declare function createValidation<
|
|
203
|
+
Entity extends object,
|
|
204
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
205
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
type User = {
|
|
204
208
|
name: string;
|
|
205
209
|
surname: string;
|
|
206
|
-
|
|
207
210
|
luckyNumber?: number;
|
|
208
|
-
}
|
|
211
|
+
};
|
|
209
212
|
|
|
210
213
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
211
214
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
215
|
+
|
|
216
|
+
// @ts-expect-error
|
|
217
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
218
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
212
219
|
```
|
|
213
220
|
|
|
214
221
|
@category Utilities
|
|
@@ -216,7 +223,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
216
223
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
217
224
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
218
225
|
//#endregion
|
|
219
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
226
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-never.d.ts
|
|
220
227
|
/**
|
|
221
228
|
Returns a boolean for whether the given type is `never`.
|
|
222
229
|
|
|
@@ -230,29 +237,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
230
237
|
```
|
|
231
238
|
import type {IsNever, And} from 'type-fest';
|
|
232
239
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
And<
|
|
236
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
237
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
238
|
-
>;
|
|
239
|
-
|
|
240
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
241
|
-
AreStringsEqual<I, O> extends true
|
|
242
|
-
? never
|
|
243
|
-
: void;
|
|
244
|
-
|
|
245
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
246
|
-
if (input === output) {
|
|
247
|
-
process.exit(0);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
240
|
+
type A = IsNever<never>;
|
|
241
|
+
//=> true
|
|
250
242
|
|
|
251
|
-
|
|
252
|
-
//=>
|
|
243
|
+
type B = IsNever<any>;
|
|
244
|
+
//=> false
|
|
245
|
+
|
|
246
|
+
type C = IsNever<unknown>;
|
|
247
|
+
//=> false
|
|
248
|
+
|
|
249
|
+
type D = IsNever<never[]>;
|
|
250
|
+
//=> false
|
|
251
|
+
|
|
252
|
+
type E = IsNever<object>;
|
|
253
|
+
//=> false
|
|
254
|
+
|
|
255
|
+
type F = IsNever<string>;
|
|
256
|
+
//=> false
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
@example
|
|
260
|
+
```
|
|
261
|
+
import type {IsNever} from 'type-fest';
|
|
262
|
+
|
|
263
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
264
|
+
|
|
265
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
266
|
+
type A = IsTrue<never>;
|
|
267
|
+
// ^? type A = never
|
|
268
|
+
|
|
269
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
270
|
+
type IsTrueFixed<T> =
|
|
271
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
253
272
|
|
|
254
|
-
|
|
255
|
-
|
|
273
|
+
type B = IsTrueFixed<never>;
|
|
274
|
+
// ^? type B = false
|
|
256
275
|
```
|
|
257
276
|
|
|
258
277
|
@category Type Guard
|
|
@@ -260,7 +279,7 @@ endIfEqual('abc', '123');
|
|
|
260
279
|
*/
|
|
261
280
|
type IsNever<T$1> = [T$1] extends [never] ? true : false;
|
|
262
281
|
//#endregion
|
|
263
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
282
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/if.d.ts
|
|
264
283
|
/**
|
|
265
284
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
266
285
|
|
|
@@ -273,7 +292,7 @@ Note:
|
|
|
273
292
|
|
|
274
293
|
@example
|
|
275
294
|
```
|
|
276
|
-
import {If} from 'type-fest';
|
|
295
|
+
import type {If} from 'type-fest';
|
|
277
296
|
|
|
278
297
|
type A = If<true, 'yes', 'no'>;
|
|
279
298
|
//=> 'yes'
|
|
@@ -293,7 +312,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
293
312
|
|
|
294
313
|
@example
|
|
295
314
|
```
|
|
296
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
315
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
297
316
|
|
|
298
317
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
299
318
|
//=> 'not any'
|
|
@@ -304,7 +323,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
304
323
|
|
|
305
324
|
@example
|
|
306
325
|
```
|
|
307
|
-
import {If, IsEqual} from 'type-fest';
|
|
326
|
+
import type {If, IsEqual} from 'type-fest';
|
|
308
327
|
|
|
309
328
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
310
329
|
|
|
@@ -315,12 +334,47 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
|
315
334
|
//=> 'not equal'
|
|
316
335
|
```
|
|
317
336
|
|
|
337
|
+
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:
|
|
338
|
+
|
|
339
|
+
@example
|
|
340
|
+
```
|
|
341
|
+
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
342
|
+
|
|
343
|
+
type HundredZeroes = StringRepeat<'0', 100>;
|
|
344
|
+
|
|
345
|
+
// The following implementation is not tail recursive
|
|
346
|
+
type Includes<S extends string, Char extends string> =
|
|
347
|
+
S extends `${infer First}${infer Rest}`
|
|
348
|
+
? If<IsEqual<First, Char>,
|
|
349
|
+
'found',
|
|
350
|
+
Includes<Rest, Char>>
|
|
351
|
+
: 'not found';
|
|
352
|
+
|
|
353
|
+
// Hence, instantiations with long strings will fail
|
|
354
|
+
// @ts-expect-error
|
|
355
|
+
type Fails = Includes<HundredZeroes, '1'>;
|
|
356
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
357
|
+
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
358
|
+
|
|
359
|
+
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
360
|
+
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
361
|
+
S extends `${infer First}${infer Rest}`
|
|
362
|
+
? IsEqual<First, Char> extends true
|
|
363
|
+
? 'found'
|
|
364
|
+
: IncludesWithoutIf<Rest, Char>
|
|
365
|
+
: 'not found';
|
|
366
|
+
|
|
367
|
+
// Now, instantiations with long strings will work
|
|
368
|
+
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
369
|
+
//=> 'not found'
|
|
370
|
+
```
|
|
371
|
+
|
|
318
372
|
@category Type Guard
|
|
319
373
|
@category Utilities
|
|
320
374
|
*/
|
|
321
375
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
322
376
|
//#endregion
|
|
323
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
377
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/type.d.ts
|
|
324
378
|
/**
|
|
325
379
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
326
380
|
*/
|
|
@@ -338,7 +392,7 @@ type HasMultipleCallSignatures<T$1 extends (...arguments_: any[]) => unknown> =
|
|
|
338
392
|
(...arguments_: infer B): unknown;
|
|
339
393
|
} ? B extends A ? A extends B ? false : true : true : false;
|
|
340
394
|
//#endregion
|
|
341
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
395
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/simplify.d.ts
|
|
342
396
|
/**
|
|
343
397
|
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.
|
|
344
398
|
|
|
@@ -384,21 +438,22 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
384
438
|
const someType: SomeType = literal;
|
|
385
439
|
const someInterface: SomeInterface = literal;
|
|
386
440
|
|
|
387
|
-
function fn(object: Record<string, unknown>): void
|
|
441
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
388
442
|
|
|
389
443
|
fn(literal); // Good: literal object type is sealed
|
|
390
444
|
fn(someType); // Good: type is sealed
|
|
445
|
+
// @ts-expect-error
|
|
391
446
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
392
447
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
393
448
|
```
|
|
394
449
|
|
|
395
450
|
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
396
|
-
@see SimplifyDeep
|
|
451
|
+
@see {@link SimplifyDeep}
|
|
397
452
|
@category Object
|
|
398
453
|
*/
|
|
399
454
|
type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
|
|
400
455
|
//#endregion
|
|
401
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
456
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-equal.d.ts
|
|
402
457
|
/**
|
|
403
458
|
Returns a boolean for whether the two given types are equal.
|
|
404
459
|
|
|
@@ -425,11 +480,11 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
425
480
|
@category Type Guard
|
|
426
481
|
@category Utilities
|
|
427
482
|
*/
|
|
428
|
-
type IsEqual<A
|
|
483
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
429
484
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
430
|
-
type _IsEqual<A
|
|
485
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
431
486
|
//#endregion
|
|
432
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
487
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
433
488
|
/**
|
|
434
489
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
435
490
|
|
|
@@ -447,6 +502,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
447
502
|
```
|
|
448
503
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
449
504
|
|
|
505
|
+
// @ts-expect-error
|
|
450
506
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
451
507
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
452
508
|
```
|
|
@@ -460,16 +516,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
460
516
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
461
517
|
|
|
462
518
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
463
|
-
?
|
|
464
|
-
:
|
|
519
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
520
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
465
521
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
466
522
|
```
|
|
467
523
|
|
|
468
524
|
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`...
|
|
469
525
|
|
|
470
526
|
```
|
|
471
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
472
|
-
|
|
473
527
|
type OmitIndexSignature<ObjectType> = {
|
|
474
528
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
475
529
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -479,14 +533,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
479
533
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
480
534
|
|
|
481
535
|
```
|
|
482
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
483
|
-
|
|
484
536
|
type OmitIndexSignature<ObjectType> = {
|
|
485
537
|
[KeyType in keyof ObjectType
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
538
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
539
|
+
as {} extends Record<KeyType, unknown>
|
|
540
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
541
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
490
542
|
]: ObjectType[KeyType];
|
|
491
543
|
};
|
|
492
544
|
```
|
|
@@ -497,32 +549,32 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
497
549
|
```
|
|
498
550
|
import type {OmitIndexSignature} from 'type-fest';
|
|
499
551
|
|
|
500
|
-
|
|
552
|
+
type Example = {
|
|
501
553
|
// These index signatures will be removed.
|
|
502
|
-
[x: string]: any
|
|
503
|
-
[x: number]: any
|
|
504
|
-
[x: symbol]: any
|
|
505
|
-
[x: `head-${string}`]: string
|
|
506
|
-
[x: `${string}-tail`]: string
|
|
507
|
-
[x: `head-${string}-tail`]: string
|
|
508
|
-
[x: `${bigint}`]: string
|
|
509
|
-
[x: `embedded-${number}`]: string
|
|
554
|
+
[x: string]: any;
|
|
555
|
+
[x: number]: any;
|
|
556
|
+
[x: symbol]: any;
|
|
557
|
+
[x: `head-${string}`]: string;
|
|
558
|
+
[x: `${string}-tail`]: string;
|
|
559
|
+
[x: `head-${string}-tail`]: string;
|
|
560
|
+
[x: `${bigint}`]: string;
|
|
561
|
+
[x: `embedded-${number}`]: string;
|
|
510
562
|
|
|
511
563
|
// These explicitly defined keys will remain.
|
|
512
564
|
foo: 'bar';
|
|
513
565
|
qux?: 'baz';
|
|
514
|
-
}
|
|
566
|
+
};
|
|
515
567
|
|
|
516
568
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
517
569
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
518
570
|
```
|
|
519
571
|
|
|
520
|
-
@see PickIndexSignature
|
|
572
|
+
@see {@link PickIndexSignature}
|
|
521
573
|
@category Object
|
|
522
574
|
*/
|
|
523
575
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
524
576
|
//#endregion
|
|
525
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
577
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
526
578
|
/**
|
|
527
579
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
528
580
|
|
|
@@ -565,12 +617,12 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
565
617
|
// }
|
|
566
618
|
```
|
|
567
619
|
|
|
568
|
-
@see OmitIndexSignature
|
|
620
|
+
@see {@link OmitIndexSignature}
|
|
569
621
|
@category Object
|
|
570
622
|
*/
|
|
571
623
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
572
624
|
//#endregion
|
|
573
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
625
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/merge.d.ts
|
|
574
626
|
// Merges two objects without worrying about index signatures.
|
|
575
627
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
576
628
|
|
|
@@ -581,12 +633,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
581
633
|
```
|
|
582
634
|
import type {Merge} from 'type-fest';
|
|
583
635
|
|
|
584
|
-
|
|
636
|
+
type Foo = {
|
|
585
637
|
[x: string]: unknown;
|
|
586
638
|
[x: number]: unknown;
|
|
587
639
|
foo: string;
|
|
588
640
|
bar: symbol;
|
|
589
|
-
}
|
|
641
|
+
};
|
|
590
642
|
|
|
591
643
|
type Bar = {
|
|
592
644
|
[x: number]: number;
|
|
@@ -610,7 +662,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
610
662
|
*/
|
|
611
663
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
612
664
|
//#endregion
|
|
613
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
665
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/object.d.ts
|
|
614
666
|
/**
|
|
615
667
|
Merges user specified options with default options.
|
|
616
668
|
|
|
@@ -665,7 +717,7 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
665
717
|
*/
|
|
666
718
|
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>>>>;
|
|
667
719
|
//#endregion
|
|
668
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
720
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/except.d.ts
|
|
669
721
|
/**
|
|
670
722
|
Filter out keys from an object.
|
|
671
723
|
|
|
@@ -727,12 +779,14 @@ type Foo = {
|
|
|
727
779
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
728
780
|
//=> {b: string}
|
|
729
781
|
|
|
782
|
+
// @ts-expect-error
|
|
730
783
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
731
784
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
732
785
|
|
|
733
786
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
734
787
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
735
788
|
|
|
789
|
+
// @ts-expect-error
|
|
736
790
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
737
791
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
738
792
|
|
|
@@ -749,12 +803,12 @@ type UserData = {
|
|
|
749
803
|
|
|
750
804
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
751
805
|
type PostPayload = Omit<UserData, 'email'>;
|
|
752
|
-
//=>
|
|
806
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
753
807
|
|
|
754
808
|
// In situations like this, `Except` works better.
|
|
755
809
|
// It simply removes the `email` key while preserving all the other keys.
|
|
756
|
-
type
|
|
757
|
-
//=>
|
|
810
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
811
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
758
812
|
```
|
|
759
813
|
|
|
760
814
|
@category Object
|
|
@@ -762,7 +816,7 @@ type PostPayload = Except<UserData, 'email'>;
|
|
|
762
816
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
763
817
|
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>> : {});
|
|
764
818
|
//#endregion
|
|
765
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1
|
|
819
|
+
//#region ../../node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/required-deep.d.ts
|
|
766
820
|
/**
|
|
767
821
|
Create a type from another type with all keys and nested keys set to required.
|
|
768
822
|
|
|
@@ -815,8 +869,8 @@ interface ItemEntityType<T$1 extends string> {
|
|
|
815
869
|
type: T$1;
|
|
816
870
|
}
|
|
817
871
|
declare const ItemEntityTypePropertyNames: PropertyNames<ItemEntityType<string>>;
|
|
818
|
-
declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
|
|
819
|
-
type: T;
|
|
872
|
+
declare const createItemEntityTypeSchema: <T$1 extends z.ZodType<string>>(schema: T$1) => z.ZodObject<{
|
|
873
|
+
type: T$1;
|
|
820
874
|
}>;
|
|
821
875
|
//#endregion
|
|
822
876
|
//#region src/models/shared/ItemMetadata.d.ts
|
|
@@ -856,9 +910,9 @@ type DeepOptionalUndefined<T$1> = T$1 extends ((...args: unknown[]) => unknown)
|
|
|
856
910
|
type ToData<T$1 extends Serializable> = DeepOptionalUndefined<DeepOmit<T$1, "toJSON">>;
|
|
857
911
|
//#endregion
|
|
858
912
|
//#region src/models/shared/WithMetadata.d.ts
|
|
859
|
-
interface WithMetadata<TBase
|
|
860
|
-
new (...args: ConstructorParameters<TBase
|
|
861
|
-
prototype: InstanceType<TBase
|
|
913
|
+
interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
|
|
914
|
+
new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
|
|
915
|
+
prototype: InstanceType<TBase> & ItemMetadata;
|
|
862
916
|
}
|
|
863
917
|
//#endregion
|
|
864
918
|
//#region src/services/app/constants.d.ts
|
|
@@ -869,18 +923,6 @@ declare const MENTION_ID_ATTRIBUTE = "data-id";
|
|
|
869
923
|
declare const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
870
924
|
declare const MENTION_TYPE_ATTRIBUTE = "data-type";
|
|
871
925
|
declare const MENTION_TYPE = "mention";
|
|
872
|
-
declare const PUSH_NOTIFICATION_MAX_LENGTH = 100;
|
|
873
|
-
//#endregion
|
|
874
|
-
//#region src/services/message/getCreateMessageNotificationPayload.d.ts
|
|
875
|
-
declare const getCreateMessageNotificationPayload: (message: string, {
|
|
876
|
-
icon,
|
|
877
|
-
title,
|
|
878
|
-
url
|
|
879
|
-
}: {
|
|
880
|
-
icon?: null | string;
|
|
881
|
-
title?: null | string;
|
|
882
|
-
url: string;
|
|
883
|
-
}) => string | undefined;
|
|
884
926
|
//#endregion
|
|
885
927
|
//#region src/services/message/getMentions.d.ts
|
|
886
928
|
declare const getMentions: (message: string) => HTMLElement[];
|
|
@@ -904,7 +946,7 @@ declare const getIsServer: () => boolean;
|
|
|
904
946
|
declare const ID_SEPARATOR = "|";
|
|
905
947
|
//#endregion
|
|
906
948
|
//#region src/util/object/getPropertyNames.d.ts
|
|
907
|
-
declare const getPropertyNames: <T>() => PropertyNames<T>;
|
|
949
|
+
declare const getPropertyNames: <T$1>() => PropertyNames<T$1>;
|
|
908
950
|
//#endregion
|
|
909
951
|
//#region src/util/object/isPlainObject.d.ts
|
|
910
952
|
declare const isPlainObject: (data: unknown) => data is object;
|
|
@@ -916,13 +958,13 @@ declare const jsonDateParse: (text: string) => any;
|
|
|
916
958
|
type MergeObjectsStrict<T$1 extends object[]> = T$1 extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K] } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T$1 extends [infer TFirst] ? TFirst : never;
|
|
917
959
|
//#endregion
|
|
918
960
|
//#region src/util/object/mergeObjectsStrict.d.ts
|
|
919
|
-
declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
|
|
961
|
+
declare const mergeObjectsStrict: <T$1 extends object[]>(...objects: T$1) => MergeObjectsStrict<T$1>;
|
|
920
962
|
//#endregion
|
|
921
963
|
//#region src/util/reactivity/getRawData.d.ts
|
|
922
|
-
declare const getRawData: <T>(data: T) => T;
|
|
964
|
+
declare const getRawData: <T$1>(data: T$1) => T$1;
|
|
923
965
|
//#endregion
|
|
924
966
|
//#region src/util/reactivity/toRawDeep.d.ts
|
|
925
|
-
declare const toRawDeep: <T extends object>(data: T) => T;
|
|
967
|
+
declare const toRawDeep: <T$1 extends object>(data: T$1) => T$1;
|
|
926
968
|
//#endregion
|
|
927
969
|
//#region src/util/regex/escapeRegExp.d.ts
|
|
928
970
|
declare const escapeRegExp: (string: string) => string;
|
|
@@ -937,13 +979,13 @@ declare const streamToText: (readable: NodeJS.ReadableStream) => Promise<string>
|
|
|
937
979
|
type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : S;
|
|
938
980
|
//#endregion
|
|
939
981
|
//#region src/util/text/toKebabCase.d.ts
|
|
940
|
-
declare const toKebabCase: <T extends string>(string: T) => CamelToKebab<T>;
|
|
982
|
+
declare const toKebabCase: <T$1 extends string>(string: T$1) => CamelToKebab<T$1>;
|
|
941
983
|
//#endregion
|
|
942
984
|
//#region src/util/text/truncate.d.ts
|
|
943
985
|
declare const truncate: (string: string, length: number) => string;
|
|
944
986
|
//#endregion
|
|
945
987
|
//#region src/util/text/uncapitalize.d.ts
|
|
946
|
-
declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
|
|
988
|
+
declare const uncapitalize: <T$1 extends string>(string: T$1) => Uncapitalize<T$1>;
|
|
947
989
|
//#endregion
|
|
948
990
|
//#region src/util/time/hrtime.d.ts
|
|
949
991
|
declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
|
|
@@ -994,4 +1036,4 @@ declare const UUIDV4_REGEX: RegExp;
|
|
|
994
1036
|
//#region src/util/id/uuid/uuidValidateV4.d.ts
|
|
995
1037
|
declare const uuidValidateV4: (uuid: string) => boolean;
|
|
996
1038
|
//#endregion
|
|
997
|
-
export { CamelToKebab, DeepOmit, DeepOmitArray, DeepOptionalProperties, DeepOptionalUndefined, DeepRequiredProperties, ExcludeFunctionProperties, FunctionProperties, ID_SEPARATOR, InvalidOperationError, ItemEntityType, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KebabToCamel, MENTION_ID_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MapValue, MergeObjectsStrict, NIL, NotFoundError, NotInitializedError, Operation,
|
|
1039
|
+
export { CamelToKebab, DeepOmit, DeepOmitArray, DeepOptionalProperties, DeepOptionalUndefined, DeepRequiredProperties, ExcludeFunctionProperties, FunctionProperties, ID_SEPARATOR, InvalidOperationError, ItemEntityType, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KebabToCamel, MENTION_ID_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MapValue, MergeObjectsStrict, NIL, NotFoundError, NotInitializedError, Operation, PartialByKeys, PropertyNames, RoutePath, SITE_NAME, SURVEY_DISPLAY_NAME, Serializable, SkipFirst, TakeFirst, ToData, TupleSlice, TupleSplit, TupleSplitHead, TupleSplitTail, UUIDV4_REGEX, WithMetadata, applyItemMetadataMixin, capitalize, createItemEntityTypeSchema, css, escapeRegExp, exhaustiveGuard, getIsServer, getMentions, getPropertyNames, getRawData, hrtime, html, isPlainObject, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, now, streamToText, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4 };
|