Skip to content

Field errors returned from onSubmitAsync aren't TS-checked #1537

@vojtech-dobes

Description

@vojtech-dobes

Describe the bug

Form's onSubmitAsync validator allows returning object like this:

return {
    fields: {
        field1: `Field1 has a problem`
    }
}

Considering the strong type checks, I expected that if field1 didn't exist, Typscript would scream about this.

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgVwM4FMBi0RwL5wBmUEuA5AAIwCGAdqjQMYDWA9FOtYzALSE5kA3AChhjCPXj8ouALwoM2GQAoEwuBrgATdIWrIANjABq1A8nSoAXInWb71GwCInAGjv2NAIxsAGd-Z4AZoAbmbAWtQw0Na2npoSAMrIXiDAMACCqACetIw21Dl5cKpwYebo+ACUcLIAfHHxnhwwyFC0jU1NhMDoBlqxal3DmgAeNjBQFsEjgTPDeCJdQR747nhVIsLSIAB0AOboMJi9-QCStPzKZNRkm9s4B0cnfVoXV2Sjd1tAA

Steps to reproduce

The linked playground already contains the imho incorrect behavior.

Expected behavior

I expected Typescript error about the fields object containing unknown key.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

This is about Typescript, not code running in browser.

TanStack Form adapter

react-form

TanStack Form version

1.12.0

TypeScript version

5.8.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions