Add extra flowtype stubs for metro (#20429)

Summary:
We ignore some `metro` flowtypes, which made `flow check` fail on `metro-config`. I now also added the `metro` stubs needed by `metro-config` to make `flow check` pass.

Closes https://github.com/facebook/react-native/issues/20431

Pull Request resolved: https://github.com/facebook/react-native/pull/20429

Reviewed By: hramos

Differential Revision: D9036903

Pulled By: CompuIves

fbshipit-source-id: 6e348e929b7c36520787bb860f5a18aa588455c3
This commit is contained in:
Ives van Hoorne 2018-07-27 20:31:20 -07:00 committed by Facebook Github Bot
parent 40f6998b67
commit 9176fc00b5
3 changed files with 43 additions and 3 deletions

View File

@ -27,3 +27,39 @@ declare module 'metro/src/lib/bundle-modules/HMRClient' {
declare module 'metro/src/lib/TerminalReporter' {
declare module.exports: any;
}
declare module 'metro/src/Bundler' {
declare module.exports: any;
}
declare module 'metro/src/DeltaBundler' {
declare module.exports: any;
}
declare module 'metro/src/ModuleGraph/types.flow.js' {
declare module.exports: any;
}
declare module 'metro/src/lib/getMaxWorkers' {
declare module.exports: any;
}
declare module 'metro/src/lib/createModuleIdFactory' {
declare module.exports: any;
}
declare module 'metro/src/shared/types.flow' {
declare module.exports: any;
}
declare module 'metro/src/lib/reporting' {
declare module.exports: any;
}
declare module 'metro/src/Server' {
declare module.exports: any;
}
declare module 'metro/src/ModuleGraph/worker/collectDependencies' {
declare module.exports: any;
}

View File

@ -129,7 +129,9 @@ const defaultRNConfig = {
*/
async function getCliConfig(): Promise<RNConfig> {
const cliArgs = minimist(process.argv.slice(2));
const config = await Config.load(path.resolve(__dirname, cliArgs.config));
const config = await Config.load(
cliArgs.config != null ? path.resolve(__dirname, cliArgs.config) : null,
);
config.transformer.assetRegistryPath = ASSET_REGISTRY_PATH;
config.resolver.hasteImplModulePath = defaultConfig.hasteImplModulePath;

View File

@ -84,8 +84,10 @@ const Config = {
getProjectPath,
getProjectRoots,
async load(configFile: string): Promise<ConfigT> {
const config: ConfigT = await loadConfig({config: configFile});
async load(configFile: ?string): Promise<ConfigT> {
const config: ConfigT = await loadConfig(
configFile ? {config: configFile} : {},
);
return mergeConfig(config, this.DEFAULT);
},