metro-bundler: fix Flow errors in OSS

Reviewed By: cpojer

Differential Revision: D5775151

fbshipit-source-id: 730ab160fdf5ea35f8047eb55a7e2844ba7a7c14
This commit is contained in:
Jean Lauliac 2017-09-08 06:33:17 -07:00 committed by Facebook Github Bot
parent 286c5ccdd9
commit 7ccbcc5ebc
4 changed files with 21 additions and 17 deletions

View File

@ -47,13 +47,13 @@ function optimizeModule(
const result = {...details, transformed: {}}; const result = {...details, transformed: {}};
const {postMinifyProcess} = optimizationOptions; const {postMinifyProcess} = optimizationOptions;
Object.entries( Object.entries(transformed).forEach(([k, t: TransformResult]) => {
transformed, const optimized = optimize(
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an error (t: $FlowFixMe),
* found when Flow v0.54 was deployed. To see the error delete this comment file,
* and run Flow. */ code,
).forEach(([k, t: TransformResult]: [*, TransformResult]) => { optimizationOptions,
const optimized = optimize(t, file, code, optimizationOptions); );
const processed = postMinifyProcess({ const processed = postMinifyProcess({
code: optimized.code, code: optimized.code,
map: optimized.map, map: optimized.map,
@ -66,7 +66,7 @@ function optimizeModule(
return {type: 'code', details: result}; return {type: 'code', details: result};
} }
function optimize(transformed, file, originalCode, options) { function optimize(transformed: TransformResult, file, originalCode, options) {
const {code, dependencyMapName, map} = transformed; const {code, dependencyMapName, map} = transformed;
const optimized = optimizeCode(code, map, file, options); const optimized = optimizeCode(code, map, file, options);

View File

@ -130,7 +130,10 @@ class Resolver {
): Promise<ResolutionResponse<Module, T>> { ): Promise<ResolutionResponse<Module, T>> {
const {platform, recursive = true, prependPolyfills} = options; const {platform, recursive = true, prependPolyfills} = options;
const resolutionResponse = await this._depGraph.getDependencies({ const resolutionResponse: ResolutionResponse<
Module,
T,
> = await this._depGraph.getDependencies({
entryPath, entryPath,
platform, platform,
options: bundlingOptions, options: bundlingOptions,
@ -144,6 +147,7 @@ class Resolver {
.forEach(polyfill => resolutionResponse.prependDependency(polyfill)); .forEach(polyfill => resolutionResponse.prependDependency(polyfill));
} }
/* $FlowFixMe: monkey patching */
resolutionResponse.getModuleId = getModuleId; resolutionResponse.getModuleId = getModuleId;
return resolutionResponse.finalize(); return resolutionResponse.finalize();
} }

View File

@ -668,7 +668,7 @@ class Server {
}), }),
Promise.all(Array.from(outdated, this.getModuleForPath, this)), Promise.all(Array.from(outdated, this.getModuleForPath, this)),
]) ])
.then(([response, changedModules]) => { .then(([response, changedModules]: [$FlowFixMe, *]) => {
debug('Update bundle: rebuild shallow bundle'); debug('Update bundle: rebuild shallow bundle');
changedModules.forEach(m => { changedModules.forEach(m => {

View File

@ -1163,17 +1163,17 @@ isstream@~0.1.2:
version "0.1.2" version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
jest-docblock@20.1.0-echo.1: jest-docblock@^21, jest-docblock@^21.0.0:
version "20.1.0-echo.1" version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-20.1.0-echo.1.tgz#be02f43ee019f97e6b83267c746ac7b40d290fe8" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.0.0.tgz#7dd57568543aec98910f749540afc15fab53a27f"
jest-haste-map@20.1.0-echo.1: jest-haste-map@^21:
version "20.1.0-echo.1" version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-20.1.0-echo.1.tgz#6dfd0c97bb51a68a35dd98326e04f994157dce81" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-21.0.0.tgz#1f099ff6aedb52ec55fa9773ce26e4bbb00b0580"
dependencies: dependencies:
fb-watchman "^2.0.0" fb-watchman "^2.0.0"
graceful-fs "^4.1.11" graceful-fs "^4.1.11"
jest-docblock "20.1.0-echo.1" jest-docblock "^21.0.0"
micromatch "^2.3.11" micromatch "^2.3.11"
sane "^2.0.0" sane "^2.0.0"
worker-farm "^1.3.1" worker-farm "^1.3.1"