New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@types/react@18 break @types/styled-components #59765
Comments
Having the same issue |
having the same |
Same issue here, a lot of files not compiling. |
Same issue here, relates to @types/react @types/react-dom |
Same here, see related thread here |
Same |
Even though there is a mistake in the @types/react, it's styled-component's fault for using the * wildcard in their package.json for @types/react |
Where is the wildcard defined? Because it doesn't look like that's a defined dependency: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/styled-components/package.json I'm having the same issue with @types/react-redux. The package has the wildcard dependency but the package.json doesn't specify @types/react directly https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-redux/package.json |
The I found this solved the issue for the specific libraries I was having issues with
|
if npm , because of @types/react-redux bug "dependencies": {
"@types/react": "^17.0.41"
} |
if use yarn, just set resolutions can fix. if npm, move @types/react to dependencies. |
If you're using at least npm 7 you can give overrides a try to resolve this. That said, it's quite concerning that new versions of a dependent package can break old builds, especially in a post-peacenotwar world. |
@xingyibiao why is this closed? I am still having this issue. The above recommendations did not work. Most of my dependencies are breaking because they have @types/react v 18 |
sry, my project has work when my package.json add resolutions field and move @types/react to dependences. I know this issue is a bug should be fix. so should I reopen this issue? |
same~! |
Hi! I solved it adding this code
to package.json file and run yarn command. Credits for: https://stackoverflow.com/users/15166457/yevhen-rybak His solution: https://stackoverflow.com/a/71828113 |
rather than force the resolution version, delete your lock file and let install recreate it, worked for me along with the react 18 codemod. |
Didn't work for me. Even deleting lock file and node_modules etc... |
For non-local development environments, such as GitHub Actions, I was able to solve the problem by adding |
I using typscript in react-native. |
I must say that I am already tired of this resolutions thingis happening many times, but many thanks to @stitch-rich, it works |
I have the problem from 20 days Just replace install modules from yarn to npm remove node_modules and install it use |
DefinitelyTyped/DefinitelyTyped#59765 be committed: # modified: package.json # modified: yarn.lock #
Having the same issue. When will it be fixed? |
Pra quem usa yarn segue o mesmo no package.json adicione em "dependencies" "@types/react": "17.0.2", depois so dar um "yarn" e seja feliz :D |
This seems to largely stem from the move of FC to be the equivalent of VFC, which makes absolutely zero sense to me, it made sense to have a separate definition that specified an element that took no children, and provided significantly more terse syntax. This: const Component: FC<PropsWithChildren<Props>> = (props) => {
} is objectively clunkier than const Component: VFC<Props> = (props) => {
} and it only gets worse the more complex your definition needs to be. This is a completely untenable change, there's massive swaths of code and projects out there that have gone that route only to have the definition pulled out, causing tons of packages to no longer compile or validate appropriately. Changing small projects are fine, but I work on a project that has hundreds, if not thousands, of components of which a vast majority now don't compile and expecting me to be able to update all my packages so they now work is just completely unrealistic in an actual large-scale production project. My only solution is to stick to the v17 defs, but that's just not the way it should have to work. Changes like this really should not happen, or there should be some kind of migration path. This seems like a very cavalier change. |
Even if you put the correct version of |
This version works for me:
|
Is there any update? The modules resolution solution is not working for me with |
Definitely solves my problems in expo 46 (react@18.0 and react-native@0.69.5)
|
Hi everyone! I've done a little research and I think I can explain why this is happening. React 18 types are incompatible with react 16 types, as everyone has already understood, it is because of props child and other different thinks. Library @types/styled-components has as a dependency package You can find this in your folder node_modules@types\styled-components\package.json When you used to React 17 in your project (before updating to version 18), your yarn.lock probably was something like this:
It means that every projects with @types/react@* uses types of version 17.0.35 After updating to version 18 your yarn.lock became like this:
You can see that despite on So there are two ways to fix this error:1. Create resolution in your package.jsonPut this in the package.json file:
And execute command
So "resolutions" means: "For all packages uses lower version, use version 18 if it is possible". 2. Clean up your yarn.lock fileRemove all code about @types/react from your yarn.lock yarn execute |
I have tried every "solution" in this thread as well as many of the linked thread - nothing is working... I literally have changed nothing in my project from a month ago when everything was working and almost every file is now red - why is this so overly complicated for seemingly no reason? I have downgraded to React/React-dom V 17.0.2 in attempts to fix the issue as well and even that's not solving my problem. What's going on? |
@Karsenh i'm prettie sure the my last solution will help you. Just check your package-lock.json or yarn.lock and make sure that all your @types/react versions use react 18 version like this:
If it is not help you maybe you have another error. And don't forget refresh your typescript/eslint server: |
Hey Sergey, thank you very much for the reply. My package-lock.json looks like this: where you can see the @types/react which I believe you're referring to are "*" I have changed them to the following but they revert whenever I run Also something extremely perplexing: I have a copy of this project on another computer just before I started making changes to deploy to Heroku (which still worked after I made those changes and updated my remote repo) but I opened that one just now and it is not having issues. The only main difference is the file hierarchy (I moved the server out to the root dir). I just ran The working project's package-lock has the following: which perplexes me. It's the same as the broken project.. I've restarted the TS server on both. I couldn't break this other project if I wanted to. I can't understand what the issue could be. EDIT: Holy crap.... This whole time it was because of the file hierarchy which I even said on multiple posts.... 🤦🏼♂️🔨 In my defense, this file file hierarchy used to work and for some reason is now causing issues. 😅 |
* Update react and next * Update three.js * Update MDX * Fix missing type * Fix type error See: DefinitelyTyped/DefinitelyTyped#59765 * Revert to Google fonts Because of missing arrow characters
our project use react@16.9, and styled-components. @types/react@18.0 release break my project, because my project dependence conflict with @types/styled-components dependence. @types/styled-components dependence @types/react@*, not block @types/react version.
see it: issue
The text was updated successfully, but these errors were encountered: