diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 428ffe20acd37..d874742cd4846 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -8,7 +8,7 @@ */ import type {HostComponent} from './ReactNativeTypes'; -import type {ReactNodeList} from 'shared/ReactTypes'; +import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes'; import type {ElementRef, Element, ElementType} from 'react'; import './ReactFabricInjection'; @@ -249,7 +249,7 @@ function createPortal( children: ReactNodeList, containerTag: number, key: ?string = null, -) { +): ReactPortal { return createPortalImpl(children, containerTag, null, key); } diff --git a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js index f3ce8a49c28f6..ecd531e3cdaf0 100644 --- a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js @@ -7,7 +7,10 @@ * @flow */ -import type {AnyNativeEvent} from './legacy-events/PluginModuleType'; +import type { + AnyNativeEvent, + EventTypes, +} from './legacy-events/PluginModuleType'; import type {TopLevelType} from './legacy-events/TopLevelEventTypes'; import SyntheticEvent from './legacy-events/SyntheticEvent'; import type {PropagationPhases} from './legacy-events/PropagationPhases'; @@ -175,7 +178,7 @@ function accumulateDirectDispatches(events: ?(Array | Object)) { // End of inline const ReactNativeBridgeEventPlugin = { - eventTypes: {}, + eventTypes: ({}: EventTypes), extractEvents: function( topLevelType: TopLevelType, diff --git a/packages/react-native-renderer/src/ReactNativeFiberInspector.js b/packages/react-native-renderer/src/ReactNativeFiberInspector.js index f0c6a8de2f566..874ac91d84734 100644 --- a/packages/react-native-renderer/src/ReactNativeFiberInspector.js +++ b/packages/react-native-renderer/src/ReactNativeFiberInspector.js @@ -30,7 +30,9 @@ let createHierarchy; let getHostNode; let getHostProps; let lastNonHostInstance; -let getInspectorDataForInstance; +let getInspectorDataForInstance: ( + closestInstance: Fiber | null, +) => InspectorData; let getOwnerHierarchy; let traverseOwnerTreeUp; @@ -142,8 +144,14 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) { }; } -let getInspectorDataForViewTag; -let getInspectorDataForViewAtPoint; +let getInspectorDataForViewTag: (viewTag: number) => Object; +let getInspectorDataForViewAtPoint: ( + findNodeHandle: (componentOrHandle: any) => ?number, + inspectedView: Object, + locationX: number, + locationY: number, + callback: (viewData: TouchedViewDataAtPoint) => mixed, +) => void; if (__DEV__) { getInspectorDataForViewTag = function(viewTag: number): Object { diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index 68241f8def7ac..b47baf0c9bb8c 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -8,7 +8,7 @@ */ import type {HostComponent} from './ReactNativeTypes'; -import type {ReactNodeList} from 'shared/ReactTypes'; +import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes'; import type {ElementRef, Element, ElementType} from 'react'; import './ReactNativeInjection'; @@ -248,7 +248,7 @@ function createPortal( children: ReactNodeList, containerTag: number, key: ?string = null, -) { +): ReactPortal { return createPortalImpl(children, containerTag, null, key); } diff --git a/packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js b/packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js index 3737d2c073b61..a1fe155e1eaaa 100644 --- a/packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js +++ b/packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js @@ -13,10 +13,10 @@ import type { PluginName, LegacyPluginModule, } from './PluginModuleType'; +import type {TopLevelType} from './TopLevelEventTypes'; type NamesToPlugins = { [key: PluginName]: LegacyPluginModule, - ..., }; type EventPluginOrder = null | Array; @@ -166,22 +166,28 @@ function publishRegistrationName( /** * Ordered list of injected plugins. */ -export const plugins = []; +export const plugins: Array> = []; /** * Mapping from event name to dispatch config */ -export const eventNameDispatchConfigs = {}; +export const eventNameDispatchConfigs: { + [eventName: string]: DispatchConfig, +} = {}; /** * Mapping from registration name to plugin module */ -export const registrationNameModules = {}; +export const registrationNameModules: { + [registrationName: string]: LegacyPluginModule, +} = {}; /** * Mapping from registration name to event name */ -export const registrationNameDependencies = {}; +export const registrationNameDependencies: { + [registrationName: string]: Array | void, +} = {}; /** * Mapping from lowercase registration names to the properly cased version, @@ -189,7 +195,9 @@ export const registrationNameDependencies = {}; * only in __DEV__. * @type {Object} */ -export const possibleRegistrationNames = __DEV__ ? {} : (null: any); +export const possibleRegistrationNames: { + [lowerCasedName: string]: string, +} = __DEV__ ? {} : (null: any); // Trust the developer to only use possibleRegistrationNames in __DEV__ /** diff --git a/packages/react-native-renderer/src/legacy-events/PluginModuleType.js b/packages/react-native-renderer/src/legacy-events/PluginModuleType.js index 9488629dca6dd..fcd8ea3ebb870 100644 --- a/packages/react-native-renderer/src/legacy-events/PluginModuleType.js +++ b/packages/react-native-renderer/src/legacy-events/PluginModuleType.js @@ -14,7 +14,7 @@ import type { } from './ReactSyntheticEventType'; import type {TopLevelType} from './TopLevelEventTypes'; -export type EventTypes = {[key: string]: DispatchConfig, ...}; +export type EventTypes = {[key: string]: DispatchConfig}; export type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent; diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index adc89ba407667..404ac2d8b315e 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -70,7 +70,7 @@ well_formed_exports.includes=/packages/react-fetch well_formed_exports.includes=/packages/react-fs well_formed_exports.includes=/packages/react-interactions well_formed_exports.includes=/packages/react-is -; well_formed_exports.includes=/packages/react-native-renderer +well_formed_exports.includes=/packages/react-native-renderer well_formed_exports.includes=/packages/react-noop-renderer well_formed_exports.includes=/packages/react-pg well_formed_exports.includes=/packages/react-reconciler