From f4d627c8faeb034eac8053fd253f17e42b85f2f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 14 Dec 2017 15:14:03 -0800 Subject: [PATCH] Fix failure due to missing Metro flow types Summary: Fixes the Flow failure due to an undefined Ast type. Before: ``` $ npm run flow -- check > react-native@1000.0.0 flow /Users/hramos/git/react-native > flow "check" Error: local-cli/__tests__/fs-mock-test.js:27 27: beforeEach(() => { ^^^^^^^^^^ beforeEach. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:53 53: expect(content).toEqual('beep'); ^^^^^^ expect. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:88 88: expect(content).toEqual('hello, world!'); ^^^^^^ expect. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:100 100: expect(content).toEqual('hello, world!'); ^^^^^^ expect. Could not resolve name Error: node_modules/metro/src/Bundler/util.js.flow:46 46: ): Ast { ^^^ Ast. Could not resolve name Error: node_modules/metro/src/ModuleGraph/worker/collect-dependencies.js.flow:283 283: const xp = (module.exports = (ast: Ast) => ^^^ Ast. Could not resolve name Error: node_modules/metro/src/assetTransformer.js.flow:29 29: ): Promise<{ast: Ast}> { ^^^ Ast. Could not resolve name ``` After ``` $ npm run flow -- check > react-native@1000.0.0 flow /Users/hramos/git/react-native > flow "check" Error: local-cli/__tests__/fs-mock-test.js:27 27: beforeEach(() => { ^^^^^^^^^^ beforeEach. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:53 53: expect(content).toEqual('beep'); ^^^^^^ expect. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:88 88: expect(content).toEqual('hello, world!'); ^^^^^^ expect. Could not resolve name Error: local-cli/__tests__/fs-mock-test.js:100 100: expect(content).toEqual('hello, world!'); ^^^^^^ expect. Could not resolve name ``` [ GENERAL ] [ BUGFIX] [ .flowconfig ] - Have Flow ignore Metro node_nodules Closes https://github.com/facebook/react-native/pull/17187 Differential Revision: D6572303 Pulled By: hramos fbshipit-source-id: aa256b9725970fcc2a6da6578c83e7c0875e3cfd --- .flowconfig | 4 ++++ flow-github/metro.js | 22 ++++++++++++++++++++++ local-cli/templates/HelloWorld/_flowconfig | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 flow-github/metro.js diff --git a/.flowconfig b/.flowconfig index 0cac4b51657b4e..f63fddf53a8f7a 100644 --- a/.flowconfig +++ b/.flowconfig @@ -22,11 +22,15 @@ ; Ignore polyfills .*/Libraries/polyfills/.* +; Ignore metro +.*/node_modules/metro/.* + [include] [libs] Libraries/react-native/react-native-interface.js flow/ +flow-github/ [options] emoji=true diff --git a/flow-github/metro.js b/flow-github/metro.js new file mode 100644 index 00000000000000..8c81bc32a9562c --- /dev/null +++ b/flow-github/metro.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ + +declare module 'metro' { + declare module.exports: any; +} + +declare module 'metro/src/lib/TerminalReporter' { + declare module.exports: any; +} + +declare module 'metro/src/HmrServer' { + declare module.exports: any; +} \ No newline at end of file diff --git a/local-cli/templates/HelloWorld/_flowconfig b/local-cli/templates/HelloWorld/_flowconfig index c3c02e7d8aa406..7d608958e5ffa8 100644 --- a/local-cli/templates/HelloWorld/_flowconfig +++ b/local-cli/templates/HelloWorld/_flowconfig @@ -16,11 +16,15 @@ ; Ignore polyfills .*/Libraries/polyfills/.* +; Ignore metro +.*/node_modules/metro/.* + [include] [libs] node_modules/react-native/Libraries/react-native/react-native-interface.js node_modules/react-native/flow/ +node_modules/react-native/flow-github/ [options] emoji=true