T
TanStack•7mo ago
typical-coral

field.state.meta.errors type is undefined[] when using Form level schema only?

https://stackblitz.com/edit/vitejs-vite-4fblmacv?file=src%2Fcomponents%2FForm.tsx You can see the highlighted type error for errors? Not sure if this should be inferred from a generic? I notice that if I use a field level validator, the type is updated.
juanvilladev
StackBlitz
Vitejs - Vite (forked) - StackBlitz
Next generation frontend tooling. It's fast!
9 Replies
eastern-cyan
eastern-cyan•7mo ago
Make a GH issue please. We took this edgecase into consideration but if it's not working I'll have to figure out why Might be a simple fix In fact, I know why this is happening. We're doing errors[field] in our type when we need to be doing DeepValue<error, field> this is our bad. I'm unavailable today so can you make an issue with this detail included. Will be a minor patch very easy fix
typical-coral
typical-coralOP•7mo ago
Nice yeah I can create it! Sorry wasn't sure if it was really an issue or a skill issue haha
typical-coral
typical-coralOP•7mo ago
GitHub
FieldMetaDerived.errors inferred as undefined[] when using Form lev...
Describe the bug When defining a form that only had form level validations, the inferred type for field.sate.meta.errors is returning undefined[] despite returning an array of ValibotError (in my e...
eastern-cyan
eastern-cyan•7mo ago
Thanks! Technically it's only subfields that have this problem So field.subfield
typical-coral
typical-coralOP•7mo ago
Oh noted, I'll update it
eastern-cyan
eastern-cyan•7mo ago
Oh... Oh dear.... I didn't test this well enough at all 😦 This was a fantastic catch. This would be embarassing to launch for v1 Thank you immensely @juanvilladev
typical-coral
typical-coralOP•7mo ago
You're welcome dude! Hyped for V1 🙂
eastern-cyan
eastern-cyan•7mo ago
This should fix it! With tests and all

Did you find this page helpful?