Skip to content

Commit

Permalink
Fix failure due to missing Metro flow types
Browse files Browse the repository at this point in the history
Summary:
Fixes the Flow failure due to an undefined Ast type.

Before:

```
 $ npm run flow -- check

> [email protected] 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

> [email protected] 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 #17187

Differential Revision: D6572303

Pulled By: hramos

fbshipit-source-id: aa256b9725970fcc2a6da6578c83e7c0875e3cfd
  • Loading branch information
hramos authored and facebook-github-bot committed Dec 14, 2017
1 parent eca51eb commit f4d627c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions flow-github/metro.js
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions local-cli/templates/HelloWorld/_flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4d627c

Please sign in to comment.