Commit 20931fe
Add missing pointer event types to the TypeScript
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: #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 — `<View onPointerOver={e => 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: 08d364d2e156953027c0d951ab3d895a1eeab159PointerEvents interface (#57159)1 parent e4a5ed3 commit 20931fe
2 files changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
268 | 276 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
341 | 353 | | |
342 | 354 | | |
343 | 355 | | |
| |||
0 commit comments