From 982edf5d9655b7eca3825d113f90ebdbed4aaa39 Mon Sep 17 00:00:00 2001 From: "Sebastian \"Sebbie\" Silbermann" Date: Wed, 4 Feb 2026 12:06:48 +0100 Subject: [PATCH 01/10] [react] Add types for `SubmitEvent.submitter` in `react@canary` (#74451) --- types/react-dom/test/canary-tests.tsx | 9 +++++++++ types/react-dom/test/react-dom-tests.tsx | 2 +- types/react/canary.d.ts | 9 +++++++++ types/react/index.d.ts | 4 ++-- types/react/ts5.0/canary.d.ts | 9 +++++++++ types/react/ts5.0/index.d.ts | 4 ++-- 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/types/react-dom/test/canary-tests.tsx b/types/react-dom/test/canary-tests.tsx index d44db301a7160b..22ca8ed555c643 100644 --- a/types/react-dom/test/canary-tests.tsx +++ b/types/react-dom/test/canary-tests.tsx @@ -99,3 +99,12 @@ function fragmentRefTest() {
; } + +function formrelatedEventTests() { +
{ + // $ExpectType HTMLElement | null + event.submitter; + }} + />; +} diff --git a/types/react-dom/test/react-dom-tests.tsx b/types/react-dom/test/react-dom-tests.tsx index f5e92498ef3589..1184d2e084705e 100644 --- a/types/react-dom/test/react-dom-tests.tsx +++ b/types/react-dom/test/react-dom-tests.tsx @@ -756,7 +756,7 @@ function formrelatedEventTests() { { - // @ts-expect-error -- submitter is not yet exposed by React + // Only passes because program includes React Canary types event.submitter; // $ExpectType EventTarget & HTMLFormElement event.target; diff --git a/types/react/canary.d.ts b/types/react/canary.d.ts index b1cac75e162f5d..e9a4312fcb27cb 100644 --- a/types/react/canary.d.ts +++ b/types/react/canary.d.ts @@ -30,6 +30,8 @@ export {}; declare const UNDEFINED_VOID_ONLY: unique symbol; type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never }; +type NativeSubmitEvent = SubmitEvent; + declare module "." { export function unstable_useCacheRefresh(): () => void; @@ -117,4 +119,11 @@ declare module "." { export interface FragmentProps { ref?: Ref | undefined; } + + interface SubmitEvent extends SyntheticEvent { + /** + * Only available in react@canary + */ + submitter: HTMLElement | null; + } } diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 40620b451199f7..de2143c01ea47e 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -2158,7 +2158,7 @@ declare namespace React { } interface SubmitEvent extends SyntheticEvent { - // Currently not exposed by Reat + // `submitter` is available in react@canary // submitter: HTMLElement | null; // SubmitEvents are always targetted at HTMLFormElements. target: EventTarget & HTMLFormElement; @@ -3525,7 +3525,7 @@ declare namespace React { value?: string | readonly string[] | number | undefined; wrap?: string | undefined; - // No other element dispatching change events can be nested in a + // No other element dispatching change events can be nested in a