T
TanStack2mo ago
metropolitan-bronze

Field type for further prop autcomplete

Hello all, I have a questions. I have tanstack form created with createFormHook. I have InputFormField component provided by the form. However when I use it like on screenshot it does not show me the props my InputFormField has. So I cannot qutocomplete them. Also if some prop of this field is mandatory - linter will not spot the error. Is there a way I can strictly type it? Thank you in advance.
No description
No description
5 Replies
passive-yellow
passive-yellow2mo ago
your inner field is explicitly typed as any and therefore ditches any prop constraints that the component has
metropolitan-bronze
metropolitan-bronzeOP2mo ago
But what should I use instead?
passive-yellow
passive-yellow2mo ago
it doesn't warn you because any.<prop> is any again. you shouldn't need to type fieldInner as anything. Do you get an error if you don't?
metropolitan-bronze
metropolitan-bronzeOP2mo ago
Ah. I get it now. I was looking for a type in the library but now I see that I can skip typing at all
passive-yellow
passive-yellow2mo ago
Tanstack Form aims to not have you need to specify any generics or type properties. It ideally types them for you You can read up on the reasoning here

Did you find this page helpful?