Typescript error: __DEV__ conflicts with React Native
See original GitHub issueIntended outcome:
No typescript errors
Actual outcome:
When the client is used with react-native, Typescript throws an error:
node_modules/@apollo/client/utilities/globals/global.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped variable '__DEV__'.
2 const __DEV__: boolean | undefined;
~~~~~~~
node_modules/@types/react-native/index.d.ts:9904:11
9904 const __DEV__: boolean;
~~~~~~~
'__DEV__' was also declared here.
How to reproduce the issue:
- Create a react-native project from typescript template
- Add
@apollo/client
- Make sure skipLibCheck in tsconfig is false
- Run tsc
Versions
System: OS: macOS 11.5.2 Binaries: Node: 14.18.1 - /usr/local/opt/nvm/versions/node/v14.18.1/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 6.14.15 - /usr/local/opt/nvm/versions/node/v14.18.1/bin/npm Browsers: Chrome: 95.0.4638.69 Firefox: 87.0 Safari: 14.1.2 npmPackages: @apollo/client: 3.4.16 => 3.4.16 apollo-link-timeout: 4.0.0 => 4.0.0
react-native: 0.66.2 typescript: 4.4.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
TypeScript and React Native, hundreds of errors from ...
I'm thinking that the typings for @types/react maybe depended on the node typings, and by explicitly installing them I introduced a bunch of ......
Read more >Using TypeScript - React Native
TypeScript is a language which extends JavaScript by adding type definitions, much like Flow. While React Native is built in Flow, ...
Read more >Troubleshooting | React Navigation
Error : While trying to resolve module "@react-navigation/native" from file "/path/to/src/App.js", the package ... npm install --save-dev typescript
Read more >TypeScript errors and how to fix them
TS1471: Module ' @headlessui/react ' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported ......
Read more >Integrating with Other Libraries - React
The easiest way to avoid conflicts is to prevent the React component from updating. You can do this by rendering elements that React...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@benjamn can confirm that 3.5.9 no longer produces the error. Thanks!
These changes are now available from npm in
@apollo/client@3.5.9
(just published). Please give that version a try when you have a chance @szymn @danilobuerger @mitsuhiko!