Skip to content

Commit

Permalink
Fix regression with NativeSyntheticEvent and add test. (#38600)
Browse files Browse the repository at this point in the history
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: #38600

Test Plan: Added a test and ran `yarn test-typescript`

Reviewed By: NickGerleman

Differential Revision: D47739191

Pulled By: lunaleaps

fbshipit-source-id: 0c8b51a62f589a716121e9bfa8ce7e6103f37f6b
  • Loading branch information
mmmulani authored and facebook-github-bot committed Jul 25, 2023
1 parent aa47484 commit fedad15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/react-native/Libraries/Types/CoreEventTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import type * as React from 'react';
import {NodeHandle} from '../ReactNative/RendererProxy';
import {HostComponent} from '../../types/public/ReactNativeTypes';

export interface LayoutRectangle {
Expand Down Expand Up @@ -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 {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/types/__typetests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ const testNativeSyntheticEvent = <T extends {}>(
e.isTrusted;
e.nativeEvent;
e.target;
e.target.measure(() => {});
e.timeStamp;
e.type;
e.nativeEvent;
Expand Down

0 comments on commit fedad15

Please sign in to comment.