Skip to content

Commit 0cf9fc1

Browse files
authored
Fix React Native flow types (#20889)
1 parent 2e8bbcb commit 0cf9fc1

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212

1313
'use strict';
1414

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';
2117

2218
// Event configs
2319
const customBubblingEventTypes: {
@@ -42,9 +38,7 @@ exports.customDirectEventTypes = customDirectEventTypes;
4238
const viewConfigCallbacks = new Map();
4339
const viewConfigs = new Map();
4440

45-
function processEventTypes(
46-
viewConfig: ReactNativeBaseComponentViewConfig<>,
47-
): void {
41+
function processEventTypes(viewConfig: ViewConfig): void {
4842
const {bubblingEventTypes, directEventTypes} = viewConfig;
4943

5044
if (__DEV__) {
@@ -82,7 +76,7 @@ function processEventTypes(
8276
* A callback is provided to load the view config from UIManager.
8377
* The callback is deferred until the view is actually rendered.
8478
*/
85-
exports.register = function(name: string, callback: ViewConfigGetter): string {
79+
exports.register = function(name: string, callback: () => ViewConfig): string {
8680
invariant(
8781
!viewConfigCallbacks.has(name),
8882
'Tried to register two views with the same name %s',
@@ -103,7 +97,7 @@ exports.register = function(name: string, callback: ViewConfigGetter): string {
10397
* If this is the first time the view has been used,
10498
* This configuration will be lazy-loaded from UIManager.
10599
*/
106-
exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> {
100+
exports.get = function(name: string): ViewConfig {
107101
let viewConfig;
108102
if (!viewConfigs.has(name)) {
109103
const callback = viewConfigCallbacks.get(name);

scripts/rollup/shims/react-native/createReactNativeComponentClass.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
'use strict';
1212

1313
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
14-
15-
import type {ViewConfigGetter} from './ReactNativeTypes';
14+
import {type ViewConfig} from './ReactNativeTypes';
1615

1716
const {register} = ReactNativeViewConfigRegistry;
1817

@@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry;
2625
*/
2726
const createReactNativeComponentClass = function(
2827
name: string,
29-
callback: ViewConfigGetter,
28+
callback: () => ViewConfig,
3029
): string {
3130
return register(name, callback);
3231
};

0 commit comments

Comments
 (0)