From 406b5531a0df12b653bd2b2ad9fa2694a2503b41 Mon Sep 17 00:00:00 2001 From: ahmdshrif Date: Tue, 9 Jun 2026 19:06:59 +0300 Subject: [PATCH] Add missing pointer event types to the TypeScript `PointerEvents` interface The hand-written TypeScript types only declared 12 of the 20 pointer event handlers exposed by `ViewProps` in the Flow source (and in the generated `react-native-strict-api` types). Using `onPointerOver`, `onPointerOut`, `onGotPointerCapture` or `onLostPointerCapture` (and their `*Capture` variants) on a built-in component therefore failed to type-check, even though they are part of the public API. Add the 8 missing handlers to the `PointerEvents` interface and a type test covering them. --- .../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..422d57fc0c9 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; ;