T
TanStack5mo ago
like-gold

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
afraid-scarlet
afraid-scarlet5mo ago
your inner field is explicitly typed as any and therefore ditches any prop constraints that the component has
like-gold
like-goldOP5mo ago
But what should I use instead?
afraid-scarlet
afraid-scarlet5mo 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?
like-gold
like-goldOP5mo 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
afraid-scarlet
afraid-scarlet5mo 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?