Skip to content

Add missing pointer event types to the TypeScript PointerEvents interface#57159

Closed
ahmdshrif wants to merge 1 commit into
react:mainfrom
ahmdshrif:add-missing-pointer-events-ts-types
Closed

Add missing pointer event types to the TypeScript PointerEvents interface#57159
ahmdshrif wants to merge 1 commit into
react:mainfrom
ahmdshrif:add-missing-pointer-events-ts-types

Conversation

@ahmdshrif

@ahmdshrif ahmdshrif commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

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 — <View onPointerOver={e => e.nativeEvent.pointerId} … /> type-checks for all 8 handlers, with the event correctly inferred as PointerEvent.

…erface

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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 9, 2026
@ahmdshrif ahmdshrif marked this pull request as draft June 9, 2026 16:50
@ahmdshrif ahmdshrif marked this pull request as ready for review June 9, 2026 17:13
@meta-codesync

meta-codesync Bot commented Jun 10, 2026

Copy link
Copy Markdown

@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D108114655.

@meta-codesync meta-codesync Bot closed this in 20931fe Jun 10, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 10, 2026
@meta-codesync

meta-codesync Bot commented Jun 10, 2026

Copy link
Copy Markdown

@fabriziocucci merged this pull request in 20931fe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant