Flow: inference_mode=constrain_writes
This mode is going to be the new default in Flow going forward. There was an unfortuante large number of suppressions in this update. More on the changes can be found in this [Flow blog post](https://medium.com/flow-type/new-flow-language-rule-constrained-writes-4c70e375d190). Added some of the required annotations using the provided codemod: ```sh node_modules/.bin/flow codemod annotate-declarations --write . ``` ghstack-source-id: 0b168e1b23f1305083e71d0b931b732e94705c73 Pull Request resolved: https://github.com/facebook/react/pull/25422
Jan Kassens committed
Oct 4, 2022 at 15:39 UTC
3b6826ed9e76207d9ab7a513a069fd67b69599a8
70 files changed
+207
-88
packages/react-cache/src/LRU.js
+1
-1
@@ -57,7 +57,7 @@ export function createLRU<T>(limit: number): LRU<T> {
57
// Delete entries from the cache, starting from the end of the list.
58
if (first !== null) {
59
const resolvedFirst: Entry<T> = (first: any);
60
- let last = resolvedFirst.previous;
60
+ let last: null | Entry<T> = resolvedFirst.previous;
61
while (size > targetSize && last !== null) {
62
const onDelete = last.onDelete;
63
const previous = last.previous;
packages/react-debug-tools/src/ReactDebugHooks.js
+3
-2
@@ -217,7 +217,7 @@ function useImperativeHandle<T>(
217
// and if there is a ref callback it might not store it but if it does we
218
// have no way of knowing where. So let's only enable introspection of the
219
// ref itself if it is using the object form.
220
- let instance = undefined;
220
+ let instance: ?T = undefined;
221
if (ref !== null && typeof ref === 'object') {
222
instance = ref.current;
223
}
@@ -716,6 +716,7 @@ export function inspectHooks<Props>(
716
} finally {
717
readHookLog = hookLog;
718
hookLog = [];
719
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
720
currentDispatcher.current = previousDispatcher;
721
}
722
const rootStack = ErrorStackParser.parse(ancestorStackError);
@@ -723,7 +724,7 @@ export function inspectHooks<Props>(
724
}
725
726
function setupContexts(contextMap: Map<ReactContext<any>, any>, fiber: Fiber) {
726
- let current = fiber;
727
+ let current: null | Fiber = fiber;
728
while (current) {
729
if (current.tag === ContextProvider) {
730
const providerType: ReactProviderType<any> = current.type;
packages/react-devtools-core/src/backend.js
+4
@@ -146,6 +146,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
146
}
147
},
148
);
149
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
150
bridge.addListener(
151
'updateComponentFilters',
152
(componentFilters: Array<ComponentFilter>) => {
@@ -165,10 +166,12 @@ export function connectToDevTools(options: ?ConnectOptions) {
166
// Ideally the backend would save the filters itself, but RN doesn't provide a sync storage solution.
167
// So for now we just fall back to using the default filters...
168
if (window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ == null) {
169
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
170
bridge.send('overrideComponentFilters', savedComponentFilters);
171
}
172
173
// TODO (npm-packages) Warn if "isBackendStorageAPISupported"
174
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
175
const agent = new Agent(bridge);
176
agent.addListener('shutdown', () => {
177
// If we received 'shutdown' from `agent`, we assume the `bridge` is already shutting down,
@@ -181,6 +184,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
184
// Setup React Native style editor if the environment supports it.
185
if (resolveRNStyle != null || hook.resolveRNStyle != null) {
186
setupNativeStyleEditor(
187
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
188
bridge,
189
agent,
190
((resolveRNStyle || hook.resolveRNStyle: any): ResolveNativeStyle),
packages/react-devtools-core/src/standalone.js
+1
@@ -256,6 +256,7 @@ function initialize(socket: WebSocket) {
256
socket.close();
257
});
258
259
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
260
store = new Store(bridge, {
261
checkBridgeProtocolCompatibility: true,
262
supportsNativeInspection: true,
packages/react-devtools-shared/src/backend/DevToolsFiberComponentStack.js
+2
-1
@@ -84,9 +84,10 @@ export function getStackByFiberInDevAndProd(
84
): string {
85
try {
86
let info = '';
87
- let node = workInProgress;
87
+ let node: Fiber = workInProgress;
88
do {
89
info += describeFiber(workTagMap, node, currentDispatcherRef);
90
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
91
node = node.return;
92
} while (node);
93
return info;
packages/react-devtools-shared/src/backend/legacy/renderer.js
+4
@@ -248,6 +248,7 @@ export function attach(
248
parentIDStack.pop();
249
return result;
250
} catch (err) {
251
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
252
parentIDStack = [];
253
throw err;
254
} finally {
@@ -284,6 +285,7 @@ export function attach(
285
parentIDStack.pop();
286
return result;
287
} catch (err) {
288
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
289
parentIDStack = [];
290
throw err;
291
} finally {
@@ -320,6 +322,7 @@ export function attach(
322
parentIDStack.pop();
323
return result;
324
} catch (err) {
325
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
326
parentIDStack = [];
327
throw err;
328
} finally {
@@ -351,6 +354,7 @@ export function attach(
354
355
return result;
356
} catch (err) {
357
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
358
parentIDStack = [];
359
throw err;
360
} finally {
packages/react-devtools-shared/src/backend/profilingHooks.js
+2
-1
@@ -799,7 +799,7 @@ export function createProfilingHooks({
799
800
function getParentFibers(fiber: Fiber): Array<Fiber> {
801
const parents = [];
802
- let parent = fiber;
802
+ let parent: null | Fiber = fiber;
803
while (parent !== null) {
804
parents.push(parent);
805
parent = parent.return;
@@ -824,6 +824,7 @@ export function createProfilingHooks({
824
warning: null,
825
};
826
currentFiberStacks.set(event, getParentFibers(fiber));
827
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
828
currentTimelineData.schedulingEvents.push(event);
829
}
830
}
packages/react-devtools-shared/src/backend/renderer.js
+15
-7
@@ -2269,7 +2269,7 @@ export function attach(
2269
2270
// This is a naive implementation that shallowly recourses children.
2271
// We might want to revisit this if it proves to be too inefficient.
2272
- let child = childSet;
2272
+ let child: null | Fiber = childSet;
2273
while (child !== null) {
2274
findReorderedChildrenRecursively(child, nextChildren);
2275
child = child.sibling;
@@ -2846,11 +2846,11 @@ export function attach(
2846
// https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberTreeReflection.js
2847
function getNearestMountedFiber(fiber: Fiber): null | Fiber {
2848
let node = fiber;
2849
- let nearestMounted = fiber;
2849
+ let nearestMounted: null | Fiber = fiber;
2850
if (!fiber.alternate) {
2851
// If there is no alternate, this might be a new tree that isn't inserted
2852
// yet. If it is, then it will have a pending insertion effect on it.
2853
- let nextNode = node;
2853
+ let nextNode: Fiber = node;
2854
do {
2855
node = nextNode;
2856
if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
@@ -2859,6 +2859,7 @@ export function attach(
2859
// if that one is still mounted.
2860
nearestMounted = node.return;
2861
}
2862
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
2863
nextNode = node.return;
2864
} while (nextNode);
2865
} else {
@@ -3097,7 +3098,7 @@ export function attach(
3098
const owners: Array<SerializedElement> = [fiberToSerializedElement(fiber)];
3099
3100
if (_debugOwner) {
3100
- let owner = _debugOwner;
3101
+ let owner: null | Fiber = _debugOwner;
3102
while (owner !== null) {
3103
owners.unshift(fiberToSerializedElement(owner));
3104
owner = owner._debugOwner || null;
@@ -3256,7 +3257,7 @@ export function attach(
3257
let owners = null;
3258
if (_debugOwner) {
3259
owners = [];
3259
- let owner = _debugOwner;
3260
+ let owner: null | Fiber = _debugOwner;
3261
while (owner !== null) {
3262
owners.push(fiberToSerializedElement(owner));
3263
owner = owner._debugOwner || null;
@@ -3687,18 +3688,22 @@ export function attach(
3688
// This will enable us to send patches without re-inspecting if hydrated paths are requested.
3689
// (Reducing how often we shallow-render is a better DX for function components that use hooks.)
3690
const cleanedInspectedElement = {...mostRecentlyInspectedElement};
3691
+ // $FlowFixMe[prop-missing] found when upgrading Flow
3692
cleanedInspectedElement.context = cleanForBridge(
3693
cleanedInspectedElement.context,
3694
createIsPathAllowed('context', null),
3695
);
3696
+ // $FlowFixMe[prop-missing] found when upgrading Flow
3697
cleanedInspectedElement.hooks = cleanForBridge(
3698
cleanedInspectedElement.hooks,
3699
createIsPathAllowed('hooks', 'hooks'),
3700
);
3701
+ // $FlowFixMe[prop-missing] found when upgrading Flow
3702
cleanedInspectedElement.props = cleanForBridge(
3703
cleanedInspectedElement.props,
3704
createIsPathAllowed('props', null),
3705
);
3706
+ // $FlowFixMe[prop-missing] found when upgrading Flow
3707
cleanedInspectedElement.state = cleanForBridge(
3708
cleanedInspectedElement.state,
3709
createIsPathAllowed('state', null),
@@ -3709,6 +3714,7 @@ export function attach(
3714
responseID: requestID,
3715
type: 'full-data',
3716
// $FlowFixMe[incompatible-return] found when upgrading Flow
3717
+ // $FlowFixMe[prop-missing] found when upgrading Flow
3718
value: cleanedInspectedElement,
3719
};
3720
}
@@ -4420,13 +4426,15 @@ export function attach(
4426
// The return path will contain Fibers that are "invisible" to the store
4427
// because their keys and indexes are important to restoring the selection.
4428
function getPathForElement(id: number): Array<PathFrame> | null {
4423
- let fiber = idToArbitraryFiberMap.get(id);
4429
+ let fiber: ?Fiber = idToArbitraryFiberMap.get(id);
4430
if (fiber == null) {
4431
return null;
4432
}
4433
const keyPath = [];
4434
while (fiber !== null) {
4435
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
4436
keyPath.push(getPathFrame(fiber));
4437
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
4438
fiber = fiber.return;
4439
}
4440
keyPath.reverse();
@@ -4443,7 +4451,7 @@ export function attach(
4451
return null;
4452
}
4453
// Find the closest Fiber store is aware of.
4446
- let fiber = trackedPathMatchFiber;
4454
+ let fiber: null | Fiber = trackedPathMatchFiber;
4455
while (fiber !== null && shouldFilterFiber(fiber)) {
4456
fiber = fiber.return;
4457
}
packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
+2
-2
@@ -282,7 +282,7 @@ function findTipPos(dims, bounds, tipSize) {
282
const tipWidth = Math.max(tipSize.width, 60);
283
const margin = 5;
284
285
- let top;
285
+ let top: number | string;
286
if (dims.top + dims.height + tipHeight <= bounds.top + bounds.height) {
287
if (dims.top + dims.height < bounds.top + 0) {
288
top = bounds.top + margin;
@@ -299,7 +299,7 @@ function findTipPos(dims, bounds, tipSize) {
299
top = bounds.top + bounds.height - tipHeight - margin;
300
}
301
302
- let left = dims.left + margin;
302
+ let left: number | string = dims.left + margin;
303
if (dims.left < bounds.left) {
304
left = bounds.left + margin;
305
}
packages/react-devtools-shared/src/backend/views/utils.js
+1
-1
@@ -84,7 +84,7 @@ export function getNestedBoundingClientRect(
84
const ownerIframe = getOwnerIframe(node);
85
if (ownerIframe && ownerIframe !== boundaryWindow) {
86
const rects = [node.getBoundingClientRect()];
87
- let currentIframe = ownerIframe;
87
+ let currentIframe: null | HTMLElement = ownerIframe;
88
let onlyOneMore = false;
89
while (currentIframe) {
90
const rect = getBoundingClientRectWithBorderOffset(currentIframe);
packages/react-devtools-shared/src/devtools/cache.js
+3
-1
@@ -88,7 +88,9 @@ const resourceConfigs: Map<Resource<any, any, any>, Config> = new Map();
88
function getEntriesForResource(
89
resource: any,
90
): Map<any, any> | WeakMap<any, any> {
91
- let entriesForResource = ((entries.get(resource): any): Map<any, any>);
91
+ let entriesForResource: Map<any, any> | WeakMap<any, any> = ((entries.get(
92
+ resource,
93
+ ): any): Map<any, any>);
94
if (entriesForResource === undefined) {
95
const config = resourceConfigs.get(resource);
96
entriesForResource =
packages/react-devtools-shared/src/devtools/store.js
+6
-4
@@ -763,7 +763,7 @@ export default class Store extends EventEmitter<{
763
764
const weightDelta = 1 - element.weight;
765
766
- let parentElement = ((this._idToElement.get(
766
+ let parentElement: void | Element = ((this._idToElement.get(
767
element.parentID,
768
): any): Element);
769
while (parentElement != null) {
@@ -789,7 +789,7 @@ export default class Store extends EventEmitter<{
789
: currentElement.weight;
790
const weightDelta = newWeight - oldWeight;
791
792
- let parentElement = ((this._idToElement.get(
792
+ let parentElement: void | Element = ((this._idToElement.get(
793
currentElement.parentID,
794
): any): Element);
795
while (parentElement != null) {
@@ -806,8 +806,10 @@ export default class Store extends EventEmitter<{
806
807
currentElement =
808
currentElement.parentID !== 0
809
- ? this.getElementByID(currentElement.parentID)
810
- : null;
809
+ ? // $FlowFixMe[incompatible-type] found when upgrading Flow
810
+ this.getElementByID(currentElement.parentID)
811
+ : // $FlowFixMe[incompatible-type] found when upgrading Flow
812
+ null;
813
}
814
}
815
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/context.js
+5
-1
@@ -66,7 +66,11 @@ const resource: Resource<
66
return request.promise;
67
}
68
69
- let resolveFn = ((null: any): ResolveFn);
69
+ let resolveFn:
70
+ | ResolveFn
71
+ | ((
72
+ result: Promise<StyleAndLayoutFrontend> | StyleAndLayoutFrontend,
73
+ ) => void) = ((null: any): ResolveFn);
74
const promise = new Promise(resolve => {
75
resolveFn = resolve;
76
});
packages/react-devtools-shared/src/devtools/views/Components/NewKeyValue.js
+1
-1
@@ -57,7 +57,7 @@ export default function NewKeyValue({
57
const {id} = inspectedElement;
58
const rendererID = store.getRendererIDForElement(id);
59
if (rendererID !== null) {
60
- let basePath = newPath;
60
+ let basePath: Array<string | number> = newPath;
61
if (hookID != null) {
62
basePath = parseHookPathForEdit(basePath);
63
}
packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js
+5
-1
@@ -49,7 +49,11 @@ const resource: Resource<
49
return request.promise;
50
}
51
52
- let resolveFn = ((null: any): ResolveFn);
52
+ let resolveFn:
53
+ | ResolveFn
54
+ | ((
55
+ result: Promise<Array<SerializedElement>> | Array<SerializedElement>,
56
+ ) => void) = ((null: any): ResolveFn);
57
const promise = new Promise(resolve => {
58
resolveFn = resolve;
59
});
packages/react-devtools-shared/src/devtools/views/Components/SelectedTreeHighlight.js
+2
-1
@@ -7,6 +7,7 @@
7
* @flow
8
*/
9
10
+import type {Element} from './types';
11
import * as React from 'react';
12
import {useContext, useMemo} from 'react';
13
import {TreeStateContext} from './TreeContext';
@@ -53,7 +54,7 @@ export default function SelectedTreeHighlight(_: {}): React.Node {
54
}
55
56
let stopIndex = null;
56
- let current = element;
57
+ let current: null | Element = element;
58
while (current !== null) {
59
if (current.isCollapsed || current.children.length === 0) {
60
// We've found the last/deepest descendant.
packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js
+1
-1
@@ -294,7 +294,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
294
) {
295
const leafElement = store.getElementByID(ownerSubtreeLeafElementID);
296
if (leafElement !== null) {
297
- let currentElement = leafElement;
297
+ let currentElement: null | Element = leafElement;
298
while (currentElement !== null) {
299
if (currentElement.ownerID === selectedElementID) {
300
selectedElementIndex = store.getIndexOfElementID(
packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js
+2
-2
@@ -57,8 +57,8 @@ const TOOLTIP_OFFSET = 5;
57
// Method used to find the position of the tooltip based on current mouse position
58
function getTooltipPosition(element, mousePosition) {
59
const {height, mouseX, mouseY, width} = mousePosition;
60
- let top = 0;
61
- let left = 0;
60
+ let top: number | string = 0;
61
+ let left: number | string = 0;
62
63
if (mouseY + TOOLTIP_OFFSET + element.offsetHeight >= height) {
64
if (mouseY - TOOLTIP_OFFSET - element.offsetHeight > 0) {
packages/react-devtools-shared/src/devtools/views/hooks.js
+1
-1
@@ -238,7 +238,7 @@ export function useModalDismissSignal(
238
// Delay until after the current call stack is empty,
239
// in case this effect is being run while an event is currently bubbling.
240
// In that case, we don't want to listen to the pre-existing event.
241
- let timeoutID = setTimeout(() => {
241
+ let timeoutID: null | TimeoutID = setTimeout(() => {
242
timeoutID = null;
243
244
// It's important to listen to the ownerDocument to support the browser extension.
packages/react-devtools-shared/src/dynamicImportCache.js
+1
-1
@@ -136,7 +136,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module {
136
);
137
138
// Eventually timeout and stop trying to load the module.
139
- let timeoutID = setTimeout(function onTimeout() {
139
+ let timeoutID: null | TimeoutID = setTimeout(function onTimeout() {
140
if (__DEBUG__) {
141
console.log(
142
`[dynamicImportCache] loadModule("${moduleLoaderFunction.name}") onTimeout()`,
packages/react-devtools-shared/src/registerDevToolsEventLogger.js
+1
-1
@@ -13,7 +13,7 @@ import {registerEventLogger} from 'react-devtools-shared/src/Logger';
13
import {enableLogger} from 'react-devtools-feature-flags';
14
15
let loggingIFrame = null;
16
-let missedEvents = [];
16
+let missedEvents: Array<LoggerEvent> = [];
17
18
type LoggerContext = {
19
page_url: ?string,
packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js
+1
@@ -125,6 +125,7 @@ export function useCanvasInteraction(
125
}
126
127
function localToCanvasCoordinates(localCoordinates: Point): Point {
128
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
129
const canvasRect = cacheFirstGetCanvasBoundingRect(canvas);
130
return {
131
x: localCoordinates.x - canvasRect.left,
packages/react-dom-bindings/src/client/ReactDOMFloatClient.js
+1
-1
@@ -595,7 +595,7 @@ function createPreloadResource(
595
const limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(
596
href,
597
);
598
- let element = ownerDocument.querySelector(
598
+ let element: null | Instance | HTMLElement = ownerDocument.querySelector(
599
`link[rel="preload"][href="${limitedEscapedHref}"]`,
600
);
601
if (!element) {
packages/react-dom-bindings/src/client/ReactDOMHostConfig.js
+2
-1
@@ -593,7 +593,7 @@ export function clearSuspenseBoundary(
593
parentInstance: Instance,
594
suspenseInstance: SuspenseInstance,
595
): void {
596
- let node = suspenseInstance;
596
+ let node: Node = suspenseInstance;
597
// Delete all nodes within this suspense boundary.
598
// There might be nested nodes so we need to keep track of how
599
// deep we are and only break out when we're back on top.
@@ -620,6 +620,7 @@ export function clearSuspenseBoundary(
620
depth++;
621
}
622
}
623
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
624
node = nextNode;
625
} while (node);
626
// TODO: Warn, we didn't find the end comment boundary.
packages/react-dom-bindings/src/events/DOMPluginEventSystem.js
+8
-7
@@ -427,7 +427,7 @@ function addTrappedEventListener(
427
);
428
// If passive option is not supported, then the event will be
429
// active and not passive.
430
- let isPassiveListener = undefined;
430
+ let isPassiveListener: void | boolean = undefined;
431
if (passiveBrowserEventsSupported) {
432
// Browsers introduced an intervention, making these events
433
// passive by default on document. React doesn't bind them
@@ -578,7 +578,7 @@ export function dispatchEventForPluginEventSystem(
578
// root boundaries that match that of our current "rootContainer".
579
// If we find that "rootContainer", we find the parent fiber
580
// sub-tree for that root and make that our ancestor instance.
581
- let node = targetInst;
581
+ let node: null | Fiber = targetInst;
582
583
mainLoop: while (true) {
584
if (node === null) {
@@ -823,6 +823,7 @@ function getParent(inst: Fiber | null): Fiber | null {
823
return null;
824
}
825
do {
826
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
827
inst = inst.return;
828
// TODO: If this is a HostRoot we might want to bail out.
829
// That is depending on if we want nested subtrees (layers) to bubble
@@ -841,14 +842,14 @@ function getParent(inst: Fiber | null): Fiber | null {
842
* different trees.
843
*/
844
function getLowestCommonAncestor(instA: Fiber, instB: Fiber): Fiber | null {
844
- let nodeA = instA;
845
- let nodeB = instB;
845
+ let nodeA: null | Fiber = instA;
846
+ let nodeB: null | Fiber = instB;
847
let depthA = 0;
847
- for (let tempA = nodeA; tempA; tempA = getParent(tempA)) {
848
+ for (let tempA: null | Fiber = nodeA; tempA; tempA = getParent(tempA)) {
849
depthA++;
850
}
851
let depthB = 0;
851
- for (let tempB = nodeB; tempB; tempB = getParent(tempB)) {
852
+ for (let tempB: null | Fiber = nodeB; tempB; tempB = getParent(tempB)) {
853
depthB++;
854
}
855
@@ -886,7 +887,7 @@ function accumulateEnterLeaveListenersForEvent(
887
const registrationName = event._reactName;
888
const listeners: Array<DispatchListener> = [];
889
889
- let instance = target;
890
+ let instance: null | Fiber = target;
891
while (instance !== null) {
892
if (instance === common) {
893
break;
packages/react-fs/src/ReactFilesystem.js
+5
@@ -153,6 +153,7 @@ export function lstat(path: string, options?: {bigint?: boolean}): mixed {
153
if (!record) {
154
const thenable = fs.lstat(path, {bigint});
155
record = createRecordFromThenable(thenable);
156
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
157
lstatCache.push(bigint, record);
158
}
159
// $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -203,6 +204,7 @@ export function readdir(
204
if (!record) {
205
const thenable = fs.readdir(path, {encoding, withFileTypes});
206
record = createRecordFromThenable(thenable);
207
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
208
readdirCache.push(encoding, withFileTypes, record);
209
}
210
// $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -302,6 +304,7 @@ export function readlink(
304
if (!record) {
305
const thenable = fs.readlink(path, {encoding});
306
record = createRecordFromThenable(thenable);
307
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
308
readlinkCache.push(encoding, record);
309
}
310
// $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -344,6 +347,7 @@ export function realpath(
347
if (!record) {
348
const thenable = fs.realpath(path, {encoding});
349
record = createRecordFromThenable(thenable);
350
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
351
realpathCache.push(encoding, record);
352
}
353
// $FlowFixMe[incompatible-call] found when upgrading Flow
@@ -379,6 +383,7 @@ export function stat(path: string, options?: {bigint?: boolean}): mixed {
383
if (!record) {
384
const thenable = fs.stat(path, {bigint});
385
record = createRecordFromThenable(thenable);
386
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
387
statCache.push(bigint, record);
388
}
389
// $FlowFixMe[incompatible-call] found when upgrading Flow
packages/react-native-renderer/src/ReactNativeAttributePayload.js
+3
@@ -64,6 +64,7 @@ function restoreDeletedValuesInNestedArray(
64
} else if (node && removedKeyCount > 0) {
65
const obj = node;
66
for (const propKey in removedKeys) {
67
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
68
if (!removedKeys[propKey]) {
69
continue;
70
}
@@ -78,9 +79,11 @@ function restoreDeletedValuesInNestedArray(
79
}
80
81
if (typeof nextProp === 'function') {
82
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
83
nextProp = true;
84
}
85
if (typeof nextProp === 'undefined') {
86
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
87
nextProp = null;
88
}
89
packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js
+1
@@ -42,6 +42,7 @@ function recomputePluginOrdering(): void {
42
}
43
for (const pluginName in namesToPlugins) {
44
const pluginModule = namesToPlugins[pluginName];
45
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
46
const pluginIndex = eventPluginOrder.indexOf(pluginName);
47
48
if (pluginIndex <= -1) {
packages/react-pg/src/ReactPostgres.js
+1
-1
@@ -82,7 +82,7 @@ Pool.prototype.query = function(query: string, values?: Array<mixed>) {
82
const outerMap = unstable_getCacheForType(this.createRecordMap);
83
84
let innerMap: NestedMap = outerMap;
85
- let key = query;
85
+ let key: mixed = query;
86
if (values != null) {
87
// If we have parameters, each becomes as a nesting layer for Maps.
88
// We want to find (or create as needed) the innermost Map, and return that.
packages/react-reconciler/src/ReactChildFiber.new.js
+1
-1
@@ -319,7 +319,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
319
// instead.
320
const existingChildren: Map<string | number, Fiber> = new Map();
321
322
- let existingChild = currentFirstChild;
322
+ let existingChild: null | Fiber = currentFirstChild;
323
while (existingChild !== null) {
324
if (existingChild.key !== null) {
325
existingChildren.set(existingChild.key, existingChild);
packages/react-reconciler/src/ReactChildFiber.old.js
+1
-1
@@ -319,7 +319,7 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
319
// instead.
320
const existingChildren: Map<string | number, Fiber> = new Map();
321
322
- let existingChild = currentFirstChild;
322
+ let existingChild: null | Fiber = currentFirstChild;
323
while (existingChild !== null) {
324
if (existingChild.key !== null) {
325
existingChildren.set(existingChild.key, existingChild);
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+7
@@ -592,6 +592,7 @@ function updateSimpleMemoComponent(
592
try {
593
outerMemoType = init(payload);
594
} catch (x) {
595
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
596
outerMemoType = null;
597
}
598
// Inner propTypes will be validated in the function component path.
@@ -2990,12 +2991,15 @@ function propagateSuspenseContextChange(
2991
if (node === workInProgress) {
2992
return;
2993
}
2994
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
2995
while (node.sibling === null) {
2996
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
2997
if (node.return === null || node.return === workInProgress) {
2998
return;
2999
}
3000
node = node.return;
3001
}
3002
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3003
node.sibling.return = node.return;
3004
node = node.sibling;
3005
}
@@ -3596,13 +3600,16 @@ function remountFiber(
3600
// eslint-disable-next-line react-internal/prod-error-codes
3601
throw new Error('Expected parent to have a child.');
3602
}
3603
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3604
while (prevSibling.sibling !== oldWorkInProgress) {
3605
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3606
prevSibling = prevSibling.sibling;
3607
if (prevSibling === null) {
3608
// eslint-disable-next-line react-internal/prod-error-codes
3609
throw new Error('Expected to find the previous sibling.');
3610
}
3611
}
3612
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3613
prevSibling.sibling = newWorkInProgress;
3614
}
3615
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+7
@@ -592,6 +592,7 @@ function updateSimpleMemoComponent(
592
try {
593
outerMemoType = init(payload);
594
} catch (x) {
595
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
596
outerMemoType = null;
597
}
598
// Inner propTypes will be validated in the function component path.
@@ -2990,12 +2991,15 @@ function propagateSuspenseContextChange(
2991
if (node === workInProgress) {
2992
return;
2993
}
2994
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
2995
while (node.sibling === null) {
2996
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
2997
if (node.return === null || node.return === workInProgress) {
2998
return;
2999
}
3000
node = node.return;
3001
}
3002
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3003
node.sibling.return = node.return;
3004
node = node.sibling;
3005
}
@@ -3596,13 +3600,16 @@ function remountFiber(
3600
// eslint-disable-next-line react-internal/prod-error-codes
3601
throw new Error('Expected parent to have a child.');
3602
}
3603
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3604
while (prevSibling.sibling !== oldWorkInProgress) {
3605
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3606
prevSibling = prevSibling.sibling;
3607
if (prevSibling === null) {
3608
// eslint-disable-next-line react-internal/prod-error-codes
3609
throw new Error('Expected to find the previous sibling.');
3610
}
3611
}
3612
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3613
prevSibling.sibling = newWorkInProgress;
3614
}
3615
packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js
+4
-2
@@ -325,7 +325,7 @@ export function enqueueCapturedUpdate<State>(
325
const firstBaseUpdate = queue.firstBaseUpdate;
326
if (firstBaseUpdate !== null) {
327
// Loop through the updates and clone them.
328
- let update = firstBaseUpdate;
328
+ let update: Update<State> = firstBaseUpdate;
329
do {
330
const clone: Update<State> = {
331
eventTime: update.eventTime,
@@ -345,6 +345,7 @@ export function enqueueCapturedUpdate<State>(
345
newLast.next = clone;
346
newLast = clone;
347
}
348
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
349
update = update.next;
350
} while (update !== null);
351
@@ -534,7 +535,7 @@ export function processUpdateQueue<State>(
535
let newFirstBaseUpdate = null;
536
let newLastBaseUpdate = null;
537
537
- let update = firstBaseUpdate;
538
+ let update: Update<State> = firstBaseUpdate;
539
do {
540
// TODO: Don't need this field anymore
541
const updateEventTime = update.eventTime;
@@ -620,6 +621,7 @@ export function processUpdateQueue<State>(
621
}
622
}
623
}
624
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
625
update = update.next;
626
if (update === null) {
627
pendingQueue = queue.shared.pending;
packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js
+4
-2
@@ -325,7 +325,7 @@ export function enqueueCapturedUpdate<State>(
325
const firstBaseUpdate = queue.firstBaseUpdate;
326
if (firstBaseUpdate !== null) {
327
// Loop through the updates and clone them.
328
- let update = firstBaseUpdate;
328
+ let update: Update<State> = firstBaseUpdate;
329
do {
330
const clone: Update<State> = {
331
eventTime: update.eventTime,
@@ -345,6 +345,7 @@ export function enqueueCapturedUpdate<State>(
345
newLast.next = clone;
346
newLast = clone;
347
}
348
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
349
update = update.next;
350
} while (update !== null);
351
@@ -534,7 +535,7 @@ export function processUpdateQueue<State>(
535
let newFirstBaseUpdate = null;
536
let newLastBaseUpdate = null;
537
537
- let update = firstBaseUpdate;
538
+ let update: Update<State> = firstBaseUpdate;
539
do {
540
// TODO: Don't need this field anymore
541
const updateEventTime = update.eventTime;
@@ -620,6 +621,7 @@ export function processUpdateQueue<State>(
621
}
622
}
623
}
624
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
625
update = update.next;
626
if (update === null) {
627
pendingQueue = queue.shared.pending;
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+9
-3
@@ -1316,7 +1316,7 @@ function abortParentMarkerTransitionsForDeletedFiber(
1316
if (enableTransitionTracing) {
1317
// Find all pending markers that are waiting on child suspense boundaries in the
1318
// aborted subtree and cancels them
1319
- let fiber = abortedFiber;
1319
+ let fiber: null | Fiber = abortedFiber;
1320
while (fiber !== null) {
1321
switch (fiber.tag) {
1322
case TracingMarkerComponent:
@@ -1785,6 +1785,7 @@ function getHostSibling(fiber: Fiber): ?Instance {
1785
// last sibling.
1786
return null;
1787
}
1788
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
1789
node = node.return;
1790
}
1791
node.sibling.return = node.return;
@@ -1951,7 +1952,7 @@ function commitDeletionEffects(
1952
// TODO: Instead of searching up the fiber return path on every deletion, we
1953
// can track the nearest host component on the JS stack as we traverse the
1954
// tree during the commit phase. This would make insertions faster, too.
1954
- let parent = returnFiber;
1955
+ let parent: null | Fiber = returnFiber;
1956
findParent: while (parent !== null) {
1957
switch (parent.tag) {
1958
case HostComponent: {
@@ -2332,7 +2333,10 @@ function getRetryCache(finishedWork) {
2333
}
2334
case OffscreenComponent: {
2335
const instance: OffscreenInstance = finishedWork.stateNode;
2335
- let retryCache = instance._retryCache;
2336
+ // $FlowFixMe[incompatible-type-arg] found when upgrading Flow
2337
+ let retryCache: null | Set<Wakeable> | WeakSet<Wakeable> =
2338
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
2339
+ instance._retryCache;
2340
if (retryCache === null) {
2341
// $FlowFixMe[incompatible-type]
2342
retryCache = instance._retryCache = new PossiblyWeakSet();
@@ -3818,7 +3822,9 @@ function detachAlternateSiblings(parentFiber: Fiber) {
3822
if (detachedChild !== null) {
3823
previousFiber.child = null;
3824
do {
3825
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3826
const detachedSibling = detachedChild.sibling;
3827
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3828
detachedChild.sibling = null;
3829
detachedChild = detachedSibling;
3830
} while (detachedChild !== null);
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+9
-3
@@ -1316,7 +1316,7 @@ function abortParentMarkerTransitionsForDeletedFiber(
1316
if (enableTransitionTracing) {
1317
// Find all pending markers that are waiting on child suspense boundaries in the
1318
// aborted subtree and cancels them
1319
- let fiber = abortedFiber;
1319
+ let fiber: null | Fiber = abortedFiber;
1320
while (fiber !== null) {
1321
switch (fiber.tag) {
1322
case TracingMarkerComponent:
@@ -1785,6 +1785,7 @@ function getHostSibling(fiber: Fiber): ?Instance {
1785
// last sibling.
1786
return null;
1787
}
1788
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
1789
node = node.return;
1790
}
1791
node.sibling.return = node.return;
@@ -1951,7 +1952,7 @@ function commitDeletionEffects(
1952
// TODO: Instead of searching up the fiber return path on every deletion, we
1953
// can track the nearest host component on the JS stack as we traverse the
1954
// tree during the commit phase. This would make insertions faster, too.
1954
- let parent = returnFiber;
1955
+ let parent: null | Fiber = returnFiber;
1956
findParent: while (parent !== null) {
1957
switch (parent.tag) {
1958
case HostComponent: {
@@ -2332,7 +2333,10 @@ function getRetryCache(finishedWork) {
2333
}
2334
case OffscreenComponent: {
2335
const instance: OffscreenInstance = finishedWork.stateNode;
2335
- let retryCache = instance._retryCache;
2336
+ // $FlowFixMe[incompatible-type-arg] found when upgrading Flow
2337
+ let retryCache: null | Set<Wakeable> | WeakSet<Wakeable> =
2338
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
2339
+ instance._retryCache;
2340
if (retryCache === null) {
2341
// $FlowFixMe[incompatible-type]
2342
retryCache = instance._retryCache = new PossiblyWeakSet();
@@ -3818,7 +3822,9 @@ function detachAlternateSiblings(parentFiber: Fiber) {
3822
if (detachedChild !== null) {
3823
previousFiber.child = null;
3824
do {
3825
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3826
const detachedSibling = detachedChild.sibling;
3827
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3828
detachedChild.sibling = null;
3829
detachedChild = detachedSibling;
3830
} while (detachedChild !== null);
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+9
@@ -239,12 +239,15 @@ if (supportsMutation) {
239
if (node === workInProgress) {
240
return;
241
}
242
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
243
while (node.sibling === null) {
244
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
245
if (node.return === null || node.return === workInProgress) {
246
return;
247
}
248
node = node.return;
249
}
250
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
251
node.sibling.return = node.return;
252
node = node.sibling;
253
}
@@ -359,12 +362,15 @@ if (supportsMutation) {
362
if (node === workInProgress) {
363
return;
364
}
365
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
366
while (node.sibling === null) {
367
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
368
if (node.return === null || node.return === workInProgress) {
369
return;
370
}
371
node = node.return;
372
}
373
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
374
node.sibling.return = node.return;
375
node = node.sibling;
376
}
@@ -424,12 +430,15 @@ if (supportsMutation) {
430
if (node === workInProgress) {
431
return;
432
}
433
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
434
while (node.sibling === null) {
435
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
436
if (node.return === null || node.return === workInProgress) {
437
return;
438
}
439
node = node.return;
440
}
441
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
442
node.sibling.return = node.return;
443
node = node.sibling;
444
}
packages/react-reconciler/src/ReactFiberCompleteWork.old.js
+9
@@ -239,12 +239,15 @@ if (supportsMutation) {
239
if (node === workInProgress) {
240
return;
241
}
242
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
243
while (node.sibling === null) {
244
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
245
if (node.return === null || node.return === workInProgress) {
246
return;
247
}
248
node = node.return;
249
}
250
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
251
node.sibling.return = node.return;
252
node = node.sibling;
253
}
@@ -359,12 +362,15 @@ if (supportsMutation) {
362
if (node === workInProgress) {
363
return;
364
}
365
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
366
while (node.sibling === null) {
367
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
368
if (node.return === null || node.return === workInProgress) {
369
return;
370
}
371
node = node.return;
372
}
373
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
374
node.sibling.return = node.return;
375
node = node.sibling;
376
}
@@ -424,12 +430,15 @@ if (supportsMutation) {
430
if (node === workInProgress) {
431
return;
432
}
433
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
434
while (node.sibling === null) {
435
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
436
if (node.return === null || node.return === workInProgress) {
437
return;
438
}
439
node = node.return;
440
}
441
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
442
node.sibling.return = node.return;
443
node = node.sibling;
444
}
packages/react-reconciler/src/ReactFiberComponentStack.js
+2
-1
@@ -60,9 +60,10 @@ function describeFiber(fiber: Fiber): string {
60
export function getStackByFiberInDevAndProd(workInProgress: Fiber): string {
61
try {
62
let info = '';
63
- let node = workInProgress;
63
+ let node: Fiber = workInProgress;
64
do {
65
info += describeFiber(node);
66
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
67
node = node.return;
68
} while (node);
69
return info;
packages/react-reconciler/src/ReactFiberContext.new.js
+2
-1
@@ -303,7 +303,7 @@ function findCurrentUnmaskedContext(fiber: Fiber): Object {
303
);
304
}
305
306
- let node = fiber;
306
+ let node: Fiber = fiber;
307
do {
308
switch (node.tag) {
309
case HostRoot:
@@ -316,6 +316,7 @@ function findCurrentUnmaskedContext(fiber: Fiber): Object {
316
break;
317
}
318
}
319
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
320
node = node.return;
321
} while (node !== null);
322
packages/react-reconciler/src/ReactFiberContext.old.js
+2
-1
@@ -303,7 +303,7 @@ function findCurrentUnmaskedContext(fiber: Fiber): Object {
303
);
304
}
305
306
- let node = fiber;
306
+ let node: Fiber = fiber;
307
do {
308
switch (node.tag) {
309
case HostRoot:
@@ -316,6 +316,7 @@ function findCurrentUnmaskedContext(fiber: Fiber): Object {
316
break;
317
}
318
}
319
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
320
node = node.return;
321
} while (node !== null);
322
packages/react-reconciler/src/ReactFiberHooks.new.js
+2
@@ -387,7 +387,9 @@ function areHookInputsEqual(
387
);
388
}
389
}
390
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
391
for (let i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
392
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
393
if (is(nextDeps[i], prevDeps[i])) {
394
continue;
395
}
packages/react-reconciler/src/ReactFiberHooks.old.js
+2
@@ -387,7 +387,9 @@ function areHookInputsEqual(
387
);
388
}
389
}
390
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
391
for (let i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
392
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
393
if (is(nextDeps[i], prevDeps[i])) {
394
continue;
395
}
packages/react-reconciler/src/ReactFiberHotReloading.new.js
+1
@@ -303,6 +303,7 @@ function scheduleFibersWithFamiliesRecursively(
303
if (failedBoundaries !== null) {
304
if (
305
failedBoundaries.has(fiber) ||
306
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
307
(alternate !== null && failedBoundaries.has(alternate))
308
) {
309
needsRemount = true;
packages/react-reconciler/src/ReactFiberHotReloading.old.js
+1
@@ -303,6 +303,7 @@ function scheduleFibersWithFamiliesRecursively(
303
if (failedBoundaries !== null) {
304
if (
305
failedBoundaries.has(fiber) ||
306
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
307
(alternate !== null && failedBoundaries.has(alternate))
308
) {
309
needsRemount = true;
packages/react-reconciler/src/ReactFiberNewContext.new.js
+1
-1
@@ -525,7 +525,7 @@ function propagateParentContextChanges(
525
// Collect all the parent providers that changed. Since this is usually small
526
// number, we use an Array instead of Set.
527
let contexts = null;
528
- let parent = workInProgress;
528
+ let parent: null | Fiber = workInProgress;
529
let isInsidePropagationBailout = false;
530
while (parent !== null) {
531
if (!isInsidePropagationBailout) {
packages/react-reconciler/src/ReactFiberNewContext.old.js
+1
-1
@@ -525,7 +525,7 @@ function propagateParentContextChanges(
525
// Collect all the parent providers that changed. Since this is usually small
526
// number, we use an Array instead of Set.
527
let contexts = null;
528
- let parent = workInProgress;
528
+ let parent: null | Fiber = workInProgress;
529
let isInsidePropagationBailout = false;
530
while (parent !== null) {
531
if (!isInsidePropagationBailout) {
packages/react-reconciler/src/ReactFiberReconciler.new.js
+1
-1
@@ -525,7 +525,7 @@ export function findHostInstanceWithNoPortals(
525
return hostFiber.stateNode;
526
}
527
528
-let shouldErrorImpl = fiber => null;
528
+let shouldErrorImpl: Fiber => ?boolean = fiber => null;
529
530
export function shouldError(fiber: Fiber): ?boolean {
531
return shouldErrorImpl(fiber);
packages/react-reconciler/src/ReactFiberReconciler.old.js
+1
-1
@@ -525,7 +525,7 @@ export function findHostInstanceWithNoPortals(
525
return hostFiber.stateNode;
526
}
527
528
-let shouldErrorImpl = fiber => null;
528
+let shouldErrorImpl: Fiber => ?boolean = fiber => null;
529
530
export function shouldError(fiber: Fiber): ?boolean {
531
return shouldErrorImpl(fiber);
packages/react-reconciler/src/ReactFiberScope.new.js
+2
-2
@@ -86,7 +86,7 @@ function collectScopedNodesFromChildren(
86
fn: ReactScopeQuery,
87
scopedNodes: Array<any>,
88
): void {
89
- let child = startingChild;
89
+ let child: null | Fiber = startingChild;
90
while (child !== null) {
91
collectScopedNodes(child, fn, scopedNodes);
92
child = child.sibling;
@@ -97,7 +97,7 @@ function collectFirstScopedNodeFromChildren(
97
startingChild: Fiber,
98
fn: ReactScopeQuery,
99
): Object | null {
100
- let child = startingChild;
100
+ let child: null | Fiber = startingChild;
101
while (child !== null) {
102
const scopedNode = collectFirstScopedNode(child, fn);
103
if (scopedNode !== null) {
packages/react-reconciler/src/ReactFiberScope.old.js
+2
-2
@@ -86,7 +86,7 @@ function collectScopedNodesFromChildren(
86
fn: ReactScopeQuery,
87
scopedNodes: Array<any>,
88
): void {
89
- let child = startingChild;
89
+ let child: null | Fiber = startingChild;
90
while (child !== null) {
91
collectScopedNodes(child, fn, scopedNodes);
92
child = child.sibling;
@@ -97,7 +97,7 @@ function collectFirstScopedNodeFromChildren(
97
startingChild: Fiber,
98
fn: ReactScopeQuery,
99
): Object | null {
100
- let child = startingChild;
100
+ let child: null | Fiber = startingChild;
101
while (child !== null) {
102
const scopedNode = collectFirstScopedNode(child, fn);
103
if (scopedNode !== null) {
packages/react-reconciler/src/ReactFiberSyncTaskQueue.new.js
+2
-1
@@ -63,8 +63,9 @@ export function flushSyncCallbacks(): null {
63
// $FlowFixMe[incompatible-use] found when upgrading Flow
64
for (; i < queue.length; i++) {
65
// $FlowFixMe[incompatible-use] found when upgrading Flow
66
- let callback = queue[i];
66
+ let callback: SchedulerCallback = queue[i];
67
do {
68
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
69
callback = callback(isSync);
70
} while (callback !== null);
71
}
packages/react-reconciler/src/ReactFiberSyncTaskQueue.old.js
+2
-1
@@ -63,8 +63,9 @@ export function flushSyncCallbacks(): null {
63
// $FlowFixMe[incompatible-use] found when upgrading Flow
64
for (; i < queue.length; i++) {
65
// $FlowFixMe[incompatible-use] found when upgrading Flow
66
- let callback = queue[i];
66
+ let callback: SchedulerCallback = queue[i];
67
do {
68
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
69
callback = callback(isSync);
70
} while (callback !== null);
71
}
packages/react-reconciler/src/ReactFiberThrow.new.js
+2
-1
@@ -488,7 +488,7 @@ function throwException(
488
// We didn't find a boundary that could handle this type of exception. Start
489
// over and traverse parent path again, this time treating the exception
490
// as an error.
491
- let workInProgress = returnFiber;
491
+ let workInProgress: Fiber = returnFiber;
492
do {
493
switch (workInProgress.tag) {
494
case HostRoot: {
@@ -528,6 +528,7 @@ function throwException(
528
default:
529
break;
530
}
531
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
532
workInProgress = workInProgress.return;
533
} while (workInProgress !== null);
534
}
packages/react-reconciler/src/ReactFiberThrow.old.js
+2
-1
@@ -488,7 +488,7 @@ function throwException(
488
// We didn't find a boundary that could handle this type of exception. Start
489
// over and traverse parent path again, this time treating the exception
490
// as an error.
491
- let workInProgress = returnFiber;
491
+ let workInProgress: Fiber = returnFiber;
492
do {
493
switch (workInProgress.tag) {
494
case HostRoot: {
@@ -528,6 +528,7 @@ function throwException(
528
default:
529
break;
530
}
531
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
532
workInProgress = workInProgress.return;
533
} while (workInProgress !== null);
534
}
packages/react-reconciler/src/ReactFiberTreeReflection.js
+4
-3
@@ -30,11 +30,11 @@ const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
30
31
export function getNearestMountedFiber(fiber: Fiber): null | Fiber {
32
let node = fiber;
33
- let nearestMounted = fiber;
33
+ let nearestMounted: null | Fiber = fiber;
34
if (!fiber.alternate) {
35
// If there is no alternate, this might be a new tree that isn't inserted
36
// yet. If it is, then it will have a pending insertion effect on it.
37
- let nextNode = node;
37
+ let nextNode: Fiber = node;
38
do {
39
node = nextNode;
40
if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
@@ -43,6 +43,7 @@ export function getNearestMountedFiber(fiber: Fiber): null | Fiber {
43
// if that one is still mounted.
44
nearestMounted = node.return;
45
}
46
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
47
nextNode = node.return;
48
} while (nextNode);
49
} else {
@@ -339,7 +340,7 @@ export function doesFiberContain(
340
parentFiber: Fiber,
341
childFiber: Fiber,
342
): boolean {
342
- let node = childFiber;
343
+ let node: null | Fiber = childFiber;
344
const parentFiberAlternate = parentFiber.alternate;
345
while (node !== null) {
346
if (node === parentFiber || node === parentFiberAlternate) {
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+5
-3
@@ -742,7 +742,7 @@ export function scheduleUpdateOnFiber(
742
root === rootCommittingMutationOrLayoutEffects
743
) {
744
if (fiber.mode & ProfileMode) {
745
- let current = fiber;
745
+ let current: null | Fiber = fiber;
746
while (current !== null) {
747
if (current.tag === Profiler) {
748
const {id, onNestedUpdateScheduled} = current.memoizedProps;
@@ -2195,7 +2195,7 @@ function resumeSuspendedUnitOfWork(
2195
function completeUnitOfWork(unitOfWork: Fiber): void {
2196
// Attempt to complete the current unit of work, then move to the next
2197
// sibling. If there are no more siblings, return to the parent fiber.
2198
- let completedWork = unitOfWork;
2198
+ let completedWork: Fiber = unitOfWork;
2199
do {
2200
// The current, flushed, state of this fiber is the alternate. Ideally
2201
// nothing should rely on this, but relying on it here means that we don't
@@ -2281,6 +2281,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
2281
return;
2282
}
2283
// Otherwise, return to the parent
2284
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
2285
completedWork = returnFiber;
2286
// Update the next thing we're working on in case something throws.
2287
workInProgress = completedWork;
@@ -3388,7 +3389,7 @@ function invokeEffectsInDev(
3389
fiberFlags: Flags,
3390
invokeEffectFn: (fiber: Fiber) => void,
3391
) {
3391
- let current = firstChild;
3392
+ let current: null | Fiber = firstChild;
3393
let subtreeRoot = null;
3394
while (current != null) {
3395
const primarySubtreeFlag = current.subtreeFlags & fiberFlags;
@@ -3445,6 +3446,7 @@ export function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber: Fiber) {
3446
if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
3447
return;
3448
}
3449
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3450
didWarnStateUpdateForNotYetMountedComponent.add(componentName);
3451
} else {
3452
didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+5
-3
@@ -742,7 +742,7 @@ export function scheduleUpdateOnFiber(
742
root === rootCommittingMutationOrLayoutEffects
743
) {
744
if (fiber.mode & ProfileMode) {
745
- let current = fiber;
745
+ let current: null | Fiber = fiber;
746
while (current !== null) {
747
if (current.tag === Profiler) {
748
const {id, onNestedUpdateScheduled} = current.memoizedProps;
@@ -2195,7 +2195,7 @@ function resumeSuspendedUnitOfWork(
2195
function completeUnitOfWork(unitOfWork: Fiber): void {
2196
// Attempt to complete the current unit of work, then move to the next
2197
// sibling. If there are no more siblings, return to the parent fiber.
2198
- let completedWork = unitOfWork;
2198
+ let completedWork: Fiber = unitOfWork;
2199
do {
2200
// The current, flushed, state of this fiber is the alternate. Ideally
2201
// nothing should rely on this, but relying on it here means that we don't
@@ -2281,6 +2281,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
2281
return;
2282
}
2283
// Otherwise, return to the parent
2284
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
2285
completedWork = returnFiber;
2286
// Update the next thing we're working on in case something throws.
2287
workInProgress = completedWork;
@@ -3388,7 +3389,7 @@ function invokeEffectsInDev(
3389
fiberFlags: Flags,
3390
invokeEffectFn: (fiber: Fiber) => void,
3391
) {
3391
- let current = firstChild;
3392
+ let current: null | Fiber = firstChild;
3393
let subtreeRoot = null;
3394
while (current != null) {
3395
const primarySubtreeFlag = current.subtreeFlags & fiberFlags;
@@ -3445,6 +3446,7 @@ export function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber: Fiber) {
3446
if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
3447
return;
3448
}
3449
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
3450
didWarnStateUpdateForNotYetMountedComponent.add(componentName);
3451
} else {
3452
didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
packages/react-reconciler/src/ReactPostPaintCallback.js
+1
-1
@@ -9,7 +9,7 @@
9
import {requestPostPaintCallback} from './ReactFiberHostConfig';
10
11
let postPaintCallbackScheduled = false;
12
-let callbacks = [];
12
+let callbacks: Array<any | ((endTime: number) => void)> = [];
13
14
export function schedulePostPaintCallback(callback: (endTime: number) => void) {
15
callbacks.push(callback);
packages/react-reconciler/src/ReactStrictModeWarnings.new.js
+1
-1
@@ -31,7 +31,7 @@ if (__DEV__) {
31
const findStrictRoot = (fiber: Fiber): Fiber | null => {
32
let maybeStrictRoot = null;
33
34
- let node = fiber;
34
+ let node: null | Fiber = fiber;
35
while (node !== null) {
36
if (node.mode & StrictLegacyMode) {
37
maybeStrictRoot = node;
packages/react-reconciler/src/ReactStrictModeWarnings.old.js
+1
-1
@@ -31,7 +31,7 @@ if (__DEV__) {
31
const findStrictRoot = (fiber: Fiber): Fiber | null => {
32
let maybeStrictRoot = null;
33
34
- let node = fiber;
34
+ let node: null | Fiber = fiber;
35
while (node !== null) {
36
if (node.mode & StrictLegacyMode) {
37
maybeStrictRoot = node;
packages/react-reconciler/src/ReactTestSelectors.js
+5
-5
@@ -28,11 +28,11 @@ import {
28
supportsTestSelectors,
29
} from './ReactFiberHostConfig';
30
31
-let COMPONENT_TYPE = 0b000;
32
-let HAS_PSEUDO_CLASS_TYPE = 0b001;
33
-let ROLE_TYPE = 0b010;
34
-let TEST_NAME_TYPE = 0b011;
35
-let TEXT_TYPE = 0b100;
31
+let COMPONENT_TYPE: symbol | number = 0b000;
32
+let HAS_PSEUDO_CLASS_TYPE: symbol | number = 0b001;
33
+let ROLE_TYPE: symbol | number = 0b010;
34
+let TEST_NAME_TYPE: symbol | number = 0b011;
35
+let TEXT_TYPE: symbol | number = 0b100;
36
37
if (typeof Symbol === 'function' && Symbol.for) {
38
const symbolFor = Symbol.for;
packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js
+1
@@ -88,6 +88,7 @@ export default class ReactFlightWebpackPlugin {
88
) {
89
this.clientReferences = [(options.clientReferences: $FlowFixMe)];
90
} else {
91
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
92
this.clientReferences = options.clientReferences;
93
}
94
if (typeof options.chunkName === 'string') {
packages/react-server/src/ReactFizzComponentStack.js
+2
-1
@@ -39,7 +39,7 @@ export function getStackByComponentStackNode(
39
): string {
40
try {
41
let info = '';
42
- let node = componentStack;
42
+ let node: ComponentStackNode = componentStack;
43
do {
44
switch (node.tag) {
45
case 0:
@@ -52,6 +52,7 @@ export function getStackByComponentStackNode(
52
info += describeClassComponentFrame(node.type, null, null);
53
break;
54
}
55
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
56
node = node.parent;
57
} while (node);
58
return info;
packages/react-server/src/ReactFizzHooks.js
+5
-1
@@ -147,7 +147,9 @@ function areHookInputsEqual(
147
);
148
}
149
}
150
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
151
for (let i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
152
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
153
if (is(nextDeps[i], prevDeps[i])) {
154
continue;
155
}
@@ -344,7 +346,7 @@ export function useReducer<S, I, A>(
346
renderPhaseUpdates.delete(queue);
347
// $FlowFixMe[incompatible-use] found when upgrading Flow
348
let newState = workInProgressHook.memoizedState;
347
- let update = firstRenderPhaseUpdate;
349
+ let update: Update<any> = firstRenderPhaseUpdate;
350
do {
351
// Process this render phase update. We don't have to check the
352
// priority because it will always be the same as the current
@@ -357,6 +359,7 @@ export function useReducer<S, I, A>(
359
if (__DEV__) {
360
isInHookUserCodeInDev = false;
361
}
362
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
363
update = update.next;
364
} while (update !== null);
365
@@ -442,6 +445,7 @@ function useRef<T>(initialValue: T): {current: T} {
445
if (__DEV__) {
446
Object.seal(ref);
447
}
448
+ // $FlowFixMe[incompatible-use] found when upgrading Flow
449
workInProgressHook.memoizedState = ref;
450
return ref;
451
} else {
packages/react-test-renderer/src/ReactTestRenderer.js
+2
@@ -468,6 +468,7 @@ function create(
468
let concurrentUpdatesByDefault = null;
469
if (typeof options === 'object' && options !== null) {
470
if (typeof options.createNodeMock === 'function') {
471
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
472
createNodeMock = options.createNodeMock;
473
}
474
if (options.unstable_isConcurrent === true) {
@@ -561,6 +562,7 @@ function create(
562
return;
563
}
564
updateContainer(null, root, null, null);
565
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
566
container = null;
567
root = null;
568
},
packages/react/src/ReactAct.js
+1
@@ -207,6 +207,7 @@ function flushActQueue(queue) {
207
for (; i < queue.length; i++) {
208
let callback = queue[i];
209
do {
210
+ // $FlowFixMe[incompatible-type] found when upgrading Flow
211
callback = callback(true);
212
} while (callback !== null);
213
}
packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
+1
-1
@@ -43,7 +43,7 @@ export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
43
// copies of the hook/component.
44
let hasMemo = false;
45
let memoizedSnapshot;
46
- let memoizedSelection;
46
+ let memoizedSelection: Selection;
47
const memoizedSelector = nextSnapshot => {
48
if (!hasMemo) {
49
// The first time the hook is called, there is no memoized result.
scripts/flow/config/flowconfig
-1
@@ -43,7 +43,6 @@ untyped-type-import=error
43
%CI_MAX_WORKERS%
44
exact_by_default=true
45
munge_underscores=false
46
-inference_mode=classic
46
47
# Substituted by createFlowConfig.js:
48
%REACT_RENDERER_FLOW_OPTIONS%