From 605db4427c5ebb7ad0fdc4dc7dbc5ed6fe5b0bd7 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Wed, 28 Jun 2023 07:18:53 -0700 Subject: [PATCH] Replace $Call in react-native (#38104) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38104 With the introduction of [new utility types](https://flow.org/en/docs/types/utilities/#toc-return-type) in Flow, these $Call are no longer needed Changelog: [Internal] Reviewed By: javache Differential Revision: D47078502 fbshipit-source-id: 7fc5f6aa08052b8de8e3f0a45ce2d7a24cb4e1b5 --- packages/react-native/Libraries/Interaction/PanResponder.js | 5 +---- .../react-native/Libraries/Utilities/ReactNativeTestTools.js | 3 +-- .../Libraries/promiseRejectionTrackingOptions.js | 4 +--- .../js/examples/PlatformColor/PlatformColorExample.js | 5 ++++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/react-native/Libraries/Interaction/PanResponder.js b/packages/react-native/Libraries/Interaction/PanResponder.js index e64011e7873..71bec342048 100644 --- a/packages/react-native/Libraries/Interaction/PanResponder.js +++ b/packages/react-native/Libraries/Interaction/PanResponder.js @@ -574,9 +574,6 @@ function clearInteractionHandle( } } -export type PanResponderInstance = $Call< - $PropertyType, - PanResponderConfig, ->; +export type PanResponderInstance = ReturnType<(typeof PanResponder)['create']>; export default PanResponder; diff --git a/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js b/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js index 86715750541..f36e735eb2a 100644 --- a/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js +++ b/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js @@ -28,7 +28,6 @@ const ReactTestRenderer = require('react-test-renderer'); const shallowRenderer = new ShallowRenderer(); export type ReactTestInstance = $PropertyType; export type Predicate = (node: ReactTestInstance) => boolean; -type $ReturnType = $Call<((...A) => Ret) => Ret, Fn>; /* $FlowFixMe[value-as-type] (>=0.125.1 site=react_native_fb) This comment * suppresses an error found when Flow v0.125.1 was deployed. To see the error, * delete this comment and run Flow. */ @@ -36,7 +35,7 @@ export type ReactTestRendererJSON = /* $FlowFixMe[prop-missing] (>=0.125.1 site=react_native_fb) This comment * suppresses an error found when Flow v0.125.1 was deployed. To see the error, * delete this comment and run Flow. */ - $ReturnType; + ReturnType; function byClickable(): Predicate { return withMessage( diff --git a/packages/react-native/Libraries/promiseRejectionTrackingOptions.js b/packages/react-native/Libraries/promiseRejectionTrackingOptions.js index a57f3666899..b951f612ecf 100644 --- a/packages/react-native/Libraries/promiseRejectionTrackingOptions.js +++ b/packages/react-native/Libraries/promiseRejectionTrackingOptions.js @@ -10,9 +10,7 @@ import typeof {enable} from 'promise/setimmediate/rejection-tracking'; -type ExtractOptionsType =

(((options?: ?P) => void)) => P; - -let rejectionTrackingOptions: $Call = { +let rejectionTrackingOptions: $NonMaybeType[0]> = { allRejections: true, onUnhandled: (id, rejection = {}) => { let message: string; diff --git a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js index cb41b818280..37535f520a1 100644 --- a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js +++ b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js @@ -15,7 +15,10 @@ const {DynamicColorIOS, PlatformColor, StyleSheet, Text, View} = ReactNative; function PlatformColorsExample() { function createTable() { - let colors: Array<{color: $Call, label: string}> = []; + let colors: Array<{ + color: ReturnType, + label: string, + }> = []; if (Platform.OS === 'ios') { colors = [ // https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors