@samitouri / QOS-React-2 / commits / 0b4f443020

[flow] enable enforce_local_inference_annotations (#25921)

This setting is an incremental path to the next Flow version enforcing type annotations on most functions (except some inline callbacks). Used ``` node_modules/.bin/flow codemod annotate-functions-and-classes --write . ``` to add a majority of the types with some hand cleanup when for large inferred objects that should just be `Fiber` or weird constructs including `any`. Suppressed the remaining issues. Builds on #25918

Jan Kassens committed Jan 9, 2023 at 15:46 UTC 0b4f443020af386f2b48c47c074cb504ed672dc8
144 files changed +689 -371
packages/jest-react/src/internalAct.js
+1 -1
@@ -122,7 +122,7 @@ export function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
122 }
123 }
124
125 -function flushActWork(resolve, reject) {
125 +function flushActWork(resolve: () => void, reject: (error: any) => void) {
126 if (Scheduler.unstable_hasPendingWork()) {
127 try {
128 Scheduler.unstable_flushUntilNextPaint();
packages/react-cache/src/ReactCacheOld.js
+4 -3
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import type {Thenable} from 'shared/ReactTypes';
10 +import type {ReactContext, Thenable} from 'shared/ReactTypes';
11
12 import * as React from 'react';
13
@@ -48,7 +48,7 @@ const ReactCurrentDispatcher =
48 React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
49 .ReactCurrentDispatcher;
50
51 -function readContext(Context) {
51 +function readContext(Context: ReactContext<mixed>) {
52 const dispatcher = ReactCurrentDispatcher.current;
53 if (dispatcher === null) {
54 // This wasn't being minified but we're going to retire this package anyway.
@@ -62,6 +62,7 @@ function readContext(Context) {
62 return dispatcher.readContext(Context);
63 }
64
65 +// $FlowFixMe[missing-local-annot]
66 function identityHashFn(input) {
67 if (__DEV__) {
68 if (
@@ -133,7 +134,7 @@ function accessResult<I, K, V>(
134 }
135 }
136
136 -function deleteEntry(resource, key) {
137 +function deleteEntry(resource: any, key: mixed) {
138 const entriesForResource = entries.get(resource);
139 if (entriesForResource !== undefined) {
140 entriesForResource.delete(key);
packages/react-client/src/ReactFlightClient.js
+9 -2
@@ -94,6 +94,7 @@ type SomeChunk<T> =
94 | InitializedChunk<T>
95 | ErroredChunk<T>;
96
97 +// $FlowFixMe[missing-this-annot]
98 function Chunk(status: any, value: any, reason: any, response: Response) {
99 this.status = status;
100 this.value = value;
@@ -104,6 +105,7 @@ function Chunk(status: any, value: any, reason: any, response: Response) {
105 Chunk.prototype = (Object.create(Promise.prototype): any);
106 // TODO: This doesn't return a new Promise chain unlike the real .then
107 Chunk.prototype.then = function<T>(
108 + this: SomeChunk<T>,
109 resolve: (value: T) => mixed,
110 reject: (reason: mixed) => mixed,
111 ) {
@@ -369,7 +371,11 @@ export function reportGlobalError(response: Response, error: Error): void {
371 });
372 }
373
372 -function createElement(type, key, props): React$Element<any> {
374 +function createElement(
375 + type: mixed,
376 + key: mixed,
377 + props: mixed,
378 +): React$Element<any> {
379 const element: any = {
380 // This tag allows us to uniquely identify this as a React Element
381 $$typeof: REACT_ELEMENT_TYPE,
@@ -446,6 +452,7 @@ function createModelResolver<T>(
452 value: null,
453 };
454 }
455 + // $FlowFixMe[missing-local-annot]
456 return value => {
457 parentObject[key] = value;
458 blocked.deps--;
@@ -465,7 +472,7 @@ function createModelResolver<T>(
472 }
473
474 function createModelReject<T>(chunk: SomeChunk<T>) {
468 - return error => triggerErrorOnChunk(chunk, error);
475 + return (error: mixed) => triggerErrorOnChunk(chunk, error);
476 }
477
478 export function parseModelString(
packages/react-client/src/ReactFlightClientStream.js
+1
@@ -122,6 +122,7 @@ export function processBinaryChunk(
122 }
123
124 function createFromJSONCallback(response: Response) {
125 + // $FlowFixMe[missing-this-annot]
126 return function(key: string, value: JSONValue) {
127 if (typeof value === 'string') {
128 // We can't use .bind here because we need the "this" value.
packages/react-debug-tools/src/ReactDebugHooks.js
+9 -9
@@ -350,7 +350,7 @@ const Dispatcher: DispatcherType = {
350 // create a proxy to throw a custom error
351 // in case future versions of React adds more hooks
352 const DispatcherProxyHandler = {
353 - get(target, prop) {
353 + get(target: DispatcherType, prop: string) {
354 if (target.hasOwnProperty(prop)) {
355 return target[prop];
356 }
@@ -404,7 +404,7 @@ export type HooksTree = Array<HooksNode>;
404
405 let mostLikelyAncestorIndex = 0;
406
407 -function findSharedIndex(hookStack, rootStack, rootIndex) {
407 +function findSharedIndex(hookStack: any, rootStack: any, rootIndex: number) {
408 const source = rootStack[rootIndex].source;
409 hookSearch: for (let i = 0; i < hookStack.length; i++) {
410 if (hookStack[i].source === source) {
@@ -425,7 +425,7 @@ function findSharedIndex(hookStack, rootStack, rootIndex) {
425 return -1;
426 }
427
428 -function findCommonAncestorIndex(rootStack, hookStack) {
428 +function findCommonAncestorIndex(rootStack: any, hookStack: any) {
429 let rootIndex = findSharedIndex(
430 hookStack,
431 rootStack,
@@ -446,7 +446,7 @@ function findCommonAncestorIndex(rootStack, hookStack) {
446 return -1;
447 }
448
449 -function isReactWrapper(functionName, primitiveName) {
449 +function isReactWrapper(functionName: any, primitiveName: string) {
450 if (!functionName) {
451 return false;
452 }
@@ -460,7 +460,7 @@ function isReactWrapper(functionName, primitiveName) {
460 );
461 }
462
463 -function findPrimitiveIndex(hookStack, hook) {
463 +function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
464 const stackCache = getPrimitiveStackCache();
465 const primitiveStack = stackCache.get(hook.primitive);
466 if (primitiveStack === undefined) {
@@ -488,7 +488,7 @@ function findPrimitiveIndex(hookStack, hook) {
488 return -1;
489 }
490
491 -function parseTrimmedStack(rootStack, hook) {
491 +function parseTrimmedStack(rootStack: any, hook: HookLogEntry) {
492 // Get the stack trace between the primitive hook function and
493 // the root function call. I.e. the stack frames of custom hooks.
494 const hookStack = ErrorStackParser.parse(hook.stackError);
@@ -520,8 +520,8 @@ function parseCustomHookName(functionName: void | string): string {
520 }
521
522 function buildTree(
523 - rootStack,
524 - readHookLog,
523 + rootStack: any,
524 + readHookLog: Array<HookLogEntry>,
525 includeHooksSource: boolean,
526 ): HooksTree {
527 const rootChildren = [];
@@ -764,7 +764,7 @@ function inspectHooksOfForwardRef<Props, Ref>(
764 return buildTree(rootStack, readHookLog, includeHooksSource);
765 }
766
767 -function resolveDefaultProps(Component, baseProps) {
767 +function resolveDefaultProps(Component: any, baseProps: any) {
768 if (Component && Component.defaultProps) {
769 // Resolve default props. Taken from ReactElement
770 const props = assign({}, baseProps);
packages/react-devtools-core/src/backend.js
+2 -2
@@ -44,7 +44,7 @@ const hook: ?DevToolsHook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
44
45 let savedComponentFilters: Array<ComponentFilter> = getDefaultComponentFilters();
46
47 -function debug(methodName: string, ...args) {
47 +function debug(methodName: string, ...args: Array<mixed>) {
48 if (__DEBUG__) {
49 console.log(
50 `%c[core/backend] %c${methodName}`,
@@ -276,7 +276,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
276 scheduleRetry();
277 }
278
279 - function handleMessage(event) {
279 + function handleMessage(event: MessageEvent) {
280 let data;
281 try {
282 if (typeof event.data === 'string') {
packages/react-devtools-core/src/standalone.js
+6 -4
@@ -86,11 +86,12 @@ let bridge: FrontendBridge | null = null;
86 let store: Store | null = null;
87 let root = null;
88
89 -const log = (...args) => console.log('[React DevTools]', ...args);
90 -log.warn = (...args) => console.warn('[React DevTools]', ...args);
91 -log.error = (...args) => console.error('[React DevTools]', ...args);
89 +const log = (...args: Array<mixed>) => console.log('[React DevTools]', ...args);
90 +log.warn = (...args: Array<mixed>) => console.warn('[React DevTools]', ...args);
91 +log.error = (...args: Array<mixed>) =>
92 + console.error('[React DevTools]', ...args);
93
93 -function debug(methodName: string, ...args) {
94 +function debug(methodName: string, ...args: Array<mixed>) {
95 if (__DEBUG__) {
96 console.log(
97 `%c[core/standalone] %c${methodName}`,
@@ -166,6 +167,7 @@ function onDisconnected() {
167 disconnectedCallback();
168 }
169
170 +// $FlowFixMe[missing-local-annot]
171 function onError({code, message}) {
172 safeUnmount();
173
packages/react-devtools-extensions/src/backend.js
+3 -1
@@ -8,6 +8,7 @@
8
9 let welcomeHasInitialized = false;
10
11 +// $FlowFixMe[missing-local-annot]
12 function welcome(event) {
13 if (
14 event.source !== window ||
@@ -42,7 +43,7 @@ function welcome(event) {
43
44 window.addEventListener('message', welcome);
45
45 -function setup(hook) {
46 +function setup(hook: any) {
47 if (hook == null) {
48 // DevTools didn't get injected into this page (maybe b'c of the contentType).
49 return;
@@ -55,6 +56,7 @@ function setup(hook) {
56
57 const bridge = new Bridge({
58 listen(fn) {
59 + // $FlowFixMe[missing-local-annot]
60 const listener = event => {
61 if (
62 event.source !== window ||
packages/react-devtools-inline/src/backend.js
+2
@@ -10,6 +10,7 @@ import type {BackendBridge} from 'react-devtools-shared/src/bridge';
10 import type {Wall} from 'react-devtools-shared/src/types';
11
12 function startActivation(contentWindow: any, bridge: BackendBridge) {
13 + // $FlowFixMe[missing-local-annot]
14 const onSavedPreferences = data => {
15 // This is the only message we're listening for,
16 // so it's safe to cleanup after we've received it.
@@ -96,6 +97,7 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge {
97 if (wall == null) {
98 wall = {
99 listen(fn) {
100 + // $FlowFixMe[missing-local-annot]
101 const onMessage = ({data}) => {
102 fn(data);
103 };
packages/react-devtools-inline/src/frontend.js
+1
@@ -37,6 +37,7 @@ export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge {
37 if (wall == null) {
38 wall = {
39 listen(fn) {
40 + // $FlowFixMe[missing-local-annot]
41 const onMessage = ({data}) => {
42 fn(data);
43 };
packages/react-devtools-shared/src/backend/agent.js
+1 -1
@@ -42,7 +42,7 @@ import type {ComponentFilter} from '../types';
42 import {isSynchronousXHRSupported} from './utils';
43 import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools';
44
45 -const debug = (methodName, ...args) => {
45 +const debug = (methodName: string, ...args: Array<string>) => {
46 if (__DEBUG__) {
47 console.log(
48 `%cAgent %c${methodName}`,
packages/react-devtools-shared/src/backend/console.js
+2
@@ -197,6 +197,7 @@ export function patch({
197 ? targetConsole[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__
198 : targetConsole[method]);
199
200 + // $FlowFixMe[missing-local-annot]
201 const overrideMethod = (...args) => {
202 let shouldAppendWarningStack = false;
203 if (method !== 'log') {
@@ -335,6 +336,7 @@ export function patchForStrictMode() {
336 ? targetConsole[method].__REACT_DEVTOOLS_STRICT_MODE_ORIGINAL_METHOD__
337 : targetConsole[method]);
338
339 + // $FlowFixMe[missing-local-annot]
340 const overrideMethod = (...args) => {
341 if (!consoleSettingsRef.hideConsoleLogsInStrictMode) {
342 // Dim the text color of the double logs if we're not
packages/react-devtools-shared/src/backend/legacy/renderer.js
+1 -1
@@ -195,7 +195,7 @@ export function attach(
195 return ((internalInstanceToIDMap.get(internalInstance): any): number);
196 }
197
198 - function areEqualArrays(a, b) {
198 + function areEqualArrays(a: Array<any>, b: Array<any>) {
199 if (a.length !== b.length) {
200 return false;
201 }
packages/react-devtools-shared/src/backend/legacy/utils.js
+2
@@ -11,6 +11,7 @@ import type {InternalInstance} from './renderer';
11
12 export function decorate(object: Object, attr: string, fn: Function): Function {
13 const old = object[attr];
14 + // $FlowFixMe[missing-this-annot] webpack config needs to be updated to allow `this` type annotations
15 object[attr] = function(instance: InternalInstance) {
16 return fn.call(this, old, arguments);
17 };
@@ -34,6 +35,7 @@ export function restoreMany(source: Object, olds: Object): void {
35 }
36 }
37
38 +// $FlowFixMe[missing-this-annot] webpack config needs to be updated to allow `this` type annotations
39 export function forceUpdate(instance: InternalInstance): void {
40 if (typeof instance.forceUpdate === 'function') {
41 instance.forceUpdate();
packages/react-devtools-shared/src/backend/profilingHooks.js
+1 -1
@@ -204,7 +204,7 @@ export function createProfilingHooks({
204 }
205 }
206
207 - function markAndClear(markName) {
207 + function markAndClear(markName: string) {
208 // This method won't be called unless these functions are defined, so we can skip the extra typeof check.
209 ((performanceTarget: any): Performance).mark(markName);
210 ((performanceTarget: any): Performance).clearMarks(markName);
packages/react-devtools-shared/src/backend/renderer.js
+18 -16
@@ -2546,7 +2546,7 @@ export function attach(
2546 // We don't patch any methods so there is no cleanup.
2547 }
2548
2549 - function rootSupportsProfiling(root) {
2549 + function rootSupportsProfiling(root: any) {
2550 if (root.memoizedInteractions != null) {
2551 // v16 builds include this field for the scheduler/tracing API.
2552 return true;
@@ -2610,7 +2610,7 @@ export function attach(
2610 }
2611 }
2612
2613 - function getUpdatersList(root): Array<SerializedElement> | null {
2613 + function getUpdatersList(root: any): Array<SerializedElement> | null {
2614 return root.memoizedUpdaters != null
2615 ? Array.from(root.memoizedUpdaters)
2616 .filter(fiber => getFiberIDUnsafe(fiber) !== null)
@@ -2618,7 +2618,7 @@ export function attach(
2618 : null;
2619 }
2620
2621 - function handleCommitFiberUnmount(fiber) {
2621 + function handleCommitFiberUnmount(fiber: any) {
2622 // If the untrackFiberSet already has the unmounted Fiber, this means we've already
2623 // recordedUnmount, so we don't need to do it again. If we don't do this, we might
2624 // end up double-deleting Fibers in some cases (like Legacy Suspense).
@@ -2630,7 +2630,7 @@ export function attach(
2630 }
2631 }
2632
2633 - function handlePostCommitFiberRoot(root) {
2633 + function handlePostCommitFiberRoot(root: any) {
2634 if (isProfiling && rootSupportsProfiling(root)) {
2635 if (currentCommitProfilingMetadata !== null) {
2636 const {effectDuration, passiveEffectDuration} = getEffectDurations(
@@ -2644,7 +2644,7 @@ export function attach(
2644 }
2645 }
2646
2647 - function handleCommitFiberRoot(root, priorityLevel) {
2647 + function handleCommitFiberRoot(root: any, priorityLevel: void | number) {
2648 const current = root.current;
2649 const alternate = current.alternate;
2650
@@ -2805,18 +2805,18 @@ export function attach(
2805 }
2806 }
2807
2808 - function getDisplayNameForFiberID(id) {
2808 + function getDisplayNameForFiberID(id: number) {
2809 const fiber = idToArbitraryFiberMap.get(id);
2810 return fiber != null ? getDisplayNameForFiber(((fiber: any): Fiber)) : null;
2811 }
2812
2813 - function getFiberForNative(hostInstance) {
2813 + function getFiberForNative(hostInstance: NativeType) {
2814 return renderer.findFiberByHostInstance(hostInstance);
2815 }
2816
2817 function getFiberIDForNative(
2818 - hostInstance,
2819 - findNearestUnfilteredAncestor = false,
2818 + hostInstance: NativeType,
2819 + findNearestUnfilteredAncestor: boolean = false,
2820 ) {
2821 let fiber = renderer.findFiberByHostInstance(hostInstance);
2822 if (fiber != null) {
@@ -2832,7 +2832,7 @@ export function attach(
2832
2833 // This function is copied from React and should be kept in sync:
2834 // https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberTreeReflection.js
2835 - function assertIsMounted(fiber) {
2835 + function assertIsMounted(fiber: Fiber) {
2836 if (getNearestMountedFiber(fiber) !== fiber) {
2837 throw new Error('Unable to find node on an unmounted component.');
2838 }
@@ -3712,7 +3712,7 @@ export function attach(
3712 };
3713 }
3714
3715 - function logElementToConsole(id) {
3715 + function logElementToConsole(id: number) {
3716 const result = isMostRecentlyInspectedElementCurrent(id)
3717 ? mostRecentlyInspectedElement
3718 : inspectElementRaw(id);
@@ -4149,7 +4149,7 @@ export function attach(
4149 // null (do nothing)
4150 const forceErrorForFiberIDs = new Map();
4151
4152 - function shouldErrorFiberAccordingToMap(fiber) {
4152 + function shouldErrorFiberAccordingToMap(fiber: any) {
4153 if (typeof setErrorHandler !== 'function') {
4154 throw new Error(
4155 'Expected overrideError() to not get called for earlier React versions.',
@@ -4185,7 +4185,7 @@ export function attach(
4185 return status;
4186 }
4187
4188 - function overrideError(id, forceError) {
4188 + function overrideError(id: number, forceError: boolean) {
4189 if (
4190 typeof setErrorHandler !== 'function' ||
4191 typeof scheduleUpdate !== 'function'
@@ -4214,12 +4214,12 @@ export function attach(
4214
4215 const forceFallbackForSuspenseIDs = new Set();
4216
4217 - function shouldSuspendFiberAccordingToSet(fiber) {
4217 + function shouldSuspendFiberAccordingToSet(fiber: any) {
4218 const maybeID = getFiberIDUnsafe(((fiber: any): Fiber));
4219 return maybeID !== null && forceFallbackForSuspenseIDs.has(maybeID);
4220 }
4221
4222 - function overrideSuspense(id, forceFallback) {
4222 + function overrideSuspense(id: number, forceFallback: boolean) {
4223 if (
4224 typeof setSuspenseHandler !== 'function' ||
4225 typeof scheduleUpdate !== 'function'
@@ -4317,7 +4317,9 @@ export function attach(
4317 return true;
4318 }
4319
4320 - function updateTrackedPathStateAfterMount(mightSiblingsBeOnTrackedPath) {
4320 + function updateTrackedPathStateAfterMount(
4321 + mightSiblingsBeOnTrackedPath: boolean,
4322 + ) {
4323 // updateTrackedPathStateBeforeMount() told us whether to match siblings.
4324 // Now that we're entering siblings, let's use that information.
4325 mightBeOnTrackedPath = mightSiblingsBeOnTrackedPath;
packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
+6 -2
@@ -277,7 +277,11 @@ export default class Overlay {
277 }
278 }
279
280 -function findTipPos(dims, bounds, tipSize) {
280 +function findTipPos(
281 + dims: Box,
282 + bounds: Box,
283 + tipSize: {height: number, width: number},
284 +) {
285 const tipHeight = Math.max(tipSize.height, 20);
286 const tipWidth = Math.max(tipSize.width, 60);
287 const margin = 5;
@@ -314,7 +318,7 @@ function findTipPos(dims, bounds, tipSize) {
318 };
319 }
320
317 -function boxWrap(dims, what, node) {
321 +function boxWrap(dims: any, what: string, node: HTMLElement) {
322 assign(node.style, {
323 borderTopWidth: dims[what + 'Top'] + 'px',
324 borderLeftWidth: dims[what + 'Left'] + 'px',
packages/react-devtools-shared/src/backend/views/Highlighter/index.js
+2 -2
@@ -38,7 +38,7 @@ export default function setupHighlighter(
38 registerListenersOnWindow(window);
39 }
40
41 - function registerListenersOnWindow(window) {
41 + function registerListenersOnWindow(window: any) {
42 // This plug-in may run in non-DOM environments (e.g. React Native).
43 if (window && typeof window.addEventListener === 'function') {
44 window.addEventListener('click', onClick, true);
@@ -66,7 +66,7 @@ export default function setupHighlighter(
66 iframesListeningTo = new Set();
67 }
68
69 - function removeListenersOnWindow(window) {
69 + function removeListenersOnWindow(window: any) {
70 // This plug-in may run in non-DOM environments (e.g. React Native).
71 if (window && typeof window.removeEventListener === 'function') {
72 window.removeEventListener('click', onClick, true);
packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js
+10 -1
@@ -81,7 +81,15 @@ export default function ContextMenu({children, id}: Props): React.Node {
81 }, []);
82
83 useEffect(() => {
84 - const showMenuFn = ({data, pageX, pageY}) => {
84 + const showMenuFn = ({
85 + data,
86 + pageX,
87 + pageY,
88 + }: {
89 + data: any,
90 + pageX: number,
91 + pageY: number,
92 + }) => {
93 setState({data, isVisible: true, pageX, pageY});
94 };
95 const hideMenuFn = () => setState(HIDDEN_STATE);
@@ -96,6 +104,7 @@ export default function ContextMenu({children, id}: Props): React.Node {
104 const menu = ((menuRef.current: any): HTMLElement);
105 const container = containerRef.current;
106 if (container !== null) {
107 + // $FlowFixMe[missing-local-annot]
108 const hideUnlessContains = event => {
109 if (!menu.contains(event.target)) {
110 hideMenu();
packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenuItem.js
+1 -1
@@ -28,7 +28,7 @@ export default function ContextMenuItem({
28 }: Props): React.Node {
29 const {hideMenu} = useContext<RegistryContextType>(RegistryContext);
30
31 - const handleClick = event => {
31 + const handleClick = (event: any) => {
32 onClick();
33 hideMenu();
34 };
packages/react-devtools-shared/src/devtools/cache.js
+2 -2
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import type {Thenable} from 'shared/ReactTypes';
10 +import type {ReactContext, Thenable} from 'shared/ReactTypes';
11
12 import * as React from 'react';
13 import {createContext} from 'react';
@@ -63,7 +63,7 @@ const Rejected = 2;
63 const ReactCurrentDispatcher = (React: any)
64 .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
65
66 -function readContext(Context) {
66 +function readContext(Context: ReactContext<null>) {
67 const dispatcher = ReactCurrentDispatcher.current;
68 if (dispatcher === null) {
69 throw new Error(
packages/react-devtools-shared/src/devtools/store.js
+3 -3
@@ -46,7 +46,7 @@ import type {
46 } from 'react-devtools-shared/src/bridge';
47 import UnsupportedBridgeOperationError from 'react-devtools-shared/src/UnsupportedBridgeOperationError';
48
49 -const debug = (methodName, ...args) => {
49 +const debug = (methodName: string, ...args: Array<string>) => {
50 if (__DEBUG__) {
51 console.log(
52 `%cStore %c${methodName}`,
@@ -1146,7 +1146,7 @@ export default class Store extends EventEmitter<{
1146 debug(`Remove root ${id}`);
1147 }
1148
1149 - const recursivelyDeleteElements = elementID => {
1149 + const recursivelyDeleteElements = (elementID: number) => {
1150 const element = this._idToElement.get(elementID);
1151 this._idToElement.delete(elementID);
1152 if (element) {
@@ -1431,7 +1431,7 @@ export default class Store extends EventEmitter<{
1431 // but the downstream errors they cause will be reported as bugs.
1432 // For example, https://github.com/facebook/react/issues/21402
1433 // Emitting an error event allows the ErrorBoundary to show the original error.
1434 - _throwAndEmitError(error: Error) {
1434 + _throwAndEmitError(error: Error): empty {
1435 this.emit('error', error);
1436
1437 // Throwing is still valuable for local development
packages/react-devtools-shared/src/devtools/views/Components/ComponentSearchInput.js
+2 -1
@@ -19,7 +19,8 @@ export default function ComponentSearchInput(props: Props): React.Node {
19 const {searchIndex, searchResults, searchText} = useContext(TreeStateContext);
20 const dispatch = useContext(TreeDispatcherContext);
21
22 - const search = text => dispatch({type: 'SET_SEARCH_TEXT', payload: text});
22 + const search = (text: string) =>
23 + dispatch({type: 'SET_SEARCH_TEXT', payload: text});
24 const goToNextResult = () => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'});
25 const goToPreviousResult = () =>
26 dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'});
packages/react-devtools-shared/src/devtools/views/Components/Components.js
+1
@@ -100,6 +100,7 @@ function Components(_: {}) {
100 onResizeEnd = () =>
101 dispatch({type: 'ACTION_SET_IS_RESIZING', payload: false});
102
103 + // $FlowFixMe[missing-local-annot]
104 onResize = event => {
105 const resizeElement = resizeElementRef.current;
106 const wrapperElement = wrapperElementRef.current;
packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js
+3
@@ -36,6 +36,7 @@ export default function EditableValue({
36 externalValue: value,
37 });
38
39 + // $FlowFixMe[missing-local-annot]
40 const handleChange = ({target}) =>
41 dispatch({
42 type: 'UPDATE',
@@ -43,6 +44,7 @@ export default function EditableValue({
44 externalValue: value,
45 });
46
47 + // $FlowFixMe[missing-local-annot]
48 const handleCheckBoxToggle = ({target}) => {
49 dispatch({
50 type: 'UPDATE',
@@ -58,6 +60,7 @@ export default function EditableValue({
60 overrideValue(path, target.checked);
61 };
62
63 + // $FlowFixMe[missing-local-annot]
64 const handleKeyDown = event => {
65 // Prevent keydown events from e.g. change selected element in the tree
66 event.stopPropagation();
packages/react-devtools-shared/src/devtools/views/Components/Element.js
+5
@@ -75,6 +75,7 @@ export default function Element({data, index, style}: Props): React.Node {
75 }
76 };
77
78 + // $FlowFixMe[missing-local-annot]
79 const handleClick = ({metaKey}) => {
80 if (id !== null) {
81 logEvent({
@@ -99,6 +100,7 @@ export default function Element({data, index, style}: Props): React.Node {
100 setIsHovered(false);
101 };
102
103 + // $FlowFixMe[missing-local-annot]
104 const handleKeyDoubleClick = event => {
105 // Double clicks on key value are used for text selection (if the text has been truncated).
106 // They should not enter the owners tree view.
@@ -220,6 +222,7 @@ export default function Element({data, index, style}: Props): React.Node {
222 }
223
224 // Prevent double clicks on toggle from drilling into the owner list.
225 +// $FlowFixMe[missing-local-annot]
226 const swallowDoubleClick = event => {
227 event.preventDefault();
228 event.stopPropagation();
@@ -233,6 +236,7 @@ type ExpandCollapseToggleProps = {
236 function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
237 const {children, id, isCollapsed} = element;
238
239 + // $FlowFixMe[missing-local-annot]
240 const toggleCollapsed = event => {
241 event.preventDefault();
242 event.stopPropagation();
@@ -240,6 +244,7 @@ function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
244 store.toggleIsCollapsed(id, !isCollapsed);
245 };
246
247 + // $FlowFixMe[missing-local-annot]
248 const stopPropagation = event => {
249 // Prevent the row from selecting
250 event.stopPropagation();
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js
+1
@@ -53,6 +53,7 @@ export default function InspectedElementContextTree({
53 // We add an object with a "value" key as a wrapper around Context data
54 // so that we can use the shared <KeyValue> component to display it.
55 // This wrapper object can't be renamed.
56 + // $FlowFixMe[missing-local-annot]
57 const canRenamePathsAtDepth = depth => depth > 1;
58
59 if (isEmpty) {
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementHooksTree.js
+1
@@ -223,6 +223,7 @@ function HookView({
223
224 // Certain hooks are not editable at all (as identified by react-debug-tools).
225 // Primitive hook names (e.g. the "State" name for useState) are also never editable.
226 + // $FlowFixMe[missing-local-annot]
227 const canRenamePathsAtDepth = depth => isStateEditable && depth > 1;
228
229 const isCustomHook = subHooks.length > 0;
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspenseToggle.js
+1 -1
@@ -39,7 +39,7 @@ export default function InspectedElementSuspenseToggle({
39
40 const isSuspended = state !== null;
41
42 - const toggleSuspense = (path, value) => {
42 + const toggleSuspense = (path: any, value: boolean) => {
43 const rendererID = store.getRendererIDForElement(id);
44 if (rendererID !== null) {
45 bridge.send('overrideSuspense', {
packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js
+8 -3
@@ -138,7 +138,7 @@ export default function KeyValue({
138 paddingLeft: `${(depth - 1) * 0.75}rem`,
139 };
140
141 - const overrideValue = (newPath, newValue) => {
141 + const overrideValue = (newPath: Array<string | number>, newValue: any) => {
142 if (hookID != null) {
143 newPath = parseHookPathForEdit(newPath);
144 }
@@ -156,7 +156,7 @@ export default function KeyValue({
156 }
157 };
158
159 - const deletePath = pathToDelete => {
159 + const deletePath = (pathToDelete: Array<string | number>) => {
160 if (hookID != null) {
161 pathToDelete = parseHookPathForEdit(pathToDelete);
162 }
@@ -173,7 +173,10 @@ export default function KeyValue({
173 }
174 };
175
176 - const renamePath = (oldPath, newPath) => {
176 + const renamePath = (
177 + oldPath: Array<string | number>,
178 + newPath: Array<string | number>,
179 + ) => {
180 if (newPath[newPath.length - 1] === '') {
181 // Deleting the key suggests an intent to delete the whole path.
182 if (canDeletePaths) {
@@ -477,7 +480,9 @@ export default function KeyValue({
480 return children;
481 }
482
483 +// $FlowFixMe[missing-local-annot]
484 function DeleteToggle({deletePath, name, path}) {
485 + // $FlowFixMe[missing-local-annot]
486 const handleClick = event => {
487 event.stopPropagation();
488 deletePath(path);
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/AutoSizeInput.js
+1
@@ -27,6 +27,7 @@ export default function AutoSizeInput({
27 value,
28 ...rest
29 }: Props): React.Node {
30 + // $FlowFixMe[missing-local-annot]
31 const onFocusWrapper = event => {
32 const input = event.target;
33 if (input !== null) {
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/StyleEditor.js
+3
@@ -171,6 +171,7 @@ function Row({
171 const [isAttributeValid, setIsAttributeValid] = useState(true);
172 const [isValueValid, setIsValueValid] = useState(true);
173
174 + // $FlowFixMe[missing-local-annot]
175 const validateAndSetLocalAttribute = newAttribute => {
176 const isValid =
177 newAttribute === '' ||
@@ -183,6 +184,7 @@ function Row({
184 });
185 };
186
187 + // $FlowFixMe[missing-local-annot]
188 const validateAndSetLocalValue = newValue => {
189 let isValid = false;
190 try {
@@ -262,6 +264,7 @@ function Field({
264 placeholder,
265 value,
266 }: FieldProps) {
267 + // $FlowFixMe[missing-local-annot]
268 const onKeyDown = event => {
269 switch (event.key) {
270 case 'Enter':
packages/react-devtools-shared/src/devtools/views/Components/NewArrayValue.js
+2 -1
@@ -46,7 +46,8 @@ export default function NewArrayValue({
46
47 // This is a bit of an unusual usage of the EditableName component,
48 // but otherwise it acts the way we want for a new Array entry.
49 - const overrideName = (oldPath, newPath) => {
49 + // $FlowFixMe[missing-local-annot]
50 + const overrideName = (oldPath: any, newPath) => {
51 const value = newPath[newPath.length - 1];
52
53 let parsedValue;
packages/react-devtools-shared/src/devtools/views/Components/NewKeyValue.js
+6 -2
@@ -42,11 +42,15 @@ export default function NewKeyValue({
42 const [newPropKey, setNewPropKey] = useState<number>(0);
43 const [newPropName, setNewPropName] = useState<string>('');
44
45 - const overrideNewEntryName = (oldPath, newPath) => {
45 + // $FlowFixMe[missing-local-annot]
46 + const overrideNewEntryName = (oldPath: any, newPath) => {
47 setNewPropName(newPath[newPath.length - 1]);
48 };
49
49 - const overrideNewEntryValue = (newPath, value) => {
50 + const overrideNewEntryValue = (
51 + newPath: Array<string | number>,
52 + value: any,
53 + ) => {
54 if (!newPropName) {
55 return;
56 }
packages/react-devtools-shared/src/devtools/views/Components/OwnersStack.js
+1 -1
@@ -56,7 +56,7 @@ type State = {
56 selectedIndex: number,
57 };
58
59 -function dialogReducer(state, action) {
59 +function dialogReducer(state: State, action: Action) {
60 switch (action.type) {
61 case 'UPDATE_OWNER_ID':
62 const selectedIndex = action.owners.findIndex(
packages/react-devtools-shared/src/devtools/views/Components/Tree.js
+2 -1
@@ -101,7 +101,7 @@ export default function Tree(props: Props): React.Node {
101 // Picking an element in the inspector should put focus into the tree.
102 // This ensures that keyboard navigation works right after picking a node.
103 useEffect(() => {
104 - function handleStopInspectingNative(didSelectNode) {
104 + function handleStopInspectingNative(didSelectNode: boolean) {
105 if (didSelectNode && focusTargetRef.current !== null) {
106 focusTargetRef.current.focus();
107 logEvent({
@@ -540,6 +540,7 @@ function updateIndentationSizeVar(
540 list.style.setProperty('--indentation-size', `${maxIndentationSize}px`);
541 }
542
543 +// $FlowFixMe[missing-local-annot]
544 function InnerElementType({children, style, ...rest}) {
545 const {ownerID} = useContext(TreeStateContext);
546
packages/react-devtools-shared/src/devtools/views/ModalDialog.js
+1 -1
@@ -61,7 +61,7 @@ const ModalDialogContext: ReactContext<ModalDialogContextType> = createContext<M
61 );
62 ModalDialogContext.displayName = 'ModalDialogContext';
63
64 -function dialogReducer(state, action) {
64 +function dialogReducer(state: State, action: Action) {
65 switch (action.type) {
66 case 'HIDE':
67 return {
packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
+1 -1
@@ -28,7 +28,7 @@ import type {
28 ProfilingDataForRootFrontend,
29 } from 'react-devtools-shared/src/devtools/views/Profiler/types';
30
31 -const debug = (methodName, ...args) => {
31 +const debug = (methodName: string, ...args: Array<string>) => {
32 if (__DEBUG__) {
33 console.log(
34 `%cCommitTreeBuilder %c${methodName}`,
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js
+2 -1
@@ -7,6 +7,7 @@
7 * @flow
8 */
9
10 +import type {Stack} from '../../utils';
11 import type {SchedulingEvent} from 'react-devtools-timeline/src/types';
12
13 import * as React from 'react';
@@ -35,7 +36,7 @@ function SchedulingEventInfo({eventInfo}: SchedulingEventProps) {
36 const {componentName, timestamp} = eventInfo;
37 const componentStack = eventInfo.componentStack || null;
38
38 - const viewSource = source => {
39 + const viewSource = (source: ?Stack) => {
40 if (viewUrlSourceFunction != null && source != null) {
41 viewUrlSourceFunction(...source);
42 }
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js
+1
@@ -38,6 +38,7 @@ export default function SidebarSelectedFiberInfo(_: Props): React.Node {
38 rootID: ((rootID: any): number),
39 });
40
41 + // $FlowFixMe[missing-local-annot]
42 const handleKeyDown = event => {
43 switch (event.key) {
44 case 'ArrowUp':
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
+4
@@ -86,6 +86,7 @@ export default function SnapshotSelector(_: Props): React.Node {
86
87 let label = null;
88 if (numFilteredCommits > 0) {
89 + // $FlowFixMe[missing-local-annot]
90 const handleCommitInputChange = event => {
91 const value = parseInt(event.currentTarget.value, 10);
92 if (!isNaN(value)) {
@@ -100,10 +101,12 @@ export default function SnapshotSelector(_: Props): React.Node {
101 }
102 };
103
104 + // $FlowFixMe[missing-local-annot]
105 const handleClick = event => {
106 event.currentTarget.select();
107 };
108
109 + // $FlowFixMe[missing-local-annot]
110 const handleKeyDown = event => {
111 switch (event.key) {
112 case 'ArrowDown':
@@ -159,6 +162,7 @@ export default function SnapshotSelector(_: Props): React.Node {
162 selectCommitIndex(filteredCommitIndices[nextCommitIndex]);
163 };
164
165 + // $FlowFixMe[missing-local-annot]
166 const handleKeyDown = event => {
167 switch (event.key) {
168 case 'ArrowLeft':
packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js
+10 -2
@@ -55,7 +55,15 @@ export default function Tooltip({
55 const TOOLTIP_OFFSET = 5;
56
57 // Method used to find the position of the tooltip based on current mouse position
58 -function getTooltipPosition(element, mousePosition) {
58 +function getTooltipPosition(
59 + element: empty,
60 + mousePosition: {
61 + height: number,
62 + mouseX: number,
63 + mouseY: number,
64 + width: number,
65 + },
66 +) {
67 const {height, mouseX, mouseY, width} = mousePosition;
68 let top: number | string = 0;
69 let left: number | string = 0;
@@ -85,7 +93,7 @@ function getTooltipPosition(element, mousePosition) {
93
94 // method used to find the current mouse position inside the container
95 function getMousePosition(
88 - relativeContainer,
96 + relativeContainer: null,
97 mouseEvent: SyntheticMouseEvent<EventTarget>,
98 ) {
99 if (relativeContainer !== null) {
packages/react-devtools-shared/src/devtools/views/SearchInput.js
+2
@@ -40,9 +40,11 @@ export default function SearchInput({
40
41 const resetSearch = () => search('');
42
43 + // $FlowFixMe[missing-local-annot]
44 const handleChange = ({currentTarget}) => {
45 search(currentTarget.value);
46 };
47 + // $FlowFixMe[missing-local-annot]
48 const handleKeyPress = ({key, shiftKey}) => {
49 if (key === 'Enter') {
50 if (shiftKey) {
packages/react-devtools-shared/src/devtools/views/hooks.js
+5 -1
@@ -43,7 +43,10 @@ type UseEditableValueState = {
43 parsedValue: any,
44 };
45
46 -function useEditableValueReducer(state, action) {
46 +function useEditableValueReducer(
47 + state: UseEditableValueState,
48 + action: UseEditableValueAction,
49 +) {
50 switch (action.type) {
51 case 'RESET':
52 return {
@@ -188,6 +191,7 @@ export function useLocalStorage<T>(
191 // Listen for changes to this local storage value made from other windows.
192 // This enables the e.g. "⚛️ Elements" tab to update in response to changes from "⚛️ Settings".
193 useLayoutEffect(() => {
194 + // $FlowFixMe[missing-local-annot]
195 const onStorage = event => {
196 const newValue = getValueFromLocalStorage();
197 if (key === event.key && storedValue !== newValue) {
packages/react-devtools-shared/src/hook.js
+22 -13
@@ -9,7 +9,12 @@
9 */
10
11 import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools';
12 -import type {DevToolsHook} from 'react-devtools-shared/src/backend/types';
12 +import type {
13 + RendererID,
14 + ReactRenderer,
15 + Handler,
16 + DevToolsHook,
17 +} from 'react-devtools-shared/src/backend/types';
18
19 import {
20 patchConsoleUsingWindowValues,
@@ -40,7 +45,7 @@ export function installHook(target: any): DevToolsHook | null {
45 }
46 }
47
43 - function detectReactBuildType(renderer) {
48 + function detectReactBuildType(renderer: ReactRenderer) {
49 try {
50 if (typeof renderer.version === 'string') {
51 // React DOM Fiber (16+)
@@ -263,7 +268,7 @@ export function installHook(target: any): DevToolsHook | null {
268 ? targetConsole[method].__REACT_DEVTOOLS_STRICT_MODE_ORIGINAL_METHOD__
269 : targetConsole[method]);
270
266 - const overrideMethod = (...args) => {
271 + const overrideMethod = (...args: $ReadOnlyArray<any>) => {
272 if (!hideConsoleLogsInStrictMode) {
273 // Dim the text color of the double logs if we're not
274 // hiding them.
@@ -316,7 +321,7 @@ export function installHook(target: any): DevToolsHook | null {
321
322 let uidCounter = 0;
323
319 - function inject(renderer) {
324 + function inject(renderer: ReactRenderer) {
325 const id = ++uidCounter;
326 renderers.set(id, renderer);
327
@@ -374,19 +379,19 @@ export function installHook(target: any): DevToolsHook | null {
379
380 let hasDetectedBadDCE = false;
381
377 - function sub(event, fn) {
382 + function sub(event: string, fn: Handler) {
383 hook.on(event, fn);
384 return () => hook.off(event, fn);
385 }
386
382 - function on(event, fn) {
387 + function on(event: string, fn: Handler) {
388 if (!listeners[event]) {
389 listeners[event] = [];
390 }
391 listeners[event].push(fn);
392 }
393
389 - function off(event, fn) {
394 + function off(event: string, fn: Handler) {
395 if (!listeners[event]) {
396 return;
397 }
@@ -399,13 +404,13 @@ export function installHook(target: any): DevToolsHook | null {
404 }
405 }
406
402 - function emit(event, data) {
407 + function emit(event: string, data: any) {
408 if (listeners[event]) {
409 listeners[event].map(fn => fn(data));
410 }
411 }
412
408 - function getFiberRoots(rendererID) {
413 + function getFiberRoots(rendererID: RendererID) {
414 const roots = fiberRoots;
415 if (!roots[rendererID]) {
416 roots[rendererID] = new Set();
@@ -413,14 +418,18 @@ export function installHook(target: any): DevToolsHook | null {
418 return roots[rendererID];
419 }
420
416 - function onCommitFiberUnmount(rendererID, fiber) {
421 + function onCommitFiberUnmount(rendererID: RendererID, fiber: any) {
422 const rendererInterface = rendererInterfaces.get(rendererID);
423 if (rendererInterface != null) {
424 rendererInterface.handleCommitFiberUnmount(fiber);
425 }
426 }
427
423 - function onCommitFiberRoot(rendererID, root, priorityLevel) {
428 + function onCommitFiberRoot(
429 + rendererID: RendererID,
430 + root: any,
431 + priorityLevel: void | number,
432 + ) {
433 const mountedRoots = hook.getFiberRoots(rendererID);
434 const current = root.current;
435 const isKnownRoot = mountedRoots.has(root);
@@ -439,14 +448,14 @@ export function installHook(target: any): DevToolsHook | null {
448 }
449 }
450
442 - function onPostCommitFiberRoot(rendererID, root) {
451 + function onPostCommitFiberRoot(rendererID: RendererID, root: any) {
452 const rendererInterface = rendererInterfaces.get(rendererID);
453 if (rendererInterface != null) {
454 rendererInterface.handlePostCommitFiberRoot(root);
455 }
456 }
457
449 - function setStrictMode(rendererID, isStrictMode) {
458 + function setStrictMode(rendererID: RendererID, isStrictMode: any) {
459 const rendererInterface = rendererInterfaces.get(rendererID);
460 if (rendererInterface != null) {
461 if (isStrictMode) {
packages/react-devtools-shared/src/node_modules/react-window/src/createGridComponent.js
+15 -12
@@ -143,7 +143,13 @@ type ValidateProps = (props: Props<any>) => void;
143
144 const IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
145
146 -const defaultItemKey = ({ columnIndex, data, rowIndex }) =>
146 +const defaultItemKey = (
147 + {
148 + columnIndex,
149 + data,
150 + rowIndex
151 + }: { columnIndex: number, data: any, rowIndex: number },
152 +) =>
153 `${rowIndex}:${columnIndex}`;
154
155 // In DEV mode, this Set helps us only log a warning once per component instance.
@@ -197,7 +203,7 @@ export default function createGridComponent({
203 _resetIsScrollingTimeoutId: TimeoutID | null = null;
204 _outerRef: ?HTMLDivElement;
205
200 - static defaultProps = {
206 + static defaultProps: { direction: string, itemData: void, useIsScrolling: boolean } = {
207 direction: 'ltr',
208 itemData: undefined,
209 useIsScrolling: false,
@@ -393,7 +399,7 @@ export default function createGridComponent({
399 }
400 }
401
396 - render() {
402 + render(): any {
403 const {
404 children,
405 className,
@@ -486,7 +492,7 @@ export default function createGridComponent({
492 );
493 }
494
489 - _callOnItemsRendered: (
495 + _callOnItemsRendered: ((
496 overscanColumnStartIndex: number,
497 overscanColumnStopIndex: number,
498 overscanRowStartIndex: number,
@@ -495,8 +501,7 @@ export default function createGridComponent({
501 visibleColumnStopIndex: number,
502 visibleRowStartIndex: number,
503 visibleRowStopIndex: number
498 - ) => void;
499 - _callOnItemsRendered = memoizeOne(
504 + ) => void) = memoizeOne(
505 (
506 overscanColumnStartIndex: number,
507 overscanColumnStopIndex: number,
@@ -519,14 +524,13 @@ export default function createGridComponent({
524 })
525 );
526
522 - _callOnScroll: (
527 + _callOnScroll: ((
528 scrollLeft: number,
529 scrollTop: number,
530 horizontalScrollDirection: ScrollDirection,
531 verticalScrollDirection: ScrollDirection,
532 scrollUpdateWasRequested: boolean
528 - ) => void;
529 - _callOnScroll = memoizeOne(
533 + ) => void) = memoizeOne(
534 (
535 scrollLeft: number,
536 scrollTop: number,
@@ -595,7 +599,6 @@ export default function createGridComponent({
599 // So that pure component sCU will prevent re-renders.
600 // We maintain this cache, and pass a style prop rather than index,
601 // So that List can clear cached styles and force item re-render if necessary.
598 - _getItemStyle: (rowIndex: number, columnIndex: number) => Object;
602 _getItemStyle = (rowIndex: number, columnIndex: number): Object => {
603 const { columnWidth, direction, rowHeight } = this.props;
604
@@ -628,8 +631,8 @@ export default function createGridComponent({
631 return style;
632 };
633
631 - _getItemStyleCache: (_: any, __: any, ___: any) => ItemStyleCache;
632 - _getItemStyleCache = memoizeOne((_: any, __: any, ___: any) => ({}));
634 + _getItemStyleCache: ((_: any, __: any, ___: any) => ItemStyleCache) =
635 + memoizeOne((_: any, __: any, ___: any) => ({}));
636
637 _getHorizontalRangeToRender(): [number, number, number, number] {
638 const {
packages/react-devtools-shared/src/node_modules/react-window/src/createListComponent.js
+14 -11
@@ -162,7 +162,13 @@ export default function createListComponent({
162 _outerRef: ?HTMLDivElement;
163 _resetIsScrollingTimeoutId: TimeoutID | null = null;
164
165 - static defaultProps = {
165 + static defaultProps: {
166 + direction: string,
167 + itemData: void,
168 + layout: string,
169 + overscanCount: number,
170 + useIsScrolling: boolean,
171 + } = {
172 direction: 'ltr',
173 itemData: undefined,
174 layout: 'vertical',
@@ -288,7 +294,7 @@ export default function createListComponent({
294 }
295 }
296
291 - render() {
297 + render(): any {
298 const {
299 children,
300 className,
@@ -370,13 +376,12 @@ export default function createListComponent({
376 );
377 }
378
373 - _callOnItemsRendered: (
379 + _callOnItemsRendered: ((
380 overscanStartIndex: number,
381 overscanStopIndex: number,
382 visibleStartIndex: number,
383 visibleStopIndex: number
378 - ) => void;
379 - _callOnItemsRendered = memoizeOne(
384 + ) => void) = memoizeOne(
385 (
386 overscanStartIndex: number,
387 overscanStopIndex: number,
@@ -391,12 +396,11 @@ export default function createListComponent({
396 })
397 );
398
394 - _callOnScroll: (
399 + _callOnScroll: ((
400 scrollDirection: ScrollDirection,
401 scrollOffset: number,
402 scrollUpdateWasRequested: boolean
398 - ) => void;
399 - _callOnScroll = memoizeOne(
403 + ) => void) = memoizeOne(
404 (
405 scrollDirection: ScrollDirection,
406 scrollOffset: number,
@@ -446,7 +450,6 @@ export default function createListComponent({
450 // So that pure component sCU will prevent re-renders.
451 // We maintain this cache, and pass a style prop rather than index,
452 // So that List can clear cached styles and force item re-render if necessary.
449 - _getItemStyle: (index: number) => Object;
453 _getItemStyle = (index: number): Object => {
454 const { direction, itemSize, layout } = this.props;
455
@@ -480,8 +483,8 @@ export default function createListComponent({
483 return style;
484 };
485
483 - _getItemStyleCache: (_: any, __: any, ___: any) => ItemStyleCache;
484 - _getItemStyleCache = memoizeOne((_: any, __: any, ___: any) => ({}));
486 + _getItemStyleCache: ((_: any, __: any, ___: any) => ItemStyleCache) =
487 + memoizeOne((_: any, __: any, ___: any) => ({}));
488
489 _getRangeToRender(): [number, number, number, number] {
490 const { itemCount, overscanCount } = this.props;
packages/react-devtools-shared/src/node_modules/react-window/src/shouldComponentUpdate.js
+2 -1
@@ -7,8 +7,9 @@ import shallowDiffers from './shallowDiffers';
7 // It knows to compare individual style props and ignore the wrapper object.
8 // See https://reactjs.org/docs/react-component.html#shouldcomponentupdate
9 export default function shouldComponentUpdate(
10 + this: interface { props: any, state: any },
11 nextProps: Object,
11 - nextState: Object
12 + nextState: Object,
13 ): boolean {
14 return (
15 !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState)
packages/react-devtools-shared/src/registerDevToolsEventLogger.js
+1 -1
@@ -56,7 +56,7 @@ export function registerDevToolsEventLogger(
56 }
57 }
58
59 - function handleLoggingIFrameLoaded(iframe) {
59 + function handleLoggingIFrameLoaded(iframe: HTMLIFrameElement) {
60 if (loggingIFrame != null) {
61 return;
62 }
packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js
+3 -3
@@ -10,19 +10,19 @@
10 import * as React from 'react';
11 import {Fragment} from 'react';
12
13 -function wrapWithHoc(Component, index) {
13 +function wrapWithHoc(Component: () => any, index: number) {
14 function HOC() {
15 return <Component />;
16 }
17
18 - const displayName = Component.displayName || Component.name;
18 + const displayName = (Component: any).displayName || Component.name;
19
20 // $FlowFixMe[incompatible-type] found when upgrading Flow
21 HOC.displayName = `withHoc${index}(${displayName})`;
22 return HOC;
23 }
24
25 -function wrapWithNested(Component, times) {
25 +function wrapWithNested(Component: () => any, times: number) {
26 for (let i = 0; i < times; i++) {
27 Component = wrapWithHoc(Component, i);
28 }
packages/react-devtools-shell/src/app/EditableProps/index.js
+8 -5
@@ -7,6 +7,7 @@
7 * @flow
8 */
9
10 +import type {ReactContext} from 'shared/ReactTypes';
11 import * as React from 'react';
12 import {
13 createContext,
@@ -23,7 +24,8 @@ import {
24
25 const initialData = {foo: 'FOO', bar: 'BAR'};
26
26 -function reducer(state, action) {
27 +// $FlowFixMe[missing-local-annot]
28 +function reducer(state, action: {type: string}) {
29 switch (action.type) {
30 case 'swap':
31 return {foo: state.bar, bar: state.foo};
@@ -72,19 +74,20 @@ type Props = {name: string, toggle: boolean};
74 type State = {cities: Array<string>, state: string};
75
76 class StatefulClass extends Component<Props, State> {
75 - static contextType = BoolContext;
77 + static contextType: ReactContext<boolean> = BoolContext;
78
79 state: State = {
80 cities: ['San Francisco', 'San Jose'],
81 state: 'California',
82 };
83
82 - handleChange = ({target}) =>
84 + // $FlowFixMe[missing-local-annot]
85 + handleChange = ({target}): any =>
86 this.setState({
87 state: target.value,
88 });
89
87 - render() {
90 + render(): any {
91 return (
92 <ul>
93 <li>Name: {this.props.name}</li>
@@ -141,7 +144,7 @@ export default function EditableProps(): React.Node {
144 }
145
146 // Below copied from https://usehooks.com/
144 -function useDebounce(value, delay) {
147 +function useDebounce(value: number, delay: number) {
148 // State and setters for debounced value
149 const [debouncedValue, setDebouncedValue] = useState(value);
150
packages/react-devtools-shell/src/app/ElementTypes/index.js
+1 -1
@@ -25,7 +25,7 @@ const Context = createContext('abc');
25 Context.displayName = 'ExampleContext';
26
27 class ClassComponent extends Component<any> {
28 - render() {
28 + render(): null {
29 return null;
30 }
31 }
packages/react-devtools-shell/src/app/ErrorBoundaries/index.js
+4 -3
@@ -11,13 +11,13 @@ import * as React from 'react';
11 import {Fragment} from 'react';
12
13 class ErrorBoundary extends React.Component {
14 - state = {hasError: false};
14 + state: {hasError: boolean} = {hasError: false};
15
16 - static getDerivedStateFromError(error) {
16 + static getDerivedStateFromError(error: any): {hasError: boolean} {
17 return {hasError: true};
18 }
19
20 - render() {
20 + render(): any {
21 const {hasError} = this.state;
22 if (hasError) {
23 return (
@@ -49,6 +49,7 @@ class ErrorBoundary extends React.Component {
49 }
50 }
51
52 +// $FlowFixMe[missing-local-annot]
53 function Component({label}) {
54 return <div>{label}</div>;
55 }
packages/react-devtools-shell/src/app/Iframe/index.js
+1
@@ -19,6 +19,7 @@ export default function Iframe(): React.Node {
19
20 const iframeStyle = {border: '2px solid #eee', height: 80};
21
22 +// $FlowFixMe[missing-local-annot]
23 function Frame(props) {
24 const [element, setElement] = React.useState(null);
25
packages/react-devtools-shell/src/app/InlineWarnings/index.js
+19
@@ -3,11 +3,13 @@
3 import * as React from 'react';
4 import {Fragment, useEffect, useRef, useState} from 'react';
5
6 +// $FlowFixMe[missing-local-annot]
7 function WarnDuringRender({children = null}) {
8 console.warn('This warning fires during every render');
9 return children;
10 }
11
12 +// $FlowFixMe[missing-local-annot]
13 function WarnOnMount({children = null}) {
14 useEffect(() => {
15 console.warn('This warning fires on initial mount only');
@@ -15,6 +17,7 @@ function WarnOnMount({children = null}) {
17 return children;
18 }
19
20 +// $FlowFixMe[missing-local-annot]
21 function WarnOnUpdate({children = null}) {
22 const didMountRef = useRef(false);
23 useEffect(() => {
@@ -27,6 +30,7 @@ function WarnOnUpdate({children = null}) {
30 return children;
31 }
32
33 +// $FlowFixMe[missing-local-annot]
34 function WarnOnUnmount({children = null}) {
35 useEffect(() => {
36 return () => {
@@ -36,11 +40,13 @@ function WarnOnUnmount({children = null}) {
40 return children;
41 }
42
43 +// $FlowFixMe[missing-local-annot]
44 function ErrorDuringRender({children = null}) {
45 console.error('This error fires during every render');
46 return children;
47 }
48
49 +// $FlowFixMe[missing-local-annot]
50 function ErrorOnMount({children = null}) {
51 useEffect(() => {
52 console.error('This error fires on initial mount only');
@@ -48,6 +54,7 @@ function ErrorOnMount({children = null}) {
54 return children;
55 }
56
57 +// $FlowFixMe[missing-local-annot]
58 function ErrorOnUpdate({children = null}) {
59 const didMountRef = useRef(false);
60 useEffect(() => {
@@ -60,6 +67,7 @@ function ErrorOnUpdate({children = null}) {
67 return children;
68 }
69
70 +// $FlowFixMe[missing-local-annot]
71 function ErrorOnUnmount({children = null}) {
72 useEffect(() => {
73 return () => {
@@ -69,12 +77,14 @@ function ErrorOnUnmount({children = null}) {
77 return children;
78 }
79
80 +// $FlowFixMe[missing-local-annot]
81 function ErrorAndWarningDuringRender({children = null}) {
82 console.warn('This warning fires during every render');
83 console.error('This error fires during every render');
84 return children;
85 }
86
87 +// $FlowFixMe[missing-local-annot]
88 function ErrorAndWarningOnMount({children = null}) {
89 useEffect(() => {
90 console.warn('This warning fires on initial mount only');
@@ -83,6 +93,7 @@ function ErrorAndWarningOnMount({children = null}) {
93 return children;
94 }
95
96 +// $FlowFixMe[missing-local-annot]
97 function ErrorAndWarningOnUpdate({children = null}) {
98 const didMountRef = useRef(false);
99 useEffect(() => {
@@ -96,6 +107,7 @@ function ErrorAndWarningOnUpdate({children = null}) {
107 return children;
108 }
109
110 +// $FlowFixMe[missing-local-annot]
111 function ErrorAndWarningOnUnmount({children = null}) {
112 useEffect(() => {
113 return () => {
@@ -106,6 +118,7 @@ function ErrorAndWarningOnUnmount({children = null}) {
118 return children;
119 }
120
121 +// $FlowFixMe[missing-local-annot]
122 function ReallyLongErrorMessageThatWillCauseTextToBeTruncated({
123 children = null,
124 }) {
@@ -115,20 +128,24 @@ function ReallyLongErrorMessageThatWillCauseTextToBeTruncated({
128 return children;
129 }
130
131 +// $FlowFixMe[missing-local-annot]
132 function ErrorWithMultipleArgs({children = null}) {
133 console.error('This error', 'passes console', 4, 'arguments');
134 return children;
135 }
136
137 +// $FlowFixMe[missing-local-annot]
138 function ErrorWithStringSubstitutions({children = null}) {
139 console.error('This error uses "%s" substitutions', 'string');
140 return children;
141 }
142
143 +// $FlowFixMe[missing-local-annot]
144 function ReactErrorOnHostComponent({children = null}) {
145 return <div data-camelCasedAttribute="should-lower-case">{children}</div>;
146 }
147
148 +// $FlowFixMe[missing-local-annot]
149 function DuplicateWarningsAndErrors({children = null}) {
150 console.warn('this warning is logged twice per render');
151 console.warn('this warning is logged twice per render');
@@ -137,6 +154,7 @@ function DuplicateWarningsAndErrors({children = null}) {
154 return <div data-camelCasedAttribute="should-lower-case">{children}</div>;
155 }
156
157 +// $FlowFixMe[missing-local-annot]
158 function MultipleWarningsAndErrors({children = null}) {
159 console.warn('this is the first warning logged');
160 console.warn('this is the second warning logged');
@@ -145,6 +163,7 @@ function MultipleWarningsAndErrors({children = null}) {
163 return <div data-camelCasedAttribute="should-lower-case">{children}</div>;
164 }
165
166 +// $FlowFixMe[missing-local-annot]
167 function ComponentWithMissingKey({children}) {
168 return [<div />];
169 }
packages/react-devtools-shell/src/app/InspectableElements/Contexts.js
+51 -15
@@ -11,9 +11,11 @@ import * as React from 'react';
11 import {createContext, Component, useContext, useState} from 'react';
12 import PropTypes from 'prop-types';
13
14 +import type {ReactContext} from 'shared/ReactTypes';
15 +
16 function someNamedFunction() {}
17
16 -function formatContextForDisplay(name, value) {
18 +function formatContextForDisplay(name: string, value: any | string) {
19 return (
20 <li>
21 {name}: <pre>{JSON.stringify(value, null, 2)}</pre>
@@ -34,7 +36,17 @@ const contextData = {
36 };
37
38 class LegacyContextProvider extends Component<any> {
37 - static childContextTypes = {
39 + static childContextTypes: {
40 + array: any,
41 + bool: any,
42 + func: any,
43 + null: any,
44 + number: any,
45 + object: any,
46 + string: any,
47 + symbol: any,
48 + undefined: any,
49 + } = {
50 array: PropTypes.array,
51 bool: PropTypes.bool,
52 func: PropTypes.func,
@@ -46,17 +58,37 @@ class LegacyContextProvider extends Component<any> {
58 undefined: PropTypes.any,
59 };
60
49 - getChildContext() {
61 + getChildContext(): {
62 + array: Array<string>,
63 + bool: boolean,
64 + func: () => void,
65 + null: null,
66 + number: number,
67 + object: {outer: {inner: {...}}},
68 + string: string,
69 + symbol: symbol,
70 + undefined: void,
71 + } {
72 return contextData;
73 }
74
53 - render() {
75 + render(): any {
76 return this.props.children;
77 }
78 }
79
80 class LegacyContextConsumer extends Component<any> {
59 - static contextTypes = {
81 + static contextTypes: {
82 + array: any,
83 + bool: any,
84 + func: any,
85 + null: any,
86 + number: any,
87 + object: any,
88 + string: any,
89 + symbol: any,
90 + undefined: any,
91 + } = {
92 array: PropTypes.array,
93 bool: PropTypes.bool,
94 func: PropTypes.func,
@@ -68,26 +100,27 @@ class LegacyContextConsumer extends Component<any> {
100 undefined: PropTypes.any,
101 };
102
71 - render() {
103 + render(): any {
104 return formatContextForDisplay('LegacyContextConsumer', this.context);
105 }
106 }
107
108 class LegacyContextProviderWithUpdates extends Component<any> {
77 - constructor(props) {
109 + constructor(props: any) {
110 super(props);
111 this.state = {type: 'desktop'};
112 }
113
82 - getChildContext() {
114 + getChildContext(): {type: any} {
115 return {type: this.state.type};
116 }
117
118 + // $FlowFixMe[missing-local-annot]
119 handleChange = event => {
120 this.setState({type: event.target.value});
121 };
122
90 - render() {
123 + render(): any {
124 return (
125 <>
126 <LegacyFunctionalContextConsumer />
@@ -103,7 +136,8 @@ LegacyContextProviderWithUpdates.childContextTypes = {
136 type: PropTypes.string,
137 };
138
106 -function LegacyFunctionalContextConsumer(props, context) {
139 +// $FlowFixMe[missing-local-annot]
140 +function LegacyFunctionalContextConsumer(props: any, context) {
141 return formatContextForDisplay('LegacyFunctionContextConsumer', context.type);
142 }
143 LegacyFunctionalContextConsumer.contextTypes = {
@@ -130,9 +164,9 @@ const UndefinedContext = createContext(undefined);
164 UndefinedContext.displayName = 'UndefinedContext';
165
166 class ModernContextType extends Component<any> {
133 - static contextType = ModernContext;
167 + static contextType: ReactContext<void> = ModernContext;
168
135 - render() {
169 + render(): any {
170 return formatContextForDisplay('ModernContextType', this.context);
171 }
172 }
@@ -171,7 +205,9 @@ function FunctionalContextConsumerWithContextUpdates() {
205 const {string2, setString2} = useContext(StringContextWithUpdates2);
206 const [state, setState] = useState('state');
207
208 + // $FlowFixMe[missing-local-annot]
209 const handleChange = e => setString(e.target.value);
210 + // $FlowFixMe[missing-local-annot]
211 const handleChange2 = e => setString2(e.target.value);
212
213 return (
@@ -198,7 +234,7 @@ function FunctionalContextConsumerWithContextUpdates() {
234 }
235
236 class ModernClassContextProviderWithUpdates extends Component<any> {
201 - constructor(props) {
237 + constructor(props: any) {
238 super(props);
239 this.setString = string => {
240 this.setState({string});
@@ -210,7 +246,7 @@ class ModernClassContextProviderWithUpdates extends Component<any> {
246 };
247 }
248
213 - render() {
249 + render(): any {
250 return (
251 <StringContextWithUpdates.Provider value={this.state}>
252 <ModernClassContextConsumerWithUpdates />
@@ -220,7 +256,7 @@ class ModernClassContextProviderWithUpdates extends Component<any> {
256 }
257
258 class ModernClassContextConsumerWithUpdates extends Component<any> {
223 - render() {
259 + render(): any {
260 return (
261 <StringContextWithUpdates.Consumer>
262 {({string, setString}) => (
packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js
+2 -2
@@ -103,7 +103,7 @@ function FunctionWithHooks(props: any, ref: React$Ref<any>) {
103 const MemoWithHooks = memo(FunctionWithHooks);
104 const ForwardRefWithHooks = forwardRef(FunctionWithHooks);
105
106 -function wrapWithHoc(Component) {
106 +function wrapWithHoc(Component: (props: any, ref: React$Ref<any>) => any) {
107 function Hoc() {
108 return <Component />;
109 }
@@ -127,7 +127,7 @@ export default function CustomHooks(): React.Node {
127 }
128
129 // Below copied from https://usehooks.com/
130 -function useDebounce(value, delay) {
130 +function useDebounce(value: number, delay: number) {
131 // State and setters for debounced value
132 const [debouncedValue, setDebouncedValue] = useState(value);
133
packages/react-devtools-shell/src/app/InspectableElements/CustomObject.js
+1 -1
@@ -11,7 +11,7 @@ import * as React from 'react';
11
12 class Custom {
13 _number = 42;
14 - get number() {
14 + get number(): number {
15 return this._number;
16 }
17 }
packages/react-devtools-shell/src/app/SuspenseTree/index.js
+2 -1
@@ -29,6 +29,7 @@ function EmptySuspense() {
29 return <Suspense />;
30 }
31
32 +// $FlowFixMe[missing-local-annot]
33 function PrimaryFallbackTest({initialSuspend}) {
34 const [suspend, setSuspend] = useState(initialSuspend);
35 const fallbackStep = useTestSequence('fallback', Fallback1, Fallback2);
@@ -51,7 +52,7 @@ function PrimaryFallbackTest({initialSuspend}) {
52 );
53 }
54
54 -function useTestSequence(label, T1, T2) {
55 +function useTestSequence(label: string, T1: any => any, T2: any => any) {
56 const [step, setStep] = useState(0);
57 const next = (
58 <button onClick={() => setStep(s => (s + 1) % allSteps.length)}>
packages/react-devtools-shell/src/app/devtools.js
+1 -1
@@ -81,7 +81,7 @@ inject('dist/app-index.js', () => {
81 });
82 });
83
84 -function inject(sourcePath, callback) {
84 +function inject(sourcePath: string, callback: () => void) {
85 const script = contentDocument.createElement('script');
86 script.onload = callback;
87 script.src = sourcePath;
packages/react-devtools-shell/src/app/index.js
+3 -2
@@ -43,7 +43,7 @@ function createContainer() {
43 return container;
44 }
45
46 -function mountApp(App) {
46 +function mountApp(App: () => React$Node) {
47 const container = createContainer();
48
49 const root = createRoot(container);
@@ -52,6 +52,7 @@ function mountApp(App) {
52 unmountFunctions.push(() => root.unmount());
53 }
54
55 +// $FlowFixMe[missing-local-annot]
56 function mountStrictApp(App) {
57 function StrictRoot() {
58 return createElement(App);
@@ -65,7 +66,7 @@ function mountStrictApp(App) {
66 unmountFunctions.push(() => root.unmount());
67 }
68
68 -function mountLegacyApp(App) {
69 +function mountLegacyApp(App: () => React$Node) {
70 function LegacyRender() {
71 return createElement(App);
72 }
packages/react-devtools-shell/src/e2e-apps/ListApp.js
+1
@@ -43,6 +43,7 @@ function List() {
43 );
44 }
45
46 +// $FlowFixMe[missing-local-annot]
47 function ListItem({label}) {
48 return <li data-testname="ListItem">{label}</li>;
49 }
packages/react-devtools-shell/src/e2e-apps/ListAppLegacy.js
+3 -2
@@ -14,7 +14,7 @@ export default function App(): React.Node {
14 }
15
16 class List extends React.Component {
17 - constructor(props) {
17 + constructor(props: any) {
18 super(props);
19 this.state = {
20 items: ['one', 'two', 'three'],
@@ -28,7 +28,7 @@ class List extends React.Component {
28 }
29 };
30
31 - render() {
31 + render(): any {
32 return (
33 <div>
34 <input
@@ -50,6 +50,7 @@ class List extends React.Component {
50 }
51 }
52
53 +// $FlowFixMe[missing-local-annot]
54 function ListItem({label}) {
55 return <li data-testname="ListItem">{label}</li>;
56 }
packages/react-devtools-shell/src/e2e-regression/app-legacy.js
+1 -1
@@ -9,7 +9,7 @@ import ListApp from '../e2e-apps/ListApp';
9 import ListAppLegacy from '../e2e-apps/ListAppLegacy';
10 const version = process.env.E2E_APP_REACT_VERSION;
11
12 -function mountApp(App) {
12 +function mountApp(App: () => React$Node) {
13 const container = document.createElement('div');
14
15 ((document.body: any): HTMLBodyElement).appendChild(container);
packages/react-devtools-shell/src/e2e-regression/app.js
+1 -1
@@ -7,7 +7,7 @@ import * as ReactDOM from 'react-dom';
7 import {createRoot} from 'react-dom/client';
8 import ListApp from '../e2e-apps/ListApp';
9
10 -function mountApp(App) {
10 +function mountApp(App: () => React$Node) {
11 const container = document.createElement('div');
12
13 ((document.body: any): HTMLBodyElement).appendChild(container);
packages/react-devtools-shell/src/perf-regression/apps/LargeSubtree.js
+1 -1
@@ -9,7 +9,7 @@
9
10 import * as React from 'react';
11
12 -function generateArray(size) {
12 +function generateArray(size: number) {
13 return Array.from({length: size}, () => Math.floor(Math.random() * size));
14 }
15
packages/react-devtools-timeline/src/EventTooltip.js
+3 -2
@@ -15,11 +15,12 @@ import type {
15 ReactComponentMeasure,
16 ReactEventInfo,
17 ReactMeasure,
18 - TimelineData,
18 + ReactMeasureType,
19 SchedulingEvent,
20 Snapshot,
21 SuspenseEvent,
22 ThrownError,
23 + TimelineData,
24 UserTimingMark,
25 } from './types';
26
@@ -45,7 +46,7 @@ type Props = {
46 width: number,
47 };
48
48 -function getReactMeasureLabel(type): string | null {
49 +function getReactMeasureLabel(type: ReactMeasureType): string | null {
50 switch (type) {
51 case 'commit':
52 return 'react commit';
packages/react-devtools-timeline/src/Timeline.js
+1
@@ -117,6 +117,7 @@ const ProcessingData = () => (
117 </div>
118 );
119
120 +// $FlowFixMe[missing-local-annot]
121 const CouldNotLoadProfile = ({error, onFileSelect}) => (
122 <div className={styles.EmptyStateContainer}>
123 <div className={styles.Header}>Could not load profile</div>
packages/react-devtools-timeline/src/TimelineSearchInput.js
+2 -1
@@ -26,7 +26,8 @@ export default function TimelineSearchInput(props: Props): React.Node {
26 return null;
27 }
28
29 - const search = text => dispatch({type: 'SET_SEARCH_TEXT', payload: text});
29 + const search = (text: string) =>
30 + dispatch({type: 'SET_SEARCH_TEXT', payload: text});
31 const goToNextResult = () => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'});
32 const goToPreviousResult = () =>
33 dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'});
packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js
+2 -2
@@ -95,7 +95,7 @@ export class ReactMeasuresView extends View {
95 scaleFactor: number,
96 showGroupHighlight: boolean,
97 showHoverHighlight: boolean,
98 - ) {
98 + ): void {
99 const {frame, visibleArea} = this;
100 const {timestamp, type, duration} = measure;
101
@@ -202,7 +202,7 @@ export class ReactMeasuresView extends View {
202 }
203 }
204
205 - draw(context: CanvasRenderingContext2D) {
205 + draw(context: CanvasRenderingContext2D): void {
206 const {
207 frame,
208 _hoveredMeasure,
packages/react-devtools-timeline/src/view-base/Surface.js
+5 -1
@@ -22,7 +22,11 @@ export type ViewRefs = {
22 };
23
24 // hidpi canvas: https://www.html5rocks.com/en/tutorials/canvas/hidpi/
25 -function configureRetinaCanvas(canvas, height, width) {
25 +function configureRetinaCanvas(
26 + canvas: HTMLCanvasElement,
27 + height: number,
28 + width: number,
29 +) {
30 canvas.width = width * DPR;
31 canvas.height = height * DPR;
32 canvas.style.width = `${width}px`;
packages/react-dom-bindings/src/client/ReactDOMComponent.js
+5 -2
@@ -115,7 +115,7 @@ if (__DEV__) {
115 webview: true,
116 };
117
118 - validatePropertiesInDevelopment = function(type, props) {
118 + validatePropertiesInDevelopment = function(type: string, props: any) {
119 validateARIAProperties(type, props);
120 validateInputProperties(type, props);
121 validateUnknownProperties(type, props, {
@@ -172,7 +172,10 @@ if (__DEV__) {
172 console.error('Extra attributes from the server: %s', names);
173 };
174
175 - warnForInvalidEventListener = function(registrationName, listener) {
175 + warnForInvalidEventListener = function(
176 + registrationName: string,
177 + listener: any,
178 + ) {
179 if (listener === false) {
180 console.error(
181 'Expected `%s` listener to be a function, instead got `false`.\n\n' +
packages/react-dom-bindings/src/client/ReactDOMHostConfig.js
+2 -2
@@ -445,7 +445,7 @@ export const scheduleMicrotask: any =
445 .catch(handleErrorInNextTick)
446 : scheduleTimeout; // TODO: Determine the best fallback here.
447
448 -function handleErrorInNextTick(error) {
448 +function handleErrorInNextTick(error: any) {
449 setTimeout(() => {
450 throw error;
451 });
@@ -913,7 +913,7 @@ export function registerSuspenseInstanceRetry(
913 instance._reactRetry = callback;
914 }
915
916 -function getNextHydratable(node) {
916 +function getNextHydratable(node: ?Node) {
917 // Skip non-hydratable nodes.
918 for (; node != null; node = ((node: any): Node).nextSibling) {
919 const nodeType = node.nodeType;
packages/react-dom-bindings/src/client/ReactDOMInput.js
+2 -2
@@ -37,7 +37,7 @@ let didWarnCheckedDefaultChecked = false;
37 let didWarnControlledToUncontrolled = false;
38 let didWarnUncontrolledToControlled = false;
39
40 -function isControlled(props) {
40 +function isControlled(props: any) {
41 const usesChecked = props.type === 'checkbox' || props.type === 'radio';
42 return usesChecked ? props.checked != null : props.value != null;
43 }
@@ -351,7 +351,7 @@ export function restoreControlledState(element: Element, props: Object) {
351 updateNamedCousins(node, props);
352 }
353
354 -function updateNamedCousins(rootNode, props) {
354 +function updateNamedCousins(rootNode: InputWithWrapperState, props: any) {
355 const name = props.name;
356 if (props.type === 'radio' && name != null) {
357 let queryRoot: Element = rootNode;
packages/react-dom-bindings/src/client/ReactDOMSelect.js
+1 -1
@@ -38,7 +38,7 @@ const valuePropNames = ['value', 'defaultValue'];
38 /**
39 * Validation function for `value` and `defaultValue`.
40 */
41 -function checkSelectPropTypes(props) {
41 +function checkSelectPropTypes(props: any) {
42 if (__DEV__) {
43 checkControlledValueProps('select', props);
44
packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js
+2 -2
@@ -15,7 +15,7 @@ import {TEXT_NODE} from '../shared/HTMLNodeType';
15 * @param {DOMElement|DOMTextNode} node
16 * @return {DOMElement|DOMTextNode}
17 */
18 -function getLeafNode(node) {
18 +function getLeafNode(node: ?(Node | Element)) {
19 while (node && node.firstChild) {
20 node = node.firstChild;
21 }
@@ -29,7 +29,7 @@ function getLeafNode(node) {
29 * @param {DOMElement|DOMTextNode} node
30 * @return {?DOMElement|DOMTextNode}
31 */
32 -function getSiblingNode(node) {
32 +function getSiblingNode(node: ?(Node | Element)) {
33 while (node) {
34 if (node.nextSibling) {
35 return node.nextSibling;
packages/react-dom-bindings/src/client/inputValueTracking.js
+4 -1
@@ -78,9 +78,12 @@ function trackValueOnNode(node: any): ?ValueTracker {
78 const {get, set} = descriptor;
79 Object.defineProperty(node, valueField, {
80 configurable: true,
81 + // $FlowFixMe[missing-this-annot]
82 get: function() {
83 return get.call(this);
84 },
85 + // $FlowFixMe[missing-local-annot]
86 + // $FlowFixMe[missing-this-annot]
87 set: function(value) {
88 if (__DEV__) {
89 checkFormFieldValueStringCoercion(value);
@@ -101,7 +104,7 @@ function trackValueOnNode(node: any): ?ValueTracker {
104 getValue() {
105 return currentValue;
106 },
104 - setValue(value) {
107 + setValue(value: string) {
108 if (__DEV__) {
109 checkFormFieldValueStringCoercion(value);
110 }
packages/react-dom-bindings/src/events/DOMEventProperties.js
+1 -1
@@ -111,7 +111,7 @@ if (enableCreateEventHandleAPI) {
111 topLevelEventsToReactNames.set('afterblur', null);
112 }
113
114 -function registerSimpleEvent(domEventName, reactName) {
114 +function registerSimpleEvent(domEventName: DOMEventName, reactName: string) {
115 topLevelEventsToReactNames.set(domEventName, reactName);
116 registerTwoPhaseEvent(reactName, [domEventName]);
117 }
packages/react-dom-bindings/src/events/DOMPluginEventSystem.js
+1
@@ -462,6 +462,7 @@ function addTrappedEventListener(
462 // need support for such browsers.
463 if (enableLegacyFBSupport && isDeferredListenerForLegacyFBSupport) {
464 const originalListener = listener;
465 + // $FlowFixMe[missing-this-annot]
466 listener = function(...p) {
467 removeEventListener(
468 targetContainer,
packages/react-dom-bindings/src/events/ReactDOMEventListener.js
+8 -8
@@ -112,10 +112,10 @@ export function createEventListenerWrapperWithPriority(
112 }
113
114 function dispatchDiscreteEvent(
115 - domEventName,
116 - eventSystemFlags,
117 - container,
118 - nativeEvent,
115 + domEventName: DOMEventName,
116 + eventSystemFlags: EventSystemFlags,
117 + container: EventTarget,
118 + nativeEvent: AnyNativeEvent,
119 ) {
120 const previousPriority = getCurrentUpdatePriority();
121 const prevTransition = ReactCurrentBatchConfig.transition;
@@ -130,10 +130,10 @@ function dispatchDiscreteEvent(
130 }
131
132 function dispatchContinuousEvent(
133 - domEventName,
134 - eventSystemFlags,
135 - container,
136 - nativeEvent,
133 + domEventName: DOMEventName,
134 + eventSystemFlags: EventSystemFlags,
135 + container: EventTarget,
136 + nativeEvent: AnyNativeEvent,
137 ) {
138 const previousPriority = getCurrentUpdatePriority();
139 const prevTransition = ReactCurrentBatchConfig.transition;
packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js
+1 -1
@@ -619,7 +619,7 @@ export function retryIfBlockedOn(
619 if (queuedMouse !== null) {
620 scheduleCallbackIfUnblocked(queuedMouse, unblocked);
621 }
622 - const unblock = queuedEvent =>
622 + const unblock = (queuedEvent: QueuedReplayableEvent) =>
623 scheduleCallbackIfUnblocked(queuedEvent, unblocked);
624 queuedPointers.forEach(unblock);
625 queuedPointerCaptures.forEach(unblock);
packages/react-dom-bindings/src/events/SyntheticEvent.js
+14 -9
@@ -42,6 +42,7 @@ function createSyntheticEvent(Interface: EventInterfaceType) {
42 * normalizing browser quirks. Subclasses do not necessarily have to implement a
43 * DOM interface; custom application-specific events can also subclass this.
44 */
45 + // $FlowFixMe[missing-this-annot]
46 function SyntheticBaseEvent(
47 reactName: string | null,
48 reactEventType: string,
@@ -83,6 +84,7 @@ function createSyntheticEvent(Interface: EventInterfaceType) {
84
85 // $FlowFixMe[prop-missing] found when upgrading Flow
86 assign(SyntheticBaseEvent.prototype, {
87 + // $FlowFixMe[missing-this-annot]
88 preventDefault: function() {
89 this.defaultPrevented = true;
90 const event = this.nativeEvent;
@@ -99,6 +101,7 @@ function createSyntheticEvent(Interface: EventInterfaceType) {
101 this.isDefaultPrevented = functionThatReturnsTrue;
102 },
103
104 + // $FlowFixMe[missing-this-annot]
105 stopPropagation: function() {
106 const event = this.nativeEvent;
107 if (!event) {
@@ -147,7 +150,7 @@ const EventInterface = {
150 eventPhase: 0,
151 bubbles: 0,
152 cancelable: 0,
150 - timeStamp: function(event) {
153 + timeStamp: function(event: {[propName: string]: mixed}) {
154 return event.timeStamp || Date.now();
155 },
156 defaultPrevented: 0,
@@ -168,7 +171,7 @@ let lastMovementX;
171 let lastMovementY;
172 let lastMouseEvent;
173
171 -function updateMouseMovementPolyfillState(event) {
174 +function updateMouseMovementPolyfillState(event: {[propName: string]: mixed}) {
175 if (event !== lastMouseEvent) {
176 if (lastMouseEvent && event.type === 'mousemove') {
177 // $FlowFixMe assuming this is a number
@@ -373,7 +376,7 @@ const translateToKey = {
376 * @param {object} nativeEvent Native browser event.
377 * @return {string} Normalized `key` property.
378 */
376 -function getEventKey(nativeEvent) {
379 +function getEventKey(nativeEvent: {[propName: string]: mixed}) {
380 if (nativeEvent.key) {
381 // Normalize inconsistent values reported by browsers due to
382 // implementations of a working draft specification.
@@ -422,6 +425,8 @@ const modifierKeyToProp = {
425 // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
426 // getModifierState. If getModifierState is not supported, we map it to a set of
427 // modifier keys exposed by the event. In this case, Lock-keys are not supported.
428 +// $FlowFixMe[missing-local-annot]
429 +// $FlowFixMe[missing-this-annot]
430 function modifierStateGetter(keyArg) {
431 const syntheticEvent = this;
432 const nativeEvent = syntheticEvent.nativeEvent;
@@ -432,7 +437,7 @@ function modifierStateGetter(keyArg) {
437 return keyProp ? !!nativeEvent[keyProp] : false;
438 }
439
435 -function getEventModifierState(nativeEvent) {
440 +function getEventModifierState(nativeEvent: {[propName: string]: mixed}) {
441 return modifierStateGetter;
442 }
443
@@ -453,7 +458,7 @@ const KeyboardEventInterface = {
458 locale: 0,
459 getModifierState: getEventModifierState,
460 // Legacy Interface
456 - charCode: function(event) {
461 + charCode: function(event: {[propName: string]: mixed}) {
462 // `charCode` is the result of a KeyPress event and represents the value of
463 // the actual printable character.
464
@@ -467,7 +472,7 @@ const KeyboardEventInterface = {
472 }
473 return 0;
474 },
470 - keyCode: function(event) {
475 + keyCode: function(event: {[propName: string]: mixed}) {
476 // `keyCode` is the result of a KeyDown/Up event and represents the value of
477 // physical keyboard key.
478
@@ -480,7 +485,7 @@ const KeyboardEventInterface = {
485 }
486 return 0;
487 },
483 - which: function(event) {
488 + which: function(event: {[propName: string]: mixed}) {
489 // `which` is an alias for either `keyCode` or `charCode` depending on the
490 // type of the event.
491 if (event.type === 'keypress') {
@@ -560,7 +565,7 @@ export const SyntheticTransitionEvent: $FlowFixMe = createSyntheticEvent(
565 */
566 const WheelEventInterface = {
567 ...MouseEventInterface,
563 - deltaX(event) {
568 + deltaX(event: {[propName: string]: mixed}) {
569 return 'deltaX' in event
570 ? event.deltaX
571 : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
@@ -569,7 +574,7 @@ const WheelEventInterface = {
574 -event.wheelDeltaX
575 : 0;
576 },
572 - deltaY(event) {
577 + deltaY(event: {[propName: string]: mixed}) {
578 return 'deltaY' in event
579 ? event.deltaY
580 : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
+10 -10
@@ -192,11 +192,11 @@ let isComposing = false;
192 * @return {?object} A SyntheticCompositionEvent.
193 */
194 function extractCompositionEvent(
195 - dispatchQueue,
196 - domEventName,
197 - targetInst,
198 - nativeEvent,
199 - nativeEventTarget,
195 + dispatchQueue: DispatchQueue,
196 + domEventName: DOMEventName,
197 + targetInst: null | Fiber,
198 + nativeEvent: AnyNativeEvent,
199 + nativeEventTarget: null | EventTarget,
200 ) {
201 let eventType;
202 let fallbackData;
@@ -379,11 +379,11 @@ function getFallbackBeforeInputChars(
379 * @return {?object} A SyntheticInputEvent.
380 */
381 function extractBeforeInputEvent(
382 - dispatchQueue,
383 - domEventName,
384 - targetInst,
385 - nativeEvent,
386 - nativeEventTarget,
382 + dispatchQueue: DispatchQueue,
383 + domEventName: DOMEventName,
384 + targetInst: null | Fiber,
385 + nativeEvent: AnyNativeEvent,
386 + nativeEventTarget: null | EventTarget,
387 ) {
388 let chars;
389
packages/react-dom-bindings/src/events/plugins/ChangeEventPlugin.js
+26 -14
@@ -6,6 +6,7 @@
6 *
7 * @flow
8 */
9 +import type {TextInstance, Instance} from '../../client/ReactDOMHostConfig';
10 import type {AnyNativeEvent} from '../PluginModuleType';
11 import type {DOMEventName} from '../DOMEventNames';
12 import type {DispatchQueue} from '../DOMPluginEventSystem';
@@ -50,10 +51,11 @@ function registerEvents() {
51 }
52
53 function createAndAccumulateChangeEvent(
54 + // $FlowFixMe[missing-local-annot]
55 dispatchQueue,
54 - inst,
55 - nativeEvent,
56 - target,
56 + inst: null | Fiber,
57 + nativeEvent: AnyNativeEvent,
58 + target: null | EventTarget,
59 ) {
60 // Flag this event loop as needing state restore.
61 enqueueStateRestore(((target: any): Node));
@@ -78,7 +80,7 @@ let activeElementInst = null;
80 /**
81 * SECTION: handle `change` event
82 */
81 -function shouldUseChangeEvent(elem) {
83 +function shouldUseChangeEvent(elem: Instance | TextInstance) {
84 const nodeName = elem.nodeName && elem.nodeName.toLowerCase();
85 return (
86 nodeName === 'select' ||
@@ -86,7 +88,7 @@ function shouldUseChangeEvent(elem) {
88 );
89 }
90
89 -function manualDispatchChangeEvent(nativeEvent) {
91 +function manualDispatchChangeEvent(nativeEvent: AnyNativeEvent) {
92 const dispatchQueue = [];
93 createAndAccumulateChangeEvent(
94 dispatchQueue,
@@ -109,7 +111,7 @@ function manualDispatchChangeEvent(nativeEvent) {
111 batchedUpdates(runEventInBatch, dispatchQueue);
112 }
113
112 -function runEventInBatch(dispatchQueue) {
114 +function runEventInBatch(dispatchQueue: DispatchQueue) {
115 processDispatchQueue(dispatchQueue, 0);
116 }
117
@@ -120,7 +122,10 @@ function getInstIfValueChanged(targetInst: Object) {
122 }
123 }
124
123 -function getTargetInstForChangeEvent(domEventName: DOMEventName, targetInst) {
125 +function getTargetInstForChangeEvent(
126 + domEventName: DOMEventName,
127 + targetInst: null | Fiber,
128 +) {
129 if (domEventName === 'change') {
130 return targetInst;
131 }
@@ -143,7 +148,10 @@ if (canUseDOM) {
148 * and override the value property so that we can distinguish user events from
149 * value changes in JS.
150 */
146 -function startWatchingForValueChange(target, targetInst) {
151 +function startWatchingForValueChange(
152 + target: Instance | TextInstance,
153 + targetInst: null | Fiber,
154 +) {
155 activeElement = target;
156 activeElementInst = targetInst;
157 (activeElement: any).attachEvent('onpropertychange', handlePropertyChange);
@@ -166,6 +174,7 @@ function stopWatchingForValueChange() {
174 * (For IE <=9) Handles a propertychange event, sending a `change` event if
175 * the value of the active element has changed.
176 */
177 +// $FlowFixMe[missing-local-annot]
178 function handlePropertyChange(nativeEvent) {
179 if (nativeEvent.propertyName !== 'value') {
180 return;
@@ -177,8 +186,8 @@ function handlePropertyChange(nativeEvent) {
186
187 function handleEventsForInputEventPolyfill(
188 domEventName: DOMEventName,
180 - target,
181 - targetInst,
189 + target: Instance | TextInstance,
190 + targetInst: null | Fiber,
191 ) {
192 if (domEventName === 'focusin') {
193 // In IE9, propertychange fires for most input events but is buggy and
@@ -201,7 +210,7 @@ function handleEventsForInputEventPolyfill(
210 // For IE8 and IE9.
211 function getTargetInstForInputEventPolyfill(
212 domEventName: DOMEventName,
204 - targetInst,
213 + targetInst: null | Fiber,
214 ) {
215 if (
216 domEventName === 'selectionchange' ||
@@ -225,7 +234,7 @@ function getTargetInstForInputEventPolyfill(
234 /**
235 * SECTION: handle `click` event
236 */
228 -function shouldUseClickEvent(elem) {
237 +function shouldUseClickEvent(elem: any) {
238 // Use the `click` event to detect changes to checkbox and radio inputs.
239 // This approach works across all browsers, whereas `change` does not fire
240 // until `blur` in IE8.
@@ -237,7 +246,10 @@ function shouldUseClickEvent(elem) {
246 );
247 }
248
240 -function getTargetInstForClickEvent(domEventName: DOMEventName, targetInst) {
249 +function getTargetInstForClickEvent(
250 + domEventName: DOMEventName,
251 + targetInst: null | Fiber,
252 +) {
253 if (domEventName === 'click') {
254 return getInstIfValueChanged(targetInst);
255 }
@@ -245,7 +257,7 @@ function getTargetInstForClickEvent(domEventName: DOMEventName, targetInst) {
257
258 function getTargetInstForInputOrChangeEvent(
259 domEventName: DOMEventName,
248 - targetInst,
260 + targetInst: null | Fiber,
261 ) {
262 if (domEventName === 'input' || domEventName === 'change') {
263 return getInstIfValueChanged(targetInst);
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
+5 -1
@@ -91,7 +91,11 @@ function getEventTargetDocument(eventTarget: any) {
91 * @param {object} nativeEventTarget
92 * @return {?SyntheticEvent}
93 */
94 -function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) {
94 +function constructSelectEvent(
95 + dispatchQueue: DispatchQueue,
96 + nativeEvent: AnyNativeEvent,
97 + nativeEventTarget: null | EventTarget,
98 +) {
99 // Ensure we have the right element, and that the user is not dragging a
100 // selection (this matches native `select` event behavior). In HTML5, select
101 // fires only on input and textarea thus if there's no focused element we
packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js
+12 -6
@@ -155,15 +155,19 @@ const endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
155 * While untrusted script content should be made safe before using this api it will
156 * ensure that the script cannot be early terminated or never terminated state
157 */
158 -function escapeBootstrapScriptContent(scriptText) {
158 +function escapeBootstrapScriptContent(scriptText: string) {
159 if (__DEV__) {
160 checkHtmlStringCoercion(scriptText);
161 }
162 return ('' + scriptText).replace(scriptRegex, scriptReplacer);
163 }
164 const scriptRegex = /(<\/|<)(s)(cript)/gi;
165 -const scriptReplacer = (match, prefix, s, suffix) =>
166 - `${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;
165 +const scriptReplacer = (
166 + match: string,
167 + prefix: string,
168 + s: string,
169 + suffix: string,
170 +) => `${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;
171
172 export type BootstrapScriptDescriptor = {
173 src: string,
@@ -737,8 +741,8 @@ const endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
741
742 function pushInnerHTML(
743 target: Array<Chunk | PrecomputedChunk>,
740 - innerHTML,
741 - children,
744 + innerHTML: any,
745 + children: any,
746 ) {
747 if (innerHTML != null) {
748 if (children != null) {
@@ -775,7 +779,7 @@ let didWarnInvalidOptionChildren = false;
779 let didWarnInvalidOptionInnerHTML = false;
780 let didWarnSelectedSetOnOption = false;
781
778 -function checkSelectProp(props, propName) {
782 +function checkSelectProp(props: any, propName: string) {
783 if (__DEV__) {
784 const value = props[propName];
785 if (value != null) {
@@ -2765,6 +2769,7 @@ export function writeInitialResources(
2769 const {src, integrity} = responseState.externalRuntimeConfig;
2770 preinitImpl(resources, src, {as: 'script', integrity});
2771 }
2772 + // $FlowFixMe[missing-local-annot]
2773 function flushLinkResource(resource) {
2774 if (!resource.flushed) {
2775 pushLinkImpl(target, resource.props, responseState);
@@ -2889,6 +2894,7 @@ export function writeImmediateResources(
2894 resources: Resources,
2895 responseState: ResponseState,
2896 ): boolean {
2897 + // $FlowFixMe[missing-local-annot]
2898 function flushLinkResource(resource) {
2899 if (!resource.flushed) {
2900 pushLinkImpl(target, resource.props, responseState);
packages/react-dom-bindings/src/server/escapeTextForBrowser.js
+1 -1
@@ -50,7 +50,7 @@ const matchHtmlRegExp = /["'&<>]/;
50 * @public
51 */
52
53 -function escapeHtml(string) {
53 +function escapeHtml(string: string) {
54 if (__DEV__) {
55 checkHtmlStringCoercion(string);
56 }
packages/react-dom-bindings/src/shared/DOMProperty.js
+2 -1
@@ -213,6 +213,7 @@ export function getPropertyInfo(name: string): PropertyInfo | null {
213 return properties.hasOwnProperty(name) ? properties[name] : null;
214 }
215
216 +// $FlowFixMe[missing-this-annot]
217 function PropertyInfoRecord(
218 name: string,
219 type: PropertyType,
@@ -456,7 +457,7 @@ reservedProps.forEach(name => {
457 });
458
459 const CAMELIZE = /[\-\:]([a-z])/g;
459 -const capitalize = token => token[1].toUpperCase();
460 +const capitalize = (token: string) => token[1].toUpperCase();
461
462 // This is a list of all SVG attributes that need special casing, namespacing,
463 // or boolean value assignment. Regular attributes that just accept strings
packages/react-dom/src/client/ReactDOMRoot.js
+4
@@ -91,11 +91,13 @@ const defaultOnRecoverableError =
91 console['error'](error);
92 };
93
94 +// $FlowFixMe[missing-this-annot]
95 function ReactDOMRoot(internalRoot: FiberRoot) {
96 this._internalRoot = internalRoot;
97 }
98
99 // $FlowFixMe[prop-missing] found when upgrading Flow
100 +// $FlowFixMe[missing-this-annot]
101 ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render = function(
102 children: ReactNodeList,
103 ): void {
@@ -146,6 +148,7 @@ ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render = functio
148 };
149
150 // $FlowFixMe[prop-missing] found when upgrading Flow
151 +// $FlowFixMe[missing-this-annot]
152 ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount = function(): void {
153 if (__DEV__) {
154 if (typeof arguments[0] === 'function') {
@@ -259,6 +262,7 @@ export function createRoot(
262 return new ReactDOMRoot(root);
263 }
264
265 +// $FlowFixMe[missing-this-annot]
266 function ReactDOMHydrationRoot(internalRoot: FiberRoot) {
267 this._internalRoot = internalRoot;
268 }
packages/react-dom/src/server/ReactDOMFizzServerNode.js
+3 -2
@@ -7,6 +7,7 @@
7 * @flow
8 */
9
10 +import type {Request} from 'react-server/src/ReactFizzServer';
11 import type {ReactNodeList} from 'shared/ReactTypes';
12 import type {Writable} from 'stream';
13 import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
@@ -26,11 +27,11 @@ import {
27 createRootFormatContext,
28 } from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
29
29 -function createDrainHandler(destination: Destination, request) {
30 +function createDrainHandler(destination: Destination, request: Request) {
31 return () => startFlowing(request, destination);
32 }
33
33 -function createAbortHandler(request, reason) {
34 +function createAbortHandler(request: Request, reason: string) {
35 // eslint-disable-next-line react-internal/prod-error-codes
36 return () => abort(request, new Error(reason));
37 }
packages/react-dom/src/server/ReactDOMFizzStaticNode.js
+1 -1
@@ -42,7 +42,7 @@ type StaticResult = {
42 prelude: Readable,
43 };
44
45 -function createFakeWritable(readable): Writable {
45 +function createFakeWritable(readable: any): Writable {
46 // The current host config expects a Writable so we create
47 // a fake writable for now to push into the Readable.
48 return ({
packages/react-dom/src/server/ReactDOMLegacyServerImpl.js
+2
@@ -43,12 +43,14 @@ function renderToStringImpl(
43 let fatalError = null;
44 let result = '';
45 const destination = {
46 + // $FlowFixMe[missing-local-annot]
47 push(chunk) {
48 if (chunk !== null) {
49 result += chunk;
50 }
51 return true;
52 },
53 + // $FlowFixMe[missing-local-annot]
54 destroy(error) {
55 didFatal = true;
56 fatalError = error;
packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js
+2
@@ -40,12 +40,14 @@ class ReactMarkupReadableStream extends Readable {
40 this.startedFlowing = false;
41 }
42
43 + // $FlowFixMe[missing-local-annot]
44 _destroy(err, callback) {
45 abort(this.request);
46 // $FlowFixMe: The type definition for the callback should allow undefined and null.
47 callback(err);
48 }
49
50 + // $FlowFixMe[missing-local-annot]
51 _read(size) {
52 if (this.startedFlowing) {
53 startFlowing(this.request, this);
packages/react-interactions/events/src/dom/create-event-handle/Focus.js
+3 -2
@@ -97,7 +97,7 @@ function handleGlobalFocusVisibleEvent(
97
98 function handleFocusVisibleTargetEvents(
99 event: SyntheticEvent<EventTarget>,
100 - callback,
100 + callback: boolean => void,
101 ): void {
102 if (event.type === 'keydown') {
103 const {nativeEvent} = (event: any);
@@ -125,9 +125,10 @@ function isRelatedTargetWithin(
125 }
126
127 function setFocusVisibleListeners(
128 + // $FlowFixMe[missing-local-annot]
129 focusVisibleHandles,
130 focusTarget: EventTarget,
130 - callback,
131 + callback: boolean => void,
132 ) {
133 focusVisibleHandles.forEach(focusVisibleHandle => {
134 focusVisibleHandle.setListener(focusTarget, event =>
packages/react-native-renderer/src/ReactFabric.js
+2
@@ -201,6 +201,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
201 }
202 }
203
204 +// $FlowFixMe[missing-local-annot]
205 function onRecoverableError(error) {
206 // TODO: Expose onRecoverableError option to userspace
207 // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
@@ -236,6 +237,7 @@ function render(
237 return getPublicRootInstance(root);
238 }
239
240 +// $FlowFixMe[missing-this-annot]
241 function unmountComponentAtNode(containerTag: number) {
242 this.stopSurface(containerTag);
243 }
packages/react-native-renderer/src/ReactFabricHostConfig.js
+1
@@ -244,6 +244,7 @@ class ReactFabricHostComponent {
244 eventType: string,
245 listener: EventListener,
246 options: EventListenerOptions | boolean,
247 + // $FlowFixMe[missing-local-annot]
248 ) {
249 if (typeof eventType !== 'string') {
250 throw new Error('addEventListener_unstable eventType must be a string');
packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js
+7
@@ -31,12 +31,14 @@ const {
31 // Start of inline: the below functions were inlined from
32 // EventPropagator.js, as they deviated from ReactDOM's newer
33 // implementations.
34 +// $FlowFixMe[missing-local-annot]
35 function listenersAtPhase(inst, event, propagationPhase: PropagationPhases) {
36 const registrationName =
37 event.dispatchConfig.phasedRegistrationNames[propagationPhase];
38 return getListeners(inst, registrationName, propagationPhase, true);
39 }
40
41 +// $FlowFixMe[missing-local-annot]
42 function accumulateListenersAndInstances(inst, event, listeners) {
43 const listenersLength = listeners
44 ? isArray(listeners)
@@ -64,6 +66,7 @@ function accumulateListenersAndInstances(inst, event, listeners) {
66 }
67 }
68
69 +// $FlowFixMe[missing-local-annot]
70 function accumulateDirectionalDispatches(inst, phase, event) {
71 if (__DEV__) {
72 if (!inst) {
@@ -74,6 +77,7 @@ function accumulateDirectionalDispatches(inst, phase, event) {
77 accumulateListenersAndInstances(inst, event, listeners);
78 }
79
80 +// $FlowFixMe[missing-local-annot]
81 function getParent(inst) {
82 do {
83 inst = inst.return;
@@ -117,6 +121,7 @@ export function traverseTwoPhase(
121 }
122 }
123
124 +// $FlowFixMe[missing-local-annot]
125 function accumulateTwoPhaseDispatchesSingle(event) {
126 if (event && event.dispatchConfig.phasedRegistrationNames) {
127 traverseTwoPhase(
@@ -128,10 +133,12 @@ function accumulateTwoPhaseDispatchesSingle(event) {
133 }
134 }
135
136 +// $FlowFixMe[missing-local-annot]
137 function accumulateTwoPhaseDispatches(events) {
138 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
139 }
140
141 +// $FlowFixMe[missing-local-annot]
142 function accumulateCapturePhaseDispatches(event) {
143 if (event && event.dispatchConfig.phasedRegistrationNames) {
144 traverseTwoPhase(
packages/react-native-renderer/src/ReactNativeEventEmitter.js
+1
@@ -43,6 +43,7 @@ const EMPTY_NATIVE_EVENT = (({}: any): AnyNativeEvent);
43 * @param {Array<number>} indices Indices by which to pull subsequence.
44 * @return {Array<Touch>} Subsequence of touch objects.
45 */
46 +// $FlowFixMe[missing-local-annot]
47 const touchSubsequence = function(touches, indices) {
48 const ret = [];
49 for (let i = 0; i < indices.length; i++) {
packages/react-native-renderer/src/ReactNativeFiberInspector.js
+5
@@ -39,6 +39,7 @@ let getOwnerHierarchy;
39 let traverseOwnerTreeUp;
40
41 if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
42 + // $FlowFixMe[missing-local-annot]
43 createHierarchy = function(fiberHierarchy) {
44 return fiberHierarchy.map(fiber => ({
45 name: getComponentNameFromType(fiber.type),
@@ -68,6 +69,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
69 }));
70 };
71
72 + // $FlowFixMe[missing-local-annot]
73 getHostNode = function(fiber: Fiber | null, findNodeHandle) {
74 let hostNode;
75 // look for children first for the hostNode
@@ -84,6 +86,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
86 return null;
87 };
88
89 + // $FlowFixMe[missing-local-annot]
90 getHostProps = function(fiber) {
91 const host = findCurrentHostFiber(fiber);
92 if (host) {
@@ -128,6 +131,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
131 return hierarchy;
132 };
133
134 + // $FlowFixMe[missing-local-annot]
135 lastNonHostInstance = function(hierarchy) {
136 for (let i = hierarchy.length - 1; i > 1; i--) {
137 const instance = hierarchy[i];
@@ -139,6 +143,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
143 return hierarchy[0];
144 };
145
146 + // $FlowFixMe[missing-local-annot]
147 traverseOwnerTreeUp = function(hierarchy, instance: any) {
148 if (instance) {
149 hierarchy.unshift(instance);
packages/react-native-renderer/src/ReactNativeGetListeners.js
+1
@@ -117,6 +117,7 @@ export default function getListeners(
117 // all imperative event listeners in a function to unwrap the SyntheticEvent
118 // and pass them an Event.
119 // When this API is more stable and used more frequently, we can revisit.
120 + // $FlowFixMe[missing-local-annot]
121 const listenerFnWrapper = function(syntheticEvent, ...args) {
122 const eventInst = new CustomEvent(mangledImperativeRegistrationName, {
123 detail: syntheticEvent.nativeEvent,
packages/react-native-renderer/src/ReactNativeRenderer.js
+1
@@ -198,6 +198,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
198 }
199 }
200
201 +// $FlowFixMe[missing-local-annot]
202 function onRecoverableError(error) {
203 // TODO: Expose onRecoverableError option to userspace
204 // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
packages/react-native-renderer/src/legacy-events/EventBatching.js
+1
@@ -34,6 +34,7 @@ const executeDispatchesAndRelease = function(event: ReactSyntheticEvent) {
34 }
35 }
36 };
37 +// $FlowFixMe[missing-local-annot]
38 const executeDispatchesAndReleaseTopLevel = function(e) {
39 return executeDispatchesAndRelease(e);
40 };
packages/react-reconciler/src/DebugTracing.js
+2 -2
@@ -22,7 +22,7 @@ function formatLanes(laneOrLanes: Lane | Lanes): string {
22 return '0b' + (laneOrLanes: any).toString(2).padStart(31, '0');
23 }
24
25 -function group(...groupArgs): void {
25 +function group(...groupArgs: Array<string>): void {
26 pendingGroupArgs.push(groupArgs);
27
28 if (nativeConsoleLog === null) {
@@ -44,7 +44,7 @@ function groupEnd(): void {
44 }
45 }
46
47 -function log(...logArgs): void {
47 +function log(...logArgs: Array<mixed>): void {
48 if (printedGroupIndex < pendingGroupArgs.length - 1) {
49 for (let i = printedGroupIndex + 1; i < pendingGroupArgs.length; i++) {
50 const groupArgs = pendingGroupArgs[i];
packages/react-reconciler/src/ReactChildFiber.js
+6 -4
@@ -97,7 +97,7 @@ if (__DEV__) {
97 };
98 }
99
100 -function isReactClass(type) {
100 +function isReactClass(type: any) {
101 return type.prototype && type.prototype.isReactComponent;
102 }
103
@@ -203,7 +203,7 @@ function coerceRef(
203 ) {
204 return current.ref;
205 }
206 - const ref = function(value) {
206 + const ref = function(value: mixed) {
207 const refs = resolvedInst.refs;
208 if (value === null) {
209 delete refs[stringRef];
@@ -267,7 +267,7 @@ function warnOnFunctionType(returnFiber: Fiber) {
267 }
268 }
269
270 -function resolveLazy(lazyType) {
270 +function resolveLazy(lazyType: any) {
271 const payload = lazyType._payload;
272 const init = lazyType._init;
273 return init(payload);
@@ -284,7 +284,9 @@ type ChildReconciler = (
284 // to be able to optimize each path individually by branching early. This needs
285 // a compiler or we can do it manually. Helpers that don't need this branching
286 // live outside of this function.
287 -function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
287 +function createChildReconciler(
288 + shouldTrackSideEffects: boolean,
289 +): ChildReconciler {
290 function deleteChild(returnFiber: Fiber, childToDelete: Fiber): void {
291 if (!shouldTrackSideEffects) {
292 // Noop.
packages/react-reconciler/src/ReactFiber.js
+1
@@ -132,6 +132,7 @@ if (__DEV__) {
132 }
133
134 function FiberNode(
135 + this: $FlowFixMe,
136 tag: WorkTag,
137 pendingProps: mixed,
138 key: null | string,
packages/react-reconciler/src/ReactFiberBeginWork.js
+65 -46
@@ -1085,11 +1085,11 @@ function markRef(current: Fiber | null, workInProgress: Fiber) {
1085 }
1086
1087 function updateFunctionComponent(
1088 - current,
1089 - workInProgress,
1090 - Component,
1088 + current: null | Fiber,
1089 + workInProgress: Fiber,
1090 + Component: any,
1091 nextProps: any,
1092 - renderLanes,
1092 + renderLanes: Lanes,
1093 ) {
1094 if (__DEV__) {
1095 if (workInProgress.type !== workInProgress.elementType) {
@@ -1425,7 +1425,7 @@ function finishClassComponent(
1425 return workInProgress.child;
1426 }
1427
1428 -function pushHostRootContext(workInProgress) {
1428 +function pushHostRootContext(workInProgress: Fiber) {
1429 const root = (workInProgress.stateNode: FiberRoot);
1430 if (root.pendingContext) {
1431 pushTopLevelContextObject(
@@ -1440,7 +1440,11 @@ function pushHostRootContext(workInProgress) {
1440 pushHostContainer(workInProgress, root.containerInfo);
1441 }
1442
1443 -function updateHostRoot(current, workInProgress, renderLanes) {
1443 +function updateHostRoot(
1444 + current: null | Fiber,
1445 + workInProgress: Fiber,
1446 + renderLanes: Lanes,
1447 +) {
1448 pushHostRootContext(workInProgress);
1449
1450 if (current === null) {
@@ -1625,7 +1629,11 @@ function updateHostComponent(
1629 return workInProgress.child;
1630 }
1631
1628 -function updateHostResource(current, workInProgress, renderLanes) {
1632 +function updateHostResource(
1633 + current: null | Fiber,
1634 + workInProgress: Fiber,
1635 + renderLanes: Lanes,
1636 +) {
1637 pushHostContext(workInProgress);
1638 markRef(current, workInProgress);
1639 const currentProps = current === null ? null : current.memoizedProps;
@@ -1673,7 +1681,7 @@ function updateHostSingleton(
1681 return workInProgress.child;
1682 }
1683
1676 -function updateHostText(current, workInProgress) {
1684 +function updateHostText(current: null | Fiber, workInProgress: Fiber) {
1685 if (current === null) {
1686 tryToClaimNextHydratableInstance(workInProgress);
1687 }
@@ -1683,10 +1691,10 @@ function updateHostText(current, workInProgress) {
1691 }
1692
1693 function mountLazyComponent(
1686 - _current,
1687 - workInProgress,
1688 - elementType,
1689 - renderLanes,
1694 + _current: null | Fiber,
1695 + workInProgress: Fiber,
1696 + elementType: any,
1697 + renderLanes: Lanes,
1698 ) {
1699 resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress);
1700
@@ -1792,11 +1800,11 @@ function mountLazyComponent(
1800 }
1801
1802 function mountIncompleteClassComponent(
1795 - _current,
1796 - workInProgress,
1797 - Component,
1798 - nextProps,
1799 - renderLanes,
1803 + _current: null | Fiber,
1804 + workInProgress: Fiber,
1805 + Component: any,
1806 + nextProps: any,
1807 + renderLanes: Lanes,
1808 ) {
1809 resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress);
1810
@@ -1831,10 +1839,10 @@ function mountIncompleteClassComponent(
1839 }
1840
1841 function mountIndeterminateComponent(
1834 - _current,
1835 - workInProgress,
1836 - Component,
1837 - renderLanes,
1842 + _current: null | Fiber,
1843 + workInProgress: Fiber,
1844 + Component: $FlowFixMe,
1845 + renderLanes: Lanes,
1846 ) {
1847 resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress);
1848
@@ -2171,12 +2179,16 @@ function shouldRemainOnFallback(
2179 );
2180 }
2181
2174 -function getRemainingWorkInPrimaryTree(current: Fiber, renderLanes) {
2182 +function getRemainingWorkInPrimaryTree(current: Fiber, renderLanes: Lanes) {
2183 // TODO: Should not remove render lanes that were pinged during this render
2184 return removeLanes(current.childLanes, renderLanes);
2185 }
2186
2179 -function updateSuspenseComponent(current, workInProgress, renderLanes) {
2187 +function updateSuspenseComponent(
2188 + current: null | Fiber,
2189 + workInProgress: Fiber,
2190 + renderLanes: Lanes,
2191 +) {
2192 const nextProps = workInProgress.pendingProps;
2193
2194 // This is used by DevTools to force a boundary to suspend.
@@ -2423,9 +2435,9 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
2435 }
2436
2437 function mountSuspensePrimaryChildren(
2426 - workInProgress,
2427 - primaryChildren,
2428 - renderLanes,
2438 + workInProgress: Fiber,
2439 + primaryChildren: $FlowFixMe,
2440 + renderLanes: Lanes,
2441 ) {
2442 const mode = workInProgress.mode;
2443 const primaryChildProps: OffscreenProps = {
@@ -2443,10 +2455,10 @@ function mountSuspensePrimaryChildren(
2455 }
2456
2457 function mountSuspenseFallbackChildren(
2446 - workInProgress,
2447 - primaryChildren,
2448 - fallbackChildren,
2449 - renderLanes,
2458 + workInProgress: Fiber,
2459 + primaryChildren: $FlowFixMe,
2460 + fallbackChildren: $FlowFixMe,
2461 + renderLanes: Lanes,
2462 ) {
2463 const mode = workInProgress.mode;
2464 const progressedPrimaryFragment: Fiber | null = workInProgress.child;
@@ -2526,10 +2538,10 @@ function updateWorkInProgressOffscreenFiber(
2538 }
2539
2540 function updateSuspensePrimaryChildren(
2529 - current,
2530 - workInProgress,
2531 - primaryChildren,
2532 - renderLanes,
2541 + current: Fiber,
2542 + workInProgress: Fiber,
2543 + primaryChildren: $FlowFixMe,
2544 + renderLanes: Lanes,
2545 ) {
2546 const currentPrimaryChildFragment: Fiber = (current.child: any);
2547 const currentFallbackChildFragment: Fiber | null =
@@ -2563,11 +2575,11 @@ function updateSuspensePrimaryChildren(
2575 }
2576
2577 function updateSuspenseFallbackChildren(
2566 - current,
2567 - workInProgress,
2568 - primaryChildren,
2569 - fallbackChildren,
2570 - renderLanes,
2578 + current: Fiber,
2579 + workInProgress: Fiber,
2580 + primaryChildren: $FlowFixMe,
2581 + fallbackChildren: $FlowFixMe,
2582 + renderLanes: Lanes,
2583 ) {
2584 const mode = workInProgress.mode;
2585 const currentPrimaryChildFragment: Fiber = (current.child: any);
@@ -2688,11 +2700,11 @@ function retrySuspenseComponentWithoutHydrating(
2700 }
2701
2702 function mountSuspenseFallbackAfterRetryWithoutHydrating(
2691 - current,
2692 - workInProgress,
2693 - primaryChildren,
2694 - fallbackChildren,
2695 - renderLanes,
2703 + current: Fiber,
2704 + workInProgress: Fiber,
2705 + primaryChildren: $FlowFixMe,
2706 + fallbackChildren: $FlowFixMe,
2707 + renderLanes: Lanes,
2708 ) {
2709 const fiberMode = workInProgress.mode;
2710 const primaryChildProps: OffscreenProps = {
@@ -3550,7 +3562,11 @@ function updateContextConsumer(
3562 return workInProgress.child;
3563 }
3564
3553 -function updateScopeComponent(current, workInProgress, renderLanes) {
3565 +function updateScopeComponent(
3566 + current: null | Fiber,
3567 + workInProgress: Fiber,
3568 + renderLanes: Lanes,
3569 +) {
3570 const nextProps = workInProgress.pendingProps;
3571 const nextChildren = nextProps.children;
3572
@@ -3566,7 +3582,10 @@ export function checkIfWorkInProgressReceivedUpdate(): boolean {
3582 return didReceiveUpdate;
3583 }
3584
3569 -function resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress) {
3585 +function resetSuspendedCurrentOnMountInLegacyMode(
3586 + current: null | Fiber,
3587 + workInProgress: Fiber,
3588 +) {
3589 if ((workInProgress.mode & ConcurrentMode) === NoMode) {
3590 if (current !== null) {
3591 // A lazy component only mounts if it suspended inside a non-
packages/react-reconciler/src/ReactFiberCacheComponent.js
+2 -1
@@ -21,7 +21,8 @@ import * as Scheduler from 'scheduler';
21 const AbortControllerLocal: typeof AbortController = enableCache
22 ? typeof AbortController !== 'undefined'
23 ? AbortController
24 - : (function AbortControllerShim() {
24 + : // $FlowFixMe[missing-this-annot]
25 + (function AbortControllerShim() {
26 const listeners = [];
27 const signal = (this.signal = {
28 aborted: false,
packages/react-reconciler/src/ReactFiberClassComponent.js
+18 -16
@@ -118,7 +118,7 @@ if (__DEV__) {
118 }
119 };
120
121 - warnOnUndefinedDerivedState = function(type, partialState) {
121 + warnOnUndefinedDerivedState = function(type: any, partialState: any) {
122 if (partialState === undefined) {
123 const componentName = getComponentNameFromType(type) || 'Component';
124 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
@@ -194,7 +194,8 @@ function applyDerivedStateFromProps(
194
195 const classComponentUpdater = {
196 isMounted,
197 - enqueueSetState(inst, payload, callback) {
197 + // $FlowFixMe[missing-local-annot]
198 + enqueueSetState(inst: any, payload: any, callback) {
199 const fiber = getInstance(inst);
200 const eventTime = requestEventTime();
201 const lane = requestUpdateLane(fiber);
@@ -227,7 +228,7 @@ const classComponentUpdater = {
228 markStateUpdateScheduled(fiber, lane);
229 }
230 },
230 - enqueueReplaceState(inst, payload, callback) {
231 + enqueueReplaceState(inst: any, payload: any, callback: null) {
232 const fiber = getInstance(inst);
233 const eventTime = requestEventTime();
234 const lane = requestUpdateLane(fiber);
@@ -262,7 +263,8 @@ const classComponentUpdater = {
263 markStateUpdateScheduled(fiber, lane);
264 }
265 },
265 - enqueueForceUpdate(inst, callback) {
266 + // $FlowFixMe[missing-local-annot]
267 + enqueueForceUpdate(inst: any, callback) {
268 const fiber = getInstance(inst);
269 const eventTime = requestEventTime();
270 const lane = requestUpdateLane(fiber);
@@ -299,13 +301,13 @@ const classComponentUpdater = {
301 };
302
303 function checkShouldComponentUpdate(
302 - workInProgress,
303 - ctor,
304 - oldProps,
305 - newProps,
306 - oldState,
307 - newState,
308 - nextContext,
304 + workInProgress: Fiber,
305 + ctor: any,
306 + oldProps: any,
307 + newProps: any,
308 + oldState: any,
309 + newState: any,
310 + nextContext: any,
311 ) {
312 const instance = workInProgress.stateNode;
313 if (typeof instance.shouldComponentUpdate === 'function') {
@@ -760,7 +762,7 @@ function constructClassInstance(
762 return instance;
763 }
764
763 -function callComponentWillMount(workInProgress, instance) {
765 +function callComponentWillMount(workInProgress: Fiber, instance: any) {
766 const oldState = instance.state;
767
768 if (typeof instance.componentWillMount === 'function') {
@@ -784,10 +786,10 @@ function callComponentWillMount(workInProgress, instance) {
786 }
787
788 function callComponentWillReceiveProps(
787 - workInProgress,
788 - instance,
789 - newProps,
790 - nextContext,
789 + workInProgress: Fiber,
790 + instance: any,
791 + newProps: any,
792 + nextContext: any,
793 ) {
794 const oldState = instance.state;
795 if (typeof instance.componentWillReceiveProps === 'function') {
packages/react-reconciler/src/ReactFiberClassUpdateQueue.js
+1 -1
@@ -676,7 +676,7 @@ export function processUpdateQueue<State>(
676 }
677 }
678
679 -function callCallback(callback, context) {
679 +function callCallback(callback: () => mixed, context: any) {
680 if (typeof callback !== 'function') {
681 throw new Error(
682 'Invalid argument passed as callback. Expected a function. Instead ' +
packages/react-reconciler/src/ReactFiberCommitWork.js
+10 -7
@@ -248,7 +248,10 @@ export function reportUncaughtErrorInDEV(error: mixed) {
248 }
249 }
250
251 -const callComponentWillUnmountWithTimer = function(current, instance) {
251 +const callComponentWillUnmountWithTimer = function(
252 + current: Fiber,
253 + instance: any,
254 +) {
255 instance.props = current.memoizedProps;
256 instance.state = current.memoizedState;
257 if (shouldProfile(current)) {
@@ -1495,7 +1498,7 @@ function commitTransitionProgress(offscreenFiber: Fiber) {
1498 }
1499 }
1500
1498 -function hideOrUnhideAllChildren(finishedWork, isHidden) {
1501 +function hideOrUnhideAllChildren(finishedWork: Fiber, isHidden: boolean) {
1502 // Only hide or unhide the top-most host nodes.
1503 let hostSubtreeRoot = null;
1504
@@ -2018,9 +2021,9 @@ function commitDeletionEffects(
2021 }
2022
2023 function recursivelyTraverseDeletionEffects(
2021 - finishedRoot,
2022 - nearestMountedAncestor,
2023 - parent,
2024 + finishedRoot: FiberRoot,
2025 + nearestMountedAncestor: Fiber,
2026 + parent: Fiber,
2027 ) {
2028 // TODO: Use a static flag to skip trees that don't have unmount effects
2029 let child = parent.child;
@@ -2374,7 +2377,7 @@ function commitSuspenseHydrationCallbacks(
2377 }
2378 }
2379
2377 -function getRetryCache(finishedWork) {
2380 +function getRetryCache(finishedWork: Fiber) {
2381 // TODO: Unify the interface for the retry cache so we don't have to switch
2382 // on the tag like this.
2383 switch (finishedWork.tag) {
@@ -4017,7 +4020,7 @@ function detachAlternateSiblings(parentFiber: Fiber) {
4020
4021 function commitHookPassiveUnmountEffects(
4022 finishedWork: Fiber,
4020 - nearestMountedAncestor,
4023 + nearestMountedAncestor: null | Fiber,
4024 hookFlags: HookFlags,
4025 ) {
4026 if (shouldProfile(finishedWork)) {
packages/react-reconciler/src/ReactFiberHooks.js
+3 -3
@@ -1801,7 +1801,7 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
1801 }
1802 }
1803
1804 -function forceStoreRerender(fiber) {
1804 +function forceStoreRerender(fiber: Fiber) {
1805 const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
1806 if (root !== null) {
1807 scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
@@ -1934,7 +1934,7 @@ function mountRef<T>(initialValue: T): {current: T} {
1934 }
1935 return current;
1936 },
1937 - set current(value) {
1937 + set current(value: any) {
1938 if (currentlyRenderingFiber !== null && !didWarnAboutWrite) {
1939 if (hasBeenInitialized || !didCheckForLazyInit) {
1940 didWarnAboutWrite = true;
@@ -2736,7 +2736,7 @@ function entangleTransitionUpdate<S, A>(
2736 }
2737 }
2738
2739 -function markUpdateInDevTools<A>(fiber, lane, action: A): void {
2739 +function markUpdateInDevTools<A>(fiber: Fiber, lane: Lane, action: A): void {
2740 if (__DEV__) {
2741 if (enableDebugTracing) {
2742 if (fiber.mode & DebugTracingMode) {
packages/react-reconciler/src/ReactFiberHydrationContext.js
+1 -1
@@ -338,7 +338,7 @@ function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) {
338 warnNonhydratedInstance(returnFiber, fiber);
339 }
340
341 -function tryHydrate(fiber, nextInstance) {
341 +function tryHydrate(fiber: Fiber, nextInstance: any) {
342 switch (fiber.tag) {
343 // HostSingleton is intentionally omitted. the hydration pathway for singletons is non-fallible
344 // you can find it inlined in claimHydratableSingleton
packages/react-reconciler/src/ReactFiberReconciler.js
+1 -1
@@ -533,7 +533,7 @@ export function shouldError(fiber: Fiber): ?boolean {
533 return shouldErrorImpl(fiber);
534 }
535
536 -let shouldSuspendImpl = fiber => false;
536 +let shouldSuspendImpl = (fiber: Fiber) => false;
537
538 export function shouldSuspend(fiber: Fiber): boolean {
539 return shouldSuspendImpl(fiber);
packages/react-reconciler/src/ReactFiberRoot.js
+6 -4
@@ -45,11 +45,13 @@ export type RootState = {
45 };
46
47 function FiberRootNode(
48 - containerInfo,
48 + this: $FlowFixMe,
49 + containerInfo: any,
50 + // $FlowFixMe[missing-local-annot]
51 tag,
50 - hydrate,
51 - identifierPrefix,
52 - onRecoverableError,
52 + hydrate: any,
53 + identifierPrefix: any,
54 + onRecoverableError: any,
55 ) {
56 this.tag = tag;
57 this.containerInfo = containerInfo;
packages/react-reconciler/src/ReactFiberScope.js
+13 -4
@@ -140,7 +140,10 @@ function collectNearestChildContextValues<T>(
140 }
141 }
142
143 -function DO_NOT_USE_queryAllNodes(fn: ReactScopeQuery): null | Array<Object> {
143 +function DO_NOT_USE_queryAllNodes(
144 + this: $FlowFixMe,
145 + fn: ReactScopeQuery,
146 +): null | Array<Object> {
147 const currentFiber = getInstanceFromScope(this);
148 if (currentFiber === null) {
149 return null;
@@ -153,7 +156,10 @@ function DO_NOT_USE_queryAllNodes(fn: ReactScopeQuery): null | Array<Object> {
156 return scopedNodes.length === 0 ? null : scopedNodes;
157 }
158
156 -function DO_NOT_USE_queryFirstNode(fn: ReactScopeQuery): null | Object {
159 +function DO_NOT_USE_queryFirstNode(
160 + this: $FlowFixMe,
161 + fn: ReactScopeQuery,
162 +): null | Object {
163 const currentFiber = getInstanceFromScope(this);
164 if (currentFiber === null) {
165 return null;
@@ -165,7 +171,7 @@ function DO_NOT_USE_queryFirstNode(fn: ReactScopeQuery): null | Object {
171 return null;
172 }
173
168 -function containsNode(node: Object): boolean {
174 +function containsNode(this: $FlowFixMe, node: Object): boolean {
175 let fiber = getInstanceFromNode(node);
176 while (fiber !== null) {
177 if (fiber.tag === ScopeComponent && fiber.stateNode === this) {
@@ -176,7 +182,10 @@ function containsNode(node: Object): boolean {
182 return false;
183 }
184
179 -function getChildContextValues<T>(context: ReactContext<T>): Array<T> {
185 +function getChildContextValues<T>(
186 + this: $FlowFixMe,
187 + context: ReactContext<T>,
188 +): Array<T> {
189 const currentFiber = getInstanceFromScope(this);
190 if (currentFiber === null) {
191 return [];
packages/react-reconciler/src/ReactFiberThrow.js
+1
@@ -123,6 +123,7 @@ function createClassErrorUpdate(
123
124 const inst = fiber.stateNode;
125 if (inst !== null && typeof inst.componentDidCatch === 'function') {
126 + // $FlowFixMe[missing-this-annot]
127 update.callback = function callback() {
128 if (__DEV__) {
129 markFailedErrorBoundaryForHotReloading(fiber);
packages/react-reconciler/src/ReactFiberTreeReflection.js
+1 -1
@@ -117,7 +117,7 @@ export function isMounted(component: React$Component<any, any>): boolean {
117 return getNearestMountedFiber(fiber) === fiber;
118 }
119
120 -function assertIsMounted(fiber) {
120 +function assertIsMounted(fiber: Fiber) {
121 if (getNearestMountedFiber(fiber) !== fiber) {
122 throw new Error('Unable to find node on an unmounted component.');
123 }
packages/react-reconciler/src/ReactFiberWorkLoop.js
+21 -16
@@ -1003,7 +1003,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
1003
1004 // This is the entry point for every concurrent task, i.e. anything that
1005 // goes through Scheduler.
1006 -function performConcurrentWorkOnRoot(root, didTimeout) {
1006 +function performConcurrentWorkOnRoot(root: FiberRoot, didTimeout: boolean) {
1007 if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
1008 resetNestedUpdateFlag();
1009 }
@@ -1171,9 +1171,9 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
1171 }
1172
1173 function recoverFromConcurrentError(
1174 - root,
1175 - originallyAttemptedLanes,
1176 - errorRetryLanes,
1174 + root: FiberRoot,
1175 + originallyAttemptedLanes: Lanes,
1176 + errorRetryLanes: Lanes,
1177 ) {
1178 // If an error occurred during hydration, discard server response and fall
1179 // back to client side render.
@@ -1259,7 +1259,11 @@ export function queueRecoverableErrors(errors: Array<CapturedValue<mixed>>) {
1259 }
1260 }
1261
1262 -function finishConcurrentRender(root, exitStatus, lanes) {
1262 +function finishConcurrentRender(
1263 + root: FiberRoot,
1264 + exitStatus: RootExitStatus,
1265 + lanes: Lanes,
1266 +) {
1267 switch (exitStatus) {
1268 case RootInProgress:
1269 case RootFatalErrored: {
@@ -1439,7 +1443,7 @@ function isRenderConsistentWithExternalStores(finishedWork: Fiber): boolean {
1443 return true;
1444 }
1445
1442 -function markRootSuspended(root, suspendedLanes) {
1446 +function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) {
1447 // When suspending, we should always exclude lanes that were pinged or (more
1448 // rarely, since we try to avoid it) updated during the render phase.
1449 // TODO: Lol maybe there's a better way to factor this besides this
@@ -1449,13 +1453,12 @@ function markRootSuspended(root, suspendedLanes) {
1453 suspendedLanes,
1454 workInProgressRootInterleavedUpdatedLanes,
1455 );
1452 - // $FlowFixMe[incompatible-call] found when upgrading Flow
1456 markRootSuspended_dontCallThisOneDirectly(root, suspendedLanes);
1457 }
1458
1459 // This is the entry point for synchronous tasks that don't go
1460 // through Scheduler
1458 -function performSyncWorkOnRoot(root) {
1461 +function performSyncWorkOnRoot(root: FiberRoot) {
1462 if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
1463 syncNestedUpdateFlag();
1464 }
@@ -1764,7 +1767,7 @@ function resetSuspendedWorkLoopOnUnwind() {
1767 resetHooksOnUnwind();
1768 }
1769
1767 -function handleThrow(root, thrownValue): void {
1770 +function handleThrow(root: FiberRoot, thrownValue: any): void {
1771 // A component threw an exception. Usually this is because it suspended, but
1772 // it also includes regular program errors.
1773 //
@@ -1902,7 +1905,7 @@ function shouldAttemptToSuspendUntilDataResolves() {
1905 return false;
1906 }
1907
1905 -function pushDispatcher(container) {
1908 +function pushDispatcher(container: any) {
1909 prepareRendererToRender(container);
1910 const prevDispatcher = ReactCurrentDispatcher.current;
1911 ReactCurrentDispatcher.current = ContextOnlyDispatcher;
@@ -1916,7 +1919,7 @@ function pushDispatcher(container) {
1919 }
1920 }
1921
1919 -function popDispatcher(prevDispatcher) {
1922 +function popDispatcher(prevDispatcher: any) {
1923 resetRendererAfterRender();
1924 ReactCurrentDispatcher.current = prevDispatcher;
1925 }
@@ -1931,7 +1934,7 @@ function pushCacheDispatcher() {
1934 }
1935 }
1936
1934 -function popCacheDispatcher(prevCacheDispatcher) {
1937 +function popCacheDispatcher(prevCacheDispatcher: any) {
1938 if (enableCache) {
1939 ReactCurrentCache.current = prevCacheDispatcher;
1940 }
@@ -1973,6 +1976,7 @@ export function renderDidSuspendDelayIfPossible(): void {
1976 // pinged or updated while we were rendering.
1977 // TODO: Consider unwinding immediately, using the
1978 // SuspendedOnHydration mechanism.
1979 + // $FlowFixMe[incompatible-call] need null check workInProgressRoot
1980 markRootSuspended(workInProgressRoot, workInProgressRootRenderLanes);
1981 }
1982 }
@@ -3753,7 +3757,7 @@ export function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber: Fiber) {
3757 let beginWork;
3758 if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
3759 const dummyFiber = null;
3756 - beginWork = (current, unitOfWork, lanes) => {
3760 + beginWork = (current: null | Fiber, unitOfWork: Fiber, lanes: Lanes) => {
3761 // If a component throws an error, we replay it again in a synchronously
3762 // dispatched event, so that the debugger will treat it as an uncaught
3763 // error See ReactErrorUtils for more information.
@@ -3834,7 +3838,7 @@ if (__DEV__) {
3838 didWarnAboutUpdateInRenderForAnotherComponent = new Set();
3839 }
3840
3837 -function warnAboutRenderPhaseUpdatesInDEV(fiber) {
3841 +function warnAboutRenderPhaseUpdatesInDEV(fiber: Fiber) {
3842 if (__DEV__) {
3843 if (ReactCurrentDebugFiberIsRenderingInDEV) {
3844 switch (fiber.tag) {
@@ -3893,7 +3897,8 @@ export function restorePendingUpdaters(root: FiberRoot, lanes: Lanes): void {
3897 }
3898
3899 const fakeActCallbackNode = {};
3896 -function scheduleCallback(priorityLevel, callback) {
3900 +// $FlowFixMe[missing-local-annot]
3901 +function scheduleCallback(priorityLevel: any, callback) {
3902 if (__DEV__) {
3903 // If we're currently inside an `act` scope, bypass Scheduler and push to
3904 // the `act` queue instead.
@@ -3910,7 +3915,7 @@ function scheduleCallback(priorityLevel, callback) {
3915 }
3916 }
3917
3913 -function cancelCallback(callbackNode) {
3918 +function cancelCallback(callbackNode: any) {
3919 if (__DEV__ && callbackNode === fakeActCallbackNode) {
3920 return;
3921 }
packages/react-reconciler/src/ReactStrictModeWarnings.js
+1 -1
@@ -42,7 +42,7 @@ if (__DEV__) {
42 return maybeStrictRoot;
43 };
44
45 - const setToSortedString = set => {
45 + const setToSortedString = (set: Set<string>) => {
46 const array = [];
47 set.forEach(value => {
48 array.push(value);
packages/react-refresh/src/ReactFreshRuntime.js
+8 -6
@@ -123,7 +123,7 @@ function computeFullKey(signature: Signature): string {
123 return fullKey;
124 }
125
126 -function haveEqualSignatures(prevType, nextType) {
126 +function haveEqualSignatures(prevType: any, nextType: any) {
127 const prevSignature = allSignaturesByType.get(prevType);
128 const nextSignature = allSignaturesByType.get(nextType);
129
@@ -143,11 +143,11 @@ function haveEqualSignatures(prevType, nextType) {
143 return true;
144 }
145
146 -function isReactClass(type) {
146 +function isReactClass(type: any) {
147 return type.prototype && type.prototype.isReactComponent;
148 }
149
150 -function canPreserveStateBetween(prevType, nextType) {
150 +function canPreserveStateBetween(prevType: any, nextType: any) {
151 if (isReactClass(prevType) || isReactClass(nextType)) {
152 return false;
153 }
@@ -157,7 +157,7 @@ function canPreserveStateBetween(prevType, nextType) {
157 return false;
158 }
159
160 -function resolveFamily(type) {
160 +function resolveFamily(type: any) {
161 // Only check updated types to keep lookups fast.
162 return updatedFamiliesByType.get(type);
163 }
@@ -179,7 +179,7 @@ function cloneSet<T>(set: Set<T>): Set<T> {
179 }
180
181 // This is a safety mechanism to protect against rogue getters and Proxies.
182 -function getProperty(object, property) {
182 +function getProperty(object: any, property: string) {
183 try {
184 return object[property];
185 } catch (err) {
@@ -489,7 +489,7 @@ export function injectIntoGlobalHook(globalObject: any): void {
489
490 // Here, we just want to get a reference to scheduleRefresh.
491 const oldInject = hook.inject;
492 - hook.inject = function(injected) {
492 + hook.inject = function(this: mixed, injected) {
493 const id = oldInject.apply(this, arguments);
494 if (
495 typeof injected.scheduleRefresh === 'function' &&
@@ -518,6 +518,7 @@ export function injectIntoGlobalHook(globalObject: any): void {
518 const oldOnCommitFiberRoot = hook.onCommitFiberRoot;
519 const oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {});
520 hook.onScheduleFiberRoot = function(
521 + this: mixed,
522 id: number,
523 root: FiberRoot,
524 children: ReactNodeList,
@@ -533,6 +534,7 @@ export function injectIntoGlobalHook(globalObject: any): void {
534 return oldOnScheduleFiberRoot.apply(this, arguments);
535 };
536 hook.onCommitFiberRoot = function(
537 + this: mixed,
538 id: number,
539 root: FiberRoot,
540 maybePriorityLevel: mixed,
packages/react-server-dom-relay/src/ReactFlightDOMRelayClientHostConfig.js
+1
@@ -44,6 +44,7 @@ export function resolveModuleReference<T>(
44 return resolveModuleReferenceImpl(moduleData);
45 }
46
47 +// $FlowFixMe[missing-local-annot]
48 function parseModelRecursively(response: Response, parentObj, key, value) {
49 if (typeof value === 'string') {
50 return parseModelString(response, parentObj, key, value);
packages/react-server-dom-webpack/src/ReactFlightDOMClient.js
+2 -2
@@ -31,7 +31,7 @@ function startReadingFromStream(
31 stream: ReadableStream,
32 ): void {
33 const reader = stream.getReader();
34 - function progress({done, value}) {
34 + function progress({done, value}: {done: boolean, value: ?any, ...}) {
35 if (done) {
36 close(response);
37 return;
@@ -43,7 +43,7 @@ function startReadingFromStream(
43 .then(progress)
44 .catch(error);
45 }
46 - function error(e) {
46 + function error(e: any) {
47 reportGlobalError(response, e);
48 }
49 reader
packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js
+2 -2
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import type {ReactModel} from 'react-server/src/ReactFlightServer';
10 +import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
11 import type {Destination} from 'react-server/src/ReactServerStreamConfigNode';
12 import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
13 import type {Writable} from 'stream';
@@ -20,7 +20,7 @@ import {
20 abort,
21 } from 'react-server/src/ReactFlightServer';
22
23 -function createDrainHandler(destination: Destination, request) {
23 +function createDrainHandler(destination: Destination, request: Request) {
24 return () => startFlowing(request, destination);
25 }
26
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js
+2 -2
@@ -100,7 +100,7 @@ export async function getSource(
100 return defaultGetSource(url, context, defaultGetSource);
101 }
102
103 -function addExportNames(names, node) {
103 +function addExportNames(names: Array<string>, node: any) {
104 switch (node.type) {
105 case 'Identifier':
106 names.push(node.name);
@@ -174,7 +174,7 @@ async function parseExportNamesInto(
174 transformedSource: string,
175 names: Array<string>,
176 parentURL: string,
177 - defaultTransformSource,
177 + defaultTransformSource: TransformSourceFunction,
178 ): Promise<void> {
179 const {body} = acorn.parse(transformedSource, {
180 ecmaVersion: '2019',
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
+9 -3
@@ -16,7 +16,11 @@ module.exports = function register() {
16 const PROMISE_PROTOTYPE = Promise.prototype;
17
18 const proxyHandlers = {
19 - get: function(target, name, receiver) {
19 + get: function(
20 + target: {[string]: any},
21 + name: string,
22 + receiver: Proxy<{[string]: any}>,
23 + ) {
24 switch (name) {
25 // These names are read by the Flight runtime if you end up using the exports object.
26 case '$$typeof':
@@ -50,7 +54,8 @@ module.exports = function register() {
54 // If this module is expected to return a Promise (such as an AsyncModule) then
55 // we should resolve that with a client reference that unwraps the Promise on
56 // the client.
53 - const then = function then(resolve, reject) {
57 + // $FlowFixMe[missing-local-annot]
58 + const then = function then(resolve, reject: any) {
59 const moduleReference: {[string]: any, ...} = {
60 $$typeof: MODULE_REFERENCE,
61 filepath: target.filepath,
@@ -82,7 +87,7 @@ module.exports = function register() {
87 }
88 return cachedReference;
89 },
85 - getPrototypeOf(target) {
90 + getPrototypeOf(target: {[string]: any}) {
91 // Pretend to be a Promise in case anyone asks.
92 return PROMISE_PROTOTYPE;
93 },
@@ -108,6 +113,7 @@ module.exports = function register() {
113 const originalResolveFilename = Module._resolveFilename;
114
115 // $FlowFixMe[prop-missing] found when upgrading Flow
116 + // $FlowFixMe[missing-this-annot]
117 Module._resolveFilename = function(request, parent, isMain, options) {
118 const resolved = originalResolveFilename.apply(this, arguments);
119 if (resolved.endsWith('.server.js')) {
packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js
+3 -1
@@ -144,6 +144,7 @@ export default class ReactFlightWebpackPlugin {
144 new NullDependency.Template(),
145 );
146
147 + // $FlowFixMe[missing-local-annot]
148 const handler = parser => {
149 // We need to add all client references as dependency of something in the graph so
150 // Webpack knows which entries need to know about the relevant chunks and include the
@@ -220,7 +221,8 @@ export default class ReactFlightWebpackPlugin {
221 return c.id;
222 });
223
223 - function recordModule(id, module) {
224 + // $FlowFixMe[missing-local-annot]
225 + function recordModule(id: any, module) {
226 // TODO: Hook into deps instead of the target module.
227 // That way we know by the type of dep whether to include.
228 // It also resolves conflicts when the same module is in multiple chunks.
packages/react-server-native-relay/src/ReactFlightNativeRelayClientHostConfig.js
+1
@@ -44,6 +44,7 @@ export function resolveModuleReference<T>(
44 return resolveModuleReferenceImpl(moduleData);
45 }
46
47 +// $FlowFixMe[missing-local-annot]
48 function parseModelRecursively(response: Response, parentObj, key, value) {
49 if (typeof value === 'string') {
50 return parseModelString(response, parentObj, key, value);
packages/react-server/src/ReactFizzClassComponent.js
+8 -6
@@ -60,7 +60,7 @@ if (__DEV__) {
60 }
61 };
62
63 - warnOnUndefinedDerivedState = function(type, partialState) {
63 + warnOnUndefinedDerivedState = function(type: any, partialState: any) {
64 if (partialState === undefined) {
65 const componentName = getComponentNameFromType(type) || 'Component';
66 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
@@ -106,10 +106,11 @@ type InternalInstance = {
106 };
107
108 const classComponentUpdater = {
109 - isMounted(inst) {
109 + isMounted(inst: any) {
110 return false;
111 },
112 - enqueueSetState(inst, payload, callback) {
112 + // $FlowFixMe[missing-local-annot]
113 + enqueueSetState(inst: any, payload: any, callback) {
114 const internals: InternalInstance = getInstance(inst);
115 if (internals.queue === null) {
116 warnNoop(inst, 'setState');
@@ -122,7 +123,7 @@ const classComponentUpdater = {
123 }
124 }
125 },
125 - enqueueReplaceState(inst, payload, callback) {
126 + enqueueReplaceState(inst: any, payload: any, callback: null) {
127 const internals: InternalInstance = getInstance(inst);
128 internals.replace = true;
129 internals.queue = [payload];
@@ -132,7 +133,8 @@ const classComponentUpdater = {
133 }
134 }
135 },
135 - enqueueForceUpdate(inst, callback) {
136 + // $FlowFixMe[missing-local-annot]
137 + enqueueForceUpdate(inst: any, callback) {
138 const internals: InternalInstance = getInstance(inst);
139 if (internals.queue === null) {
140 warnNoop(inst, 'forceUpdate');
@@ -532,7 +534,7 @@ function checkClassInstance(instance: any, ctor: any, newProps: any) {
534 }
535 }
536
535 -function callComponentWillMount(type, instance) {
537 +function callComponentWillMount(type: any, instance: any) {
538 const oldState = instance.state;
539
540 if (typeof instance.componentWillMount === 'function') {
packages/react-server/src/ReactFizzServer.js
+9 -4
@@ -719,7 +719,7 @@ function renderHostElement(
719 popComponentStackInDEV(task);
720 }
721
722 -function shouldConstruct(Component) {
722 +function shouldConstruct(Component: any) {
723 return Component.prototype && Component.prototype.isReactComponent;
724 }
725
@@ -1012,7 +1012,7 @@ function resolveDefaultProps(Component: any, baseProps: Object): Object {
1012 function renderForwardRef(
1013 request: Request,
1014 task: Task,
1015 - prevThenableState,
1015 + prevThenableState: null | ThenableState,
1016 type: any,
1017 props: Object,
1018 ref: any,
@@ -1301,6 +1301,7 @@ function renderElement(
1301 );
1302 }
1303
1304 +// $FlowFixMe[missing-local-annot]
1305 function validateIterable(iterable, iteratorFn: Function): void {
1306 if (__DEV__) {
1307 // We don't support rendering Generators because it's a mutation.
@@ -1505,7 +1506,11 @@ function renderNodeDestructiveImpl(
1506 }
1507 }
1508
1508 -function renderChildrenArray(request, task, children) {
1509 +function renderChildrenArray(
1510 + request: Request,
1511 + task: Task,
1512 + children: Array<any>,
1513 +) {
1514 const totalChildren = children.length;
1515 for (let i = 0; i < totalChildren; i++) {
1516 const prevTreeContext = task.treeContext;
@@ -2027,7 +2032,7 @@ function flushSubtree(
2032
2033 function flushSegment(
2034 request: Request,
2030 - destination,
2035 + destination: Destination,
2036 segment: Segment,
2037 ): boolean {
2038 const boundary = segment.boundary;
packages/react-server/src/ReactFlightServer.js
+4 -3
@@ -193,6 +193,7 @@ export function createRequest(
193 identifierPrefix: identifierPrefix || '',
194 identifierCount: 1,
195 onError: onError === undefined ? defaultErrorHandler : onError,
196 + // $FlowFixMe[missing-this-annot]
197 toJSON: function(key: string, value: ReactModel): ReactJSONValue {
198 return resolveModelToJSON(request, this, key, value);
199 },
@@ -481,7 +482,7 @@ function escapeStringValue(value: string): string {
482 }
483 }
484
484 -function isObjectPrototype(object): boolean {
485 +function isObjectPrototype(object: any): boolean {
486 if (!object) {
487 return false;
488 }
@@ -503,7 +504,7 @@ function isObjectPrototype(object): boolean {
504 return true;
505 }
506
506 -function isSimpleObject(object): boolean {
507 +function isSimpleObject(object: any): boolean {
508 if (!isObjectPrototype(Object.getPrototypeOf(object))) {
509 return false;
510 }
@@ -529,7 +530,7 @@ function isSimpleObject(object): boolean {
530 return true;
531 }
532
532 -function objectName(object): string {
533 +function objectName(object: mixed): string {
534 // $FlowFixMe[method-unbinding]
535 const name = Object.prototype.toString.call(object);
536 return name.replace(/^\[object (.*)\]$/, function(m, p0) {
packages/react-test-renderer/src/ReactTestRenderer.js
+4
@@ -133,6 +133,7 @@ function toJSON(inst: Instance | TextInstance): ReactTestRendererNode | null {
133 }
134 }
135
136 +// $FlowFixMe[missing-local-annot]
137 function childrenToTree(node) {
138 if (!node) {
139 return null;
@@ -146,6 +147,7 @@ function childrenToTree(node) {
147 return flatten(children.map(toTree));
148 }
149
150 +// $FlowFixMe[missing-local-annot]
151 function nodeAndSiblingsArray(nodeWithSibling) {
152 const array = [];
153 let node = nodeWithSibling;
@@ -156,6 +158,7 @@ function nodeAndSiblingsArray(nodeWithSibling) {
158 return array;
159 }
160
161 +// $FlowFixMe[missing-local-annot]
162 function flatten(arr) {
163 const result = [];
164 const stack = [{i: 0, array: arr}];
@@ -449,6 +452,7 @@ function propsMatch(props: Object, filter: Object): boolean {
452 return true;
453 }
454
455 +// $FlowFixMe[missing-local-annot]
456 function onRecoverableError(error) {
457 // TODO: Expose onRecoverableError option to userspace
458 // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
packages/react/src/ReactAct.js
+6 -3
@@ -205,7 +205,10 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
205 }
206 }
207
208 -function popActScope(prevActQueue, prevActScopeDepth) {
208 +function popActScope(
209 + prevActQueue: null | Array<RendererTask>,
210 + prevActScopeDepth: number,
211 +) {
212 if (__DEV__) {
213 if (prevActScopeDepth !== actScopeDepth - 1) {
214 console.error(
@@ -252,7 +255,7 @@ function recursivelyFlushAsyncActWork<T>(
255 }
256
257 let isFlushing = false;
255 -function flushActQueue(queue) {
258 +function flushActQueue(queue: Array<RendererTask>) {
259 if (__DEV__) {
260 if (!isFlushing) {
261 // Prevent re-entrance.
@@ -304,7 +307,7 @@ function flushActQueue(queue) {
307 // environment it may cause the warning to fire too late.
308 const queueSeveralMicrotasks =
309 typeof queueMicrotask === 'function'
307 - ? callback => {
310 + ? (callback: () => void) => {
311 queueMicrotask(() => queueMicrotask(callback));
312 }
313 : queueMacrotask;
packages/react/src/ReactChildren.js
+1
@@ -296,6 +296,7 @@ function forEachChildren(
296 ): void {
297 mapChildren(
298 children,
299 + // $FlowFixMe[missing-this-annot]
300 function() {
301 forEachFunc.apply(this, arguments);
302 // Don't return anything.
packages/react/src/ReactContext.js
+6 -5
@@ -9,6 +9,7 @@
9
10 import {REACT_PROVIDER_TYPE, REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
11
12 +import type {ReactProviderType} from 'shared/ReactTypes';
13 import type {ReactContext} from 'shared/ReactTypes';
14
15 export function createContext<T>(defaultValue: T): ReactContext<T> {
@@ -66,7 +67,7 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
67 }
68 return context.Provider;
69 },
69 - set(_Provider) {
70 + set(_Provider: ReactProviderType<T>) {
71 context.Provider = _Provider;
72 },
73 },
@@ -74,7 +75,7 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
75 get() {
76 return context._currentValue;
77 },
77 - set(_currentValue) {
78 + set(_currentValue: T) {
79 context._currentValue = _currentValue;
80 },
81 },
@@ -82,7 +83,7 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
83 get() {
84 return context._currentValue2;
85 },
85 - set(_currentValue2) {
86 + set(_currentValue2: T) {
87 context._currentValue2 = _currentValue2;
88 },
89 },
@@ -90,7 +91,7 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
91 get() {
92 return context._threadCount;
93 },
93 - set(_threadCount) {
94 + set(_threadCount: number) {
95 context._threadCount = _threadCount;
96 },
97 },
@@ -110,7 +111,7 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
111 get() {
112 return context.displayName;
113 },
113 - set(displayName) {
114 + set(displayName: void | string) {
115 if (!hasWarnedAboutDisplayNameOnConsumer) {
116 console.warn(
117 'Setting `displayName` on Context.Consumer has no effect. ' +
packages/react/src/ReactLazy.js
+2
@@ -144,6 +144,7 @@ export function lazy<T>(
144 get() {
145 return defaultProps;
146 },
147 + // $FlowFixMe[missing-local-annot]
148 set(newDefaultProps) {
149 console.error(
150 'React.lazy(...): It is not supported to assign `defaultProps` to ' +
@@ -163,6 +164,7 @@ export function lazy<T>(
164 get() {
165 return propTypes;
166 },
167 + // $FlowFixMe[missing-local-annot]
168 set(newPropTypes) {
169 console.error(
170 'React.lazy(...): It is not supported to assign `propTypes` to ' +
packages/scheduler/src/forks/Scheduler.js
+8 -2
@@ -329,6 +329,7 @@ function unstable_next<T>(eventHandler: () => T): T {
329 function unstable_wrapCallback<T: (...Array<mixed>) => mixed>(callback: T): T {
330 var parentPriorityLevel = currentPriorityLevel;
331 // $FlowFixMe[incompatible-return]
332 + // $FlowFixMe[missing-this-annot]
333 return function() {
334 // This is a fork of runWithPriority, inlined for performance.
335 var previousPriorityLevel = currentPriorityLevel;
@@ -629,7 +630,9 @@ if (typeof localSetImmediate === 'function') {
630 };
631 }
632
632 -function requestHostCallback(callback) {
633 +function requestHostCallback(
634 + callback: (hasTimeRemaining: boolean, initialTime: number) => boolean,
635 +) {
636 scheduledHostCallback = callback;
637 if (!isMessageLoopRunning) {
638 isMessageLoopRunning = true;
@@ -637,7 +640,10 @@ function requestHostCallback(callback) {
640 }
641 }
642
640 -function requestHostTimeout(callback, ms: number) {
643 +function requestHostTimeout(
644 + callback: (currentTime: number) => void,
645 + ms: number,
646 +) {
647 // $FlowFixMe[not-a-function] nullable value
648 taskTimeoutID = localSetTimeout(() => {
649 callback(getCurrentTime());
packages/scheduler/src/forks/SchedulerMock.js
+1
@@ -322,6 +322,7 @@ function unstable_next<T>(eventHandler: () => T): T {
322 function unstable_wrapCallback<T: (...Array<mixed>) => mixed>(callback: T): T {
323 var parentPriorityLevel = currentPriorityLevel;
324 // $FlowFixMe[incompatible-return]
325 + // $FlowFixMe[missing-this-annot]
326 return function() {
327 // This is a fork of runWithPriority, inlined for performance.
328 var previousPriorityLevel = currentPriorityLevel;
packages/scheduler/src/forks/SchedulerPostTask.js
+1 -1
@@ -168,7 +168,7 @@ function runTask<T>(
168 }
169 }
170
171 -function handleAbortError(error) {
171 +function handleAbortError(error: any) {
172 // Abort errors are an implementation detail. We don't expose the
173 // TaskController to the user, nor do we expose the promise that is returned
174 // from `postTask`. So we should suppress them, since there's no way for the
packages/shared/ReactErrorUtils.js
+1
@@ -72,6 +72,7 @@ export function invokeGuardedCallbackAndCatchFirstError<
72 F,
73 Context,
74 >(
75 + this: mixed,
76 name: string | null,
77 func: (a: A, b: B, c: C, d: D, e: E, f: F) => void,
78 context: Context,
packages/shared/checkPropTypes.js
+1 -1
@@ -16,7 +16,7 @@ import hasOwnProperty from 'shared/hasOwnProperty';
16
17 const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
18
19 -function setCurrentlyValidatingElement(element) {
19 +function setCurrentlyValidatingElement(element: any) {
20 if (__DEV__) {
21 if (element) {
22 const owner = element._owner;
packages/shared/invokeGuardedCallbackImpl.js
+3
@@ -7,6 +7,7 @@
7 * @flow
8 */
9
10 +// $FlowFixMe[missing-this-annot]
11 function invokeGuardedCallbackProd<Args: Array<mixed>, Context>(
12 name: string | null,
13 func: (...Args) => mixed,
@@ -62,6 +63,7 @@ if (__DEV__) {
63 invokeGuardedCallbackImpl = function invokeGuardedCallbackDev<
64 Args: Array<mixed>,
65 Context,
66 + // $FlowFixMe[missing-this-annot]
67 >(name: string | null, func: (...Args) => mixed, context: Context): void {
68 // If document doesn't exist we know for sure we will crash in this method
69 // when we call document.createEvent(). However this can cause confusing
@@ -150,6 +152,7 @@ if (__DEV__) {
152 let didSetError = false;
153 let isCrossOriginError = false;
154
155 + // $FlowFixMe[missing-local-annot]
156 function handleWindowError(event) {
157 error = event.error;
158 didSetError = true;
packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
+1 -1
@@ -44,7 +44,7 @@ export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
44 let hasMemo = false;
45 let memoizedSnapshot;
46 let memoizedSelection: Selection;
47 - const memoizedSelector = nextSnapshot => {
47 + const memoizedSelector = (nextSnapshot: Snapshot) => {
48 if (!hasMemo) {
49 // The first time the hook is called, there is no memoized result.
50 hasMemo = true;
scripts/flow/config/flowconfig
+1 -1
@@ -43,7 +43,7 @@ untyped-type-import=error
43 %CI_MAX_WORKERS%
44 exact_by_default=true
45 munge_underscores=false
46 -enforce_local_inference_annotations=false
46 +enforce_local_inference_annotations=true
47
48 # Substituted by createFlowConfig.js:
49 %REACT_RENDERER_FLOW_OPTIONS%
scripts/flow/createFlowConfigs.js
-2
@@ -3,8 +3,6 @@
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
6 */
7
8 'use strict';