From fedad15a693c9715fe258f0a0a41e131374700bb Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Mon, 24 Jul 2023 18:47:11 -0700 Subject: [PATCH] Fix regression with NativeSyntheticEvent and add test. (#38600) Summary: With moving the TypeScript declarations into the repo, the NativeSyntheticEvent type was copied incorrectly from DefinitelyTyped. This was the old one: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-native/v0.70/index.d.ts#L355 ## Changelog: [GENERAL] [FIXED] - Correct the NativeSyntheticEvent type Pull Request resolved: https://github.com/facebook/react-native/pull/38600 Test Plan: Added a test and ran `yarn test-typescript` Reviewed By: NickGerleman Differential Revision: D47739191 Pulled By: lunaleaps fbshipit-source-id: 0c8b51a62f589a716121e9bfa8ce7e6103f37f6b --- packages/react-native/Libraries/Types/CoreEventTypes.d.ts | 7 +++++-- packages/react-native/types/__typetests__/index.tsx | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/Types/CoreEventTypes.d.ts b/packages/react-native/Libraries/Types/CoreEventTypes.d.ts index 7aff083b07a2bf..9e9f18f84b4496 100644 --- a/packages/react-native/Libraries/Types/CoreEventTypes.d.ts +++ b/packages/react-native/Libraries/Types/CoreEventTypes.d.ts @@ -8,7 +8,6 @@ */ import type * as React from 'react'; -import {NodeHandle} from '../ReactNative/RendererProxy'; import {HostComponent} from '../../types/public/ReactNativeTypes'; export interface LayoutRectangle { @@ -42,7 +41,11 @@ export interface TextLayoutEventData extends TargetedEvent { // Similar to React.SyntheticEvent except for nativeEvent export interface NativeSyntheticEvent - extends React.BaseSyntheticEvent {} + extends React.BaseSyntheticEvent< + T, + React.ElementRef>, + React.ElementRef> + > {} export interface NativeTouchEvent { /** diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index 26419aa6c34caf..9770ef1cf81204 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -386,6 +386,7 @@ const testNativeSyntheticEvent = ( e.isTrusted; e.nativeEvent; e.target; + e.target.measure(() => {}); e.timeStamp; e.type; e.nativeEvent;