fix `$FlowFixMe`

Reviewed By: rafeca

Differential Revision: D6258938

fbshipit-source-id: 7331d0a3216c1714099139fe6c6ab8fe11771fae
This commit is contained in:
David Aurelio 2017-11-07 06:20:27 -08:00 committed by Facebook Github Bot
parent dbb2d44c42
commit 2c5a2fec66
15 changed files with 55 additions and 122 deletions

View File

@ -251,12 +251,9 @@ class Bundler {
return this._assetServer;
}
end() {
async end() {
this._transformer.kill();
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this._resolverPromise.then(resolver =>
await this._resolverPromise.then(resolver =>
resolver
.getDependencyGraph()
.getWatcher()
@ -353,7 +350,7 @@ class Bundler {
});
}
_bundle({
_bundle<T: Bundle | HMRBundle>({
assetPlugins,
bundle,
dev,
@ -372,7 +369,7 @@ class Bundler {
unbundle,
}: {
assetPlugins?: Array<string>,
bundle: Bundle | HMRBundle,
bundle: T,
dev: boolean,
entryFile?: string,
entryModuleOnly?: boolean,
@ -387,7 +384,7 @@ class Bundler {
runBeforeMainModule?: Array<string>,
runModule?: boolean,
unbundle?: boolean,
}) {
}): Promise<T> {
const onResolutionResponse = (
response: ResolutionResponse<Module, BundlingOptions>,
) => {
@ -463,7 +460,7 @@ class Bundler {
});
}
_buildBundle({
_buildBundle<T: Bundle | HMRBundle>({
entryFile,
dev,
minify,
@ -479,7 +476,7 @@ class Bundler {
onModuleTransformed = emptyFunction,
finalizeBundle = emptyFunction,
onProgress = emptyFunction,
}: *) {
}: *): Promise<T> {
const transformingFilesLogEntry = log(
createActionStartEntry({
action_name: 'Transforming files',
@ -505,9 +502,6 @@ class Bundler {
});
}
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return Promise.all([
this._resolverPromise,
resolutionResponse,
@ -683,10 +677,7 @@ class Bundler {
+platform: string,
+minify: boolean,
+generateSourceMaps: boolean,
}) {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
}): Promise<Array<string>> {
return this.getDependencies({
entryFile,
rootEntryFile: entryFile,
@ -698,7 +689,8 @@ class Bundler {
}).then(({dependencies}) => {
const ret = [];
const promises = [];
const placeHolder = {};
/* $FlowFixMe: these are always removed */
const placeHolder: string = {};
dependencies.forEach(dep => {
if (dep.isAsset()) {
const localPath = toLocalPath(this._projectRoots, dep.path);

View File

@ -256,11 +256,8 @@ function* filter(iterator, predicate) {
}
}
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
class ArrayMap extends Map {
get(key) {
class ArrayMap<K, V> extends Map<K, Array<V>> {
get(key: K): Array<V> {
let array = super.get(key);
if (!array) {
array = [];

View File

@ -138,11 +138,8 @@ export type ConfigT = {
runBeforeMainModule: Array<string>,
};
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.56 was deployed. To see the error delete this comment and
* run Flow. */
const DEFAULT = ({
extraNodeModules: Object.create(null),
extraNodeModules: {},
getAssetExts: () => [],
getBlacklistRE: () => blacklist(),
getEnableBabelRCLookup: () => false,

View File

@ -50,7 +50,10 @@ export type DeltaTransformResponse = {|
+pre: DeltaEntries,
+post: DeltaEntries,
+delta: DeltaEntries,
+inverseDependencies: {[key: string]: $ReadOnlyArray<string>},
+inverseDependencies: {
[key: string]: $ReadOnlyArray<string>,
__proto__: null,
},
+reset: boolean,
|};
@ -317,7 +320,7 @@ class DeltaTransformer extends EventEmitter {
*/
_getInverseDependencies(
dependencyEdges: DependencyEdges,
): {[key: string]: $ReadOnlyArray<string>} {
): {[key: string]: $ReadOnlyArray<string>, __proto__: null} {
const output = Object.create(null);
for (const [path, {inverseDependencies}] of dependencyEdges.entries()) {
@ -326,9 +329,6 @@ class DeltaTransformer extends EventEmitter {
).map(dep => this._getModuleId({path: dep}));
}
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
return output;
}

View File

@ -21,7 +21,11 @@ const path = require('path');
const util = require('util');
const workerFarm = require('../worker-farm');
import type {Data as TransformData, Options as WorkerOptions} from './worker';
import type {
Data as TransformData,
Options as WorkerOptions,
TransformedCode,
} from './worker';
import type {LocalPath} from '../node-haste/lib/toLocalPath';
import type {MappingsMap} from '../lib/SourceMap';
import typeof {
@ -142,10 +146,7 @@ class Transformer {
kill() {
if (this._usesFarm && this._workers) {
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
workerFarm.end(this._workers);
workerFarm.end(this._workers, () => {});
}
}
@ -154,17 +155,12 @@ class Transformer {
localPath: LocalPath,
code: string,
options: WorkerOptions,
) {
): Promise<TransformedCode> {
if (!this._transform) {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return Promise.reject(new Error('No transform module'));
}
debug('transforming file', fileName);
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this._transform(
this._transformModulePath,
fileName,

View File

@ -46,22 +46,19 @@ type ModuleDefinition = {|
isInitialized: boolean,
verboseName?: string,
|};
type ModuleMap = {[key: ModuleID]: ModuleDefinition};
type ModuleMap = {[key: ModuleID]: ModuleDefinition, __proto__: null};
type RequireFn = (id: ModuleID | VerboseModuleNameForDev) => Exports;
type VerboseModuleNameForDev = string;
global.require = require;
global.__d = define;
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.56 was deployed. To see the error delete this comment and
* run Flow. */
const modules: ModuleMap = Object.create(null);
if (__DEV__) {
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.56 was deployed. To see the error delete this comment
* and run Flow. */
var verboseNamesToModuleIds: {[key: string]: number} = Object.create(null);
var verboseNamesToModuleIds: {
[key: string]: number,
__proto__: null,
} = Object.create(null);
}
function define(

View File

@ -24,6 +24,7 @@ const formatBundlingError = require('../lib/formatBundlingError');
const getMaxWorkers = require('../lib/getMaxWorkers');
const getOrderedDependencyPaths = require('../lib/getOrderedDependencyPaths');
const mime = require('mime-types');
const nullthrows = require('fbjs/lib/nullthrows');
const parsePlatformFilePath = require('../node-haste/lib/parsePlatformFilePath');
const path = require('path');
const symbolicate = require('./symbolicate');
@ -175,7 +176,7 @@ class Server {
workerPath: ?string,
};
_projectRoots: $ReadOnlyArray<string>;
_bundles: {};
_bundles: {__proto__: null};
_bundleBuildInfos: WeakMap<Bundle, BuildInfo>;
_changeWatchers: Array<{
req: IncomingMessage,
@ -237,9 +238,6 @@ class Server {
this._reporter = reporter;
this._projectRoots = this._opts.projectRoots;
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._bundles = Object.create(null);
this._bundleBuildInfos = new WeakMap();
this._changeWatchers = [];
@ -275,11 +273,9 @@ class Server {
for (const key in this._bundles) {
this._bundles[key]
.then(bundle => {
const deps = bundleDeps.get(bundle);
const deps = nullthrows(bundleDeps.get(bundle));
filePaths.forEach(filePath => {
// $FlowFixMe(>=0.37.0)
if (deps.files.has(filePath)) {
// $FlowFixMe(>=0.37.0)
deps.outdated.add(filePath);
}
});
@ -506,9 +502,6 @@ class Server {
}
_clearBundles() {
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._bundles = Object.create(null);
}
@ -700,8 +693,7 @@ class Server {
if (optionsJson in this._bundles) {
return this._bundles[optionsJson].then(bundle => {
const deps = bundleDeps.get(bundle);
// $FlowFixMe(>=0.37.0)
const deps = nullthrows(bundleDeps.get(bundle));
const {dependencyPairs, files, idToIndex, outdated} = deps;
if (outdated.size) {
const updatingExistingBundleLogEntry = log(
@ -713,7 +705,6 @@ class Server {
debug('Attempt to update existing bundle');
// $FlowFixMe(>=0.37.0)
deps.outdated = new Set();
const {platform, dev, minify, hot} = options;

View File

@ -68,7 +68,7 @@ type Options<TModule, TPackage> = {|
|};
class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
_immediateResolutionCache: {[key: string]: TModule};
_immediateResolutionCache: {[key: string]: TModule, __proto__: null};
_options: Options<TModule, TPackage>;
static AmbiguousModuleResolutionError: Class<AmbiguousModuleResolutionError>;
@ -146,7 +146,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
transformOptions: TransformWorkerOptions,
onProgress?: ?(finishedModules: number, totalModules: number) => mixed,
recursive: boolean,
}) {
}): Promise<void> {
const entry = this._options.moduleCache.getModule(this._options.entryPath);
response.pushDependency(entry);
@ -245,9 +245,6 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
return promise.then(value => [key, value]);
}
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return Promise.all([
// kicks off recursive dependency discovery, but doesn't block until it's
// done
@ -363,13 +360,10 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
}
_resetResolutionCache() {
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._immediateResolutionCache = Object.create(null);
}
getResolutionCache(): {[key: string]: TModule} {
getResolutionCache(): {[key: string]: TModule, __proto__: null} {
return this._immediateResolutionCache;
}
}

View File

@ -24,7 +24,7 @@ class ResolutionResponse<TModule: {hash(): string}, TOptions> {
// This is monkey-patched from Resolver.
getModuleId: ?() => number;
_mappings: {[hash: string]: Array<[string, TModule]>};
_mappings: {[hash: string]: Array<[string, TModule]>, __proto__: null};
_finalized: boolean;
_mainModule: ?TModule;
@ -34,9 +34,6 @@ class ResolutionResponse<TModule: {hash(): string}, TOptions> {
this.mocks = null;
this.numPrependedDependencies = 0;
this.options = options;
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._mappings = Object.create(null);
this._finalized = false;
}

View File

@ -144,18 +144,12 @@ class Module {
return this._getHasteName() != null;
}
getCode(transformOptions: WorkerOptions) {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this.read(transformOptions).then(({code}) => code);
async getCode(transformOptions: WorkerOptions): Promise<string> {
return (await this.read(transformOptions)).code;
}
getMap(transformOptions: WorkerOptions) {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this.read(transformOptions).then(({map}) => map);
async getMap(transformOptions: WorkerOptions) {
return (await this.read(transformOptions)).map;
}
getName(): string {
@ -186,11 +180,8 @@ class Module {
return this._moduleCache.getPackageForModule(this);
}
getDependencies(transformOptions: WorkerOptions) {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this.read(transformOptions).then(({dependencies}) => dependencies);
async getDependencies(transformOptions: WorkerOptions) {
return (await this.read(transformOptions)).dependencies;
}
/**

View File

@ -33,9 +33,9 @@ class ModuleCache {
_getClosestPackage: GetClosestPackageFn;
_getTransformCacheKey: GetTransformCacheKey;
_globalTransformCache: ?GlobalTransformCache;
_moduleCache: {[filePath: string]: Module};
_moduleCache: {[filePath: string]: Module, __proto__: null};
_moduleOptions: ModuleOptions;
_packageCache: {[filePath: string]: Package};
_packageCache: {[filePath: string]: Package, __proto__: null};
_packageModuleMap: WeakMap<Module, string>;
_platforms: Set<string>;
_transformCode: TransformCode;
@ -72,14 +72,8 @@ class ModuleCache {
this._getTransformCacheKey = getTransformCacheKey;
this._globalTransformCache = globalTransformCache;
this._depGraphHelpers = depGraphHelpers;
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._moduleCache = Object.create(null);
this._moduleOptions = moduleOptions;
/* $FlowFixMe(>=0.56.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
this._packageCache = Object.create(null);
this._packageModuleMap = new WeakMap();
this._platforms = platforms;
@ -144,9 +138,8 @@ class ModuleCache {
}
getPackageForModule(module: Module): ?Package {
if (this._packageModuleMap.has(module)) {
const packagePath = this._packageModuleMap.get(module);
// $FlowFixMe(>=0.37.0)
let packagePath = this._packageModuleMap.get(module);
if (packagePath) {
if (this._packageCache[packagePath]) {
return this._packageCache[packagePath];
} else {
@ -154,7 +147,7 @@ class ModuleCache {
}
}
const packagePath = this._getClosestPackage(module.path);
packagePath = this._getClosestPackage(module.path);
if (!packagePath) {
return null;
}

View File

@ -43,11 +43,8 @@ class Polyfill extends Module {
return null;
}
getDependencies() {
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return Promise.resolve(this._dependencies);
async getDependencies() {
return this._dependencies;
}
isJSON() {

View File

@ -40,10 +40,7 @@ function saveAsIndexedFile(
bundle: RamBundleInfo,
options: OutputOptions,
log: (...args: Array<string>) => void,
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
): Promise<> {
): Promise<mixed> {
const {
bundleOutput,
bundleEncoding: encoding,

View File

@ -43,10 +43,7 @@ function saveUnbundle(
// overhead when reading hundreds pf assets from disk
return options.platform === 'android' && !options.indexedUnbundle
? asAssets(bundle, options, log)
: /* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
asIndexedFile(bundle, options, log);
: asIndexedFile(bundle, options, log);
}
exports.build = buildBundle;

View File

@ -17,10 +17,7 @@ function writeSourcemap(
fileName: string,
contents: string,
log: (...args: Array<string>) => void,
/* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
): Promise<> {
): Promise<mixed> {
if (!fileName) {
return Promise.resolve();
}