Skip to content

Deprecated FormEvent<HTMLFormElement> type for Form onSubmit events when using React 19 #14795

@z0n

Description

@z0n

Reproduction

Check out https://stackblitz.com/edit/github-was1dks4?file=app%2Froutes%2Fhome.tsx

The event parameter in the <fetcher.Form> onSubmit property is typed as FormEvent<HTMLFormElement>.
In the current @types/react package (v19.2.13), FormEvent is deprecated: DefinitelyTyped/DefinitelyTyped#74383

It should probably changed to a SubmitEvent instead.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @react-router/dev: 7.12.0 => 7.12.0 
    @react-router/node: 7.12.0 => 7.12.0 
    @react-router/serve: 7.12.0 => 7.12.0 
    react-router: 7.12.0 => 7.12.0 
    vite: ^7.1.7 => 7.3.1

Used Package Manager

npm

Expected Behavior

The onSubmit event parameter is using the correct up-to-date types.

Actual Behavior

I'm getting TypeScript/linter errors and warnings as I either have to use a deprecated type or deal with mismatching types (FormEvent<HTMLFormElement> vs SubmitEvent).

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