@@ -154,7 +154,7 @@ export function setError<T extends ZodValidation<AnyZodObject>>(
154154function formDataToValidation < T extends AnyZodObject > (
155155 data : FormData ,
156156 schemaData : SchemaData < T > ,
157- preprocessed ?: string [ ]
157+ preprocessed ?: ( keyof z . infer < T > ) [ ]
158158) {
159159 const output : Record < string , unknown > = { } ;
160160 const { schemaKeys, entityInfo } = schemaData ;
@@ -283,7 +283,7 @@ type SchemaData<T extends AnyZodObject> = {
283283 hasEffects : boolean ;
284284 entityInfo : Entity < T > ;
285285 schemaKeys : string [ ] ;
286- opts : SuperValidateOptions ;
286+ opts : SuperValidateOptions < T > ;
287287} ;
288288
289289type ParsedData = {
@@ -313,7 +313,7 @@ function dataToValidate<T extends AnyZodObject>(
313313function parseFormData < T extends AnyZodObject > (
314314 formData : FormData ,
315315 schemaData : SchemaData < T > ,
316- options ?: SuperValidateOptions
316+ options ?: SuperValidateOptions < T >
317317) : ParsedData {
318318 function tryParseSuperJson ( ) {
319319 if ( formData . has ( '__superform_json' ) ) {
@@ -350,7 +350,7 @@ function parseFormData<T extends AnyZodObject>(
350350function parseSearchParams < T extends AnyZodObject > (
351351 data : URL | URLSearchParams ,
352352 schemaData : SchemaData < T > ,
353- options ?: SuperValidateOptions
353+ options ?: SuperValidateOptions < T >
354354) : ParsedData {
355355 if ( data instanceof URL ) data = data . searchParams ;
356356
@@ -464,7 +464,7 @@ function validateResult<T extends AnyZodObject, M>(
464464
465465function getSchemaData < T extends AnyZodObject > (
466466 schema : ZodValidation < T > ,
467- options : SuperValidateOptions | undefined
467+ options : SuperValidateOptions < T > | undefined
468468) : SchemaData < T > {
469469 const originalSchema = schema as T ;
470470
@@ -500,23 +500,24 @@ function getSchemaData<T extends AnyZodObject>(
500500
501501/////////////////////////////////////////////////////////////////////
502502
503- export type SuperValidateOptions = Partial < {
504- errors : boolean ;
505- id : string ;
506- warnings : {
507- multipleRegexps ?: boolean ;
508- multipleSteps ?: boolean ;
509- } ;
510- preprocessed : string [ ] ;
511- } > ;
503+ export type SuperValidateOptions < T extends AnyZodObject = AnyZodObject > =
504+ Partial < {
505+ errors : boolean ;
506+ id : string ;
507+ warnings : {
508+ multipleRegexps ?: boolean ;
509+ multipleSteps ?: boolean ;
510+ } ;
511+ preprocessed : ( keyof z . infer < T > ) [ ] ;
512+ } > ;
512513
513514export async function superValidate <
514515 T extends ZodValidation < AnyZodObject > ,
515516 // eslint-disable-next-line @typescript-eslint/no-explicit-any
516517 M = any
517518> (
518519 schema : T ,
519- options ?: SuperValidateOptions
520+ options ?: SuperValidateOptions < UnwrapEffects < T > >
520521) : Promise < SuperValidated < UnwrapEffects < T > , M > > ;
521522
522523export async function superValidate <
@@ -534,7 +535,7 @@ export async function superValidate<
534535 | null
535536 | undefined ,
536537 schema : T ,
537- options ?: SuperValidateOptions
538+ options ?: SuperValidateOptions < UnwrapEffects < T > >
538539) : Promise < SuperValidated < UnwrapEffects < T > , M > > ;
539540
540541/**
@@ -548,11 +549,11 @@ export async function superValidate<
548549 M = any
549550> (
550551 data : unknown ,
551- schema ?: T | SuperValidateOptions ,
552- options ?: SuperValidateOptions
552+ schema ?: T | SuperValidateOptions < UnwrapEffects < T > > ,
553+ options ?: SuperValidateOptions < UnwrapEffects < T > >
553554) : Promise < SuperValidated < UnwrapEffects < T > , M > > {
554555 if ( data && typeof data === 'object' && 'safeParseAsync' in data ) {
555- options = schema as SuperValidateOptions | undefined ;
556+ options = schema as SuperValidateOptions < UnwrapEffects < T > > | undefined ;
556557 schema = data as T ;
557558 data = null ;
558559 }
@@ -625,7 +626,7 @@ export function superValidateSync<
625626 M = any
626627> (
627628 schema : T ,
628- options ?: SuperValidateOptions
629+ options ?: SuperValidateOptions < UnwrapEffects < T > >
629630) : SuperValidated < UnwrapEffects < T > , M > ;
630631
631632export function superValidateSync <
@@ -641,7 +642,7 @@ export function superValidateSync<
641642 | null
642643 | undefined ,
643644 schema : T ,
644- options ?: SuperValidateOptions
645+ options ?: SuperValidateOptions < UnwrapEffects < T > >
645646) : SuperValidated < UnwrapEffects < T > , M > ;
646647
647648/**
@@ -655,11 +656,11 @@ export function superValidateSync<
655656 M = any
656657> (
657658 data : unknown ,
658- schema ?: T | SuperValidateOptions ,
659- options ?: SuperValidateOptions
659+ schema ?: T | SuperValidateOptions < UnwrapEffects < T > > ,
660+ options ?: SuperValidateOptions < UnwrapEffects < T > >
660661) : SuperValidated < UnwrapEffects < T > , M > {
661662 if ( data && typeof data === 'object' && 'safeParse' in data ) {
662- options = schema as SuperValidateOptions | undefined ;
663+ options = schema as SuperValidateOptions < UnwrapEffects < T > > | undefined ;
663664 schema = data as T ;
664665 data = null ;
665666 }
0 commit comments