Skip to content

Conversation

jinwoo0103
Copy link
Contributor

@jinwoo0103 jinwoo0103 commented Aug 4, 2025

This reverts commit bc09647 (PR #801).


I think #801 fix was not a typo.
When raw option is enabled, TTransformedValues should be z.input, not z.output.

function zodResolver<
  Input extends FieldValues,
  Context,
  Output,
  T extends z4.$ZodType<Output, Input> = z4.$ZodType<Output, Input>,
>(
  schema: z4.$ZodType<Output, Input>,
  schemaOptions: Zod4ParseParams | undefined, // already partial
  resolverOptions: RawResolverOptions,
): Resolver<z4.input<T>, Context, z4.output<T>>;
export type Resolver<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = (values: TFieldValues, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues, TTransformedValues>> | ResolverResult<TFieldValues, TTransformedValues>;

It breaks my project's type, when raw option is enabled.

TMI) For Zod v3, we can see TTransformedValues is correctly assigned when raw option is enabled as below.

export function zodResolver<Input extends FieldValues, Context, Output>(
  schema: Zod3Type<Output, Input>,
  schemaOptions: Zod3ParseParams | undefined,
  resolverOptions: RawResolverOptions,
): Resolver<Input, Context, Input>;

Please tell me if i'm wrong!
Thank you for reading my purpose!

@uncvrd
Copy link

uncvrd commented Sep 13, 2025

I'm also confused why #801 was approved, if it's a raw, the output should be the input which this PR re-implements

@jorisre jorisre merged commit e95721d into react-hook-form:master Sep 14, 2025
4 checks passed
Copy link
Contributor

🎉 This PR is included in version 5.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants