@eslint-react/shared 1.24.1 → 1.24.2-beta.1

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 CHANGED
@@ -571,7 +571,7 @@ type Prettify<TObject> = {
571
571
  /**
572
572
  * Marks specific keys as optional.
573
573
  */
574
- type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
574
+ type MarkOptional<TObject, TKeys extends keyof TObject> = Partial<TObject> & Required<Omit<TObject, TKeys>>;
575
575
  /**
576
576
  * Extracts first tuple item.
577
577
  */
@@ -599,79 +599,48 @@ type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknow
599
599
  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?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
600
600
 
601
601
  /**
602
- * Pipe action type.
603
- */
604
- type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
605
- /**
606
- * Pipe action async type.
607
- */
608
- type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
609
- /**
610
- * Pipe item type.
602
+ * Optional entry schema type.
611
603
  */
612
- type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
613
- /**
614
- * Pipe item async type.
615
- */
616
- type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
604
+ type OptionalEntrySchema = ExactOptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown>;
617
605
  /**
618
- * Schema without pipe type.
606
+ * Optional entry schema async type.
619
607
  */
620
- type SchemaWithoutPipe<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema & {
621
- pipe?: never;
622
- };
623
-
608
+ type OptionalEntrySchemaAsync = ExactOptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
624
609
  /**
625
610
  * Object entries interface.
626
611
  */
627
612
  interface ObjectEntries {
628
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>>;
613
+ [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | OptionalEntrySchema;
629
614
  }
630
615
  /**
631
616
  * Object entries async interface.
632
617
  */
633
618
  interface ObjectEntriesAsync {
634
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
619
+ [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | OptionalEntrySchema | OptionalEntrySchemaAsync;
635
620
  }
636
- /**
637
- * Question mark schema type.
638
- */
639
- type QuestionMarkSchema = NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
640
- /**
641
- * Has default type.
642
- */
643
- type HasDefault<TSchema extends QuestionMarkSchema> = undefined extends TSchema['default'] ? false : true;
644
- /**
645
- * Exact optional input type.
646
- */
647
- type ExactOptionalInput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends OptionalSchema<infer TWrapped, unknown> | OptionalSchemaAsync<infer TWrapped, unknown> ? ExactOptionalInput<TWrapped> : InferInput<TSchema>;
648
- /**
649
- * Exact optional output type.
650
- */
651
- type ExactOptionalOutput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends SchemaWithoutPipe<OptionalSchema<infer TWrapped, unknown>> | SchemaWithoutPipe<OptionalSchemaAsync<infer TWrapped, unknown>> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> : InferOutput<TSchema>;
652
621
  /**
653
622
  * Infer entries input type.
654
623
  */
655
624
  type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
656
- -readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
625
+ -readonly [TKey in keyof TEntries]: InferInput<TEntries[TKey]>;
657
626
  };
658
627
  /**
659
628
  * Infer entries output type.
660
629
  */
661
630
  type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
662
- -readonly [TKey in keyof TEntries]: ExactOptionalOutput<TEntries[TKey]>;
631
+ -readonly [TKey in keyof TEntries]: InferOutput<TEntries[TKey]>;
663
632
  };
664
633
  /**
665
634
  * Optional input keys type.
666
635
  */
667
636
  type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
668
- [TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? TKey : never;
637
+ [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? TKey : never;
669
638
  }[keyof TEntries];
670
639
  /**
671
640
  * Optional output keys type.
672
641
  */
673
642
  type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
674
- [TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? undefined extends InferOutput<TEntries[TKey]> ? HasDefault<TEntries[TKey]> extends false ? TKey : never : never : never;
643
+ [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? undefined extends TEntries[TKey]['default'] ? TKey : never : never;
675
644
  }[keyof TEntries];
676
645
  /**
677
646
  * Input with question marks type.
@@ -888,15 +857,32 @@ interface Config<TIssue extends BaseIssue<unknown>> {
888
857
  */
889
858
  readonly message?: ErrorMessage<TIssue> | undefined;
890
859
  /**
891
- * Whether it was abort early.
860
+ * Whether it should be aborted early.
892
861
  */
893
862
  readonly abortEarly?: boolean | undefined;
894
863
  /**
895
- * Whether the pipe was abort early.
864
+ * Whether a pipe should be aborted early.
896
865
  */
897
866
  readonly abortPipeEarly?: boolean | undefined;
898
867
  }
899
868
 
869
+ /**
870
+ * Pipe action type.
871
+ */
872
+ type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
873
+ /**
874
+ * Pipe action async type.
875
+ */
876
+ type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
877
+ /**
878
+ * Pipe item type.
879
+ */
880
+ type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
881
+ /**
882
+ * Pipe item async type.
883
+ */
884
+ type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
885
+
900
886
  /**
901
887
  * Array issue interface.
902
888
  */
@@ -1011,6 +997,92 @@ declare function boolean(): BooleanSchema<undefined>;
1011
997
  */
1012
998
  declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
1013
999
 
1000
+ /**
1001
+ * Exact optional schema interface.
1002
+ */
1003
+ interface ExactOptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, never>> extends BaseSchema<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1004
+ /**
1005
+ * The schema type.
1006
+ */
1007
+ readonly type: 'exact_optional';
1008
+ /**
1009
+ * The schema reference.
1010
+ */
1011
+ readonly reference: typeof exactOptional;
1012
+ /**
1013
+ * The expected property.
1014
+ */
1015
+ readonly expects: TWrapped['expects'];
1016
+ /**
1017
+ * The wrapped schema.
1018
+ */
1019
+ readonly wrapped: TWrapped;
1020
+ /**
1021
+ * The default value.
1022
+ */
1023
+ readonly default: TDefault;
1024
+ }
1025
+ /**
1026
+ * Creates an exact optional schema.
1027
+ *
1028
+ * @param wrapped The wrapped schema.
1029
+ *
1030
+ * @returns An exact optional schema.
1031
+ */
1032
+ declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchema<TWrapped, undefined>;
1033
+ /**
1034
+ * Creates an exact optional schema.
1035
+ *
1036
+ * @param wrapped The wrapped schema.
1037
+ * @param default_ The default value.
1038
+ *
1039
+ * @returns An exact optional schema.
1040
+ */
1041
+ declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchema<TWrapped, TDefault>;
1042
+
1043
+ /**
1044
+ * Exact optional schema async interface.
1045
+ */
1046
+ interface ExactOptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, never>> extends BaseSchemaAsync<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1047
+ /**
1048
+ * The schema type.
1049
+ */
1050
+ readonly type: 'exact_optional';
1051
+ /**
1052
+ * The schema reference.
1053
+ */
1054
+ readonly reference: typeof exactOptional | typeof exactOptionalAsync;
1055
+ /**
1056
+ * The expected property.
1057
+ */
1058
+ readonly expects: TWrapped['expects'];
1059
+ /**
1060
+ * The wrapped schema.
1061
+ */
1062
+ readonly wrapped: TWrapped;
1063
+ /**
1064
+ * The default value.
1065
+ */
1066
+ readonly default: TDefault;
1067
+ }
1068
+ /**
1069
+ * Creates an exact optional schema.
1070
+ *
1071
+ * @param wrapped The wrapped schema.
1072
+ *
1073
+ * @returns An exact optional schema.
1074
+ */
1075
+ declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchemaAsync<TWrapped, undefined>;
1076
+ /**
1077
+ * Creates an exact optional schema.
1078
+ *
1079
+ * @param wrapped The wrapped schema.
1080
+ * @param default_ The default value.
1081
+ *
1082
+ * @returns An exact optional schema.
1083
+ */
1084
+ declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchemaAsync<TWrapped, TDefault>;
1085
+
1014
1086
  /**
1015
1087
  * Infer nullish output type.
1016
1088
  */
