From 20931fe9755b62f6487d18325e78468e234ea80f Mon Sep 17 00:00:00 2001 From: ahmdshrif Date: Wed, 10 Jun 2026 05:21:52 -0700 Subject: [PATCH] Add missing pointer event types to the TypeScript `PointerEvents` interface (#57159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: The hand-written TypeScript types declare only **12 of the 20** pointer event handlers that `ViewProps` actually exposes (per the Flow source and the generated `react-native-strict-api` types). The `PointerEvents` interface in `Libraries/Types/CoreEventTypes.d.ts` is missing: - `onPointerOver` / `onPointerOverCapture` - `onPointerOut` / `onPointerOutCapture` - `onGotPointerCapture` / `onGotPointerCaptureCapture` - `onLostPointerCapture` / `onLostPointerCaptureCapture` These are part of the W3C Pointer Events API. They are declared in the Flow source — `Libraries/Components/View/ViewPropTypes.js` (all typed `(e: PointerEvent) => void`) — and in the generated `react-native-strict-api` types, but were missing from the hand-written TypeScript types, so TypeScript users get a type error using them on any built-in component: ``` Property 'onPointerOver' does not exist on type '... ViewProps'. Did you mean 'onPointerMove'? ``` This adds the 8 missing handlers to the `PointerEvents` interface (matching the existing 12) and a type test covering them. ## Changelog: [GENERAL] [FIXED] - Add missing pointer event handler types (`onPointerOver`, `onPointerOut`, `onGotPointerCapture`, `onLostPointerCapture`, and their `*Capture` variants) to the TypeScript types Pull Request resolved: https://github.com/react/react-native/pull/57159 Test Plan: `yarn test-typescript` passes. Verified before/after with `tsc -p packages/react-native/types/tsconfig.json`: - **Before** (props absent): the added type test fails with `Property 'onPointerOver' does not exist on type '... ViewProps'`. - **After**: passes — ` e.nativeEvent.pointerId} … />` type-checks for all 8 handlers, with the event correctly inferred as `PointerEvent`. Reviewed By: huntie Differential Revision: D108114655 Pulled By: fabriziocucci fbshipit-source-id: 08d364d2e156953027c0d951ab3d895a1eeab159 --- .../react-native/Libraries/Types/CoreEventTypes.d.ts | 8 ++++++++ packages/react-native/types/__typetests__/index.tsx | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/react-native/Libraries/Types/CoreEventTypes.d.ts b/packages/react-native/Libraries/Types/CoreEventTypes.d.ts index 1325e1d635d..3bcef4f26b9 100644 --- a/packages/react-native/Libraries/Types/CoreEventTypes.d.ts +++ b/packages/react-native/Libraries/Types/CoreEventTypes.d.ts @@ -265,4 +265,12 @@ export interface PointerEvents { onPointerDownCapture?: ((event: PointerEvent) => void) | undefined; onPointerUp?: ((event: PointerEvent) => void) | undefined; onPointerUpCapture?: ((event: PointerEvent) => void) | undefined; + onPointerOver?: ((event: PointerEvent) => void) | undefined; + onPointerOverCapture?: ((event: PointerEvent) => void) | undefined; + onPointerOut?: ((event: PointerEvent) => void) | undefined; + onPointerOutCapture?: ((event: PointerEvent) => void) | undefined; + onGotPointerCapture?: ((event: PointerEvent) => void) | undefined; + onGotPointerCaptureCapture?: ((event: PointerEvent) => void) | undefined; + onLostPointerCapture?: ((event: PointerEvent) => void) | undefined; + onLostPointerCaptureCapture?: ((event: PointerEvent) => void) | undefined; } diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index 7f372d745c1..71e2298a193 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -338,6 +338,18 @@ const lists = StyleSheet.create({ const container = StyleSheet.compose(page.container, lists.listContainer); ; + +// Pointer events (W3C): all variants should be accepted on View. + e.nativeEvent.pointerId} + onPointerOverCapture={e => e.nativeEvent.pointerId} + onPointerOut={e => e.nativeEvent.pointerId} + onPointerOutCapture={e => e.nativeEvent.pointerId} + onGotPointerCapture={e => e.nativeEvent.pointerId} + onGotPointerCaptureCapture={e => e.nativeEvent.pointerId} + onLostPointerCapture={e => e.nativeEvent.pointerId} + onLostPointerCaptureCapture={e => e.nativeEvent.pointerId} +/>; const text = StyleSheet.compose(page.text, lists.listItem) as TextStyle; ;