12 Replies
wise-whiteOP•4mo ago
I am getting type error when providing default values, and also the type of value isn't as it should be.
probable-pink•4mo ago
Try
wise-whiteOP•4mo ago
It fixes the issue of value's status being string, but the typescript error on
onChange
is still the same.correct-apricot•4mo ago
the enum is both set to optional and has a default. You only need one of them
and it‘s likely why the type is weird
wise-whiteOP•4mo ago
Doesn't fix the error even after removing
.optional()
with just default()
correct-apricot•4mo ago
gave it a test and it seems to work

correct-apricot•4mo ago
no errors on my end
wise-whiteOP•4mo ago
I just initialized a project using create-start-app, and it's showing errors for me.
https://github.com/binamralamsal/tanstack-form-error-test
GitHub
GitHub - binamralamsal/tanstack-form-error-test
Contribute to binamralamsal/tanstack-form-error-test development by creating an account on GitHub.
wise-whiteOP•4mo ago

probable-pink•4mo ago
wise-whiteOP•4mo ago
Thanks for the help to both of you! It resolved my issue
probable-pink•4mo ago
Nice 🙂
Just to have it here for future reference and to add some more info:
https://tanstack.com/form/latest/docs/framework/react/guides/submission-handling#transforming-data-with-standard-schemas
Your defaultValues are the
z.input
and you can use schema.parse(value)
in onSubmit
to get the values of the z.infer/z.output Type.