From 17357acdc74276d4b502af739d2aa3052345dbb8 Mon Sep 17 00:00:00 2001 From: David <4661784+retyui@users.noreply.github.com> Date: Mon, 10 Oct 2022 19:24:11 +0200 Subject: [PATCH] fix: Update incorrect `SwitchChangeEvent` type --- Libraries/Components/Switch/Switch.d.ts | 6 +++++- Libraries/Components/Switch/Switch.js | 1 + types/__typetests__/index.tsx | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/Switch/Switch.d.ts b/Libraries/Components/Switch/Switch.d.ts index 263c9845fe985a..ea52709c54d5e1 100644 --- a/Libraries/Components/Switch/Switch.d.ts +++ b/Libraries/Components/Switch/Switch.d.ts @@ -13,6 +13,7 @@ import {NativeMethods} from '../../Renderer/shims/ReactNativeTypes'; import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet'; import {ViewStyle} from '../../StyleSheet/StyleSheetTypes'; import {ViewProps} from '../View/ViewPropTypes'; +import {NativeSyntheticEvent, TargetedEvent} from '../../Types/CoreEventTypes'; export interface SwitchPropsIOS extends ViewProps { /** @@ -37,10 +38,13 @@ export interface SwitchPropsIOS extends ViewProps { tintColor?: ColorValue | undefined; } -export interface SwitchChangeEvent extends React.SyntheticEvent { +export interface SwitchChangeEventData extends TargetedEvent { value: boolean; } +export interface SwitchChangeEvent + extends NativeSyntheticEvent {} + export interface SwitchProps extends SwitchPropsIOS { /** * Color of the foreground switch grip. diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index a25f60efcb9d2c..ea89d7aeee170f 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -27,6 +27,7 @@ import * as React from 'react'; type SwitchChangeEvent = SyntheticEvent< $ReadOnly<{| value: boolean, + target: number, |}>, >; diff --git a/types/__typetests__/index.tsx b/types/__typetests__/index.tsx index acf7713e18afa4..9e74cc4c675e95 100644 --- a/types/__typetests__/index.tsx +++ b/types/__typetests__/index.tsx @@ -1429,7 +1429,7 @@ const SwitchOnChangePromiseTest = () => ( { const e: SwitchChangeEvent = event; - return new Promise(() => e.value); + return new Promise(() => e.nativeEvent.value); }} /> );