@@ -1070,7 +1142,7 @@ interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseI
1070
1142
  /**
1071
1143
  * The schema reference.
1072
1144
  */
1073
- readonly reference: typeof nullishAsync;
1145
+ readonly reference: typeof nullish | typeof nullishAsync;
1074
1146
  /**
1075
1147
  * The expected property.
1076
1148
  */
@@ -1117,7 +1189,7 @@ interface ObjectIssue extends BaseIssue<unknown> {
1117
1189
  /**
1118
1190
  * The expected property.
1119
1191
  */
1120
- readonly expected: 'Object';
1192
+ readonly expected: 'Object' | `"${string}"`;
1121
1193
  }
1122
1194
 
1123
1195
  /**
@@ -1204,20 +1276,20 @@ interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue
1204
1276
  readonly default: TDefault;
1205
1277
  }
1206
1278
  /**
1207
- * Creates a optional schema.
1279
+ * Creates an optional schema.
1208
1280
  *
1209
1281
  * @param wrapped The wrapped schema.
1210
1282
  *
1211
- * @returns A optional schema.
1283
+ * @returns An optional schema.
1212
1284
  */
1213
1285
  declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, undefined>;
1214
1286
  /**
1215
- * Creates a optional schema.
1287
+ * Creates an optional schema.
1216
1288
  *
1217
1289
  * @param wrapped The wrapped schema.
1218
1290
  * @param default_ The default value.
1219
1291
  *
1220
- * @returns A optional schema.
1292
+ * @returns An optional schema.
1221
1293
  */
