Skip to content

Commit

Permalink
Fix React Native flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Feb 26, 2021
1 parent 2e8bbcb commit 310f94d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
18 changes: 5 additions & 13 deletions scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
* @flow strict-local
*/

/* eslint-disable react-internal/invariant-args */

'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 +36,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 +74,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 +95,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 310f94d

Please sign in to comment.