subField properties are type unknown
Hi!
I am receiving type unknown on all properties in a subField using the array method in the Vue Example:
Type in the v-for is correct:
But the type in subField is wrong.


17 Replies
optimistic-goldOP•9mo ago

optimistic-goldOP•9mo ago
This seems like a type thing only for now.
rival-black•9mo ago
This isn't a bug; it's an intentional safeguard when types are too large for us to safely navigate
Prior to this the "could be infinite" type errors were too abundant
optimistic-goldOP•9mo ago
Okay, is this a general thing for subFields or only in my case because they are too large?
rival-black•9mo ago
Only in your case cuz the schema is too big
optimistic-goldOP•9mo ago
Would it be possible to have a big schema when Typescript is ported to Go and implemented, are you aware?
rival-black•9mo ago
TypeScript's Go port will not loosen restrictions on nested types et al according to the authors appearance on Syntax.fm
optimistic-goldOP•9mo ago
Hi again @crutchcorn
I've tried reducing my schema to only to be a lot smaller. I still get the unknown types.

rival-black•9mo ago
Make a bug report
plain-purple•9mo ago
I just filed the bug report here @crutchcorn @Mads
https://github.com/TanStack/form/issues/1295
GitHub
Subfield types set to unknown · Issue #1295 · TanStack/form
Describe the bug This is a typescript typing bug that was not present in 0.42.0 (I'm unaware of when it was introduced as I just upgraded to v1 from that version). It causes some subfields'...
unwilling-turquoise•9mo ago
the issue happens when using optional or nullable type on array fields
foreign-sapphire•9mo ago
just encountered this as well, seems really confusing, since TS types alone (when accessing the same path outside TanStack Form) are correct
I’m wondering whether there’s any semi-elegant way to work around it until it’s fixed upstream. @Mads / @Oudwin / @h3llo have you managed to work around it somehow?
optimistic-goldOP•9mo ago
@selrond yeah its annoying but i only use subFields a few places, so I just ignore it. I guess you could type it manually instead?
foreign-sapphire•9mo ago
type assertions it is…
plain-purple•9mo ago
Yep type assertions @selrond
genetic-orange•9mo ago
Curious why you guys are making entire array fields optional/nullable?
On my team’s forms they’re always required and can simply be initiated as an empty array.
Lets say your backend requires no empty arrays, then use minimum count of array elements in your Schema, or a jankier solution could be to use a transform to convert to null or undefined if count if elements is 0
This way your input schema doesn’t get affected by optional or nullable
foreign-sapphire•9mo ago
@juanvilladev good question, I guess I could make use of empty arrays as a default fallback, thanks for the idea.
The thing is I’m creating a form that’s will be API-based, so what comes in a payload dictates the form structure, thus the nullable fields.