1222
1294
  declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
1223
1295
 
@@ -1232,7 +1304,7 @@ interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, Base
1232
1304
  /**
1233
1305
  * The schema reference.
1234
1306
  */
1235
- readonly reference: typeof optionalAsync;
1307
+ readonly reference: typeof optional | typeof optionalAsync;
1236
1308
  /**
1237
1309
  * The expected property.
1238
1310
  */
@@ -1850,15 +1922,15 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
1850
1922
  };
1851
1923
  readonly additionalComponents?: {
1852
1924
  name: string;
1853
- as?: string;
1925
+ as?: string | undefined;
1854
1926
  attributes?: {
1855
1927
  name: string;
1856
- as?: string;
1857
- controlled?: boolean;
1858
- defaultValue?: string;
1859
- }[];
1860
- selector?: string;
1861
- }[];
1928
+ as?: string | undefined;
1929
+ controlled?: boolean | undefined;
1930
+ defaultValue?: string | undefined;
1931
+ }[] | undefined;
1932
+ selector?: string | undefined;
1933
+ }[] | undefined;
1862
1934
  };
1863
1935
 
1864
1936
  interface Dictionary<Type> {
package/dist/index.d.ts CHANGED
@@ -571,7 +571,7 @@ type Prettify<TObject> = {
571
571
  /**
572
572
  * Marks specific keys as optional.
573
573
  */
574
- type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
574
+ type MarkOptional<TObject, TKeys extends keyof TObject> = Partial<TObject> & Required<Omit<TObject, TKeys>>;
575
575
  /**
576
576
  * Extracts first tuple item.
577
577
  */
@@ -599,79 +599,48 @@ type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknow
599
599
  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?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
600
600
 
601
601
  /**
602
- * Pipe action type.
603
- */
604
- type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
605
- /**
606
- * Pipe action async type.
607
- */
608
- type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
609
- /**
610
- * Pipe item type.
602
+ * Optional entry schema type.
611
603
  */
612
- type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
613
- /**
614
- * Pipe item async type.
615
- */
616
- type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
604
+ type OptionalEntrySchema = ExactOptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown>;
617
605
  /**
618
- * Schema without pipe type.
606
+ * Optional entry schema async type.
619
607
  */
620
- type SchemaWithoutPipe<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema & {
621
- pipe?: never;
622
- };
623
-
608
+ type OptionalEntrySchemaAsync = ExactOptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
624
609
  /**
625
610
  * Object entries interface.
626
611
  */
627
612
  interface ObjectEntries {
628
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>>;
613
+ [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | OptionalEntrySchema;
629
614
  }
630
615
  /**
631
616
  * Object entries async interface.
632
617
  */
633
618
  interface ObjectEntriesAsync {
634
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
619
+ [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | OptionalEntrySchema | OptionalEntrySchemaAsync;
635
620
  }
636
- /**
637
- * Question mark schema type.
638
- */
639
- type QuestionMarkSchema = NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
640
- /**
641
- * Has default type.
642
- */
643
- type HasDefault<TSchema extends QuestionMarkSchema> = undefined extends TSchema['default'] ? false : true;
644
- /**
645
- * Exact optional input type.
646
- */
647
- type ExactOptionalInput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends OptionalSchema<infer TWrapped, unknown> | OptionalSchemaAsync<infer TWrapped, unknown> ? ExactOptionalInput<TWrapped> : InferInput<TSchema>;
648
- /**
649
- * Exact optional output type.
650
- */
651
- type ExactOptionalOutput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends SchemaWithoutPipe<OptionalSchema<infer TWrapped, unknown>> | SchemaWithoutPipe<OptionalSchemaAsync<infer TWrapped, unknown>> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> : InferOutput<TSchema>;
652
621
  /**
653
622
  * Infer entries input type.
654
623
  */
655
624
  type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
656
- -readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
625
+ -readonly [TKey in keyof TEntries]: InferInput<TEntries[TKey]>;
657
626
  };
658
627
  /**
659
628
  * Infer entries output type.
660
629
  */
661
630
  type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
662
- -readonly [TKey in keyof TEntries]: ExactOptionalOutput<TEntries[TKey]>;
631
+ -readonly [TKey in keyof TEntries]: InferOutput<TEntries[TKey]>;
663
632
  };
664
633
  /**
665
634
  * Optional input keys type.
666
635
  */
667
636
  type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
668
- [TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? TKey : never;
637
+ [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? TKey : never;
669
638
  }[keyof TEntries];
670
639
  /**
671
640
  * Optional output keys type.
672
641
  */
673
642
  type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
674
- [TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? undefined extends InferOutput<TEntries[TKey]> ? HasDefault<TEntries[TKey]> extends false ? TKey : never : never : never;
643
+ [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? undefined extends TEntries[TKey]['default'] ? TKey : never : never;
675
644
  }[keyof TEntries];
676
645
  /**
677
646
  * Input with question marks type.
@@ -888,15 +857,32 @@ interface Config<TIssue extends BaseIssue<unknown>> {
888
857
  */
889
858
  readonly message?: ErrorMessage<TIssue> | undefined;
890
859
  /**
891
- * Whether it was abort early.
860
+ * Whether it should be aborted early.
892
861
  */
893
862
  readonly abortEarly?: boolean | undefined;
894
863
  /**
895
- * Whether the pipe was abort early.
864
+ * Whether a pipe should be aborted early.
896
865
  */
897
866
  readonly abortPipeEarly?: boolean | undefined;
898
867
  }
899
868
 
869
+ /**
870
+ * Pipe action type.
871
+ */
872
+ type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
873
+ /**
874
+ * Pipe action async type.
875
+ */
876
+ type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
877
+ /**
878
+ * Pipe item type.
879
+ */
880
+ type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
881
+ /**
882
+ * Pipe item async type.
883
+ */
884
+ type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
885
+
900
886
  /**
901
887
  * Array issue interface.
902
888
  */
@@ -1011,6 +997,92 @@ declare function boolean(): BooleanSchema<undefined>;
1011
997
  */
1012
998
  declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
1013
999
 
1000
+ /**
1001
+ * Exact optional schema interface.
1002
+ */
1003
+ interface ExactOptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, never>> extends BaseSchema<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1004
+ /**
1005
+ * The schema type.
1006
+ */
1007
+ readonly type: 'exact_optional';
1008
+ /**
1009
+ * The schema reference.
1010
+ */
1011
+ readonly reference: typeof exactOptional;
1012
+ /**
1013
+ * The expected property.
1014
+ */
1015
+ readonly expects: TWrapped['expects'];
1016
+ /**
1017
+ * The wrapped schema.
1018
+ */
1019
+ readonly wrapped: TWrapped;
1020
+ /**
1021
+ * The default value.
1022
+ */
1023
+ readonly default: TDefault;
1024
+ }
1025
+ /**
1026
+ * Creates an exact optional schema.
1027
+ *
1028
+ * @param wrapped The wrapped schema.
1029
+ *
1030
+ * @returns An exact optional schema.
1031
+ */
1032
+ declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchema<TWrapped, undefined>;
1033
+ /**
1034
+ * Creates an exact optional schema.
1035
+ *
1036
+ * @param wrapped The wrapped schema.
1037
+ * @param default_ The default value.
1038
+ *
1039
+ * @returns An exact optional schema.
1040
+ */
1041
+ declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchema<TWrapped, TDefault>;
1042
+
1043
+ /**
1044
+ * Exact optional schema async interface.
1045
+ */
1046
+ interface ExactOptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, never>> extends BaseSchemaAsync<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1047
+ /**
1048
+ * The schema type.
1049
+ */
1050
+ readonly type: 'exact_optional';
1051
+ /**
1052
+ * The schema reference.
1053
+ */
1054
+ readonly reference: typeof exactOptional | typeof exactOptionalAsync;
1055
+ /**
1056
+ * The expected property.
1057
+ */
1058
+ readonly expects: TWrapped['expects'];
1059
+ /**
1060
+ * The wrapped schema.
1061
+ */
1062
+ readonly wrapped: TWrapped;
1063
+ /**
1064
+ * The default value.
1065
+ */
1066
+ readonly default: TDefault;
1067
+ }
1068
+ /**
1069
+ * Creates an exact optional schema.
1070
+ *
1071
+ * @param wrapped The wrapped schema.
1072
+ *
1073
+ * @returns An exact optional schema.
1074
+ */
1075
+ declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchemaAsync<TWrapped, undefined>;
1076
+ /**
1077
+ * Creates an exact optional schema.
1078
+ *
1079
+ * @param wrapped The wrapped schema.
1080
+ * @param default_ The default value.
1081
+ *
1082
+ * @returns An exact optional schema.
1083
+ */
1084
+ declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchemaAsync<TWrapped, TDefault>;
1085
+
1014
1086
  /**
1015
1087
  * Infer nullish output type.
1016
1088
  */
@@ -1070,7 +1142,7 @@ interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseI
1070
1142
  /**
1071
1143
  * The schema reference.
1072
1144
  */
1073
- readonly reference: typeof nullishAsync;
1145
+ readonly reference: typeof nullish | typeof nullishAsync;
1074
1146
  /**
1075
1147
  * The expected property.
1076
1148
  */
@@ -1117,7 +1189,7 @@ interface ObjectIssue extends BaseIssue<unknown> {
1117
1189
  /**
1118
1190
  * The expected property.
1119
1191
  */
1120
- readonly expected: 'Object';
1192
+ readonly expected: 'Object' | `"${string}"`;
1121
1193
  }
1122
1194
 
1123
1195
  /**
@@ -1204,20 +1276,20 @@ interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue
1204
1276
  readonly default: TDefault;
1205
1277
  }
1206
1278
  /**
1207
- * Creates a optional schema.
1279
+ * Creates an optional schema.
1208
1280
  *
1209
1281
  * @param wrapped The wrapped schema.
1210
1282
  *
1211
- * @returns A optional schema.
1283
+ * @returns An optional schema.
1212
1284
  */
1213
1285
  declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, undefined>;
1214
1286
  /**
1215
- * Creates a optional schema.
1287
+ * Creates an optional schema.
1216
1288
  *
1217
1289
  * @param wrapped The wrapped schema.
1218
1290
  * @param default_ The default value.
1219
1291
  *
1220
- * @returns A optional schema.
1292
+ * @returns An optional schema.
1221
1293
  */
1222
1294
  declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
1223
1295
 
@@ -1232,7 +1304,7 @@ interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, Base
1232
1304
  /**
1233
1305
  * The schema reference.
1234
1306
  */
1235
- readonly reference: typeof optionalAsync;
1307
+ readonly reference: typeof optional | typeof optionalAsync;
1236
1308
  /**
1237
1309
  * The expected property.
1238
1310
  */
@@ -1850,15 +1922,15 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
1850
1922
  };
