`any` type in form validators when using formOptions
Open
A pull request for this has already been merged.
- #1679 by @a-is-4-adam — merged
type: bug
v1
v2: needs investigation
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
const formOpts = formOptions({
defaultValues: {
description: "",
},
validators: {
onSubmit: data => { //// HERE data IS any
console.log("validando", data); // OUTPUT: { value: { description: "" }, formApi: {...
}
}
});
Your minimal, reproducible example
. just copy the code above
Steps to reproduce
- Copy and paste this code in your editor, see the type of data
const formOpts = formOptions({
defaultValues: {
description: "",
},
validators: {
onSubmit: data => { //// HERE data IS any
console.log("validando", data); // OUTPUT: { value: { description: "" }, formApi: {...
}
}
});
Expected behavior
I expected to infer the type
How often does this bug happen?
Every time
Screenshots or Videos
Platform
- linux
TanStack Form adapter
react-form
TanStack Form version
v1.14.1
TypeScript version
v5.8.3
Additional context
Maybe related to https://github.com/TanStack/form/issues/1583
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 at the formOptions call in the minimal TSX reproduction and trace the validators option's type definitions for the react-form adapter; use the editor or TypeScript checker to inspect onSubmit's inferred data. Done means data is inferred from defaultValues rather than any, and the reproduction no longer shows the reported type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100