When running flow I get the following error:
Error ┈┈ index.js:3:29
Cannot resolve module react-native.
1│ /* @flow */
2│
3│ import { AppRegistry } from 'react-native';
4│ import App from './src/App';
5│
6│ AppRegistry.registerComponent('myApp', () => App);
Found 1 error
Now, I don't care about checking that my code is calling in to libraries (like react-native) with the correctly annotated Flow types. So I don't need to import type libs for these external libraries. I simply want to get rid of this error, and just have Flow check my own code files for type errors (at least for now).
Is there a config option I can use to ignore these types of errors (which are not code errors)?
Add something like this to your .flowconfig:
[options]
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/src/react-native-dummy.js'
Contents of src/react-native-dummy.js:
declare export default {NativeModules: Object};
That was all that I needed, if there are other symbols that you need just add them to the dummy file (AppRegistry I guess).
Relevant Flow config documentation: https://flow.org/en/docs/config/options/#toc-module-name-mapper-regex-string
@lll000111 that worked perfectly. thanks!
This is the only option that has worked for me.
declare export default {NativeModules: Object};
Perfect!
Most helpful comment
Add something like this to your .flowconfig:
Contents of src/react-native-dummy.js:
That was all that I needed, if there are other symbols that you need just add them to the dummy file (
AppRegistryI guess).Relevant Flow config documentation: https://flow.org/en/docs/config/options/#toc-module-name-mapper-regex-string