Skip to content
Source
Sign inSign up
TanStack/form

formErrors.map(error) has broken type inference #1325

OpentheVedanta(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

Image

The {error} of type void or undefined. This is directly highlighted in one of the examples: https://tanstack.com/form/latest/docs/framework/react/examples/next-server-actions

You can see right before it, the error is casted as a string or unknown however, this would be better solved in a case especially with mergeForm/server-validations.

I will try to trace back the code causing this and raise a PR.

Your minimal, reproducible example

https://tanstack.com/form/latest/docs/framework/react/examples/next-server-actions

Steps to reproduce

Download the project for highlighting of the type inference error.

Expected behavior

I would expect this to be similar to field-level error:

UnwrapOneLevelOfArray<UnwrapFieldValidateOrFn<{
    firstName: string;
    age: number;
}, "age", ({ value }: {
    value: number;
    fieldApi: FieldApi<{
        firstName: string;
        age: number;
    }, "age", number, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
}) => "Client validation: You must be at least 8" | undefined, ({ value }: {
    ...;
}) => void>>

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

All.

TanStack Form adapter

react-form

TanStack Form version

v0.43.2 (form-core)

TypeScript version

v5.6.3

Additional context

No response

  1. LeCarbonator(GitHub profile, opens in a new tab) added labelsv2: needs investigation

  2. LeCarbonator(GitHub profile, opens in a new tab) removed labelsv2: needs investigation

  3. SSR validation should be fixed for v2, since they are now specified within formOptions. This is likely still present for v1.

  4. LeCarbonator(GitHub profile, opens in a new tab) added labelstype: bug

  5. LeCarbonator(GitHub profile, opens in a new tab) added labelsscope: react

  6. LeCarbonator(GitHub profile, opens in a new tab) added labelsarea: types

Sign in to join this conversation.