Why my form from useAppForm is of any type even with defaultValues?
How do I get typesefety with form coposition?

26 Replies
quickest-silverā¢5w ago
I ran into this too and Luca LeCarbonator suggested adding a specific type to the default values:
and then pass that into the
useAppForm. should fix the type inference
that still doesn't make sense though, in my code, i still get a type on the form when defaultValues isn't given a concrete type.sunny-greenā¢5w ago
that looks like a temporary TS server error. Have you tried restarting it?
ratty-blushOPā¢5w ago
It doesn't work unfortunately

ratty-blushOPā¢5w ago
Tried restarting TS server/editor window reload
sunny-greenā¢5w ago
what's your TypeScript version
ratty-blushOPā¢5w ago
"typescript": "^5.9.3",
All the latest. Spun up project yesterday
sunny-greenā¢5w ago
it's an irritating issue, because I remember multiple conversations, but all of them had different solutions
and of course I can't find them in chatlog as reference
ratty-blushOPā¢5w ago
I'm losing type already here


ratty-blushOPā¢5w ago
I'm using basic shadcn components

sunny-greenā¢5w ago
hmm ... what are your imports for creating
createFormHook?ratty-blushOPā¢5w ago

ratty-blushOPā¢5w ago
If it helps here is my package.json with all deps versions

sunny-greenā¢5w ago
looks completely fine. Removing
node_modules and reinstalling also doesn't work?ratty-blushOPā¢5w ago
Yep, just did that as I thought it might help
But no luck
sunny-greenā¢5w ago
about this section - Is this component made by you, or is this one of the imported shadcn components?
ratty-blushOPā¢5w ago
Imported from shadcn
ratty-blushOPā¢5w ago
Just plain input

sunny-greenā¢5w ago
was just curious about the source of
useFieldContext in there, but it looks like that does come from you
yeah, I'm stumped. The last confirmed chatlog I could find was a typescript < v5.4 issue, so that's not applicable hereratty-blushOPā¢5w ago
Are there ways it's possible that downgrading some dependencies might resolve this? If so what would you suggest I change?
sunny-greenā¢5w ago
Hmm, nothing in particular. I do notice that you're likely on the RC of TanStack Start, so perhaps @nneaowwplane knows about this
flat-fuchsiaā¢5w ago
I don't see any reason that start has to do with this. š
sunny-greenā¢5w ago
well, it was worth a try :Sadge:
ratty-blushOPā¢5w ago
Does anyone has any idea what I could do to try to fix it? I tried downgrading typescript and tanstack/form and issues persist
the type I get for useAppForm is
With simpler type I get the same return type of any
And withForm is
quickest-silverā¢5w ago
And your IDE Typescript is set to your project's version and not built-in Typescript? I debugged a similar issue for a day before I checked that and it resolved my issues.
ratty-blushOPā¢5w ago
That worked! You're amazing! Thanks
sunny-greenā¢5w ago
keeping that in mind for the future! Great tip!