question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript errors caused by @types/react

See original GitHub issue

Summary

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:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wcandilloncommented, Jun 1, 2022

@KieQuang I solved the issue by adding the following:

   "resolutions": {
      "@types/react": "17.0.30"
   },
0reactions
KieQuangcommented, Jun 3, 2022

@wcandillon Tkank!!! But when i remove yarn.lock package-lock.json and try reinstall i got this issue again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple versions of `@types/react` causes TypeScript errors ...
It's because @types/react-native pulls them in. Seeing its package.json it appears it's because it has an * version for @types/react, so it pulls...
Read more >
TypeScript errors and how to fix them
Common Errors. Below you find a list of common TypeScript errors along with the buggy code and its fixed version. If you're interested...
Read more >
React Typescript not giving type checking errors
I'm encountering a strange issue with React where TypeScript does not show any errors after running npm start or npm build .
Read more >
Common React TypeScript ESLint / Lint Errors & Warning ...
In this article, I showed you common React TypeScript ESLint errors and warning messages typical found when using the Airbnb style guide &...
Read more >
Why do TypeScript errors in React cause compilation failure?
Is it possible to stop compilation failure during TypeScript errors in React and therefore stop showing it on browser?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found