Add missing pointer event types to the TypeScript PointerEvents interface#57159
Open
ahmdshrif wants to merge 1 commit into
Open
Add missing pointer event types to the TypeScript PointerEvents interface#57159ahmdshrif wants to merge 1 commit into
PointerEvents interface#57159ahmdshrif wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The hand-written TypeScript types declare only 12 of the 20 pointer event handlers that
ViewPropsactually exposes (per the Flow source and the generatedreact-native-strict-apitypes). ThePointerEventsinterface inLibraries/Types/CoreEventTypes.d.tsis missing:onPointerOver/onPointerOverCaptureonPointerOut/onPointerOutCaptureonGotPointerCapture/onGotPointerCaptureCaptureonLostPointerCapture/onLostPointerCaptureCaptureThese 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 generatedreact-native-strict-apitypes, but were missing from the hand-written TypeScript types, so TypeScript users get a type error using them on any built-in component:This adds the 8 missing handlers to the
PointerEventsinterface (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*Capturevariants) to the TypeScript typesTest Plan:
yarn test-typescriptpasses.Verified before/after with
tsc -p packages/react-native/types/tsconfig.json:Property 'onPointerOver' does not exist on type '... ViewProps'.<View onPointerOver={e => e.nativeEvent.pointerId} … />type-checks for all 8 handlers, with the event correctly inferred asPointerEvent.