Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inferring form keys and types from the zod return type #551

Open
SeanCassiere opened this issue Apr 29, 2023 · 1 comment
Open

Inferring form keys and types from the zod return type #551

SeanCassiere opened this issue Apr 29, 2023 · 1 comment

Comments

@SeanCassiere
Copy link

Is your feature request related to a problem? Please describe.
It gets pretty annoying when using the zodResolver, that I need to infer the zod-schema type AND pass it into the useForm hook to get the necessary type-completions.
It's more frustrating as zod is known for its great TS-first approach and type inference (see the usage in tRPC).
This particular gap in the types is noticeable when using the handleSubmit in rhf, and all the key-values are possibly undefined, even though the zod-schema wouldn't allow for it to pass its validation.

Describe the solution you'd like
Using the provided zod-schema in the zodResolver to infer the TFieldValues used in the useForm hook in rhf.

Describe alternatives you've considered
Generics seem the only feasible way of doing this.

Additional context
Add any other context or screenshots about the feature request here.

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

No branches or pull requests

3 participants