Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2nd function argument of serverValidate should be in type FormDataInfo | FormDataTransform instead of Parameters<typeof decode>[1] #1374

Open
mwskwong opened this issue Apr 4, 2025 · 0 comments

Comments

@mwskwong
Copy link

mwskwong commented Apr 4, 2025

Describe the bug

async (formData: FormData, info?: Parameters<typeof decode>[1]) => {

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

  1. Create a serverValidate function by using createServerValidate according to the doc
  2. Attempt to add a 2nd arg when calling the function
  3. 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

@mwskwong mwskwong changed the title 2nd function argument of serverValidate should be in type FormDataInfo | FormDataTransform instead of FormDataTransform 2nd function argument of serverValidate should be in type FormDataInfo | FormDataTransform instead of Parameters<typeof decode>[1] Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant