Flow cannot access types defined in source code
See original GitHub issueDescription
it looks like there are lots of nice flow typing already inlined for many react native apis/components. but my flow typechecker is not able to access them in my project.
I’m guessing Flow is not able to leverage the existing types in the source, possibly due to this file using getters (flow cant resolve types from getters?) :
https://github.com/facebook/react-native/blob/0.42-stable/Libraries/react-native/react-native.js#L9
Reproduction Steps and Sample Code
Here’s an example that isn’t working:
// @flow
import { StatusBar } from 'react-native';
const fn = () => {
StatusBar.setBarStyle('this-is-not-in-enum');
};
The call to StatusBar.setBarStyle should generate a flow error based on the flow types in the react-native source code. You can see that code in https://github.com/facebook/react-native/blob/0.42-stable/Libraries/Components/StatusBar/StatusBar.js#L201
My .flowconfig:
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore templates for 'react-native init'
.*/local-cli/templates/.*
; Ignore the website subdir
<PROJECT_ROOT>/website/.*
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
[include]
[libs]
Libraries/react-native/react-native-interface.js
flow/
[options]
emoji=true
module.system=haste
experimental.strict_type_args=true
munge_underscores=true
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
unsafe.enable_getters_and_setters=true
[version]
^0.38.0
Additional Information
- React Native version: 0.42.3
- Platform: n/a
- Development Operating System: osx
- Dev tools: flow 0.38.0
p.s. SO issue here: http://stackoverflow.com/questions/43126131/how-to-use-react-native-flow-types
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
This is actually a regression in recent RN versions, we used to do a hack to work around getters not working but they do work now so we removed the hack but didn’t enable flow in react-native-implementations.js which exports all RN modules.
I have a PR up to fix this but it hasn’t been reviewed yet. https://github.com/facebook/react-native/pull/12917
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we’re automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.