@samitouri / QOS-React-2 / commits / b1f34aa307

Flow: types first in react-native-renderer (#25363)

Jan Kassens committed Oct 3, 2022 at 17:03 UTC b1f34aa307b004681b3d4c75446d354cda6368cb
7 files changed +36 -17
packages/react-native-renderer/src/ReactFabric.js
+2 -2
@@ -8,7 +8,7 @@
8 */
9
10 import type {HostComponent} from './ReactNativeTypes';
11 -import type {ReactNodeList} from 'shared/ReactTypes';
11 +import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes';
12 import type {ElementRef, Element, ElementType} from 'react';
13
14 import './ReactFabricInjection';
@@ -249,7 +249,7 @@ function createPortal(
249 children: ReactNodeList,
250 containerTag: number,
251 key: ?string = null,
252 -) {
252 +): ReactPortal {
253 return createPortalImpl(children, containerTag, null, key);
254 }
255
packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js
+5 -2
@@ -7,7 +7,10 @@
7 * @flow
8 */
9
10 -import type {AnyNativeEvent} from './legacy-events/PluginModuleType';
10 +import type {
11 + AnyNativeEvent,
12 + EventTypes,
13 +} from './legacy-events/PluginModuleType';
14 import type {TopLevelType} from './legacy-events/TopLevelEventTypes';
15 import SyntheticEvent from './legacy-events/SyntheticEvent';
16 import type {PropagationPhases} from './legacy-events/PropagationPhases';
@@ -175,7 +178,7 @@ function accumulateDirectDispatches(events: ?(Array<Object> | Object)) {
178 // End of inline
179
180 const ReactNativeBridgeEventPlugin = {
178 - eventTypes: {},
181 + eventTypes: ({}: EventTypes),
182
183 extractEvents: function(
184 topLevelType: TopLevelType,
packages/react-native-renderer/src/ReactNativeFiberInspector.js
+11 -3
@@ -30,7 +30,9 @@ let createHierarchy;
30 let getHostNode;
31 let getHostProps;
32 let lastNonHostInstance;
33 -let getInspectorDataForInstance;
33 +let getInspectorDataForInstance: (
34 + closestInstance: Fiber | null,
35 +) => InspectorData;
36 let getOwnerHierarchy;
37 let traverseOwnerTreeUp;
38
@@ -142,8 +144,14 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
144 };
145 }
146
145 -let getInspectorDataForViewTag;
146 -let getInspectorDataForViewAtPoint;
147 +let getInspectorDataForViewTag: (viewTag: number) => Object;
148 +let getInspectorDataForViewAtPoint: (
149 + findNodeHandle: (componentOrHandle: any) => ?number,
150 + inspectedView: Object,
151 + locationX: number,
152 + locationY: number,
153 + callback: (viewData: TouchedViewDataAtPoint) => mixed,
154 +) => void;
155
156 if (__DEV__) {
157 getInspectorDataForViewTag = function(viewTag: number): Object {
packages/react-native-renderer/src/ReactNativeRenderer.js
+2 -2
@@ -8,7 +8,7 @@
8 */
9
10 import type {HostComponent} from './ReactNativeTypes';
11 -import type {ReactNodeList} from 'shared/ReactTypes';
11 +import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes';
12 import type {ElementRef, Element, ElementType} from 'react';
13
14 import './ReactNativeInjection';
@@ -248,7 +248,7 @@ function createPortal(
248 children: ReactNodeList,
249 containerTag: number,
250 key: ?string = null,
251 -) {
251 +): ReactPortal {
252 return createPortalImpl(children, containerTag, null, key);
253 }
254
packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js
+14 -6
@@ -13,10 +13,10 @@ import type {
13 PluginName,
14 LegacyPluginModule,
15 } from './PluginModuleType';
16 +import type {TopLevelType} from './TopLevelEventTypes';
17
18 type NamesToPlugins = {
19 [key: PluginName]: LegacyPluginModule<AnyNativeEvent>,
19 - ...,
20 };
21 type EventPluginOrder = null | Array<PluginName>;
22
@@ -166,22 +166,28 @@ function publishRegistrationName(
166 /**
167 * Ordered list of injected plugins.
168 */
169 -export const plugins = [];
169 +export const plugins: Array<LegacyPluginModule<AnyNativeEvent>> = [];
170
171 /**
172 * Mapping from event name to dispatch config
173 */
174 -export const eventNameDispatchConfigs = {};
174 +export const eventNameDispatchConfigs: {
175 + [eventName: string]: DispatchConfig,
176 +} = {};
177
178 /**
179 * Mapping from registration name to plugin module
180 */
179 -export const registrationNameModules = {};
181 +export const registrationNameModules: {
182 + [registrationName: string]: LegacyPluginModule<AnyNativeEvent>,
183 +} = {};
184
185 /**
186 * Mapping from registration name to event name
187 */
184 -export const registrationNameDependencies = {};
188 +export const registrationNameDependencies: {
189 + [registrationName: string]: Array<TopLevelType> | void,
190 +} = {};
191
192 /**
193 * Mapping from lowercase registration names to the properly cased version,
@@ -189,7 +195,9 @@ export const registrationNameDependencies = {};
195 * only in __DEV__.
196 * @type {Object}
197 */
192 -export const possibleRegistrationNames = __DEV__ ? {} : (null: any);
198 +export const possibleRegistrationNames: {
199 + [lowerCasedName: string]: string,
200 +} = __DEV__ ? {} : (null: any);
201 // Trust the developer to only use possibleRegistrationNames in __DEV__
202
203 /**
packages/react-native-renderer/src/legacy-events/PluginModuleType.js
+1 -1
@@ -14,7 +14,7 @@ import type {
14 } from './ReactSyntheticEventType';
15 import type {TopLevelType} from './TopLevelEventTypes';
16
17 -export type EventTypes = {[key: string]: DispatchConfig, ...};
17 +export type EventTypes = {[key: string]: DispatchConfig};
18
19 export type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent;
20
scripts/flow/config/flowconfig
+1 -1
@@ -70,7 +70,7 @@ well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fetch
70 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fs
71 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-interactions
72 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-is
73 -; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-native-renderer
73 +well_formed_exports.includes=<PROJECT_ROOT>/packages/react-native-renderer
74 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-noop-renderer
75 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-pg
76 well_formed_exports.includes=<PROJECT_ROOT>/packages/react-reconciler