T
TanStack6mo ago
flat-fuchsia

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.
No description
No description
17 Replies
flat-fuchsia
flat-fuchsiaOP6mo ago
No description
flat-fuchsia
flat-fuchsiaOP6mo ago
This seems like a type thing only for now.
quaint-moccasin
quaint-moccasin6mo 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
flat-fuchsia
flat-fuchsiaOP6mo ago
Okay, is this a general thing for subFields or only in my case because they are too large?
quaint-moccasin
quaint-moccasin6mo ago
Only in your case cuz the schema is too big
flat-fuchsia
flat-fuchsiaOP6mo ago
Would it be possible to have a big schema when Typescript is ported to Go and implemented, are you aware?
quaint-moccasin
quaint-moccasin6mo ago
TypeScript's Go port will not loosen restrictions on nested types et al according to the authors appearance on Syntax.fm
flat-fuchsia
flat-fuchsiaOP6mo ago
Hi again @crutchcorn I've tried reducing my schema to only to be a lot smaller. I still get the unknown types.
No description
quaint-moccasin
quaint-moccasin6mo ago
Make a bug report
plain-purple
plain-purple6mo 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'...
fair-rose
fair-rose6mo ago
the issue happens when using optional or nullable type on array fields
flat-fuchsia
flat-fuchsia6mo 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?
flat-fuchsia
flat-fuchsiaOP6mo 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?
flat-fuchsia
flat-fuchsia6mo ago
type assertions it is…
plain-purple
plain-purple6mo ago
Yep type assertions @selrond
continuing-cyan
continuing-cyan6mo 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
flat-fuchsia
flat-fuchsia6mo 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.

Did you find this page helpful?