Skip to content

Commit 64fe791

Browse files
committed
Flow upgrade to 0.146
This upgrade made more expressions invalidate refinements. In some places this lead to a large number of suppressions that I automatically suppressed and should be followed up on when the code is touched. I think most of them might require either manual annotations or moving a value into a const to allow refinement. ghstack-source-id: a45b40a Pull Request resolved: #25410
1 parent d3c6c16 commit 64fe791

33 files changed

+138
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
6464
"fbjs-scripts": "1.2.0",
6565
"filesize": "^6.0.1",
66-
"flow-bin": "^0.145.0",
66+
"flow-bin": "^0.146.0",
6767
"glob": "^7.1.6",
6868
"glob-stream": "^6.1.0",
6969
"google-closure-compiler": "^20200517.0.0",

packages/react-devtools-core/src/editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export function launchEditor(
186186
childProcess = spawn(editor, args, {stdio: 'inherit'});
187187
}
188188
childProcess.on('error', function() {});
189+
// $FlowFixMe[incompatible-use] found when upgrading Flow
189190
childProcess.on('exit', function(errorCode) {
190191
childProcess = null;
191192
});

packages/react-devtools-shared/src/backend/profilingHooks.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ export function createProfilingHooks({
350350
);
351351
}
352352

353+
// $FlowFixMe[incompatible-use] found when upgrading Flow
353354
currentReactComponentMeasure.duration =
355+
// $FlowFixMe[incompatible-use] found when upgrading Flow
354356
getRelativeTime() - currentReactComponentMeasure.timestamp;
355357
currentReactComponentMeasure = null;
356358
}
@@ -393,7 +395,9 @@ export function createProfilingHooks({
393395
);
394396
}
395397

398+
// $FlowFixMe[incompatible-use] found when upgrading Flow
396399
currentReactComponentMeasure.duration =
400+
// $FlowFixMe[incompatible-use] found when upgrading Flow
397401
getRelativeTime() - currentReactComponentMeasure.timestamp;
398402
currentReactComponentMeasure = null;
399403
}
@@ -438,7 +442,9 @@ export function createProfilingHooks({
438442
);
439443
}
440444

445+
// $FlowFixMe[incompatible-use] found when upgrading Flow
441446
currentReactComponentMeasure.duration =
447+
// $FlowFixMe[incompatible-use] found when upgrading Flow
442448
getRelativeTime() - currentReactComponentMeasure.timestamp;
443449
currentReactComponentMeasure = null;
444450
}
@@ -481,7 +487,9 @@ export function createProfilingHooks({
481487
);
482488
}
483489

490+
// $FlowFixMe[incompatible-use] found when upgrading Flow
484491
currentReactComponentMeasure.duration =
492+
// $FlowFixMe[incompatible-use] found when upgrading Flow
485493
getRelativeTime() - currentReactComponentMeasure.timestamp;
486494
currentReactComponentMeasure = null;
487495
}
@@ -526,7 +534,9 @@ export function createProfilingHooks({
526534
);
527535
}
528536

