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

Form field types don't get inferred from zod schema #1066

Open
pavle99 opened this issue Dec 12, 2024 · 0 comments
Open

Form field types don't get inferred from zod schema #1066

pavle99 opened this issue Dec 12, 2024 · 0 comments

Comments

@pavle99
Copy link

pavle99 commented Dec 12, 2024

Describe the bug

Without type casting the default values, the form type gets inferred as ReactFormExtendedApi<TYPE, Validator<unknown, z.ZodType<any, z.ZodTypeDef, any>>> where TYPE is the type of object passed to default values instead of it being the type inferred from the zod schema.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-9w9uhn8b?file=src%2Findex.tsx

Steps to reproduce

Try removing the as User in line 35 in index.tsx file and see how the type of the form changes when you add/remove/modify any of the fields in the default values.

Expected behavior

Expected the form type to be inferred from the zod schema passed, as well as have type safety in default values without needing to manually cast the type.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

OS: Windows 11
Browser: Chrome
Version: 130.0.6723.71 (Official Build) (64-bit)

TanStack Form adapter

react-form

TanStack Form version

0.40.0

TypeScript version

5.6.3

Additional context

No response

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

No branches or pull requests

1 participant