From 0cf9fc10ba9d47099f3507080dd736054d877a20 Mon Sep 17 00:00:00 2001 From: Ricky Date: Fri, 26 Feb 2021 00:00:32 -0500 Subject: [PATCH] Fix React Native flow types (#20889) --- .../ReactNativeViewConfigRegistry.js | 16 +++++----------- .../createReactNativeComponentClass.js | 5 ++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js b/scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js index 2c09ddf3caab1..5f219fea65208 100644 --- a/scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js +++ b/scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js @@ -12,12 +12,8 @@ 'use strict'; -import type { - ReactNativeBaseComponentViewConfig, - ViewConfigGetter, -} from './ReactNativeTypes'; - -const invariant = require('invariant'); +import {type ViewConfig} from './ReactNativeTypes'; +import invariant from 'invariant'; // Event configs const customBubblingEventTypes: { @@ -42,9 +38,7 @@ exports.customDirectEventTypes = customDirectEventTypes; const viewConfigCallbacks = new Map(); const viewConfigs = new Map(); -function processEventTypes( - viewConfig: ReactNativeBaseComponentViewConfig<>, -): void { +function processEventTypes(viewConfig: ViewConfig): void { const {bubblingEventTypes, directEventTypes} = viewConfig; if (__DEV__) { @@ -82,7 +76,7 @@ function processEventTypes( * A callback is provided to load the view config from UIManager. * The callback is deferred until the view is actually rendered. */ -exports.register = function(name: string, callback: ViewConfigGetter): string { +exports.register = function(name: string, callback: () => ViewConfig): string { invariant( !viewConfigCallbacks.has(name), 'Tried to register two views with the same name %s', @@ -103,7 +97,7 @@ exports.register = function(name: string, callback: ViewConfigGetter): string { * If this is the first time the view has been used, * This configuration will be lazy-loaded from UIManager. */ -exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> { +exports.get = function(name: string): ViewConfig { let viewConfig; if (!viewConfigs.has(name)) { const callback = viewConfigCallbacks.get(name); diff --git a/scripts/rollup/shims/react-native/createReactNativeComponentClass.js b/scripts/rollup/shims/react-native/createReactNativeComponentClass.js index 86a758d918b48..f8f4c9284e4c3 100644 --- a/scripts/rollup/shims/react-native/createReactNativeComponentClass.js +++ b/scripts/rollup/shims/react-native/createReactNativeComponentClass.js @@ -11,8 +11,7 @@ 'use strict'; import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; - -import type {ViewConfigGetter} from './ReactNativeTypes'; +import {type ViewConfig} from './ReactNativeTypes'; const {register} = ReactNativeViewConfigRegistry; @@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry; */ const createReactNativeComponentClass = function( name: string, - callback: ViewConfigGetter, + callback: () => ViewConfig, ): string { return register(name, callback); };