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
This commit is contained in:
Mehdi Mulani
2023-07-24 18:47:11 -07:00
committed by Facebook GitHub Bot
parent aa474847ec
commit fedad15a69
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -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<T>
extends React.BaseSyntheticEvent<T, NodeHandle, NodeHandle> {}
extends React.BaseSyntheticEvent<
T,
React.ElementRef<HostComponent<unknown>>,
React.ElementRef<HostComponent<unknown>>
> {}
export interface NativeTouchEvent {
/**
@@ -386,6 +386,7 @@ const testNativeSyntheticEvent = <T extends {}>(
e.isTrusted;
e.nativeEvent;
e.target;
e.target.measure(() => {});
e.timeStamp;
e.type;
e.nativeEvent;