-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
Description
In a fresh RN v0.63.2 project (the latest, as of writing), some lines in node_modules/react-native/interface.js
suppress Flow type-checking for fetch
by making it (and Headers
, Request
, and Response
) any
.
Like #22590, but the file has since been moved, in e54ecf9. Those lines first appeared in 7141948 (6fe3b2229 on the PR branch). I'm taking @ferrannp's invitation on #22590 to comment further saying the issue hasn't been fixed (though I'm blocked from posting on the same issue). Back then, as now, the issue is certainly not related to one's precise configuration (beyond using Flow instead of not using Flow), and running the repro should confirm that. 😉 Let me know if the repro fails, though.
React Native version:
$ react-native info
info Fetching system and libraries information...
System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 582.10 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.12.0 - ~/.nvm/versions/node/v12.12.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v12.12.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /Users/chrisbobbe/.gem/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 25, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.2
System Images: android-28 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.7/11E801a - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_212-release - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
To set up, make a new project with react-native init
and run yarn add flow-bin@^0.122.0
(or whichever version is mentioned under [version]
in .flowconfig
.). Then insert, e.g., fetch('https://www.google.com')
in some valid FILE at LINE and COLUMN (e.g., App.js at line 1, column 1)
Then, to see the problem:
Run yarn flow type-at-pos FILE LINE COLUMN
(e.g., yarn flow type-at-pos App.js 1 1
)
Expected Results
I expect this output:
(input: RequestInfo, init?: RequestOptions) => Promise<Response>
(or whatever Flow's internal type definitions have for fetch
at the Flow version appropriate for the RN version)
Instead, I get this output:
any (explicit)
If I remove the indicated lines in node_modules/react-native/interface.js
and rerun steps 1 and 2 above, I get the expected output.