Typescript errors caused by @types/react
See original GitHub issueSummary
After upgrading to Expo 45, seeing errors for all JSX elements within return()
statements. The error reads something like:
Type ‘React.ReactNode’ is not assignable to type ‘import(“…/node_modules/@types/hoist-non-react-statics/node_modules/@types/react/index”).ReactNode’
The problem was fixed by upgrading to the latest version of @types/react which 18.0.9
. However, I am unable to run the development environment locally without the required/expected dependency.
✔ It looks like you’re trying to use TypeScript but don’t have the required dependencies installed. Would you like to install @types/react? Y/n Please install @types/react by running: npm install --save-dev @types/react@~17.0.21
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android, iOS
SDK Version (managed workflow only)
Expo 45
Environment
expo-env-info 1.0.3 environment info: System: OS: macOS Mojave 10.14.6 Shell: 3.2.57 - /bin/bash Binaries: Node: 14.17.6 - /usr/local/bin/node npm: 6.14.15 - /usr/local/bin/npm Watchman: 2021.09.13.00 - /usr/local/bin/watchman IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7678000 Xcode: /undefined - /usr/bin/xcodebuild npmPackages: babel-preset-expo: ~9.1.0 => 9.1.0 expo: ^45.0.0 => 45.0.1 react: 17.0.2 => 17.0.2 react-dom: 17.0.2 => 17.0.2 react-native: 0.68.1 => 0.68.1 react-native-web: 0.17.7 => 0.17.7 npmGlobalPackages: eas-cli: 0.52.0 expo-cli: 5.4.3 Expo Workflow: managed
Reproducible demo
Upgrade to Expo 45 with @types/react@~17.0.21
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
@KieQuang I solved the issue by adding the following:
@wcandillon Tkank!!! But when i remove yarn.lock package-lock.json and try reinstall i got this issue again.