-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
Run react-native info
in your terminal and paste its contents here.
[skip envinfo]
Description
I spent some time trying to improve the flow typing in our codebase last week. I was stumped why functions using fetch
couldn't properly type the return value Promise<Response>
. Flow definitely includes proper typing.
I traced it down to the react-native-interface.js
which erases types for fetch
and it's associated types (https://github.com/facebook/react-native/blob/master/Libraries/react-native/react-native-interface.js#L21).
It looks like this was set up 4 years ago according to git blame and I suspect that was before Flow added those types as built-ins.
Reproducible Demo
In any React Native project that uses Flow, just run yarn flow type-at-pos <file-that-uses-fetch.js> row col
(for a position where fetch
is used).
You'll see the result is any
.
If you comment out the line in the project .flowconfig
that includes react-native-interface.js
([libs] section
) that same flow type-at-pos
command returns the correct type (Promise<Response>
).