Skip to content

Commit

Permalink
Flow upgrade to 0.146
Browse files Browse the repository at this point in the history
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: a45b40abf03474b691a2dc18a4f1f3b06cfbdffd
Pull Request resolved: #25410
  • Loading branch information
kassens committed Oct 4, 2022
1 parent d3c6c16 commit 64fe791
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "1.2.0",
"filesize": "^6.0.1",
"flow-bin": "^0.145.0",
"flow-bin": "^0.146.0",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-core/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function launchEditor(
childProcess = spawn(editor, args, {stdio: 'inherit'});
}
childProcess.on('error', function() {});
// $FlowFixMe[incompatible-use] found when upgrading Flow
childProcess.on('exit', function(errorCode) {
childProcess = null;
});
Expand Down
10 changes: 10 additions & 0 deletions packages/react-devtools-shared/src/backend/profilingHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ export function createProfilingHooks({
);
}

// $FlowFixMe[incompatible-use] found when upgrading Flow
currentReactComponentMeasure.duration =
// $FlowFixMe[incompatible-use] found when upgrading Flow
getRelativeTime() - currentReactComponentMeasure.timestamp;
currentReactComponentMeasure = null;
}
Expand Down Expand Up @@ -393,7 +395,9 @@ export function createProfilingHooks({
);
}

// $FlowFixMe[incompatible-use] found when upgrading Flow
currentReactComponentMeasure.duration =
// $FlowFixMe[incompatible-use] found when upgrading Flow
getRelativeTime() - currentReactComponentMeasure.timestamp;
currentReactComponentMeasure = null;
}
Expand Down Expand Up @@ -438,7 +442,9 @@ export function createProfilingHooks({
);
}

// $FlowFixMe[incompatible-use] found when upgrading Flow
currentReactComponentMeasure.duration =
// $FlowFixMe[incompatible-use] found when upgrading Flow
getRelativeTime() - currentReactComponentMeasure.timestamp;
currentReactComponentMeasure = null;
}
Expand Down Expand Up @@ -481,7 +487,9 @@ export function createProfilingHooks({
);
}

// $FlowFixMe[incompatible-use] found when upgrading Flow
currentReactComponentMeasure.duration =
// $FlowFixMe[incompatible-use] found when upgrading Flow
getRelativeTime() - currentReactComponentMeasure.timestamp;
currentReactComponentMeasure = null;
}
Expand Down Expand Up @@ -526,7 +534,9 @@ export function createProfilingHooks({
);
}

