form
form copied to clipboard
2nd function argument of `serverValidate` should be in type `FormDataInfo | FormDataTransform` instead of `Parameters<typeof decode>[1]`
Describe the bug
https://github.com/TanStack/form/blob/a1568ff667ef6afe8aff576bdc1079327701a6de/packages/react-form/src/nextjs/createServerValidate.ts#L69
Since decode() has two definitions (simplified):
declare function decode(formData: FormData, info: FormDataInfo, transform?: FormDataTransform): TOutput;
declare function decode(formData: FormData, transform?: FormDataTransform): TOutput;
Specifying Parameters<typeof decode>[1] will result in FormDataTransform, while it is perfectly fine to specify FormDataInfo in this case. In fact, the variable name info is likely initially intended for the latter.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/dpnwf9?file=%2Fapp%2Factions.ts%3A6%2C42
Steps to reproduce
- Create a
serverValidatefunction by usingcreateServerValidateaccording to the doc - Attempt to add a 2nd arg when calling the function
- Observe the TS error
Expected behavior
The 2nd arg of serverValidate() should support both FormDataInfo and FormDataTransform, according to the definition of decode()
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
N/A
TanStack Form adapter
react-form
TanStack Form version
v1.2.4
TypeScript version
v5.8.2
Additional context
No response