1851
1923
  readonly additionalComponents?: {
1852
1924
  name: string;
1853
- as?: string;
1925
+ as?: string | undefined;
1854
1926
  attributes?: {
1855
1927
  name: string;
1856
- as?: string;
1857
- controlled?: boolean;
1858
- defaultValue?: string;
1859
- }[];
1860
- selector?: string;
1861
- }[];
1928
+ as?: string | undefined;
1929
+ controlled?: boolean | undefined;
1930
+ defaultValue?: string | undefined;
1931
+ }[] | undefined;
1932
+ selector?: string | undefined;
1933
+ }[] | undefined;
1862
1934
  };
1863
1935
 
1864
1936
  interface Dictionary<Type> {
package/dist/index.js CHANGED
@@ -234,7 +234,7 @@ function getReactVersion(fallback = "19.0.0") {
234
234
  }
235
235
  }
236
236
 
237
- // ../../node_modules/.pnpm/valibot@1.0.0-beta.12_typescript@5.7.3/node_modules/valibot/dist/index.js
237
+ // ../../node_modules/.pnpm/valibot@1.0.0-beta.14_typescript@5.7.3/node_modules/valibot/dist/index.js
238
238
  var store;
239
239
  // @__NO_SIDE_EFFECTS__
240
240
  function getGlobalConfig(config2) {
@@ -275,9 +275,9 @@ function _stringify(input) {
275
275
  return type;
276
276
  }
277
277
  function _addIssue(context, label, dataset, config2, other) {
278
- const input = dataset.value;
279
- const expected = context.expects ?? null;
280
- const received = /* @__PURE__ */ _stringify(input);
278
+ const input = other && "input" in other ? other.input : dataset.value;
279
+ const expected = other?.expected ?? context.expects ?? null;
280
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
281
281
  const issue = {
282
282
  kind: context.kind,
283
283
  type: context.type,
@@ -293,7 +293,7 @@ function _addIssue(context, label, dataset, config2, other) {
293
293
  abortPipeEarly: config2.abortPipeEarly
294
294
  };
295
295
  const isSchema = context.kind === "schema";
296
- const message = context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
296
+ const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
297
297
  if (message) {
298
298
  issue.message = typeof message === "function" ? (
299
299
  // @ts-expect-error
@@ -439,38 +439,61 @@ function object(entries, message) {
439
439
  dataset.typed = true;
440
440
  dataset.value = {};
441
441
  for (const key in this.entries) {
442
- const value2 = input[key];
443
- const valueDataset = this.entries[key]["~run"]({ value: value2 }, config2);
444
- if (valueDataset.issues) {
445
- const pathItem = {
446
- type: "object",
447
- origin: "value",
448
- input,
449
- key,
450
- value: value2
451
- };
452
- for (const issue of valueDataset.issues) {
453
- if (issue.path) {
454
- issue.path.unshift(pathItem);
455
- } else {
456
- issue.path = [pathItem];
442
+ const valueSchema = this.entries[key];
443
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
444
+ valueSchema.default !== undefined) {
445
+ const value2 = key in input ? (
446
+ // @ts-expect-error
447
+ input[key]
448
+ ) : /* @__PURE__ */ getDefault(valueSchema);
449
+ const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
450
+ if (valueDataset.issues) {
451
+ const pathItem = {
452
+ type: "object",
453
+ origin: "value",
454
+ input,
455
+ key,
456
+ value: value2
457
+ };
458
+ for (const issue of valueDataset.issues) {
459
+ if (issue.path) {
460
+ issue.path.unshift(pathItem);
461
+ } else {
462
+ issue.path = [pathItem];
463
+ }
464
+ dataset.issues?.push(issue);
465
+ }
466
+ if (!dataset.issues) {
467
+ dataset.issues = valueDataset.issues;
468
+ }
469
+ if (config2.abortEarly) {
470
+ dataset.typed = false;
471
+ break;
457
472
  }
458
- dataset.issues?.push(issue);
459
473
  }
460
- if (!dataset.issues) {
461
- dataset.issues = valueDataset.issues;
474
+ if (!valueDataset.typed) {
475
+ dataset.typed = false;
462
476
  }
477
+ dataset.value[key] = valueDataset.value;
478
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
479
+ _addIssue(this, "key", dataset, config2, {
480
+ input: undefined,
481
+ expected: `"${key}"`,
482
+ path: [
483
+ {
484
+ type: "object",
485
+ origin: "key",
486
+ input,
487
+ key,
488
+ // @ts-expect-error
489
+ value: input[key]
490
+ }
491
+ ]
492
+ });
463
493
  if (config2.abortEarly) {
464
- dataset.typed = false;
465
494
  break;
466
495
  }
467
496
  }
468
- if (!valueDataset.typed) {
469
- dataset.typed = false;
470
- }
471
- if (valueDataset.value !== undefined || key in input) {
472
- dataset.value[key] = valueDataset.value;
473
- }
474
497
  }
475
498
  } else {
476
499
  _addIssue(this, "type", dataset, config2);
package/dist/index.mjs CHANGED
@@ -226,7 +226,7 @@ function getReactVersion(fallback = "19.0.0") {
226
226
  }
227
227
  }
228
228
 
229
- // ../../node_modules/.pnpm/valibot@1.0.0-beta.12_typescript@5.7.3/node_modules/valibot/dist/index.js
229
+ // ../../node_modules/.pnpm/valibot@1.0.0-beta.14_typescript@5.7.3/node_modules/valibot/dist/index.js
230
230
  var store;
231
231
  // @__NO_SIDE_EFFECTS__
232
232
  function getGlobalConfig(config2) {
@@ -267,9 +267,9 @@ function _stringify(input) {
267
267
  return type;
268
268
  }
269
269
  function _addIssue(context, label, dataset, config2, other) {
270
- const input = dataset.value;
271
- const expected = context.expects ?? null;
272
- const received = /* @__PURE__ */ _stringify(input);
270
+ const input = other && "input" in other ? other.input : dataset.value;
271
+ const expected = other?.expected ?? context.expects ?? null;
272
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
273
273
  const issue = {
274
274
  kind: context.kind,
275
275
  type: context.type,
@@ -285,7 +285,7 @@ function _addIssue(context, label, dataset, config2, other) {
285
285
  abortPipeEarly: config2.abortPipeEarly
286
286
  };
287
287
  const isSchema = context.kind === "schema";
288
- const message = context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
288
+ const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
289
289
  if (message) {
290
290
  issue.message = typeof message === "function" ? (
291
291
  // @ts-expect-error
@@ -431,38 +431,61 @@ function object(entries, message) {
431
431
  dataset.typed = true;
432
432
  dataset.value = {};
433
433
  for (const key in this.entries) {
434
- const value2 = input[key];
435
- const valueDataset = this.entries[key]["~run"]({ value: value2 }, config2);
436
- if (valueDataset.issues) {
437
- const pathItem = {
438
- type: "object",
439
- origin: "value",
440
- input,
441
- key,
442
- value: value2
443
- };
444
- for (const issue of valueDataset.issues) {
445
- if (issue.path) {
446
- issue.path.unshift(pathItem);
447
- } else {
448
- issue.path = [pathItem];
434
+ const valueSchema = this.entries[key];
435
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
436
+ valueSchema.default !== undefined) {
437
+ const value2 = key in input ? (
438
+ // @ts-expect-error
439
+ input[key]
440
+ ) : /* @__PURE__ */ getDefault(valueSchema);
441
+ const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
442
+ if (valueDataset.issues) {
443
+ const pathItem = {
444
+ type: "object",
445
+ origin: "value",
446
+ input,
447
+ key,
448
+ value: value2
449
+ };
450
+ for (const issue of valueDataset.issues) {
451
+ if (issue.path) {
452
+ issue.path.unshift(pathItem);
453
+ } else {
454
+ issue.path = [pathItem];
455
+ }
456
+ dataset.issues?.push(issue);
457
+ }
458
+ if (!dataset.issues) {
459
+ dataset.issues = valueDataset.issues;
460
+ }
461
+ if (config2.abortEarly) {
462
+ dataset.typed = false;
463
+ break;
449
464
  }
450
- dataset.issues?.push(issue);
451
465
  }
452
- if (!dataset.issues) {
453
- dataset.issues = valueDataset.issues;
466
+ if (!valueDataset.typed) {
467
+ dataset.typed = false;
454
468
  }
469
+ dataset.value[key] = valueDataset.value;
470
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
471
+ _addIssue(this, "key", dataset, config2, {
472
+ input: undefined,
473
+ expected: `"${key}"`,
474
+ path: [
475
+ {
476
+ type: "object",
477
+ origin: "key",
478
+ input,
479
+ key,
480
+ // @ts-expect-error
481
+ value: input[key]
482
+ }
483
+ ]
484
+ });
455
485
  if (config2.abortEarly) {
456
- dataset.typed = false;
457
486
  break;
458
487
  }
459
488
  }
460
- if (!valueDataset.typed) {
461
- dataset.typed = false;
462
- }
463
- if (valueDataset.value !== undefined || key in input) {
464
- dataset.value[key] = valueDataset.value;
465
- }
466
489
  }
467
490
  } else {
468
491
  _addIssue(this, "type", dataset, config2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.24.1",
3
+ "version": "1.24.2-beta.1",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -36,15 +36,15 @@
36
36
  "@typescript-eslint/utils": "^8.21.0",
37
37
  "picomatch": "^4.0.2",
38
38
  "ts-pattern": "^5.6.2",
39
- "@eslint-react/eff": "1.24.1"
39
+ "@eslint-react/eff": "1.24.2-beta.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/picomatch": "^3.0.2",
43
43
  "fast-equals": "^5.2.2",
44
44
  "micro-memoize": "^4.1.3",
45
- "tsup": "^8.3.5",
45
+ "tsup": "^8.3.6",
46
46
  "type-fest": "^4.33.0",
47
- "valibot": "^1.0.0-beta.12",
47
+ "valibot": "^1.0.0-beta.14",
48
48
  "@workspace/configs": "0.0.0"
49
49
  },
50
50
  "engines": {