@eslint-react/shared 1.8.0-beta.2 → 1.8.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1645 -130
- package/dist/index.d.ts +1645 -130
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import * as valibot from 'valibot';
|
|
3
|
-
import { InferOutput } from 'valibot';
|
|
4
|
-
import * as micro_memoize from 'micro-memoize';
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* -----------------------------------------------------------------------------
|
|
@@ -67,41 +64,1460 @@ declare const HOST_SVG_COMPONENT_TYPES: readonly ["a", "animate", "animateMotion
|
|
|
67
64
|
*/
|
|
68
65
|
declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
69
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Array issue type.
|
|
69
|
+
*/
|
|
70
|
+
interface ArrayIssue extends BaseIssue<unknown> {
|
|
71
|
+
/**
|
|
72
|
+
* The issue kind.
|
|
73
|
+
*/
|
|
74
|
+
readonly kind: 'schema';
|
|
75
|
+
/**
|
|
76
|
+
* The issue type.
|
|
77
|
+
*/
|
|
78
|
+
readonly type: 'array';
|
|
79
|
+
/**
|
|
80
|
+
* The expected property.
|
|
81
|
+
*/
|
|
82
|
+
readonly expected: 'Array';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Array schema type.
|
|
87
|
+
*/
|
|
88
|
+
interface ArraySchema<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<ArrayIssue> | undefined> extends BaseSchema<InferInput<TItem>[], InferOutput<TItem>[], ArrayIssue | InferIssue<TItem>> {
|
|
89
|
+
/**
|
|
90
|
+
* The schema type.
|
|
91
|
+
*/
|
|
92
|
+
readonly type: 'array';
|
|
93
|
+
/**
|
|
94
|
+
* The schema reference.
|
|
95
|
+
*/
|
|
96
|
+
readonly reference: typeof array;
|
|
97
|
+
/**
|
|
98
|
+
* The expected property.
|
|
99
|
+
*/
|
|
100
|
+
readonly expects: 'Array';
|
|
101
|
+
/**
|
|
102
|
+
* The array item schema.
|
|
103
|
+
*/
|
|
104
|
+
readonly item: TItem;
|
|
105
|
+
/**
|
|
106
|
+
* The error message.
|
|
107
|
+
*/
|
|
108
|
+
readonly message: TMessage;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Creates an array schema.
|
|
112
|
+
*
|
|
113
|
+
* @param item The item schema.
|
|
114
|
+
*
|
|
115
|
+
* @returns An array schema.
|
|
116
|
+
*/
|
|
117
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Creates an array schema.
|
|
120
|
+
*
|
|
121
|
+
* @param item The item schema.
|
|
122
|
+
* @param message The error message.
|
|
123
|
+
*
|
|
124
|
+
* @returns An array schema.
|
|
125
|
+
*/
|
|
126
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Boolean issue type.
|
|
130
|
+
*/
|
|
131
|
+
interface BooleanIssue extends BaseIssue<unknown> {
|
|
132
|
+
/**
|
|
133
|
+
* The issue kind.
|
|
134
|
+
*/
|
|
135
|
+
readonly kind: 'schema';
|
|
136
|
+
/**
|
|
137
|
+
* The issue type.
|
|
138
|
+
*/
|
|
139
|
+
readonly type: 'boolean';
|
|
140
|
+
/**
|
|
141
|
+
* The expected property.
|
|
142
|
+
*/
|
|
143
|
+
readonly expected: 'boolean';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Boolean schema type.
|
|
147
|
+
*/
|
|
148
|
+
interface BooleanSchema<TMessage extends ErrorMessage<BooleanIssue> | undefined> extends BaseSchema<boolean, boolean, BooleanIssue> {
|
|
149
|
+
/**
|
|
150
|
+
* The schema type.
|
|
151
|
+
*/
|
|
152
|
+
readonly type: 'boolean';
|
|
153
|
+
/**
|
|
154
|
+
* The schema reference.
|
|
155
|
+
*/
|
|
156
|
+
readonly reference: typeof boolean;
|
|
157
|
+
/**
|
|
158
|
+
* The expected property.
|
|
159
|
+
*/
|
|
160
|
+
readonly expects: 'boolean';
|
|
161
|
+
/**
|
|
162
|
+
* The error message.
|
|
163
|
+
*/
|
|
164
|
+
readonly message: TMessage;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Creates a boolean schema.
|
|
168
|
+
*
|
|
169
|
+
* @returns A boolean schema.
|
|
170
|
+
*/
|
|
171
|
+
declare function boolean(): BooleanSchema<undefined>;
|
|
172
|
+
/**
|
|
173
|
+
* Creates a boolean schema.
|
|
174
|
+
*
|
|
175
|
+
* @param message The error message.
|
|
176
|
+
*
|
|
177
|
+
* @returns A boolean schema.
|
|
178
|
+
*/
|
|
179
|
+
declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Lazy schema type.
|
|
183
|
+
*/
|
|
184
|
+
interface LazySchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>> extends BaseSchema<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
|
|
185
|
+
/**
|
|
186
|
+
* The schema type.
|
|
187
|
+
*/
|
|
188
|
+
readonly type: 'lazy';
|
|
189
|
+
/**
|
|
190
|
+
* The schema reference.
|
|
191
|
+
*/
|
|
192
|
+
readonly reference: typeof lazy;
|
|
193
|
+
/**
|
|
194
|
+
* The expected property.
|
|
195
|
+
*/
|
|
196
|
+
readonly expects: 'unknown';
|
|
197
|
+
/**
|
|
198
|
+
* The schema getter.
|
|
199
|
+
*/
|
|
200
|
+
readonly getter: (input: unknown) => TWrapped;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Creates a lazy schema.
|
|
204
|
+
*
|
|
205
|
+
* @param getter The schema getter.
|
|
206
|
+
*
|
|
207
|
+
* @returns A lazy schema.
|
|
208
|
+
*/
|
|
209
|
+
declare function lazy<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(getter: (input: unknown) => TWrapped): LazySchema<TWrapped>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Lazy schema async type.
|
|
213
|
+
*/
|
|
214
|
+
interface LazySchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> extends BaseSchemaAsync<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
|
|
215
|
+
/**
|
|
216
|
+
* The schema type.
|
|
217
|
+
*/
|
|
218
|
+
readonly type: 'lazy';
|
|
219
|
+
/**
|
|
220
|
+
* The schema reference.
|
|
221
|
+
*/
|
|
222
|
+
readonly reference: typeof lazyAsync;
|
|
223
|
+
/**
|
|
224
|
+
* The expected property.
|
|
225
|
+
*/
|
|
226
|
+
readonly expects: 'unknown';
|
|
227
|
+
/**
|
|
228
|
+
* The schema getter.
|
|
229
|
+
*/
|
|
230
|
+
readonly getter: (input: unknown) => MaybePromise<TWrapped>;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Creates a lazy schema.
|
|
234
|
+
*
|
|
235
|
+
* @param getter The schema getter.
|
|
236
|
+
*
|
|
237
|
+
* @returns A lazy schema.
|
|
238
|
+
*/
|
|
239
|
+
declare function lazyAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(getter: (input: unknown) => MaybePromise<TWrapped>): LazySchemaAsync<TWrapped>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Union issue type.
|
|
243
|
+
*/
|
|
244
|
+
interface UnionIssue<TSubIssue extends BaseIssue<unknown>> extends BaseIssue<unknown> {
|
|
245
|
+
/**
|
|
246
|
+
* The issue kind.
|
|
247
|
+
*/
|
|
248
|
+
readonly kind: 'schema';
|
|
249
|
+
/**
|
|
250
|
+
* The issue type.
|
|
251
|
+
*/
|
|
252
|
+
readonly type: 'union';
|
|
253
|
+
/**
|
|
254
|
+
* The expected property.
|
|
255
|
+
*/
|
|
256
|
+
readonly expected: string;
|
|
257
|
+
/**
|
|
258
|
+
* The sub issues.
|
|
259
|
+
*/
|
|
260
|
+
readonly issues?: [TSubIssue, ...TSubIssue[]];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Union options type.
|
|
265
|
+
*/
|
|
266
|
+
type UnionOptions = MaybeReadonly<BaseSchema<unknown, unknown, BaseIssue<unknown>>[]>;
|
|
267
|
+
/**
|
|
268
|
+
* Union schema type.
|
|
269
|
+
*/
|
|
270
|
+
interface UnionSchema<TOptions extends UnionOptions, TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined> extends BaseSchema<InferInput<TOptions[number]>, InferOutput<TOptions[number]>, UnionIssue<InferIssue<TOptions[number]>> | InferIssue<TOptions[number]>> {
|
|
271
|
+
/**
|
|
272
|
+
* The schema type.
|
|
273
|
+
*/
|
|
274
|
+
readonly type: 'union';
|
|
275
|
+
/**
|
|
276
|
+
* The schema reference.
|
|
277
|
+
*/
|
|
278
|
+
readonly reference: typeof union;
|
|
279
|
+
/**
|
|
280
|
+
* The union options.
|
|
281
|
+
*/
|
|
282
|
+
readonly options: TOptions;
|
|
283
|
+
/**
|
|
284
|
+
* The error message.
|
|
285
|
+
*/
|
|
286
|
+
readonly message: TMessage;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Creates an union schema.
|
|
290
|
+
*
|
|
291
|
+
* @param options The union options.
|
|
292
|
+
*
|
|
293
|
+
* @returns An union schema.
|
|
294
|
+
*/
|
|
295
|
+
declare function union<const TOptions extends UnionOptions>(options: TOptions): UnionSchema<TOptions, undefined>;
|
|
296
|
+
/**
|
|
297
|
+
* Creates an union schema.
|
|
298
|
+
*
|
|
299
|
+
* @param options The union options.
|
|
300
|
+
* @param message The error message.
|
|
301
|
+
*
|
|
302
|
+
* @returns An union schema.
|
|
303
|
+
*/
|
|
304
|
+
declare function union<const TOptions extends UnionOptions, const TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined>(options: TOptions, message: TMessage): UnionSchema<TOptions, TMessage>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Union options async type.
|
|
308
|
+
*/
|
|
309
|
+
type UnionOptionsAsync = MaybeReadonly<(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>)[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Union schema async type.
|
|
312
|
+
*/
|
|
313
|
+
interface UnionSchemaAsync<TOptions extends UnionOptionsAsync, TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined> extends BaseSchemaAsync<InferInput<TOptions[number]>, InferOutput<TOptions[number]>, UnionIssue<InferIssue<TOptions[number]>> | InferIssue<TOptions[number]>> {
|
|
314
|
+
/**
|
|
315
|
+
* The schema type.
|
|
316
|
+
*/
|
|
317
|
+
readonly type: 'union';
|
|
318
|
+
/**
|
|
319
|
+
* The schema reference.
|
|
320
|
+
*/
|
|
321
|
+
readonly reference: typeof unionAsync;
|
|
322
|
+
/**
|
|
323
|
+
* The union options.
|
|
324
|
+
*/
|
|
325
|
+
readonly options: TOptions;
|
|
326
|
+
/**
|
|
327
|
+
* The error message.
|
|
328
|
+
*/
|
|
329
|
+
readonly message: TMessage;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Creates an union schema.
|
|
333
|
+
*
|
|
334
|
+
* @param options The union options.
|
|
335
|
+
*
|
|
336
|
+
* @returns An union schema.
|
|
337
|
+
*/
|
|
338
|
+
declare function unionAsync<const TOptions extends UnionOptionsAsync>(options: TOptions): UnionSchemaAsync<TOptions, undefined>;
|
|
339
|
+
/**
|
|
340
|
+
* Creates an union schema.
|
|
341
|
+
*
|
|
342
|
+
* @param options The union options.
|
|
343
|
+
* @param message The error message.
|
|
344
|
+
*
|
|
345
|
+
* @returns An union schema.
|
|
346
|
+
*/
|
|
347
|
+
declare function unionAsync<const TOptions extends UnionOptionsAsync, const TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined>(options: TOptions, message: TMessage): UnionSchemaAsync<TOptions, TMessage>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Non nullable issue type.
|
|
351
|
+
*/
|
|
352
|
+
interface NonNullableIssue extends BaseIssue<unknown> {
|
|
353
|
+
/**
|
|
354
|
+
* The issue kind.
|
|
355
|
+
*/
|
|
356
|
+
readonly kind: 'schema';
|
|
357
|
+
/**
|
|
358
|
+
* The issue type.
|
|
359
|
+
*/
|
|
360
|
+
readonly type: 'non_nullable';
|
|
361
|
+
/**
|
|
362
|
+
* The expected property.
|
|
363
|
+
*/
|
|
364
|
+
readonly expected: '!null';
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Infer non nullable input type.
|
|
368
|
+
*/
|
|
369
|
+
type InferNonNullableInput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = NonNullable$1<InferInput<TWrapped>>;
|
|
370
|
+
/**
|
|
371
|
+
* Infer non nullable output type.
|
|
372
|
+
*/
|
|
373
|
+
type InferNonNullableOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = NonNullable$1<InferOutput<TWrapped>>;
|
|
374
|
+
/**
|
|
375
|
+
* Infer non nullable issue type.
|
|
376
|
+
*/
|
|
377
|
+
type InferNonNullableIssue<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TWrapped extends UnionSchema<UnionOptions, ErrorMessage<UnionIssue<BaseIssue<unknown>>> | undefined> | UnionSchemaAsync<UnionOptionsAsync, ErrorMessage<UnionIssue<BaseIssue<unknown>>> | undefined> ? Exclude<InferIssue<TWrapped>, {
|
|
378
|
+
type: 'null' | 'union';
|
|
379
|
+
}> | UnionIssue<InferNonNullableIssue<TWrapped['options'][number]>> : Exclude<InferIssue<TWrapped>, {
|
|
380
|
+
type: 'null';
|
|
381
|
+
}>;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Non nullable schema type.
|
|
385
|
+
*/
|
|
386
|
+
interface NonNullableSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<NonNullableIssue> | undefined> extends BaseSchema<InferNonNullableInput<TWrapped>, InferNonNullableOutput<TWrapped>, NonNullableIssue | InferNonNullableIssue<TWrapped>> {
|
|
387
|
+
/**
|
|
388
|
+
* The schema type.
|
|
389
|
+
*/
|
|
390
|
+
readonly type: 'non_nullable';
|
|
391
|
+
/**
|
|
392
|
+
* The schema reference.
|
|
393
|
+
*/
|
|
394
|
+
readonly reference: typeof nonNullable;
|
|
395
|
+
/**
|
|
396
|
+
* The expected property.
|
|
397
|
+
*/
|
|
398
|
+
readonly expects: '!null';
|
|
399
|
+
/**
|
|
400
|
+
* The wrapped schema.
|
|
401
|
+
*/
|
|
402
|
+
readonly wrapped: TWrapped;
|
|
403
|
+
/**
|
|
404
|
+
* The error message.
|
|
405
|
+
*/
|
|
406
|
+
readonly message: TMessage;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Creates a non nullable schema.
|
|
410
|
+
*
|
|
411
|
+
* @param wrapped The wrapped schema.
|
|
412
|
+
*
|
|
413
|
+
* @returns A non nullable schema.
|
|
414
|
+
*/
|
|
415
|
+
declare function nonNullable<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NonNullableSchema<TWrapped, undefined>;
|
|
416
|
+
/**
|
|
417
|
+
* Creates a non nullable schema.
|
|
418
|
+
*
|
|
419
|
+
* @param wrapped The wrapped schema.
|
|
420
|
+
* @param message The error message.
|
|
421
|
+
*
|
|
422
|
+
* @returns A non nullable schema.
|
|
423
|
+
*/
|
|
424
|
+
declare function nonNullable<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<NonNullableIssue> | undefined>(wrapped: TWrapped, message: TMessage): NonNullableSchema<TWrapped, TMessage>;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Non nullable schema async type.
|
|
428
|
+
*/
|
|
429
|
+
interface NonNullableSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<NonNullableIssue> | undefined> extends BaseSchemaAsync<InferNonNullableInput<TWrapped>, InferNonNullableOutput<TWrapped>, NonNullableIssue | InferNonNullableIssue<TWrapped>> {
|
|
430
|
+
/**
|
|
431
|
+
* The schema type.
|
|
432
|
+
*/
|
|
433
|
+
readonly type: 'non_nullable';
|
|
434
|
+
/**
|
|
435
|
+
* The schema reference.
|
|
436
|
+
*/
|
|
437
|
+
readonly reference: typeof nonNullableAsync;
|
|
438
|
+
/**
|
|
439
|
+
* The expected property.
|
|
440
|
+
*/
|
|
441
|
+
readonly expects: '!null';
|
|
442
|
+
/**
|
|
443
|
+
* The wrapped schema.
|
|
444
|
+
*/
|
|
445
|
+
readonly wrapped: TWrapped;
|
|
446
|
+
/**
|
|
447
|
+
* The error message.
|
|
448
|
+
*/
|
|
449
|
+
readonly message: TMessage;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Creates a non nullable schema.
|
|
453
|
+
*
|
|
454
|
+
* @param wrapped The wrapped schema.
|
|
455
|
+
*
|
|
456
|
+
* @returns A non nullable schema.
|
|
457
|
+
*/
|
|
458
|
+
declare function nonNullableAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NonNullableSchemaAsync<TWrapped, undefined>;
|
|
459
|
+
/**
|
|
460
|
+
* Creates a non nullable schema.
|
|
461
|
+
*
|
|
462
|
+
* @param wrapped The wrapped schema.
|
|
463
|
+
* @param message The error message.
|
|
464
|
+
*
|
|
465
|
+
* @returns A non nullable schema.
|
|
466
|
+
*/
|
|
467
|
+
declare function nonNullableAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<NonNullableIssue> | undefined>(wrapped: TWrapped, message: TMessage): NonNullableSchemaAsync<TWrapped, TMessage>;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Infer nullish output type.
|
|
471
|
+
*/
|
|
472
|
+
type InferNullishOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> = [TDefault] extends [never] ? InferOutput<TWrapped> | null | undefined : NonNullish<InferOutput<TWrapped>> | Extract<DefaultValue<TDefault>, null | undefined>;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Nullish schema type.
|
|
476
|
+
*/
|
|
477
|
+
interface NullishSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, null | undefined>> extends BaseSchema<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
478
|
+
/**
|
|
479
|
+
* The schema type.
|
|
480
|
+
*/
|
|
481
|
+
readonly type: 'nullish';
|
|
482
|
+
/**
|
|
483
|
+
* The schema reference.
|
|
484
|
+
*/
|
|
485
|
+
readonly reference: typeof nullish;
|
|
486
|
+
/**
|
|
487
|
+
* The expected property.
|
|
488
|
+
*/
|
|
489
|
+
readonly expects: `${TWrapped['expects']} | null | undefined`;
|
|
490
|
+
/**
|
|
491
|
+
* The wrapped schema.
|
|
492
|
+
*/
|
|
493
|
+
readonly wrapped: TWrapped;
|
|
494
|
+
/**
|
|
495
|
+
* The default value.
|
|
496
|
+
*/
|
|
497
|
+
readonly default: TDefault;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Creates a nullish schema.
|
|
501
|
+
*
|
|
502
|
+
* @param wrapped The wrapped schema.
|
|
503
|
+
*
|
|
504
|
+
* @returns A nullish schema.
|
|
505
|
+
*/
|
|
506
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchema<TWrapped, never>;
|
|
507
|
+
/**
|
|
508
|
+
* Creates a nullish schema.
|
|
509
|
+
*
|
|
510
|
+
* @param wrapped The wrapped schema.
|
|
511
|
+
* @param default_ The default value.
|
|
512
|
+
*
|
|
513
|
+
* @returns A nullish schema.
|
|
514
|
+
*/
|
|
515
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Nullish schema async type.
|
|
519
|
+
*/
|
|
520
|
+
interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
521
|
+
/**
|
|
522
|
+
* The schema type.
|
|
523
|
+
*/
|
|
524
|
+
readonly type: 'nullish';
|
|
525
|
+
/**
|
|
526
|
+
* The schema reference.
|
|
527
|
+
*/
|
|
528
|
+
readonly reference: typeof nullishAsync;
|
|
529
|
+
/**
|
|
530
|
+
* The expected property.
|
|
531
|
+
*/
|
|
532
|
+
readonly expects: `${TWrapped['expects']} | null | undefined`;
|
|
533
|
+
/**
|
|
534
|
+
* The wrapped schema.
|
|
535
|
+
*/
|
|
536
|
+
readonly wrapped: TWrapped;
|
|
537
|
+
/**
|
|
538
|
+
* The default value.
|
|
539
|
+
*/
|
|
540
|
+
readonly default: TDefault;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Creates a nullish schema.
|
|
544
|
+
*
|
|
545
|
+
* @param wrapped The wrapped schema.
|
|
546
|
+
*
|
|
547
|
+
* @returns A nullish schema.
|
|
548
|
+
*/
|
|
549
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchemaAsync<TWrapped, never>;
|
|
550
|
+
/**
|
|
551
|
+
* Creates a nullish schema.
|
|
552
|
+
*
|
|
553
|
+
* @param wrapped The wrapped schema.
|
|
554
|
+
* @param default_ The default value.
|
|
555
|
+
*
|
|
556
|
+
* @returns A nullish schema.
|
|
557
|
+
*/
|
|
558
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchemaAsync<TWrapped, TDefault>;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Object issue type.
|
|
562
|
+
*/
|
|
563
|
+
interface ObjectIssue extends BaseIssue<unknown> {
|
|
564
|
+
/**
|
|
565
|
+
* The issue kind.
|
|
566
|
+
*/
|
|
567
|
+
readonly kind: 'schema';
|
|
568
|
+
/**
|
|
569
|
+
* The issue type.
|
|
570
|
+
*/
|
|
571
|
+
readonly type: 'object';
|
|
572
|
+
/**
|
|
573
|
+
* The expected property.
|
|
574
|
+
*/
|
|
575
|
+
readonly expected: 'Object';
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Object schema type.
|
|
580
|
+
*/
|
|
581
|
+
interface ObjectSchema<TEntries extends ObjectEntries, TMessage extends ErrorMessage<ObjectIssue> | undefined> extends BaseSchema<InferObjectInput<TEntries>, InferObjectOutput<TEntries>, ObjectIssue | InferObjectIssue<TEntries>> {
|
|
582
|
+
/**
|
|
583
|
+
* The schema type.
|
|
584
|
+
*/
|
|
585
|
+
readonly type: 'object';
|
|
586
|
+
/**
|
|
587
|
+
* The schema reference.
|
|
588
|
+
*/
|
|
589
|
+
readonly reference: typeof object;
|
|
590
|
+
/**
|
|
591
|
+
* The expected property.
|
|
592
|
+
*/
|
|
593
|
+
readonly expects: 'Object';
|
|
594
|
+
/**
|
|
595
|
+
* The entries schema.
|
|
596
|
+
*/
|
|
597
|
+
readonly entries: TEntries;
|
|
598
|
+
/**
|
|
599
|
+
* The error message.
|
|
600
|
+
*/
|
|
601
|
+
readonly message: TMessage;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Creates an object schema.
|
|
605
|
+
*
|
|
606
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
607
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
608
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
609
|
+
* validate unknown entries, use `objectWithRest`.
|
|
610
|
+
*
|
|
611
|
+
* @param entries The entries schema.
|
|
612
|
+
*
|
|
613
|
+
* @returns An object schema.
|
|
614
|
+
*/
|
|
615
|
+
declare function object<const TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries, undefined>;
|
|
616
|
+
/**
|
|
617
|
+
* Creates an object schema.
|
|
618
|
+
*
|
|
619
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
620
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
621
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
622
|
+
* validate unknown entries, use `objectWithRest`.
|
|
623
|
+
*
|
|
624
|
+
* @param entries The entries schema.
|
|
625
|
+
* @param message The error message.
|
|
626
|
+
*
|
|
627
|
+
* @returns An object schema.
|
|
628
|
+
*/
|
|
629
|
+
declare function object<const TEntries extends ObjectEntries, const TMessage extends ErrorMessage<ObjectIssue> | undefined>(entries: TEntries, message: TMessage): ObjectSchema<TEntries, TMessage>;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Infer optional output type.
|
|
633
|
+
*/
|
|
634
|
+
type InferOptionalOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> = [TDefault] extends [never] ? InferOutput<TWrapped> | undefined : NonOptional<InferOutput<TWrapped>> | Extract<DefaultValue<TDefault>, undefined>;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Optional schema type.
|
|
638
|
+
*/
|
|
639
|
+
interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, undefined>> extends BaseSchema<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
640
|
+
/**
|
|
641
|
+
* The schema type.
|
|
642
|
+
*/
|
|
643
|
+
readonly type: 'optional';
|
|
644
|
+
/**
|
|
645
|
+
* The schema reference.
|
|
646
|
+
*/
|
|
647
|
+
readonly reference: typeof optional;
|
|
648
|
+
/**
|
|
649
|
+
* The expected property.
|
|
650
|
+
*/
|
|
651
|
+
readonly expects: `${TWrapped['expects']} | undefined`;
|
|
652
|
+
/**
|
|
653
|
+
* The wrapped schema.
|
|
654
|
+
*/
|
|
655
|
+
readonly wrapped: TWrapped;
|
|
656
|
+
/**
|
|
657
|
+
* The default value.
|
|
658
|
+
*/
|
|
659
|
+
readonly default: TDefault;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Creates a optional schema.
|
|
663
|
+
*
|
|
664
|
+
* @param wrapped The wrapped schema.
|
|
665
|
+
*
|
|
666
|
+
* @returns A optional schema.
|
|
667
|
+
*/
|
|
668
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, never>;
|
|
669
|
+
/**
|
|
670
|
+
* Creates a optional schema.
|
|
671
|
+
*
|
|
672
|
+
* @param wrapped The wrapped schema.
|
|
673
|
+
* @param default_ The default value.
|
|
674
|
+
*
|
|
675
|
+
* @returns A optional schema.
|
|
676
|
+
*/
|
|
677
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Optional schema async type.
|
|
681
|
+
*/
|
|
682
|
+
interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
683
|
+
/**
|
|
684
|
+
* The schema type.
|
|
685
|
+
*/
|
|
686
|
+
readonly type: 'optional';
|
|
687
|
+
/**
|
|
688
|
+
* The schema reference.
|
|
689
|
+
*/
|
|
690
|
+
readonly reference: typeof optionalAsync;
|
|
691
|
+
/**
|
|
692
|
+
* The expected property.
|
|
693
|
+
*/
|
|
694
|
+
readonly expects: `${TWrapped['expects']} | undefined`;
|
|
695
|
+
/**
|
|
696
|
+
* The wrapped schema.
|
|
697
|
+
*/
|
|
698
|
+
readonly wrapped: TWrapped;
|
|
699
|
+
/**
|
|
700
|
+
* The default value.
|
|
701
|
+
*/
|
|
702
|
+
readonly default: TDefault;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Creates an optional schema.
|
|
706
|
+
*
|
|
707
|
+
* @param wrapped The wrapped schema.
|
|
708
|
+
*
|
|
709
|
+
* @returns An optional schema.
|
|
710
|
+
*/
|
|
711
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchemaAsync<TWrapped, never>;
|
|
712
|
+
/**
|
|
713
|
+
* Creates an optional schema.
|
|
714
|
+
*
|
|
715
|
+
* @param wrapped The wrapped schema.
|
|
716
|
+
* @param default_ The default value.
|
|
717
|
+
*
|
|
718
|
+
* @returns An optional schema.
|
|
719
|
+
*/
|
|
720
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchemaAsync<TWrapped, TDefault>;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Schema with pipe type.
|
|
724
|
+
*/
|
|
725
|
+
type SchemaWithPipe<TPipe extends [
|
|
726
|
+
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
727
|
+
...PipeItem<unknown, unknown, BaseIssue<unknown>>[]
|
|
728
|
+
]> = Omit<FirstTupleItem<TPipe>, '_run' | '_types'> & {
|
|
729
|
+
/**
|
|
730
|
+
* The pipe items.
|
|
731
|
+
*/
|
|
732
|
+
readonly pipe: TPipe;
|
|
733
|
+
/**
|
|
734
|
+
* Parses unknown input.
|
|
735
|
+
*
|
|
736
|
+
* @param dataset The input dataset.
|
|
737
|
+
* @param config The configuration.
|
|
738
|
+
*
|
|
739
|
+
* @returns The output dataset.
|
|
740
|
+
*
|
|
741
|
+
* @internal
|
|
742
|
+
*/
|
|
743
|
+
_run(dataset: Dataset<unknown, never>, config: Config<InferIssue<FirstTupleItem<TPipe>>>): Dataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>;
|
|
744
|
+
/**
|
|
745
|
+
* Input, output and issue type.
|
|
746
|
+
*
|
|
747
|
+
* @internal
|
|
748
|
+
*/
|
|
749
|
+
readonly _types?: {
|
|
750
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
751
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
752
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Schema with pipe async type.
|
|
758
|
+
*/
|
|
759
|
+
type SchemaWithPipeAsync<TPipe extends [
|
|
760
|
+
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
761
|
+
...(PipeItem<unknown, unknown, BaseIssue<unknown>> | PipeItemAsync<unknown, unknown, BaseIssue<unknown>>)[]
|
|
762
|
+
]> = Omit<FirstTupleItem<TPipe>, 'async' | '_run' | '_types'> & {
|
|
763
|
+
/**
|
|
764
|
+
* The pipe items.
|
|
765
|
+
*/
|
|
766
|
+
readonly pipe: TPipe;
|
|
767
|
+
/**
|
|
768
|
+
* Whether it's async.
|
|
769
|
+
*/
|
|
770
|
+
readonly async: true;
|
|
771
|
+
/**
|
|
772
|
+
* Parses unknown input.
|
|
773
|
+
*
|
|
774
|
+
* @param dataset The input dataset.
|
|
775
|
+
* @param config The configuration.
|
|
776
|
+
*
|
|
777
|
+
* @returns The output dataset.
|
|
778
|
+
*
|
|
779
|
+
* @internal
|
|
780
|
+
*/
|
|
781
|
+
_run(dataset: Dataset<unknown, never>, config: Config<InferIssue<FirstTupleItem<TPipe>>>): Promise<Dataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>>;
|
|
782
|
+
/**
|
|
783
|
+
* Input, output and issue type.
|
|
784
|
+
*
|
|
785
|
+
* @internal
|
|
786
|
+
*/
|
|
787
|
+
readonly _types?: {
|
|
788
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
789
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
790
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* String issue type.
|
|
796
|
+
*/
|
|
797
|
+
interface StringIssue extends BaseIssue<unknown> {
|
|
798
|
+
/**
|
|
799
|
+
* The issue kind.
|
|
800
|
+
*/
|
|
801
|
+
readonly kind: 'schema';
|
|
802
|
+
/**
|
|
803
|
+
* The issue type.
|
|
804
|
+
*/
|
|
805
|
+
readonly type: 'string';
|
|
806
|
+
/**
|
|
807
|
+
* The expected property.
|
|
808
|
+
*/
|
|
809
|
+
readonly expected: 'string';
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* String schema type.
|
|
813
|
+
*/
|
|
814
|
+
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
815
|
+
/**
|
|
816
|
+
* The schema type.
|
|
817
|
+
*/
|
|
818
|
+
readonly type: 'string';
|
|
819
|
+
/**
|
|
820
|
+
* The schema reference.
|
|
821
|
+
*/
|
|
822
|
+
readonly reference: typeof string;
|
|
823
|
+
/**
|
|
824
|
+
* The expected property.
|
|
825
|
+
*/
|
|
826
|
+
readonly expects: 'string';
|
|
827
|
+
/**
|
|
828
|
+
* The error message.
|
|
829
|
+
*/
|
|
830
|
+
readonly message: TMessage;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Creates a string schema.
|
|
834
|
+
*
|
|
835
|
+
* @returns A string schema.
|
|
836
|
+
*/
|
|
837
|
+
declare function string(): StringSchema<undefined>;
|
|
838
|
+
/**
|
|
839
|
+
* Creates a string schema.
|
|
840
|
+
*
|
|
841
|
+
* @param message The error message.
|
|
842
|
+
*
|
|
843
|
+
* @returns A string schema.
|
|
844
|
+
*/
|
|
845
|
+
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Base metadata type.
|
|
849
|
+
*/
|
|
850
|
+
interface BaseMetadata<TInput> {
|
|
851
|
+
/**
|
|
852
|
+
* The object kind.
|
|
853
|
+
*/
|
|
854
|
+
readonly kind: 'metadata';
|
|
855
|
+
/**
|
|
856
|
+
* The metadata type.
|
|
857
|
+
*/
|
|
858
|
+
readonly type: string;
|
|
859
|
+
/**
|
|
860
|
+
* The metadata reference.
|
|
861
|
+
*/
|
|
862
|
+
readonly reference: (...args: any[]) => BaseMetadata<unknown>;
|
|
863
|
+
/**
|
|
864
|
+
* Input, output and issue type.
|
|
865
|
+
*
|
|
866
|
+
* @internal
|
|
867
|
+
*/
|
|
868
|
+
readonly _types?: {
|
|
869
|
+
readonly input: TInput;
|
|
870
|
+
readonly output: TInput;
|
|
871
|
+
readonly issue: never;
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Typed dataset type.
|
|
877
|
+
*/
|
|
878
|
+
interface TypedDataset<TValue, TIssue extends BaseIssue<unknown>> {
|
|
879
|
+
/**
|
|
880
|
+
* Whether is's typed.
|
|
881
|
+
*/
|
|
882
|
+
typed: true;
|
|
883
|
+
/**
|
|
884
|
+
* The dataset value.
|
|
885
|
+
*/
|
|
886
|
+
value: TValue;
|
|
887
|
+
/**
|
|
888
|
+
* The dataset issues.
|
|
889
|
+
*/
|
|
890
|
+
issues?: [TIssue, ...TIssue[]];
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Untyped dataset type.
|
|
894
|
+
*/
|
|
895
|
+
interface UntypedDataset<TIssue extends BaseIssue<unknown>> {
|
|
896
|
+
/**
|
|
897
|
+
* Whether is's typed.
|
|
898
|
+
*/
|
|
899
|
+
typed: false;
|
|
900
|
+
/**
|
|
901
|
+
* The dataset value.
|
|
902
|
+
*/
|
|
903
|
+
value: unknown;
|
|
904
|
+
/**
|
|
905
|
+
* The dataset issues.
|
|
906
|
+
*/
|
|
907
|
+
issues?: [TIssue, ...TIssue[]];
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Dataset type.
|
|
911
|
+
*/
|
|
912
|
+
type Dataset<TValue, TIssue extends BaseIssue<unknown>> = TypedDataset<TValue, TIssue> | UntypedDataset<TIssue>;
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Base schema type.
|
|
916
|
+
*/
|
|
917
|
+
interface BaseSchema<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
918
|
+
/**
|
|
919
|
+
* The object kind.
|
|
920
|
+
*/
|
|
921
|
+
readonly kind: 'schema';
|
|
922
|
+
/**
|
|
923
|
+
* The schema type.
|
|
924
|
+
*/
|
|
925
|
+
readonly type: string;
|
|
926
|
+
/**
|
|
927
|
+
* The schema reference.
|
|
928
|
+
*/
|
|
929
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
930
|
+
/**
|
|
931
|
+
* The expected property.
|
|
932
|
+
*/
|
|
933
|
+
readonly expects: string;
|
|
934
|
+
/**
|
|
935
|
+
* Whether it's async.
|
|
936
|
+
*/
|
|
937
|
+
readonly async: false;
|
|
938
|
+
/**
|
|
939
|
+
* Parses unknown input.
|
|
940
|
+
*
|
|
941
|
+
* @param dataset The input dataset.
|
|
942
|
+
* @param config The configuration.
|
|
943
|
+
*
|
|
944
|
+
* @returns The output dataset.
|
|
945
|
+
*
|
|
946
|
+
* @internal
|
|
947
|
+
*/
|
|
948
|
+
_run(dataset: Dataset<unknown, never>, config: Config<TIssue>): Dataset<TOutput, TIssue>;
|
|
949
|
+
/**
|
|
950
|
+
* Input, output and issue type.
|
|
951
|
+
*
|
|
952
|
+
* @internal
|
|
953
|
+
*/
|
|
954
|
+
readonly _types?: {
|
|
955
|
+
readonly input: TInput;
|
|
956
|
+
readonly output: TOutput;
|
|
957
|
+
readonly issue: TIssue;
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Base schema async type.
|
|
962
|
+
*/
|
|
963
|
+
interface BaseSchemaAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseSchema<TInput, TOutput, TIssue>, 'reference' | 'async' | '_run'> {
|
|
964
|
+
/**
|
|
965
|
+
* The schema reference.
|
|
966
|
+
*/
|
|
967
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
968
|
+
/**
|
|
969
|
+
* Whether it's async.
|
|
970
|
+
*/
|
|
971
|
+
readonly async: true;
|
|
972
|
+
/**
|
|
973
|
+
* Parses unknown input.
|
|
974
|
+
*
|
|
975
|
+
* @param dataset The input dataset.
|
|
976
|
+
* @param config The configuration.
|
|
977
|
+
*
|
|
978
|
+
* @returns The output dataset.
|
|
979
|
+
*
|
|
980
|
+
* @internal
|
|
981
|
+
*/
|
|
982
|
+
_run(dataset: Dataset<unknown, never>, config: Config<TIssue>): Promise<Dataset<TOutput, TIssue>>;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Base transformation type.
|
|
987
|
+
*/
|
|
988
|
+
interface BaseTransformation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
989
|
+
/**
|
|
990
|
+
* The object kind.
|
|
991
|
+
*/
|
|
992
|
+
readonly kind: 'transformation';
|
|
993
|
+
/**
|
|
994
|
+
* The transformation type.
|
|
995
|
+
*/
|
|
996
|
+
readonly type: string;
|
|
997
|
+
/**
|
|
998
|
+
* The transformation reference.
|
|
999
|
+
*/
|
|
1000
|
+
readonly reference: (...args: any[]) => BaseTransformation<unknown, unknown, BaseIssue<unknown>>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Whether it's async.
|
|
1003
|
+
*/
|
|
1004
|
+
readonly async: false;
|
|
1005
|
+
/**
|
|
1006
|
+
* Transforms known input.
|
|
1007
|
+
*
|
|
1008
|
+
* @param dataset The input dataset.
|
|
1009
|
+
* @param config The configuration.
|
|
1010
|
+
*
|
|
1011
|
+
* @returns The output dataset.
|
|
1012
|
+
*
|
|
1013
|
+
* @internal
|
|
1014
|
+
*/
|
|
1015
|
+
_run(dataset: TypedDataset<TInput, never>, config: Config<TIssue>): Dataset<TOutput, TIssue>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Input, output and issue type.
|
|
1018
|
+
*
|
|
1019
|
+
* @internal
|
|
1020
|
+
*/
|
|
1021
|
+
readonly _types?: {
|
|
1022
|
+
readonly input: TInput;
|
|
1023
|
+
readonly output: TOutput;
|
|
1024
|
+
readonly issue: TIssue;
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Base transformation async type.
|
|
1029
|
+
*/
|
|
1030
|
+
interface BaseTransformationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseTransformation<TInput, TOutput, TIssue>, 'reference' | 'async' | '_run'> {
|
|
1031
|
+
/**
|
|
1032
|
+
* The transformation reference.
|
|
1033
|
+
*/
|
|
1034
|
+
readonly reference: (...args: any[]) => BaseTransformation<unknown, unknown, BaseIssue<unknown>> | BaseTransformationAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Whether it's async.
|
|
1037
|
+
*/
|
|
1038
|
+
readonly async: true;
|
|
1039
|
+
/**
|
|
1040
|
+
* Transforms known input.
|
|
1041
|
+
*
|
|
1042
|
+
* @param dataset The input dataset.
|
|
1043
|
+
* @param config The configuration.
|
|
1044
|
+
*
|
|
1045
|
+
* @returns The output dataset.
|
|
1046
|
+
*
|
|
1047
|
+
* @internal
|
|
1048
|
+
*/
|
|
1049
|
+
_run(dataset: TypedDataset<TInput, never>, config: Config<TIssue>): Promise<Dataset<TOutput, TIssue>>;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Base validation type.
|
|
1054
|
+
*/
|
|
1055
|
+
interface BaseValidation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
1056
|
+
/**
|
|
1057
|
+
* The object kind.
|
|
1058
|
+
*/
|
|
1059
|
+
readonly kind: 'validation';
|
|
1060
|
+
/**
|
|
1061
|
+
* The validation type.
|
|
1062
|
+
*/
|
|
1063
|
+
readonly type: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* The validation reference.
|
|
1066
|
+
*/
|
|
1067
|
+
readonly reference: (...args: any[]) => BaseValidation<unknown, unknown, BaseIssue<unknown>>;
|
|
1068
|
+
/**
|
|
1069
|
+
* The expected property.
|
|
1070
|
+
*/
|
|
1071
|
+
readonly expects: string | null;
|
|
1072
|
+
/**
|
|
1073
|
+
* Whether it's async.
|
|
1074
|
+
*/
|
|
1075
|
+
readonly async: false;
|
|
1076
|
+
/**
|
|
1077
|
+
* Validates known input.
|
|
1078
|
+
*
|
|
1079
|
+
* @param dataset The input dataset.
|
|
1080
|
+
* @param config The configuration.
|
|
1081
|
+
*
|
|
1082
|
+
* @returns The output dataset.
|
|
1083
|
+
*
|
|
1084
|
+
* @internal
|
|
1085
|
+
*/
|
|
1086
|
+
_run(dataset: Dataset<TInput, BaseIssue<unknown>>, config: Config<TIssue>): Dataset<TOutput, BaseIssue<unknown> | TIssue>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Input, output and issue type.
|
|
1089
|
+
*
|
|
1090
|
+
* @internal
|
|
1091
|
+
*/
|
|
1092
|
+
readonly _types?: {
|
|
1093
|
+
readonly input: TInput;
|
|
1094
|
+
readonly output: TOutput;
|
|
1095
|
+
readonly issue: TIssue;
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Base validation async type.
|
|
1100
|
+
*/
|
|
1101
|
+
interface BaseValidationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseValidation<TInput, TOutput, TIssue>, 'reference' | 'async' | '_run'> {
|
|
1102
|
+
/**
|
|
1103
|
+
* The validation reference.
|
|
1104
|
+
*/
|
|
1105
|
+
readonly reference: (...args: any[]) => BaseValidation<unknown, unknown, BaseIssue<unknown>> | BaseValidationAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
1106
|
+
/**
|
|
1107
|
+
* Whether it's async.
|
|
1108
|
+
*/
|
|
1109
|
+
readonly async: true;
|
|
1110
|
+
/**
|
|
1111
|
+
* Validates known input.
|
|
1112
|
+
*
|
|
1113
|
+
* @param dataset The input dataset.
|
|
1114
|
+
* @param config The configuration.
|
|
1115
|
+
*
|
|
1116
|
+
* @returns The output dataset.
|
|
1117
|
+
*
|
|
1118
|
+
* @internal
|
|
1119
|
+
*/
|
|
1120
|
+
_run(dataset: Dataset<TInput, BaseIssue<unknown>>, config: Config<TIssue>): Promise<Dataset<TOutput, BaseIssue<unknown> | TIssue>>;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Infer input type.
|
|
1125
|
+
*/
|
|
1126
|
+
type InferInput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<unknown, unknown, BaseIssue<unknown>> | BaseValidationAsync<unknown, unknown, BaseIssue<unknown>> | BaseTransformation<unknown, unknown, BaseIssue<unknown>> | BaseTransformationAsync<unknown, unknown, BaseIssue<unknown>> | BaseMetadata<unknown>> = NonNullable<TItem['_types']>['input'];
|
|
1127
|
+
/**
|
|
1128
|
+
* Infer output type.
|
|
1129
|
+
*/
|
|
1130
|
+
type InferOutput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<unknown, unknown, BaseIssue<unknown>> | BaseValidationAsync<unknown, unknown, BaseIssue<unknown>> | BaseTransformation<unknown, unknown, BaseIssue<unknown>> | BaseTransformationAsync<unknown, unknown, BaseIssue<unknown>> | BaseMetadata<unknown>> = NonNullable<TItem['_types']>['output'];
|
|
1131
|
+
/**
|
|
1132
|
+
* Infer issue type.
|
|
1133
|
+
*/
|
|
1134
|
+
type InferIssue<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<unknown, unknown, BaseIssue<unknown>> | BaseValidationAsync<unknown, unknown, BaseIssue<unknown>> | BaseTransformation<unknown, unknown, BaseIssue<unknown>> | BaseTransformationAsync<unknown, unknown, BaseIssue<unknown>> | BaseMetadata<unknown>> = NonNullable<TItem['_types']>['issue'];
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Extracts `null` from a type.
|
|
1138
|
+
*/
|
|
1139
|
+
type NonNullable$1<TValue> = TValue extends null ? never : TValue;
|
|
1140
|
+
/**
|
|
1141
|
+
* Extracts `null` and `undefined` from a type.
|
|
1142
|
+
*/
|
|
1143
|
+
type NonNullish<TValue> = TValue extends null | undefined ? never : TValue;
|
|
1144
|
+
/**
|
|
1145
|
+
* Extracts `undefined` from a type.
|
|
1146
|
+
*/
|
|
1147
|
+
type NonOptional<TValue> = TValue extends undefined ? never : TValue;
|
|
1148
|
+
/**
|
|
1149
|
+
* Constructs a type that is maybe readonly.
|
|
1150
|
+
*/
|
|
1151
|
+
type MaybeReadonly<TValue> = TValue | Readonly<TValue>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Constructs a type that is maybe a promise.
|
|
1154
|
+
*/
|
|
1155
|
+
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Prettifies a type for better readability.
|
|
1158
|
+
*
|
|
1159
|
+
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
1160
|
+
* the final type in the preview instead of the utility types used.
|
|
1161
|
+
*/
|
|
1162
|
+
type Prettify<TObject> = {
|
|
1163
|
+
[TKey in keyof TObject]: TObject[TKey];
|
|
1164
|
+
} & {};
|
|
1165
|
+
/**
|
|
1166
|
+
* Marks specific keys as optional.
|
|
1167
|
+
*/
|
|
1168
|
+
type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Extracts first tuple item.
|
|
1171
|
+
*/
|
|
1172
|
+
type FirstTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[0];
|
|
1173
|
+
/**
|
|
1174
|
+
* Extracts last tuple item.
|
|
1175
|
+
*/
|
|
1176
|
+
type LastTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[TTuple extends [unknown, ...infer TRest] ? TRest['length'] : never];
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Error message type.
|
|
1180
|
+
*/
|
|
1181
|
+
type ErrorMessage<TIssue extends BaseIssue<unknown>> = ((issue: TIssue) => string) | string;
|
|
1182
|
+
/**
|
|
1183
|
+
* Default type.
|
|
1184
|
+
*/
|
|
1185
|
+
type Default<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: Dataset<TInput, never>, config?: Config<InferIssue<TWrapped>>) => MaybeReadonly<InferInput<TWrapped> | TInput>);
|
|
1186
|
+
/**
|
|
1187
|
+
* Default async type.
|
|
1188
|
+
*/
|
|
1189
|
+
type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: Dataset<TInput, never>, config?: Config<InferIssue<TWrapped>>) => MaybePromise<MaybeReadonly<InferInput<TWrapped> | TInput>>);
|
|
1190
|
+
/**
|
|
1191
|
+
* Default value type.
|
|
1192
|
+
*/
|
|
1193
|
+
type DefaultValue<TDefault extends Default<BaseSchema<unknown, unknown, BaseIssue<unknown>>, null | undefined> | DefaultAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, null | undefined>> = TDefault extends DefaultAsync<infer TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, infer TInput> ? TDefault extends (dataset?: Dataset<TInput, never>, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
|
|
1194
|
+
/**
|
|
1195
|
+
* Question mark schema type.
|
|
1196
|
+
*
|
|
1197
|
+
* TODO: Document that for simplicity and bundle size, we currently do not
|
|
1198
|
+
* distinguish between `undefined` and missing keys when using `optional` and
|
|
1199
|
+
* `nullish`.
|
|
1200
|
+
*/
|
|
1201
|
+
type QuestionMarkSchema = NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | LazySchema<QuestionMarkSchema> | NonNullableSchema<QuestionMarkSchema, ErrorMessage<NonNullableIssue> | undefined>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Question mark schema async type.
|
|
1204
|
+
*/
|
|
1205
|
+
type QuestionMarkSchemaAsync = NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | LazySchemaAsync<QuestionMarkSchema | QuestionMarkSchemaAsync> | NonNullableSchemaAsync<QuestionMarkSchema | QuestionMarkSchemaAsync, ErrorMessage<NonNullableIssue> | undefined>;
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Pipe action type.
|
|
1209
|
+
*/
|
|
1210
|
+
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Pipe action async type.
|
|
1213
|
+
*/
|
|
1214
|
+
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Pipe item type.
|
|
1217
|
+
*/
|
|
1218
|
+
type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Pipe item async type.
|
|
1221
|
+
*/
|
|
1222
|
+
type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Object entries type.
|
|
1226
|
+
*/
|
|
1227
|
+
interface ObjectEntries {
|
|
1228
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Object entries async type.
|
|
1232
|
+
*/
|
|
1233
|
+
interface ObjectEntriesAsync {
|
|
1234
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Infer entries input type.
|
|
1238
|
+
*/
|
|
1239
|
+
type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
1240
|
+
-readonly [TKey in keyof TEntries]: InferInput<TEntries[TKey]>;
|
|
1241
|
+
};
|
|
1242
|
+
/**
|
|
1243
|
+
* Infer entries output type.
|
|
1244
|
+
*/
|
|
1245
|
+
type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
1246
|
+
-readonly [TKey in keyof TEntries]: InferOutput<TEntries[TKey]>;
|
|
1247
|
+
};
|
|
1248
|
+
/**
|
|
1249
|
+
* Optional keys type.
|
|
1250
|
+
*/
|
|
1251
|
+
type OptionalKeys<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries> | InferEntriesOutput<TEntries>> = {
|
|
1252
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema | QuestionMarkSchemaAsync ? undefined extends TObject[TKey] ? TKey : never : never;
|
|
1253
|
+
}[keyof TEntries];
|
|
1254
|
+
/**
|
|
1255
|
+
* With question marks type.
|
|
1256
|
+
*/
|
|
1257
|
+
type WithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries> | InferEntriesOutput<TEntries>> = MarkOptional<TObject, OptionalKeys<TEntries, TObject>>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Readonly keys type.
|
|
1260
|
+
*/
|
|
1261
|
+
type ReadonlyKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
1262
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<[
|
|
1263
|
+
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
1264
|
+
...PipeItem<unknown, unknown, BaseIssue<unknown>>[]
|
|
1265
|
+
]> | SchemaWithPipeAsync<[
|
|
1266
|
+
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
1267
|
+
...(PipeItem<unknown, unknown, BaseIssue<unknown>> | PipeItemAsync<unknown, unknown, BaseIssue<unknown>>)[]
|
|
1268
|
+
]> ? 'readonly' extends TEntries[TKey]['pipe'][number]['type'] ? TKey : never : never;
|
|
1269
|
+
}[keyof TEntries];
|
|
1270
|
+
/**
|
|
1271
|
+
* With readonly type.
|
|
1272
|
+
*/
|
|
1273
|
+
type WithReadonly<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends WithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>> = Readonly<TObject> & Pick<TObject, Exclude<keyof TObject, ReadonlyKeys<TEntries>>>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Infer object input type.
|
|
1276
|
+
*/
|
|
1277
|
+
type InferObjectInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<WithQuestionMarks<TEntries, InferEntriesInput<TEntries>>>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Infer object output type.
|
|
1280
|
+
*/
|
|
1281
|
+
type InferObjectOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<WithReadonly<TEntries, WithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>>>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Infer object issue type.
|
|
1284
|
+
*/
|
|
1285
|
+
type InferObjectIssue<TEntries extends ObjectEntries | ObjectEntriesAsync> = InferIssue<TEntries[keyof TEntries]>;
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Array path item type.
|
|
1289
|
+
*/
|
|
1290
|
+
interface ArrayPathItem {
|
|
1291
|
+
/**
|
|
1292
|
+
* The path item type.
|
|
1293
|
+
*/
|
|
1294
|
+
readonly type: 'array';
|
|
1295
|
+
/**
|
|
1296
|
+
* The path item origin.
|
|
1297
|
+
*/
|
|
1298
|
+
readonly origin: 'value';
|
|
1299
|
+
/**
|
|
1300
|
+
* The path item input.
|
|
1301
|
+
*/
|
|
1302
|
+
readonly input: MaybeReadonly<unknown[]>;
|
|
1303
|
+
/**
|
|
1304
|
+
* The path item key.
|
|
1305
|
+
*/
|
|
1306
|
+
readonly key: number;
|
|
1307
|
+
/**
|
|
1308
|
+
* The path item value.
|
|
1309
|
+
*/
|
|
1310
|
+
readonly value: unknown;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Map path item type.
|
|
1314
|
+
*/
|
|
1315
|
+
interface MapPathItem {
|
|
1316
|
+
/**
|
|
1317
|
+
* The path item type.
|
|
1318
|
+
*/
|
|
1319
|
+
readonly type: 'map';
|
|
1320
|
+
/**
|
|
1321
|
+
* The path item origin.
|
|
1322
|
+
*/
|
|
1323
|
+
readonly origin: 'key' | 'value';
|
|
1324
|
+
/**
|
|
1325
|
+
* The path item input.
|
|
1326
|
+
*/
|
|
1327
|
+
readonly input: Map<unknown, unknown>;
|
|
1328
|
+
/**
|
|
1329
|
+
* The path item key.
|
|
1330
|
+
*/
|
|
1331
|
+
readonly key: unknown;
|
|
1332
|
+
/**
|
|
1333
|
+
* The path item value.
|
|
1334
|
+
*/
|
|
1335
|
+
readonly value: unknown;
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Object path item type.
|
|
1339
|
+
*/
|
|
1340
|
+
interface ObjectPathItem {
|
|
1341
|
+
/**
|
|
1342
|
+
* The path item type.
|
|
1343
|
+
*/
|
|
1344
|
+
readonly type: 'object';
|
|
1345
|
+
/**
|
|
1346
|
+
* The path item origin.
|
|
1347
|
+
*/
|
|
1348
|
+
readonly origin: 'key' | 'value';
|
|
1349
|
+
/**
|
|
1350
|
+
* The path item input.
|
|
1351
|
+
*/
|
|
1352
|
+
readonly input: Record<string, unknown>;
|
|
1353
|
+
/**
|
|
1354
|
+
* The path item key.
|
|
1355
|
+
*/
|
|
1356
|
+
readonly key: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* The path item value.
|
|
1359
|
+
*/
|
|
1360
|
+
readonly value: unknown;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Set path item type.
|
|
1364
|
+
*/
|
|
1365
|
+
interface SetPathItem {
|
|
1366
|
+
/**
|
|
1367
|
+
* The path item type.
|
|
1368
|
+
*/
|
|
1369
|
+
readonly type: 'set';
|
|
1370
|
+
/**
|
|
1371
|
+
* The path item origin.
|
|
1372
|
+
*/
|
|
1373
|
+
readonly origin: 'value';
|
|
1374
|
+
/**
|
|
1375
|
+
* The path item input.
|
|
1376
|
+
*/
|
|
1377
|
+
readonly input: Set<unknown>;
|
|
1378
|
+
/**
|
|
1379
|
+
* The path item key.
|
|
1380
|
+
*/
|
|
1381
|
+
readonly key: null;
|
|
1382
|
+
/**
|
|
1383
|
+
* The path item key.
|
|
1384
|
+
*/
|
|
1385
|
+
readonly value: unknown;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Unknown path item type.
|
|
1389
|
+
*/
|
|
1390
|
+
interface UnknownPathItem {
|
|
1391
|
+
/**
|
|
1392
|
+
* The path item type.
|
|
1393
|
+
*/
|
|
1394
|
+
readonly type: 'unknown';
|
|
1395
|
+
/**
|
|
1396
|
+
* The path item origin.
|
|
1397
|
+
*/
|
|
1398
|
+
readonly origin: 'key' | 'value';
|
|
1399
|
+
/**
|
|
1400
|
+
* The path item input.
|
|
1401
|
+
*/
|
|
1402
|
+
readonly input: unknown;
|
|
1403
|
+
/**
|
|
1404
|
+
* The path item key.
|
|
1405
|
+
*/
|
|
1406
|
+
readonly key: unknown;
|
|
1407
|
+
/**
|
|
1408
|
+
* The path item value.
|
|
1409
|
+
*/
|
|
1410
|
+
readonly value: unknown;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Issue path item type.
|
|
1414
|
+
*
|
|
1415
|
+
* TODO: Document that the input of the path may be different from the input of
|
|
1416
|
+
* the issue.
|
|
1417
|
+
*/
|
|
1418
|
+
type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem;
|
|
1419
|
+
/**
|
|
1420
|
+
* Base issue type.
|
|
1421
|
+
*/
|
|
1422
|
+
interface BaseIssue<TInput> extends Config<BaseIssue<TInput>> {
|
|
1423
|
+
/**
|
|
1424
|
+
* The issue kind.
|
|
1425
|
+
*/
|
|
1426
|
+
readonly kind: 'schema' | 'validation' | 'transformation';
|
|
1427
|
+
/**
|
|
1428
|
+
* The issue type.
|
|
1429
|
+
*/
|
|
1430
|
+
readonly type: string;
|
|
1431
|
+
/**
|
|
1432
|
+
* The raw input data.
|
|
1433
|
+
*/
|
|
1434
|
+
readonly input: TInput;
|
|
1435
|
+
/**
|
|
1436
|
+
* The expected property.
|
|
1437
|
+
*/
|
|
1438
|
+
readonly expected: string | null;
|
|
1439
|
+
/**
|
|
1440
|
+
* The received property.
|
|
1441
|
+
*/
|
|
1442
|
+
readonly received: string;
|
|
1443
|
+
/**
|
|
1444
|
+
* The error message.
|
|
1445
|
+
*/
|
|
1446
|
+
readonly message: string;
|
|
1447
|
+
/**
|
|
1448
|
+
* The input requirement.
|
|
1449
|
+
*/
|
|
1450
|
+
readonly requirement?: unknown;
|
|
1451
|
+
/**
|
|
1452
|
+
* The issue path.
|
|
1453
|
+
*
|
|
1454
|
+
* TODO: Investigate if it is possible to make the path type safe based on the
|
|
1455
|
+
* input.
|
|
1456
|
+
*/
|
|
1457
|
+
readonly path?: [IssuePathItem, ...IssuePathItem[]];
|
|
1458
|
+
/**
|
|
1459
|
+
* The sub issues.
|
|
1460
|
+
*/
|
|
1461
|
+
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]];
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Config type.
|
|
1466
|
+
*/
|
|
1467
|
+
interface Config<TIssue extends BaseIssue<unknown>> {
|
|
1468
|
+
/**
|
|
1469
|
+
* The selected language.
|
|
1470
|
+
*/
|
|
1471
|
+
readonly lang?: string;
|
|
1472
|
+
/**
|
|
1473
|
+
* The error message.
|
|
1474
|
+
*/
|
|
1475
|
+
readonly message?: ErrorMessage<TIssue>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Whether it was abort early.
|
|
1478
|
+
*/
|
|
1479
|
+
readonly abortEarly?: boolean;
|
|
1480
|
+
/**
|
|
1481
|
+
* Whether the pipe was abort early.
|
|
1482
|
+
*/
|
|
1483
|
+
readonly abortPipeEarly?: boolean;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
70
1486
|
/**
|
|
71
1487
|
* @internal
|
|
72
1488
|
* @description
|
|
73
1489
|
* This allows the rule to know some key information before checking for user-defined hooks.
|
|
74
1490
|
* For example, the position of the `deps` argument for the user-defined `useCustomEffect` hook that represents the built-in `useEffect` hook.
|
|
75
1491
|
*/
|
|
76
|
-
declare const CustomHookSchema:
|
|
1492
|
+
declare const CustomHookSchema: ObjectSchema<{}, undefined>;
|
|
77
1493
|
/**
|
|
78
1494
|
* @internal
|
|
79
1495
|
*/
|
|
80
|
-
declare const CustomAttributeSchema:
|
|
1496
|
+
declare const CustomAttributeSchema: ObjectSchema<{
|
|
81
1497
|
/**
|
|
82
1498
|
* The name of the attribute in the user-defined component.
|
|
83
1499
|
* @example
|
|
84
1500
|
* "to"
|
|
85
1501
|
*/
|
|
86
|
-
readonly name:
|
|
1502
|
+
readonly name: StringSchema<undefined>;
|
|
87
1503
|
/**
|
|
88
1504
|
* The name of the attribute in the built-in component.
|
|
89
1505
|
* @example
|
|
90
1506
|
* "href"
|
|
91
1507
|
*/
|
|
92
|
-
readonly as:
|
|
1508
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
93
1509
|
/**
|
|
94
1510
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
95
1511
|
* @example
|
|
96
1512
|
* `true`
|
|
97
1513
|
*/
|
|
98
|
-
readonly controlled:
|
|
1514
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
99
1515
|
/**
|
|
100
1516
|
* The default value of the attribute in the user-defined component.
|
|
101
1517
|
* @example
|
|
102
1518
|
* `"/"`
|
|
103
1519
|
*/
|
|
104
|
-
readonly defaultValue:
|
|
1520
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
105
1521
|
}, undefined>;
|
|
106
1522
|
/**
|
|
107
1523
|
* @internal
|
|
@@ -111,317 +1527,416 @@ declare const CustomAttributeSchema: valibot.ObjectSchema<{
|
|
|
111
1527
|
* Which attribute is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
|
|
112
1528
|
* Which attributes are used as `children` props for a user-defined `Button` component to receive children of that component.
|
|
113
1529
|
*/
|
|
114
|
-
declare const CustomComponentSchema:
|
|
1530
|
+
declare const CustomComponentSchema: ObjectSchema<{
|
|
115
1531
|
/**
|
|
116
1532
|
* The name of the user-defined component.
|
|
117
1533
|
* @example
|
|
118
1534
|
* "Link"
|
|
119
1535
|
*/
|
|
120
|
-
readonly name:
|
|
1536
|
+
readonly name: StringSchema<undefined>;
|
|
121
1537
|
/**
|
|
122
1538
|
* The ESQuery selector to select the component precisely.
|
|
123
1539
|
* @example
|
|
124
1540
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
125
1541
|
*/
|
|
126
|
-
readonly selector:
|
|
1542
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, never>;
|
|
127
1543
|
/**
|
|
128
1544
|
* The name of the built-in component that the user-defined component represents.
|
|
129
1545
|
* @example
|
|
130
1546
|
* "a"
|
|
131
1547
|
*/
|
|
132
|
-
readonly as:
|
|
1548
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
133
1549
|
/**
|
|
134
1550
|
* Pre-defined attributes that are used in the user-defined component.
|
|
135
1551
|
* @example
|
|
136
1552
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
137
1553
|
*/
|
|
138
|
-
readonly attributes:
|
|
1554
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
139
1555
|
/**
|
|
140
1556
|
* The name of the attribute in the user-defined component.
|
|
141
1557
|
* @example
|
|
142
1558
|
* "to"
|
|
143
1559
|
*/
|
|
144
|
-
readonly name:
|
|
1560
|
+
readonly name: StringSchema<undefined>;
|
|
145
1561
|
/**
|
|
146
1562
|
* The name of the attribute in the built-in component.
|
|
147
1563
|
* @example
|
|
148
1564
|
* "href"
|
|
149
1565
|
*/
|
|
150
|
-
readonly as:
|
|
1566
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
151
1567
|
/**
|
|
152
1568
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
153
1569
|
* @example
|
|
154
1570
|
* `true`
|
|
155
1571
|
*/
|
|
156
|
-
readonly controlled:
|
|
1572
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
157
1573
|
/**
|
|
158
1574
|
* The default value of the attribute in the user-defined component.
|
|
159
1575
|
* @example
|
|
160
1576
|
* `"/"`
|
|
161
1577
|
*/
|
|
162
|
-
readonly defaultValue:
|
|
1578
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
163
1579
|
}, undefined>, undefined>, readonly []>;
|
|
164
1580
|
}, undefined>;
|
|
165
1581
|
/**
|
|
166
1582
|
* @internal
|
|
167
1583
|
*/
|
|
168
|
-
declare const ESLintReactSettingsSchema:
|
|
169
|
-
readonly importSource:
|
|
170
|
-
readonly jsxPragma:
|
|
171
|
-
readonly jsxPragmaFrag:
|
|
172
|
-
readonly polymorphicPropName:
|
|
173
|
-
readonly strict:
|
|
174
|
-
readonly version:
|
|
175
|
-
readonly additionalComponents:
|
|
1584
|
+
declare const ESLintReactSettingsSchema: ObjectSchema<{
|
|
1585
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, never>;
|
|
1586
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, never>;
|
|
1587
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, never>;
|
|
1588
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, never>;
|
|
1589
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
1590
|
+
readonly version: OptionalSchema<StringSchema<undefined>, never>;
|
|
1591
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
176
1592
|
/**
|
|
177
1593
|
* The name of the user-defined component.
|
|
178
1594
|
* @example
|
|
179
1595
|
* "Link"
|
|
180
1596
|
*/
|
|
181
|
-
readonly name:
|
|
1597
|
+
readonly name: StringSchema<undefined>;
|
|
182
1598
|
/**
|
|
183
1599
|
* The ESQuery selector to select the component precisely.
|
|
184
1600
|
* @example
|
|
185
1601
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
186
1602
|
*/
|
|
187
|
-
readonly selector:
|
|
1603
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, never>;
|
|
188
1604
|
/**
|
|
189
1605
|
* The name of the built-in component that the user-defined component represents.
|
|
190
1606
|
* @example
|
|
191
1607
|
* "a"
|
|
192
1608
|
*/
|
|
193
|
-
readonly as:
|
|
1609
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
194
1610
|
/**
|
|
195
1611
|
* Pre-defined attributes that are used in the user-defined component.
|
|
196
1612
|
* @example
|
|
197
1613
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
198
1614
|
*/
|
|
199
|
-
readonly attributes:
|
|
1615
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
200
1616
|
/**
|
|
201
1617
|
* The name of the attribute in the user-defined component.
|
|
202
1618
|
* @example
|
|
203
1619
|
* "to"
|
|
204
1620
|
*/
|
|
205
|
-
readonly name:
|
|
1621
|
+
readonly name: StringSchema<undefined>;
|
|
206
1622
|
/**
|
|
207
1623
|
* The name of the attribute in the built-in component.
|
|
208
1624
|
* @example
|
|
209
1625
|
* "href"
|
|
210
1626
|
*/
|
|
211
|
-
readonly as:
|
|
1627
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
212
1628
|
/**
|
|
213
1629
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
214
1630
|
* @example
|
|
215
1631
|
* `true`
|
|
216
1632
|
*/
|
|
217
|
-
readonly controlled:
|
|
1633
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
218
1634
|
/**
|
|
219
1635
|
* The default value of the attribute in the user-defined component.
|
|
220
1636
|
* @example
|
|
221
1637
|
* `"/"`
|
|
222
1638
|
*/
|
|
223
|
-
readonly defaultValue:
|
|
1639
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
224
1640
|
}, undefined>, undefined>, readonly []>;
|
|
225
1641
|
}, undefined>, undefined>, never>;
|
|
226
|
-
readonly additionalHooks:
|
|
227
|
-
readonly use:
|
|
228
|
-
readonly useActionState:
|
|
229
|
-
readonly useCallback:
|
|
230
|
-
readonly useContext:
|
|
231
|
-
readonly useDebugValue:
|
|
232
|
-
readonly useDeferredValue:
|
|
233
|
-
readonly useEffect:
|
|
234
|
-
readonly useId:
|
|
235
|
-
readonly useImperativeHandle:
|
|
236
|
-
readonly useInsertionEffect:
|
|
237
|
-
readonly useLayoutEffect:
|
|
238
|
-
readonly useMemo:
|
|
239
|
-
readonly useOptimistic:
|
|
240
|
-
readonly useReducer:
|
|
241
|
-
readonly useRef:
|
|
242
|
-
readonly useState:
|
|
243
|
-
readonly useSyncExternalStore:
|
|
244
|
-
readonly useTransition:
|
|
1642
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1643
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1644
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1645
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1646
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1647
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1648
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1649
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1650
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1651
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1652
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1653
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1654
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1655
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1656
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1657
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1658
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1659
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1660
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
245
1661
|
}, undefined>, never>;
|
|
246
1662
|
}, undefined>;
|
|
247
1663
|
/**
|
|
248
1664
|
* @internal
|
|
249
1665
|
*/
|
|
250
|
-
declare const ESLintSettingsSchema:
|
|
251
|
-
readonly "react-x":
|
|
252
|
-
readonly importSource:
|
|
253
|
-
readonly jsxPragma:
|
|
254
|
-
readonly jsxPragmaFrag:
|
|
255
|
-
readonly polymorphicPropName:
|
|
256
|
-
readonly strict:
|
|
257
|
-
readonly version:
|
|
258
|
-
readonly additionalComponents:
|
|
1666
|
+
declare const ESLintSettingsSchema: OptionalSchema<ObjectSchema<{
|
|
1667
|
+
readonly "react-x": OptionalSchema<ObjectSchema<{
|
|
1668
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, never>;
|
|
1669
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, never>;
|
|
1670
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, never>;
|
|
1671
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, never>;
|
|
1672
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
1673
|
+
readonly version: OptionalSchema<StringSchema<undefined>, never>;
|
|
1674
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
259
1675
|
/**
|
|
260
1676
|
* The name of the user-defined component.
|
|
261
1677
|
* @example
|
|
262
1678
|
* "Link"
|
|
263
1679
|
*/
|
|
264
|
-
readonly name:
|
|
1680
|
+
readonly name: StringSchema<undefined>;
|
|
265
1681
|
/**
|
|
266
1682
|
* The ESQuery selector to select the component precisely.
|
|
267
1683
|
* @example
|
|
268
1684
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
269
1685
|
*/
|
|
270
|
-
readonly selector:
|
|
1686
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, never>;
|
|
271
1687
|
/**
|
|
272
1688
|
* The name of the built-in component that the user-defined component represents.
|
|
273
1689
|
* @example
|
|
274
1690
|
* "a"
|
|
275
1691
|
*/
|
|
276
|
-
readonly as:
|
|
1692
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
277
1693
|
/**
|
|
278
1694
|
* Pre-defined attributes that are used in the user-defined component.
|
|
279
1695
|
* @example
|
|
280
1696
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
281
1697
|
*/
|
|
282
|
-
readonly attributes:
|
|
1698
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
283
1699
|
/**
|
|
284
1700
|
* The name of the attribute in the user-defined component.
|
|
285
1701
|
* @example
|
|
286
1702
|
* "to"
|
|
287
1703
|
*/
|
|
288
|
-
readonly name:
|
|
1704
|
+
readonly name: StringSchema<undefined>;
|
|
289
1705
|
/**
|
|
290
1706
|
* The name of the attribute in the built-in component.
|
|
291
1707
|
* @example
|
|
292
1708
|
* "href"
|
|
293
1709
|
*/
|
|
294
|
-
readonly as:
|
|
1710
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
295
1711
|
/**
|
|
296
1712
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
297
1713
|
* @example
|
|
298
1714
|
* `true`
|
|
299
1715
|
*/
|
|
300
|
-
readonly controlled:
|
|
1716
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
301
1717
|
/**
|
|
302
1718
|
* The default value of the attribute in the user-defined component.
|
|
303
1719
|
* @example
|
|
304
1720
|
* `"/"`
|
|
305
1721
|
*/
|
|
306
|
-
readonly defaultValue:
|
|
1722
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
307
1723
|
}, undefined>, undefined>, readonly []>;
|
|
308
1724
|
}, undefined>, undefined>, never>;
|
|
309
|
-
readonly additionalHooks:
|
|
310
|
-
readonly use:
|
|
311
|
-
readonly useActionState:
|
|
312
|
-
readonly useCallback:
|
|
313
|
-
readonly useContext:
|
|
314
|
-
readonly useDebugValue:
|
|
315
|
-
readonly useDeferredValue:
|
|
316
|
-
readonly useEffect:
|
|
317
|
-
readonly useId:
|
|
318
|
-
readonly useImperativeHandle:
|
|
319
|
-
readonly useInsertionEffect:
|
|
320
|
-
readonly useLayoutEffect:
|
|
321
|
-
readonly useMemo:
|
|
322
|
-
readonly useOptimistic:
|
|
323
|
-
readonly useReducer:
|
|
324
|
-
readonly useRef:
|
|
325
|
-
readonly useState:
|
|
326
|
-
readonly useSyncExternalStore:
|
|
327
|
-
readonly useTransition:
|
|
1725
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1726
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1727
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1728
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1729
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1730
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1731
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1732
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1733
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1734
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1735
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1736
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1737
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1738
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1739
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1740
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1741
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1742
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1743
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
328
1744
|
}, undefined>, never>;
|
|
329
1745
|
}, undefined>, never>;
|
|
330
1746
|
/**
|
|
331
1747
|
* @internal
|
|
332
1748
|
* @deprecated
|
|
333
1749
|
*/
|
|
334
|
-
readonly reactOptions:
|
|
335
|
-
readonly importSource:
|
|
336
|
-
readonly jsxPragma:
|
|
337
|
-
readonly jsxPragmaFrag:
|
|
338
|
-
readonly polymorphicPropName:
|
|
339
|
-
readonly strict:
|
|
340
|
-
readonly version:
|
|
341
|
-
readonly additionalComponents:
|
|
1750
|
+
readonly reactOptions: OptionalSchema<ObjectSchema<{
|
|
1751
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, never>;
|
|
1752
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, never>;
|
|
1753
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, never>;
|
|
1754
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, never>;
|
|
1755
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
1756
|
+
readonly version: OptionalSchema<StringSchema<undefined>, never>;
|
|
1757
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
342
1758
|
/**
|
|
343
1759
|
* The name of the user-defined component.
|
|
344
1760
|
* @example
|
|
345
1761
|
* "Link"
|
|
346
1762
|
*/
|
|
347
|
-
readonly name:
|
|
1763
|
+
readonly name: StringSchema<undefined>;
|
|
348
1764
|
/**
|
|
349
1765
|
* The ESQuery selector to select the component precisely.
|
|
350
1766
|
* @example
|
|
351
1767
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
352
1768
|
*/
|
|
353
|
-
readonly selector:
|
|
1769
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, never>;
|
|
354
1770
|
/**
|
|
355
1771
|
* The name of the built-in component that the user-defined component represents.
|
|
356
1772
|
* @example
|
|
357
1773
|
* "a"
|
|
358
1774
|
*/
|
|
359
|
-
readonly as:
|
|
1775
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
360
1776
|
/**
|
|
361
1777
|
* Pre-defined attributes that are used in the user-defined component.
|
|
362
1778
|
* @example
|
|
363
1779
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
364
1780
|
*/
|
|
365
|
-
readonly attributes:
|
|
1781
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
366
1782
|
/**
|
|
367
1783
|
* The name of the attribute in the user-defined component.
|
|
368
1784
|
* @example
|
|
369
1785
|
* "to"
|
|
370
1786
|
*/
|
|
371
|
-
readonly name:
|
|
1787
|
+
readonly name: StringSchema<undefined>;
|
|
372
1788
|
/**
|
|
373
1789
|
* The name of the attribute in the built-in component.
|
|
374
1790
|
* @example
|
|
375
1791
|
* "href"
|
|
376
1792
|
*/
|
|
377
|
-
readonly as:
|
|
1793
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
378
1794
|
/**
|
|
379
1795
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
380
1796
|
* @example
|
|
381
1797
|
* `true`
|
|
382
1798
|
*/
|
|
383
|
-
readonly controlled:
|
|
1799
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
384
1800
|
/**
|
|
385
1801
|
* The default value of the attribute in the user-defined component.
|
|
386
1802
|
* @example
|
|
387
1803
|
* `"/"`
|
|
388
1804
|
*/
|
|
389
|
-
readonly defaultValue:
|
|
1805
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
390
1806
|
}, undefined>, undefined>, readonly []>;
|
|
391
1807
|
}, undefined>, undefined>, never>;
|
|
392
|
-
readonly additionalHooks:
|
|
393
|
-
readonly use:
|
|
394
|
-
readonly useActionState:
|
|
395
|
-
readonly useCallback:
|
|
396
|
-
readonly useContext:
|
|
397
|
-
readonly useDebugValue:
|
|
398
|
-
readonly useDeferredValue:
|
|
399
|
-
readonly useEffect:
|
|
400
|
-
readonly useId:
|
|
401
|
-
readonly useImperativeHandle:
|
|
402
|
-
readonly useInsertionEffect:
|
|
403
|
-
readonly useLayoutEffect:
|
|
404
|
-
readonly useMemo:
|
|
405
|
-
readonly useOptimistic:
|
|
406
|
-
readonly useReducer:
|
|
407
|
-
readonly useRef:
|
|
408
|
-
readonly useState:
|
|
409
|
-
readonly useSyncExternalStore:
|
|
410
|
-
readonly useTransition:
|
|
1808
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1809
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1810
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1811
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1812
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1813
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1814
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1815
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1816
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1817
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1818
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1819
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1820
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1821
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1822
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1823
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1824
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1825
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
1826
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, never>;
|
|
411
1827
|
}, undefined>, never>;
|
|
412
1828
|
}, undefined>, never>;
|
|
413
1829
|
}, undefined>, {}>;
|
|
414
|
-
|
|
1830
|
+
type CustomHook = InferOutput<typeof CustomHookSchema>;
|
|
1831
|
+
type CustomAttribute = InferOutput<typeof CustomAttributeSchema>;
|
|
1832
|
+
type CustomComponent = InferOutput<typeof CustomComponentSchema>;
|
|
1833
|
+
type ESLintReactSettings = InferOutput<typeof ESLintReactSettingsSchema>;
|
|
1834
|
+
type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
|
|
1835
|
+
|
|
1836
|
+
interface Dictionary<Type> {
|
|
1837
|
+
[key: string]: Type;
|
|
1838
|
+
[index: number]: Type;
|
|
415
1839
|
}
|
|
416
|
-
|
|
1840
|
+
|
|
1841
|
+
type AnyFn = (...args: any[]) => any;
|
|
1842
|
+
|
|
1843
|
+
type Key = any[];
|
|
1844
|
+
type RawKey = Key | IArguments;
|
|
1845
|
+
type Value = any;
|
|
1846
|
+
|
|
1847
|
+
interface CacheSnapshot {
|
|
1848
|
+
keys: Key[];
|
|
1849
|
+
size: number;
|
|
1850
|
+
values: Value[];
|
|
417
1851
|
}
|
|
418
|
-
|
|
1852
|
+
|
|
1853
|
+
declare class Cache<Fn extends AnyFn> {
|
|
1854
|
+
readonly canTransformKey: boolean;
|
|
1855
|
+
readonly getKeyIndex: KeyIndexGetter;
|
|
1856
|
+
readonly options: NormalizedOptions<Fn>;
|
|
1857
|
+
readonly shouldCloneArguments: boolean;
|
|
1858
|
+
readonly shouldUpdateOnAdd: boolean;
|
|
1859
|
+
readonly shouldUpdateOnChange: boolean;
|
|
1860
|
+
readonly shouldUpdateOnHit: boolean;
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* The prevents call arguments which have cached results.
|
|
1864
|
+
*/
|
|
1865
|
+
keys: Key[];
|
|
1866
|
+
/**
|
|
1867
|
+
* The results of previous cached calls.
|
|
1868
|
+
*/
|
|
1869
|
+
values: Value[];
|
|
1870
|
+
|
|
1871
|
+
constructor(options: NormalizedOptions<Fn>);
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* The number of cached [key,value] results.
|
|
1875
|
+
*/
|
|
1876
|
+
get size(): number;
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* A copy of the cache at a moment in time. This is useful
|
|
1880
|
+
* to compare changes over time, since the cache mutates
|
|
1881
|
+
* internally for performance reasons.
|
|
1882
|
+
*/
|
|
1883
|
+
get snapshot(): CacheSnapshot;
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* Order the array based on a Least-Recently-Used basis.
|
|
1887
|
+
*/
|
|
1888
|
+
orderByLru(key: Key, value: Value, startingIndex: number): void;
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* Update the promise method to auto-remove from cache if rejected, and
|
|
1892
|
+
* if resolved then fire cache hit / changed.
|
|
1893
|
+
*/
|
|
1894
|
+
updateAsyncCache(memoized: Memoized<Fn>): void;
|
|
419
1895
|
}
|
|
420
|
-
|
|
1896
|
+
|
|
1897
|
+
type EqualityComparator = (object1: any, object2: any) => boolean;
|
|
1898
|
+
|
|
1899
|
+
type MatchingKeyComparator = (key1: Key, key2: RawKey) => boolean;
|
|
1900
|
+
|
|
1901
|
+
type CacheModifiedHandler<Fn extends AnyFn> = (
|
|
1902
|
+
cache: Cache<Fn>,
|
|
1903
|
+
options: NormalizedOptions<Fn>,
|
|
1904
|
+
memoized: Memoized<Fn>,
|
|
1905
|
+
) => void;
|
|
1906
|
+
|
|
1907
|
+
type KeyTransformer = (args: Key) => Key;
|
|
1908
|
+
|
|
1909
|
+
type KeyIndexGetter = (keyToMatch: RawKey) => number;
|
|
1910
|
+
|
|
1911
|
+
interface StandardOptions<Fn extends AnyFn> {
|
|
1912
|
+
isEqual?: EqualityComparator;
|
|
1913
|
+
isMatchingKey?: MatchingKeyComparator;
|
|
1914
|
+
isPromise?: boolean;
|
|
1915
|
+
maxSize?: number;
|
|
1916
|
+
onCacheAdd?: CacheModifiedHandler<Fn>;
|
|
1917
|
+
onCacheChange?: CacheModifiedHandler<Fn>;
|
|
1918
|
+
onCacheHit?: CacheModifiedHandler<Fn>;
|
|
1919
|
+
transformKey?: KeyTransformer;
|
|
421
1920
|
}
|
|
422
|
-
|
|
1921
|
+
|
|
1922
|
+
interface Options<Fn extends AnyFn>
|
|
1923
|
+
extends StandardOptions<Fn>,
|
|
1924
|
+
Dictionary<any> {}
|
|
1925
|
+
|
|
1926
|
+
interface NormalizedOptions<Fn extends AnyFn> extends Options<Fn> {
|
|
1927
|
+
isEqual: EqualityComparator;
|
|
1928
|
+
isPromise: boolean;
|
|
1929
|
+
maxSize: number;
|
|
423
1930
|
}
|
|
424
1931
|
|
|
1932
|
+
type Memoized<Fn extends AnyFn> = Fn &
|
|
1933
|
+
Dictionary<any> & {
|
|
1934
|
+
cache: Cache<Fn>;
|
|
1935
|
+
fn: Fn;
|
|
1936
|
+
isMemoized: true;
|
|
1937
|
+
options: NormalizedOptions<Fn>;
|
|
1938
|
+
};
|
|
1939
|
+
|
|
425
1940
|
/**
|
|
426
1941
|
* This is an expanded version of `CustomComponent` with all shorthand properties expanded.
|
|
427
1942
|
* @internal
|
|
@@ -453,7 +1968,7 @@ declare function decodeSettings(data: unknown): ESLintReactSettings;
|
|
|
453
1968
|
* @returns The expanded settings.
|
|
454
1969
|
* @internal
|
|
455
1970
|
*/
|
|
456
|
-
declare const expandSettings:
|
|
1971
|
+
declare const expandSettings: Memoized<(settings: ESLintReactSettings) => ESLintReactSettingsExpanded>;
|
|
457
1972
|
/**
|
|
458
1973
|
* The default ESLint settings for "react-x".
|
|
459
1974
|
*/
|