Type inference from serverValidate is misleading
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
The type of the response from serverValidate (from a createServerValidate) in the example next server actions app has the age field as number, but if you access age at runtime it will be a string.
Your minimal, reproducible example
Steps to reproduce
- Open stackblitz
- Check the type that ts expects for
validatedData:
- See at runtime that printed age is actually a string:
Expected behavior
I'd expect that the type of validatedData should be remain a FormData since it doesn't actually parse the fields into their typescript types.
Another option could be that all the fields of validatedData are strings?
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
macOS
chrome 135
TanStack Form adapter
None
TanStack Form version
1.6.3
TypeScript version
5.8.2
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/index.tsx in the linked next-server-actions StackBlitz example and trace createServerValidate through the serverValidate response type. Compare the declared validatedData type with the runtime age value. Done means the inferred type accurately reflects the returned data, with the expected representation for fields such as age made explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100