Describe the bug#
When defining a form that only has form level validations, the inferred type for subfield.sate.meta.errors is returning undefined[] despite returning an array of ValibotError (in my example).
Your minimal, reproducible example#
https://stackblitz.com/edit/vitejs-vite-4fblmacv?file=src%2FApp.tsx,src%2Fcomponents%2FForm.tsx
Steps to reproduce#
- Enter stackblitz
- Note how we have a type error for subfield.state.meta.errors, this is because the inferred type is undefined[].
Expected behavior#
If I'm not mistaken, the inferred type should be a union of the Field Level validator return type and the Form Level validator return type.
For the basic example I provide, since we don't have a field level validator, I'd expect it to be a ValibotError.
Would be pretty nice though to have a discriminated union based on ValidationSource
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
See stackblitz, using tanstack/form v0.43.2 and React.
TanStack Form adapter#
react-form
TanStack Form version#
v0.43.2
TypeScript version#
~5.7.2
Additional context#