// $FlowFixMe[incompatible-use] found when upgrading Flow
currentReactComponentMeasure.duration =
// $FlowFixMe[incompatible-use] found when upgrading Flow
getRelativeTime() - currentReactComponentMeasure.timestamp;
currentReactComponentMeasure = null;
}
Expand Down
11 changes: 10 additions & 1 deletion packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ export function attach(
const id = getFiberIDThrows(fiber);
const contexts = getContextsForFiber(fiber);
if (contexts !== null) {
// $FlowFixMe[incompatible-use] found when upgrading Flow
idToContextsMap.set(id, contexts);
}
}
Expand Down Expand Up @@ -1380,8 +1381,10 @@ export function attach(
function getContextChangedKeys(fiber: Fiber): null | boolean | Array<string> {
if (idToContextsMap !== null) {
const id = getFiberIDThrows(fiber);
// $FlowFixMe[incompatible-use] found when upgrading Flow
const prevContexts = idToContextsMap.has(id)
? idToContextsMap.get(id)
? // $FlowFixMe[incompatible-use] found when upgrading Flow
idToContextsMap.get(id)
: null;
const nextContexts = getContextsForFiber(fiber);

Expand Down Expand Up @@ -2636,7 +2639,9 @@ export function attach(
const {effectDuration, passiveEffectDuration} = getEffectDurations(
root,
);
// $FlowFixMe[incompatible-use] found when upgrading Flow
currentCommitProfilingMetadata.effectDuration = effectDuration;
// $FlowFixMe[incompatible-use] found when upgrading Flow
currentCommitProfilingMetadata.passiveEffectDuration = passiveEffectDuration;
}
}
Expand Down Expand Up @@ -3702,6 +3707,7 @@ export function attach(
id,
responseID: requestID,
type: 'full-data',
// $FlowFixMe[incompatible-return] found when upgrading Flow
value: cleanedInspectedElement,
};
}
Expand Down Expand Up @@ -4276,6 +4282,7 @@ export function attach(
) {
// Is this the next Fiber we should select? Let's compare the frames.
const actualFrame = getPathFrame(fiber);
// $FlowFixMe[incompatible-use] found when upgrading Flow
const expectedFrame = trackedPath[trackedPathMatchDepth + 1];
if (expectedFrame === undefined) {
throw new Error('Expected to see a frame at the next depth.');
Expand All @@ -4289,6 +4296,7 @@ export function attach(
trackedPathMatchFiber = fiber;
trackedPathMatchDepth++;
// Are we out of frames to match?
// $FlowFixMe[incompatible-use] found when upgrading Flow
if (trackedPathMatchDepth === trackedPath.length - 1) {
// There's nothing that can possibly match afterwards.
// Don't check the children.
Expand Down Expand Up @@ -4443,6 +4451,7 @@ export function attach(
}
return {
id: getFiberIDThrows(fiber),
// $FlowFixMe[incompatible-use] found when upgrading Flow
isFullMatch: trackedPathMatchDepth === trackedPath.length - 1,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const resource: Resource<
(element: Element) => {
const request = inProgressRequests.get(element);
if (request != null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
return request.promise;
}

Expand All @@ -53,6 +54,7 @@ const resource: Resource<
resolveFn = resolve;
});

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

return promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function findHookNames(
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export function inspectElement({

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

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

return [inspectedElement, type];
Expand Down
4 changes: 4 additions & 0 deletions packages/react-devtools/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ app.on('ready', function() {
}

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

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

// Emitted when the window is closed.
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.on('closed', function() {
mainWindow = null;
});
Expand Down
3 changes: 3 additions & 0 deletions packages/react-dom-bindings/src/client/ReactDOMFloatClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ function preinit(href: string, options: PreinitOptions) {
options,
);
resource = createStyleResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentDocument,
href,
precedence,
Expand Down Expand Up @@ -347,6 +348,7 @@ export function getResource(
} else {
const resourceProps = stylePropsFromRawProps(styleRawProps);
resource = createStyleResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentDocument,
href,
precedence,
Expand Down Expand Up @@ -382,6 +384,7 @@ export function getResource(
} else {
const resourceProps = preloadPropsFromRawProps(preloadRawProps);
resource = createPreloadResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentDocument,
href,
resourceProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ function extractCompositionEvent(
}
}

// $FlowFixMe[incompatible-call] found when upgrading Flow
const listeners = accumulateTwoPhaseListeners(targetInst, eventType);
if (listeners.length > 0) {
// $FlowFixMe[incompatible-type]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function extractEvents(
const nearestMounted = getNearestMountedFiber(to);
if (
to !== nearestMounted ||
// $FlowFixMe[incompatible-use] found when upgrading Flow
(to.tag !== HostComponent && to.tag !== HostText)
) {
to = null;
Expand Down
15 changes: 15 additions & 0 deletions packages/react-dom-bindings/src/server/ReactDOMFloatServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function preload(href: string, options: PreloadOptions) {
options !== null
) {
const as = options.as;
// $FlowFixMe[incompatible-use] found when upgrading Flow
let resource = currentResources.preloadsMap.get(href);
if (resource) {
if (__DEV__) {
Expand All @@ -159,12 +160,14 @@ function preload(href: string, options: PreloadOptions) {
}
} else {
resource = createPreloadResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
href,
as,
preloadPropsFromPreloadOptions(href, as, options),
);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
captureExplicitPreloadResourceDependency(currentResources, resource);
}
}
Expand Down Expand Up @@ -199,6 +202,7 @@ function preinit(href: string, options: PreinitOptions) {
case 'style': {
const precedence = options.precedence || 'default';

// $FlowFixMe[incompatible-use] found when upgrading Flow
let resource = currentResources.stylesMap.get(href);
if (resource) {
if (__DEV__) {
Expand All @@ -216,6 +220,7 @@ function preinit(href: string, options: PreinitOptions) {
options,
);
resource = createStyleResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
href,
precedence,
Expand All @@ -224,6 +229,7 @@ function preinit(href: string, options: PreinitOptions) {
}

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

return;
Expand Down Expand Up @@ -459,9 +465,11 @@ export function resourcesFromLink(props: Props): boolean {
if (__DEV__) {
validateLinkPropsForStyleResource(props);
}
// $FlowFixMe[incompatible-use] found when upgrading Flow
let preloadResource = currentResources.preloadsMap.get(href);
if (!preloadResource) {
preloadResource = createPreloadResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
href,
'style',
Expand All @@ -472,6 +480,7 @@ export function resourcesFromLink(props: Props): boolean {
}
}
captureImplicitPreloadResourceDependency(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
preloadResource,
);
Expand All @@ -492,14 +501,17 @@ export function resourcesFromLink(props: Props): boolean {
} else {
const resourceProps = stylePropsFromRawProps(href, precedence, props);
resource = createStyleResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
href,
precedence,
resourceProps,
);
}
captureStyleResourceDependency(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
// $FlowFixMe[incompatible-use] found when upgrading Flow
currentResources.boundaryResources,
resource,
);
Expand All @@ -519,6 +531,7 @@ export function resourcesFromLink(props: Props): boolean {
if (__DEV__) {
validateLinkPropsForPreloadResource(props);
}
// $FlowFixMe[incompatible-use] found when upgrading Flow
let resource = currentResources.preloadsMap.get(href);
if (resource) {
if (__DEV__) {
Expand All @@ -534,12 +547,14 @@ export function resourcesFromLink(props: Props): boolean {
}
} else {
resource = createPreloadResource(
// $FlowFixMe[incompatible-call] found when upgrading Flow
currentResources,
href,
as,
preloadPropsFromRawProps(href, as, props),
);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
captureExplicitPreloadResourceDependency(currentResources, resource);
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/react-fs/src/ReactFilesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function access(path: string, mode?: number): void {
record = createRecordFromThenable(thenable);
accessCache.push(mode, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
readRecord(record); // No return value.
}

Expand Down Expand Up @@ -154,6 +155,7 @@ export function lstat(path: string, options?: {bigint?: boolean}): mixed {
record = createRecordFromThenable(thenable);
lstatCache.push(bigint, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
const stats = readRecord(record).value;
return stats;
}
Expand Down Expand Up @@ -203,6 +205,7 @@ export function readdir(
record = createRecordFromThenable(thenable);
readdirCache.push(encoding, withFileTypes, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
const files = readRecord(record).value;
return files;
}
Expand Down Expand Up @@ -301,6 +304,7 @@ export function readlink(
record = createRecordFromThenable(thenable);
readlinkCache.push(encoding, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
const linkString = readRecord(record).value;
return linkString;
}
Expand Down Expand Up @@ -342,6 +346,7 @@ export function realpath(
record = createRecordFromThenable(thenable);
realpathCache.push(encoding, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
const resolvedPath = readRecord(record).value;
return resolvedPath;
}
Expand Down Expand Up @@ -376,6 +381,7 @@ export function stat(path: string, options?: {bigint?: boolean}): mixed {
record = createRecordFromThenable(thenable);
statCache.push(bigint, record);
}
// $FlowFixMe[incompatible-call] found when upgrading Flow
const stats = readRecord(record).value;
return stats;
}
Loading

0 comments on commit 64fe791

Please sign in to comment.