@react-querybuilder/core 8.12.0 → 8.14.0
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/{basic-o1-sYjK6.d.ts → basic-Dxm6jWFu.d.ts} +94 -104
- package/dist/{basic-DbvrfPNz.d.mts → basic-GFsWfi0Z.d.mts} +94 -104
- package/dist/{chunk-BxBTb9qk.js → chunk-U64pC571.js} +13 -11
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +119 -118
- package/dist/cjs/react-querybuilder_core.cjs.development.js +39 -10
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +119 -118
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-Cj4t-LT4.mjs → convertQuery-DAj92cbM.mjs} +3 -3
- package/dist/{convertQuery-Cj4t-LT4.mjs.map → convertQuery-DAj92cbM.mjs.map} +1 -1
- package/dist/{convertQuery-DuY_BJHy.js → convertQuery-DRldbzhZ.js} +4 -4
- package/dist/{convertQuery-DuY_BJHy.js.map → convertQuery-DRldbzhZ.js.map} +1 -1
- package/dist/{export-WDHFbiPz.d.ts → export-6VbkhCrf.d.ts} +2 -2
- package/dist/{export-CCULKoP4.d.mts → export-_wipiqJZ.d.mts} +2 -2
- package/dist/formatQuery.d.mts +2 -2
- package/dist/formatQuery.d.ts +2 -2
- package/dist/formatQuery.js +43 -14
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +42 -13
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-BSWb9Vgd.d.ts → import-D8M7awTx.d.ts} +2 -2
- package/dist/{import-CLyHpgk8.d.mts → import-DRmutNSr.d.mts} +2 -2
- package/dist/{isRuleGroup-Do9KKsmt.js → isRuleGroup-Cjk1Q2mj.js} +2 -2
- package/dist/{isRuleGroup-Do9KKsmt.js.map → isRuleGroup-Cjk1Q2mj.js.map} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs → isRuleGroup-DztIOOKa.mjs} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs.map → isRuleGroup-DztIOOKa.mjs.map} +1 -1
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +9 -9
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +3 -3
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +13 -7
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +2 -3
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +3 -3
- package/dist/parseJsonLogic.d.ts +3 -3
- package/dist/parseJsonLogic.js +4 -4
- package/dist/parseJsonLogic.mjs +4 -4
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +5 -5
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +5 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +9 -9
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +3 -3
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +58 -7
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +3 -3
- package/dist/{prepareQueryObjects-BfnyRV5t.mjs → prepareQueryObjects-BBayjIn2.mjs} +4 -7
- package/dist/prepareQueryObjects-BBayjIn2.mjs.map +1 -0
- package/dist/{prepareQueryObjects-DCtJJrF5.js → prepareQueryObjects-BxWvIPI4.js} +5 -8
- package/dist/prepareQueryObjects-BxWvIPI4.js.map +1 -0
- package/dist/react-querybuilder_core.d.mts +119 -118
- package/dist/react-querybuilder_core.legacy-esm.d.ts +119 -118
- package/dist/react-querybuilder_core.legacy-esm.js +42 -16
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +39 -10
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +119 -118
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/{transformQuery-DvJTAvkh.js → transformQuery-ClBRfnFg.js} +3 -3
- package/dist/{transformQuery-DvJTAvkh.js.map → transformQuery-ClBRfnFg.js.map} +1 -1
- package/dist/{transformQuery-Bq4iyYsE.mjs → transformQuery-DUpbpqjX.mjs} +2 -2
- package/dist/{transformQuery-Bq4iyYsE.mjs.map → transformQuery-DUpbpqjX.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -2
- package/dist/transformQuery.mjs +1 -2
- package/dist/{utils-CoYbYnVo.js → utils-CR1ToTMW.js} +3 -3
- package/dist/{utils-CoYbYnVo.js.map → utils-CR1ToTMW.js.map} +1 -1
- package/dist/{utils-DxH23QtE.mjs → utils-nQU7WCM9.mjs} +2 -2
- package/dist/{utils-DxH23QtE.mjs.map → utils-nQU7WCM9.mjs.map} +1 -1
- package/package.json +14 -13
- package/dist/chunk-DrjzjjTJ.mjs +0 -23
- package/dist/chunk-Dv2ph0Ay.js +0 -23
- package/dist/prepareQueryObjects-BfnyRV5t.mjs.map +0 -1
- package/dist/prepareQueryObjects-DCtJJrF5.js.map +0 -1
|
@@ -14,34 +14,6 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
14
14
|
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
A more applicable example which could make its way into your library code follows.
|
|
18
|
-
|
|
19
|
-
@example
|
|
20
|
-
```
|
|
21
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
22
|
-
|
|
23
|
-
class CommandOne {
|
|
24
|
-
commands: {
|
|
25
|
-
a1: () => undefined,
|
|
26
|
-
b1: () => undefined,
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class CommandTwo {
|
|
31
|
-
commands: {
|
|
32
|
-
a2: (argA: string) => undefined,
|
|
33
|
-
b2: (argB: string) => undefined,
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
38
|
-
type Union = typeof union;
|
|
39
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
40
|
-
|
|
41
|
-
type Intersection = UnionToIntersection<Union>;
|
|
42
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
17
|
@category Type
|
|
46
18
|
*/
|
|
47
19
|
type UnionToIntersection<Union> = (
|
|
@@ -117,8 +89,8 @@ import type {IsAny} from 'type-fest';
|
|
|
117
89
|
const typedObject = {a: 1, b: 2} as const;
|
|
118
90
|
const anyObject: any = {a: 1, b: 2};
|
|
119
91
|
|
|
120
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
121
|
-
return
|
|
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];
|
|
122
94
|
}
|
|
123
95
|
|
|
124
96
|
const typedA = get(typedObject, 'a');
|
|
@@ -143,17 +115,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
143
115
|
```
|
|
144
116
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
145
117
|
|
|
146
|
-
|
|
118
|
+
type User = {
|
|
147
119
|
name: string;
|
|
148
120
|
surname: string;
|
|
149
121
|
|
|
150
122
|
luckyNumber?: number;
|
|
151
|
-
}
|
|
123
|
+
};
|
|
152
124
|
|
|
153
|
-
|
|
125
|
+
type Admin = {
|
|
154
126
|
name: string;
|
|
155
127
|
surname?: string;
|
|
156
|
-
}
|
|
128
|
+
};
|
|
157
129
|
|
|
158
130
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
159
131
|
//=> true
|
|
@@ -186,12 +158,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
186
158
|
```
|
|
187
159
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
188
160
|
|
|
189
|
-
|
|
161
|
+
type User = {
|
|
190
162
|
name: string;
|
|
191
163
|
surname: string;
|
|
192
164
|
|
|
193
165
|
luckyNumber?: number;
|
|
194
|
-
}
|
|
166
|
+
};
|
|
195
167
|
|
|
196
168
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
197
169
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -199,12 +171,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
199
171
|
};
|
|
200
172
|
|
|
201
173
|
const update1: UpdateOperation<User> = {
|
|
202
|
-
name: 'Alice'
|
|
174
|
+
name: 'Alice',
|
|
203
175
|
};
|
|
204
176
|
|
|
205
177
|
const update2: UpdateOperation<User> = {
|
|
206
178
|
name: 'Bob',
|
|
207
|
-
luckyNumber: REMOVE_FIELD
|
|
179
|
+
luckyNumber: REMOVE_FIELD,
|
|
208
180
|
};
|
|
209
181
|
```
|
|
210
182
|
|
|
@@ -224,17 +196,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
224
196
|
```
|
|
225
197
|
import type {RequiredKeysOf} from 'type-fest';
|
|
226
198
|
|
|
227
|
-
declare function createValidation<
|
|
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;
|
|
228
203
|
|
|
229
|
-
|
|
204
|
+
type User = {
|
|
230
205
|
name: string;
|
|
231
206
|
surname: string;
|
|
232
|
-
|
|
233
207
|
luckyNumber?: number;
|
|
234
|
-
}
|
|
208
|
+
};
|
|
235
209
|
|
|
236
210
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
237
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"'.
|
|
238
216
|
```
|
|
239
217
|
|
|
240
218
|
@category Utilities
|
|
@@ -256,29 +234,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
256
234
|
```
|
|
257
235
|
import type {IsNever, And} from 'type-fest';
|
|
258
236
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
And<
|
|
262
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
263
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
264
|
-
>;
|
|
265
|
-
|
|
266
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
267
|
-
AreStringsEqual<I, O> extends true
|
|
268
|
-
? never
|
|
269
|
-
: void;
|
|
270
|
-
|
|
271
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
272
|
-
if (input === output) {
|
|
273
|
-
process.exit(0);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
237
|
+
type A = IsNever<never>;
|
|
238
|
+
//=> true
|
|
276
239
|
|
|
277
|
-
|
|
278
|
-
//=>
|
|
240
|
+
type B = IsNever<any>;
|
|
241
|
+
//=> false
|
|
242
|
+
|
|
243
|
+
type C = IsNever<unknown>;
|
|
244
|
+
//=> false
|
|
245
|
+
|
|
246
|
+
type D = IsNever<never[]>;
|
|
247
|
+
//=> false
|
|
279
248
|
|
|
280
|
-
|
|
281
|
-
//=>
|
|
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
|
+
// ^? type A = 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
|
+
// ^? type B = false
|
|
282
272
|
```
|
|
283
273
|
|
|
284
274
|
@category Type Guard
|
|
@@ -299,7 +289,7 @@ Note:
|
|
|
299
289
|
|
|
300
290
|
@example
|
|
301
291
|
```
|
|
302
|
-
import {If} from 'type-fest';
|
|
292
|
+
import type {If} from 'type-fest';
|
|
303
293
|
|
|
304
294
|
type A = If<true, 'yes', 'no'>;
|
|
305
295
|
//=> 'yes'
|
|
@@ -319,7 +309,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
319
309
|
|
|
320
310
|
@example
|
|
321
311
|
```
|
|
322
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
312
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
323
313
|
|
|
324
314
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
325
315
|
//=> 'not any'
|
|
@@ -330,7 +320,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
330
320
|
|
|
331
321
|
@example
|
|
332
322
|
```
|
|
333
|
-
import {If, IsEqual} from 'type-fest';
|
|
323
|
+
import type {If, IsEqual} from 'type-fest';
|
|
334
324
|
|
|
335
325
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
336
326
|
|
|
@@ -461,10 +451,11 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
461
451
|
const someType: SomeType = literal;
|
|
462
452
|
const someInterface: SomeInterface = literal;
|
|
463
453
|
|
|
464
|
-
function fn(object: Record<string, unknown>): void
|
|
454
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
465
455
|
|
|
466
456
|
fn(literal); // Good: literal object type is sealed
|
|
467
457
|
fn(someType); // Good: type is sealed
|
|
458
|
+
// @ts-expect-error
|
|
468
459
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
469
460
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
470
461
|
```
|
|
@@ -502,7 +493,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
502
493
|
@category Type Guard
|
|
503
494
|
@category Utilities
|
|
504
495
|
*/
|
|
505
|
-
type IsEqual<A, B> = [A
|
|
496
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
506
497
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
507
498
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
508
499
|
//#endregion
|
|
@@ -524,6 +515,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
524
515
|
```
|
|
525
516
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
526
517
|
|
|
518
|
+
// @ts-expect-error
|
|
527
519
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
528
520
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
529
521
|
```
|
|
@@ -537,16 +529,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
537
529
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
538
530
|
|
|
539
531
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
540
|
-
?
|
|
541
|
-
:
|
|
532
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
533
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
542
534
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
543
535
|
```
|
|
544
536
|
|
|
545
537
|
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`...
|
|
546
538
|
|
|
547
539
|
```
|
|
548
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
549
|
-
|
|
550
540
|
type OmitIndexSignature<ObjectType> = {
|
|
551
541
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
552
542
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -556,14 +546,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
556
546
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
557
547
|
|
|
558
548
|
```
|
|
559
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
560
|
-
|
|
561
549
|
type OmitIndexSignature<ObjectType> = {
|
|
562
550
|
[KeyType in keyof ObjectType
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
551
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
552
|
+
as {} extends Record<KeyType, unknown>
|
|
553
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
554
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
567
555
|
]: ObjectType[KeyType];
|
|
568
556
|
};
|
|
569
557
|
```
|
|
@@ -574,21 +562,21 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
574
562
|
```
|
|
575
563
|
import type {OmitIndexSignature} from 'type-fest';
|
|
576
564
|
|
|
577
|
-
|
|
565
|
+
type Example = {
|
|
578
566
|
// These index signatures will be removed.
|
|
579
|
-
[x: string]: any
|
|
580
|
-
[x: number]: any
|
|
581
|
-
[x: symbol]: any
|
|
582
|
-
[x: `head-${string}`]: string
|
|
583
|
-
[x: `${string}-tail`]: string
|
|
584
|
-
[x: `head-${string}-tail`]: string
|
|
585
|
-
[x: `${bigint}`]: string
|
|
586
|
-
[x: `embedded-${number}`]: string
|
|
567
|
+
[x: string]: any;
|
|
568
|
+
[x: number]: any;
|
|
569
|
+
[x: symbol]: any;
|
|
570
|
+
[x: `head-${string}`]: string;
|
|
571
|
+
[x: `${string}-tail`]: string;
|
|
572
|
+
[x: `head-${string}-tail`]: string;
|
|
573
|
+
[x: `${bigint}`]: string;
|
|
574
|
+
[x: `embedded-${number}`]: string;
|
|
587
575
|
|
|
588
576
|
// These explicitly defined keys will remain.
|
|
589
577
|
foo: 'bar';
|
|
590
578
|
qux?: 'baz';
|
|
591
|
-
}
|
|
579
|
+
};
|
|
592
580
|
|
|
593
581
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
594
582
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
@@ -658,12 +646,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
658
646
|
```
|
|
659
647
|
import type {Merge} from 'type-fest';
|
|
660
648
|
|
|
661
|
-
|
|
649
|
+
type Foo = {
|
|
662
650
|
[x: string]: unknown;
|
|
663
651
|
[x: number]: unknown;
|
|
664
652
|
foo: string;
|
|
665
653
|
bar: symbol;
|
|
666
|
-
}
|
|
654
|
+
};
|
|
667
655
|
|
|
668
656
|
type Bar = {
|
|
669
657
|
[x: number]: number;
|
|
@@ -842,12 +830,14 @@ type Foo = {
|
|
|
842
830
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
843
831
|
//=> {b: string}
|
|
844
832
|
|
|
833
|
+
// @ts-expect-error
|
|
845
834
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
846
835
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
847
836
|
|
|
848
837
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
849
838
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
850
839
|
|
|
840
|
+
// @ts-expect-error
|
|
851
841
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
852
842
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
853
843
|
|
|
@@ -864,12 +854,12 @@ type UserData = {
|
|
|
864
854
|
|
|
865
855
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
866
856
|
type PostPayload = Omit<UserData, 'email'>;
|
|
867
|
-
//=>
|
|
857
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
868
858
|
|
|
869
859
|
// In situations like this, `Except` works better.
|
|
870
860
|
// It simply removes the `email` key while preserving all the other keys.
|
|
871
|
-
type
|
|
872
|
-
//=>
|
|
861
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
862
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
873
863
|
```
|
|
874
864
|
|
|
875
865
|
@category Object
|
|
@@ -891,7 +881,7 @@ type Foo = {
|
|
|
891
881
|
a?: number;
|
|
892
882
|
b: string;
|
|
893
883
|
c?: boolean;
|
|
894
|
-
}
|
|
884
|
+
};
|
|
895
885
|
|
|
896
886
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
897
887
|
// type SomeRequired = {
|
|
@@ -973,7 +963,7 @@ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<Requi
|
|
|
973
963
|
*
|
|
974
964
|
* @group Option Lists
|
|
975
965
|
*/
|
|
976
|
-
type ToFlexibleOption<Opt
|
|
966
|
+
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
977
967
|
/**
|
|
978
968
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
979
969
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
@@ -1001,38 +991,38 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1001
991
|
*
|
|
1002
992
|
* @group Option Lists
|
|
1003
993
|
*/
|
|
1004
|
-
type ToFullOption<Opt
|
|
994
|
+
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1005
995
|
/**
|
|
1006
996
|
* A group of {@link Option}s, usually within an {@link OptionList}.
|
|
1007
997
|
*
|
|
1008
998
|
* @group Option Lists
|
|
1009
999
|
*/
|
|
1010
|
-
interface OptionGroup<Opt
|
|
1000
|
+
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1011
1001
|
label: string;
|
|
1012
|
-
options: WithUnknownIndex<Opt
|
|
1002
|
+
options: WithUnknownIndex<Opt>[];
|
|
1013
1003
|
}
|
|
1014
1004
|
/**
|
|
1015
1005
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1016
1006
|
*
|
|
1017
1007
|
* @group Option Lists
|
|
1018
1008
|
*/
|
|
1019
|
-
type FlexibleOptionGroup<Opt
|
|
1009
|
+
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1020
1010
|
label: string;
|
|
1021
|
-
options: (Opt
|
|
1011
|
+
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1022
1012
|
};
|
|
1023
1013
|
/**
|
|
1024
1014
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1025
1015
|
*
|
|
1026
1016
|
* @group Option Lists
|
|
1027
1017
|
*/
|
|
1028
|
-
type OptionList<Opt
|
|
1018
|
+
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1029
1019
|
/**
|
|
1030
1020
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1031
1021
|
* may use either `name` or `value` as the primary identifier.
|
|
1032
1022
|
*
|
|
1033
1023
|
* @group Option Lists
|
|
1034
1024
|
*/
|
|
1035
|
-
type FlexibleOptionList<Opt
|
|
1025
|
+
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1036
1026
|
/**
|
|
1037
1027
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1038
1028
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1040,7 +1030,7 @@ type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] |
|
|
|
1040
1030
|
*
|
|
1041
1031
|
* @group Option Lists
|
|
1042
1032
|
*/
|
|
1043
|
-
type FullOptionList<Opt
|
|
1033
|
+
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1044
1034
|
//#endregion
|
|
1045
1035
|
//#region src/types/ruleGroups.d.ts
|
|
1046
1036
|
/**
|
|
@@ -1289,4 +1279,4 @@ type ParseNumbersModerationLevel = "-limited" | "";
|
|
|
1289
1279
|
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
1290
1280
|
//#endregion
|
|
1291
1281
|
export { Except as C, SetRequired as S, RuleGroupType as _, ValueSource as a, FullOptionList as b, RuleValidator as c, DefaultRuleGroupTypeIC as d, RuleGroupTypeAny as f, DefaultRuleGroupType as g, DefaultOperatorName as h, ParseNumbersPropConfig as i, ValidationMap as l, DefaultCombinatorName as m, FullOperator as n, ValueSources as o, RuleGroupTypeIC as p, InputType as r, QueryValidator as s, FullField as t, ValidationResult as u, RuleType as v, OptionList as x, FlexibleOptionList as y };
|
|
1292
|
-
//# sourceMappingURL=basic-
|
|
1282
|
+
//# sourceMappingURL=basic-GFsWfi0Z.d.mts.map
|
|
@@ -5,16 +5,18 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
9
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
return to;
|
|
20
22
|
};
|
|
@@ -25,10 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
27
|
|
|
26
28
|
//#endregion
|
|
27
29
|
|
|
28
|
-
Object.defineProperty(exports, '
|
|
30
|
+
Object.defineProperty(exports, '__commonJSMin', {
|
|
29
31
|
enumerable: true,
|
|
30
32
|
get: function () {
|
|
31
|
-
return
|
|
33
|
+
return __commonJSMin;
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
36
|
Object.defineProperty(exports, '__toESM', {
|