Fix React Native flow types (#20889)
Ricky committed
Feb 26, 2021 at 00:00 UTC
0cf9fc10ba9d47099f3507080dd736054d877a20
2 files changed
+7
-14
scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js
+5
-11
@@ -12,12 +12,8 @@
12
13
'use strict';
14
15
-import type {
16
- ReactNativeBaseComponentViewConfig,
17
- ViewConfigGetter,
18
-} from './ReactNativeTypes';
19
-
20
-const invariant = require('invariant');
15
+import {type ViewConfig} from './ReactNativeTypes';
16
+import invariant from 'invariant';
17
18
// Event configs
19
const customBubblingEventTypes: {
@@ -42,9 +38,7 @@ exports.customDirectEventTypes = customDirectEventTypes;
38
const viewConfigCallbacks = new Map();
39
const viewConfigs = new Map();
40
45
-function processEventTypes(
46
- viewConfig: ReactNativeBaseComponentViewConfig<>,
47
-): void {
41
+function processEventTypes(viewConfig: ViewConfig): void {
42
const {bubblingEventTypes, directEventTypes} = viewConfig;
43
44
if (__DEV__) {
@@ -82,7 +76,7 @@ function processEventTypes(
76
* A callback is provided to load the view config from UIManager.
77
* The callback is deferred until the view is actually rendered.
78
*/
85
-exports.register = function(name: string, callback: ViewConfigGetter): string {
79
+exports.register = function(name: string, callback: () => ViewConfig): string {
80
invariant(
81
!viewConfigCallbacks.has(name),
82
'Tried to register two views with the same name %s',
@@ -103,7 +97,7 @@ exports.register = function(name: string, callback: ViewConfigGetter): string {
97
* If this is the first time the view has been used,
98
* This configuration will be lazy-loaded from UIManager.
99
*/
106
-exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> {
100
+exports.get = function(name: string): ViewConfig {
101
let viewConfig;
102
if (!viewConfigs.has(name)) {
103
const callback = viewConfigCallbacks.get(name);
scripts/rollup/shims/react-native/createReactNativeComponentClass.js
+2
-3
@@ -11,8 +11,7 @@
11
'use strict';
12
13
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
14
-
15
-import type {ViewConfigGetter} from './ReactNativeTypes';
14
+import {type ViewConfig} from './ReactNativeTypes';
15
16
const {register} = ReactNativeViewConfigRegistry;
17
@@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry;
25
*/
26
const createReactNativeComponentClass = function(
27
name: string,
29
- callback: ViewConfigGetter,
28
+ callback: () => ViewConfig,
29
): string {
30
return register(name, callback);
31
};