537+
// $FlowFixMe[incompatible-use] found when upgrading Flow
529538
currentReactComponentMeasure.duration =
539+
// $FlowFixMe[incompatible-use] found when upgrading Flow
530540
getRelativeTime() - currentReactComponentMeasure.timestamp;
531541
currentReactComponentMeasure = null;
532542
}

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ export function attach(
13101310
const id = getFiberIDThrows(fiber);
13111311
const contexts = getContextsForFiber(fiber);
13121312
if (contexts !== null) {
1313+
// $FlowFixMe[incompatible-use] found when upgrading Flow
13131314
idToContextsMap.set(id, contexts);
13141315
}
13151316
}
@@ -1380,8 +1381,10 @@ export function attach(
13801381
function getContextChangedKeys(fiber: Fiber): null | boolean | Array<string> {
13811382
if (idToContextsMap !== null) {
13821383
const id = getFiberIDThrows(fiber);
1384+
// $FlowFixMe[incompatible-use] found when upgrading Flow
13831385
const prevContexts = idToContextsMap.has(id)
1384-
? idToContextsMap.get(id)
1386+
? // $FlowFixMe[incompatible-use] found when upgrading Flow
1387+
idToContextsMap.get(id)
13851388
: null;
13861389
const nextContexts = getContextsForFiber(fiber);
13871390

@@ -2636,7 +2639,9 @@ export function attach(
26362639
const {effectDuration, passiveEffectDuration} = getEffectDurations(
26372640
root,
26382641
);
2642+
// $FlowFixMe[incompatible-use] found when upgrading Flow
26392643
currentCommitProfilingMetadata.effectDuration = effectDuration;
2644+
// $FlowFixMe[incompatible-use] found when upgrading Flow
26402645
currentCommitProfilingMetadata.passiveEffectDuration = passiveEffectDuration;
26412646
}
26422647
}
@@ -3702,6 +3707,7 @@ export function attach(
37023707
id,
37033708
responseID: requestID,
37043709
type: 'full-data',
3710+
// $FlowFixMe[incompatible-return] found when upgrading Flow
37053711
value: cleanedInspectedElement,
37063712
};
37073713
}
@@ -4276,6 +4282,7 @@ export function attach(
42764282
) {
42774283
// Is this the next Fiber we should select? Let's compare the frames.
42784284
const actualFrame = getPathFrame(fiber);
4285+
// $FlowFixMe[incompatible-use] found when upgrading Flow
42794286
const expectedFrame = trackedPath[trackedPathMatchDepth + 1];
42804287
if (expectedFrame === undefined) {
42814288
throw new Error('Expected to see a frame at the next depth.');
@@ -4289,6 +4296,7 @@ export function attach(
42894296
trackedPathMatchFiber = fiber;
42904297
trackedPathMatchDepth++;
42914298
// Are we out of frames to match?
4299+
// $FlowFixMe[incompatible-use] found when upgrading Flow
42924300
if (trackedPathMatchDepth === trackedPath.length - 1) {
42934301
// There's nothing that can possibly match afterwards.
42944302
// Don't check the children.
@@ -4443,6 +4451,7 @@ export function attach(
44434451
}
44444452
return {
44454453
id: getFiberIDThrows(fiber),
4454+
// $FlowFixMe[incompatible-use] found when upgrading Flow
44464455
isFullMatch: trackedPathMatchDepth === trackedPath.length - 1,
44474456
};
44484457
}

packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const resource: Resource<
4545
(element: Element) => {
4646
const request = inProgressRequests.get(element);
4747
if (request != null) {
48+
// $FlowFixMe[incompatible-call] found when upgrading Flow
4849
return request.promise;
4950
}
5051

@@ -53,6 +54,7 @@ const resource: Resource<
5354
resolveFn = resolve;
5455
});
5556

57+
// $FlowFixMe[incompatible-call] found when upgrading Flow
5658
inProgressRequests.set(element, {promise, resolveFn});
5759

5860
return promise;

packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ function findHookNames(
186186
}
187187

188188
const key = getHookSourceLocationKey(hookSource);
189+
// $FlowFixMe[incompatible-call] found when upgrading Flow
189190
map.set(key, name);
190191
});
191192

packages/react-devtools-shared/src/inspectedElementMutableSource.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export function inspectElement({
137137

138138
// A path has been hydrated.
139139
// Merge it with the latest copy we have locally and resolve with the merged value.
140+
// $FlowFixMe[incompatible-type] found when upgrading Flow
140141
inspectedElement = inspectedElementCache.get(id) || null;
141142
if (inspectedElement !== null) {
142143
// Clone element
@@ -150,6 +151,7 @@ export function inspectElement({
150151
hydrateHelper(value, ((path: any): Path)),
151152
);
152153

154+
// $FlowFixMe[incompatible-call] found when upgrading Flow
153155
inspectedElementCache.set(id, inspectedElement);
154156

155157
return [inspectedElement, type];

packages/react-devtools/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ app.on('ready', function() {
4040
}
4141

4242
// https://stackoverflow.com/questions/32402327/
43+
// $FlowFixMe[incompatible-use] found when upgrading Flow
4344
mainWindow.webContents.on('new-window', function(event, url) {
4445
event.preventDefault();
4546
require('electron').shell.openExternal(url);
4647
});
4748

4849
// and load the index.html of the app.
50+
// $FlowFixMe[incompatible-use] found when upgrading Flow
4951
mainWindow.loadURL('file://' + __dirname + '/app.html'); // eslint-disable-line no-path-concat
52+
// $FlowFixMe[incompatible-use] found when upgrading Flow
5053
mainWindow.webContents.executeJavaScript(
5154
// We use this so that RN can keep relative JSX __source filenames
5255
// but "click to open in editor" still works. js1 passes project roots
@@ -55,6 +58,7 @@ app.on('ready', function() {
5558
);
5659

5760
// Emitted when the window is closed.
61+
// $FlowFixMe[incompatible-use] found when upgrading Flow
5862
mainWindow.on('closed', function() {
5963
mainWindow = null;
6064
});

packages/react-dom-bindings/src/client/ReactDOMFloatClient.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ function preinit(href: string, options: PreinitOptions) {
241241
options,
242242
);
243243
resource = createStyleResource(
244+
// $FlowFixMe[incompatible-call] found when upgrading Flow
244245
currentDocument,
245246
href,
246247
precedence,
@@ -347,6 +348,7 @@ export function getResource(
347348
} else {
348349
const resourceProps = stylePropsFromRawProps(styleRawProps);
349350
resource = createStyleResource(
351+
// $FlowFixMe[incompatible-call] found when upgrading Flow
350352
currentDocument,
351353
href,
352354
precedence,
@@ -382,6 +384,7 @@ export function getResource(
382384
} else {
383385
const resourceProps = preloadPropsFromRawProps(preloadRawProps);
384386
resource = createPreloadResource(
387+
// $FlowFixMe[incompatible-call] found when upgrading Flow
385388
currentDocument,
386389
href,
387390
resourceProps,

packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ function extractCompositionEvent(
227227
}
228228
}
229229

230+
// $FlowFixMe[incompatible-call] found when upgrading Flow
230231
const listeners = accumulateTwoPhaseListeners(targetInst, eventType);
231232
if (listeners.length > 0) {
232233
// $FlowFixMe[incompatible-type]

packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function extractEvents(
104104
const nearestMounted = getNearestMountedFiber(to);
105105
if (
106106
to !== nearestMounted ||
107+
// $FlowFixMe[incompatible-use] found when upgrading Flow
107108
(to.tag !== HostComponent && to.tag !== HostText)
108109
) {
109110
to = null;

packages/react-dom-bindings/src/server/ReactDOMFloatServer.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function preload(href: string, options: PreloadOptions) {
144144
options !== null
145145
) {
146146
const as = options.as;
147+
// $FlowFixMe[incompatible-use] found when upgrading Flow
147148
let resource = currentResources.preloadsMap.get(href);
148149
if (resource) {
149150
if (__DEV__) {
@@ -159,12 +160,14 @@ function preload(href: string, options: PreloadOptions) {
159160
}
160161
} else {
161162
resource = createPreloadResource(
163+
// $FlowFixMe[incompatible-call] found when upgrading Flow
162164
currentResources,
163165
href,
164166
as,
165167
preloadPropsFromPreloadOptions(href, as, options),
166168
);
167169
}
170+
// $FlowFixMe[incompatible-call] found when upgrading Flow
168171
captureExplicitPreloadResourceDependency(currentResources, resource);
169172
}
170173
}
@@ -199,6 +202,7 @@ function preinit(href: string, options: PreinitOptions) {
199202
case 'style': {
200203
const precedence = options.precedence || 'default';
201204

205+
// $FlowFixMe[incompatible-use] found when upgrading Flow
202206
let resource = currentResources.stylesMap.get(href);
203207
if (resource) {
204208
if (__DEV__) {
@@ -216,6 +220,7 @@ function preinit(href: string, options: PreinitOptions) {
216220
options,
217221
);
218222
resource = createStyleResource(
223+
// $FlowFixMe[incompatible-call] found when upgrading Flow
219224
currentResources,
220225
href,
221226
precedence,
@@ -224,6 +229,7 @@ function preinit(href: string, options: PreinitOptions) {
224229
}
225230

226231
// Do not associate preinit style resources with any specific boundary regardless of where it is called
232+
// $FlowFixMe[incompatible-call] found when upgrading Flow
227233
captureStyleResourceDependency(currentResources, null, resource);
228234

229235
return;
@@ -459,9 +465,11 @@ export function resourcesFromLink(props: Props): boolean {
459465
if (__DEV__) {
460466
validateLinkPropsForStyleResource(props);
461467
}
468+
// $FlowFixMe[incompatible-use] found when upgrading Flow
462469
let preloadResource = currentResources.preloadsMap.get(href);
463470
if (!preloadResource) {
464471
preloadResource = createPreloadResource(
472+
// $FlowFixMe[incompatible-call] found when upgrading Flow
465473
currentResources,
466474
href,
467475
'style',
@@ -472,6 +480,7 @@ export function resourcesFromLink(props: Props): boolean {
472480
}
473481
}
474482
captureImplicitPreloadResourceDependency(
483+
// $FlowFixMe[incompatible-call] found when upgrading Flow
475484
currentResources,
476485
preloadResource,
477486
);
@@ -492,14 +501,17 @@ export function resourcesFromLink(props: Props): boolean {
492501
} else {
493502
const resourceProps = stylePropsFromRawProps(href, precedence, props);
494503
resource = createStyleResource(
504+
// $FlowFixMe[incompatible-call] found when upgrading Flow
495505
currentResources,
496506
href,
497507
precedence,
498508
resourceProps,
499509
);
500510
}
501511
captureStyleResourceDependency(
512+
// $FlowFixMe[incompatible-call] found when upgrading Flow
502513
currentResources,
514+
// $FlowFixMe[incompatible-use] found when upgrading Flow
503515
currentResources.boundaryResources,
504516
resource,
505517
);
@@ -519,6 +531,7 @@ export function resourcesFromLink(props: Props): boolean {
519531
if (__DEV__) {
520532
validateLinkPropsForPreloadResource(props);
521533
}
534+
// $FlowFixMe[incompatible-use] found when upgrading Flow
522535
let resource = currentResources.preloadsMap.get(href);
523536
if (resource) {
524537
if (__DEV__) {
@@ -534,12 +547,14 @@ export function resourcesFromLink(props: Props): boolean {
534547
}
535548
} else {
536549
resource = createPreloadResource(
550+
// $FlowFixMe[incompatible-call] found when upgrading Flow
537551
currentResources,
538552
href,
539553
as,
540554
preloadPropsFromRawProps(href, as, props),
541555
);
542556
}
557+
// $FlowFixMe[incompatible-call] found when upgrading Flow
543558
captureExplicitPreloadResourceDependency(currentResources, resource);
544559
return true;
545560
}

packages/react-fs/src/ReactFilesystem.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function access(path: string, mode?: number): void {
121121
record = createRecordFromThenable(thenable);
122122
accessCache.push(mode, record);
123123
}
124+
// $FlowFixMe[incompatible-call] found when upgrading Flow
124125
readRecord(record); // No return value.
125126
}
126127

@@ -154,6 +155,7 @@ export function lstat(path: string, options?: {bigint?: boolean}): mixed {
154155
record = createRecordFromThenable(thenable);
155156
lstatCache.push(bigint, record);
156157
}
158+
// $FlowFixMe[incompatible-call] found when upgrading Flow
157159
const stats = readRecord(record).value;
158160
return stats;
159161
}
@@ -203,6 +205,7 @@ export function readdir(
203205
record = createRecordFromThenable(thenable);
204206
readdirCache.push(encoding, withFileTypes, record);
205207
}
208+
// $FlowFixMe[incompatible-call] found when upgrading Flow
206209
const files = readRecord(record).value;
207210
return files;
208211
}
@@ -301,6 +304,7 @@ export function readlink(
301304
record = createRecordFromThenable(thenable);
302305
readlinkCache.push(encoding, record);
303306
}
307+
// $FlowFixMe[incompatible-call] found when upgrading Flow
304308
const linkString = readRecord(record).value;
305309
return linkString;
306310
}
@@ -342,6 +346,7 @@ export function realpath(
342346
record = createRecordFromThenable(thenable);
343347
realpathCache.push(encoding, record);
344348
}
349+
// $FlowFixMe[incompatible-call] found when upgrading Flow
345350
const resolvedPath = readRecord(record).value;
346351
return resolvedPath;
347352
}
@@ -376,6 +381,7 @@ export function stat(path: string, options?: {bigint?: boolean}): mixed {
376381
record = createRecordFromThenable(thenable);
377382
statCache.push(bigint, record);
378383
}
384+
// $FlowFixMe[incompatible-call] found when upgrading Flow
379385
const stats = readRecord(record).value;
380386
return stats;
381387
}

0 commit comments

Comments
 (0)