Skip to content

Commit

Permalink
Fix React Native flow types (#20889)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii authored Feb 26, 2021
1 parent 2e8bbcb commit 0cf9fc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 5 additions & 11 deletions scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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__) {
Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry;
*/
const createReactNativeComponentClass = function(
name: string,
callback: ViewConfigGetter,
callback: () => ViewConfig,
): string {
return register(name, callback);
};
Expand Down

0 comments on commit 0cf9fc1

Please sign in to comment.