Skip to content

Commit

Permalink
Land suppressions for 0.142.0 release to xplat
Browse files Browse the repository at this point in the history
Summary:
This change contains the suppressions for the up coming v0.142.0 Flow release.

The new suppressions are a result the following changes:
* Disallow flowing functions or inexact objects to indexed objects to improve object soundness. This can cause errors if you are passing a function or inexact objects when an indexed object is expected.
* Flow now processes imports before checking the body of a file. In some rare cases this can expose previously skipped errors due to the processing order.

Reviewed By: mroch

Differential Revision: D25820434

fbshipit-source-id: 59cc1d852ffc8cc39f0d5112ce485fb33f05c092
  • Loading branch information
pieterv authored and facebook-github-bot committed Jan 7, 2021
1 parent 144830b commit 64f6e74
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/metro-resolver/src/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function resolve(
.concat(extraPaths);
for (let i = 0; i < allDirPaths.length; ++i) {
const candidate = context.redirectModulePath(allDirPaths[i]);
// $FlowFixMe[incompatible-call]
const result = resolveFileOrDir(context, candidate, platform);
if (result.type === 'resolved') {
return result.resolution;
Expand Down
2 changes: 2 additions & 0 deletions packages/metro-transform-worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ module.exports = {

if (
ast.program.sourceType === 'module' &&
// $FlowFixMe[incompatible-use]
directives.findIndex(d => d.value.value === 'use strict') === -1
) {
// $FlowFixMe[incompatible-use]
directives.push(types.directive(types.directiveLiteral('use strict')));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ it('produces a bytecode header buffer for each module', () => {
});

it('does not produce a bytecode header buffer for a script', () => {
// $FlowFixMe[cannot-write]
myModule.output[1].type = 'bytecode/script';

const buffers = wrapModule(myModule, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('wrapModule()', () => {
});

it('should not wrap a script', () => {
// $FlowFixMe[cannot-write]
myModule.output[0].type = 'js/script';

expect(
Expand All @@ -82,6 +83,7 @@ describe('wrapModule()', () => {
dev: true,
projectRoot: '/root',
}),
// $FlowFixMe[incompatible-use]
).toEqual(myModule.output[0].data.code);
});

Expand Down
1 change: 1 addition & 0 deletions packages/metro/src/DeltaBundler/traverseDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ async function processModule<T>(
} catch (err) {
// If there is an error, restore the previous dependency list.
// This ensures we don't skip over them during the next traversal attempt.
// $FlowFixMe[cannot-write]
module.dependencies = previousDependencies;
throw err;
}
Expand Down
1 change: 1 addition & 0 deletions packages/metro/src/HmrServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class HmrServer<TClient: Client> {
clientUrl.protocol = 'http';
const {dev, minify, runModule, bundleEntry: _bundleEntry, ...query} =
clientUrl.query || {};
// $FlowFixMe[incompatible-type]
clientUrl.query = {
...query,
dev: dev || 'true',
Expand Down
3 changes: 3 additions & 0 deletions packages/metro/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class Server {
transformOptions.platform ||
parsePlatformFilePath(entryFile, this._platforms).platform;

// $FlowFixMe[incompatible-return]
return await getAllFiles(prepend, graph, {
platform,
processModuleFilter: this._config.serializer.processModuleFilter,
Expand Down Expand Up @@ -988,6 +989,7 @@ class Server {
const getCodeFrame = (urls, symbolicatedStack) => {
for (let i = 0; i < symbolicatedStack.length; i++) {
const {collapse, column, file, lineNumber} = symbolicatedStack[i];
// $FlowFixMe[incompatible-call]
const entryPoint = path.resolve(this._config.projectRoot, file);
if (collapse || lineNumber == null || urls.has(entryPoint)) {
continue;
Expand All @@ -999,6 +1001,7 @@ class Server {
fs.readFileSync(entryPoint, 'utf8'),
{
// Metro returns 0 based columns but codeFrameColumns expects 1-based columns
// $FlowFixMe[unsafe-addition]
start: {column: column + 1, line: lineNumber},
},
{forceColor: true},
Expand Down
1 change: 1 addition & 0 deletions packages/metro/src/lib/transformHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async function getResolveDependencyFn(
const dependencyGraph = await await bundler.getDependencyGraph();

return (from: string, to: string) =>
// $FlowFixMe[incompatible-call]
dependencyGraph.resolveDependency(from, to, platform);
}

Expand Down

0 comments on commit 64f6e74

Please sign in to comment.