-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 packages are not installed as expected #4489
Comments
Hello, Sorry if this will seem like a rant, but this is a serious issue for all Typescript users. I would be very grateful if someone from the core team acknowledged reading this issue. |
Can we establish whose problem this is at least? The problem as far as I can see is that the latest @types/react is versioned '16.x' and the latest @types/react-dom has a dependency of Typescript then has a sulk because there are two @types/react present. So is it a case that:
... or maybe something else? |
@jamiewinder as explained in the issue description, that’s mainly a yarn related issue. As far as I’m concerned, if npm can install |
My observation is that cause of this issue is yarn considers If project.json has explicit dependencies for eg I am experiencing this issue also with yarn versions 0.21.3 and 1.3.2... |
So it sounds like this regressed recently? If you can isolate a working version, that could help to isolate the change that created the bug. On the other hand, @ahz is seeing this all the way back in 0.21.3... |
Noticed this today as well. {
"name": "test",
"version": "1.0.0",
"private": true,
"dependencies": {
"@types/create-react-class": "^15.6.0",
"@types/react": "15",
"@types/react-dom": "15"
}
} Is resolved to the following
The
|
DefinitelyTyped/DefinitelyTyped#20350 this one sounds strongly related. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Yarn team, this is a pretty major issue. I am forced to use EDIT: and I now found the entire discussion at #3951 |
Have you tried to use the resolutions node in the package.json? For me the TypeScript definition issues with react are solved by the following settings in package.json:
Read more about it here. |
Is it ok and documented behavior for Yarn to add nested node_modules folder with second version of dependency?
|
I found a workaround, by using types-installer, which does work with yarn. |
Is this going to be addressed? |
Apparently yarn doesn't correctly install types! Kind of a dealbreaker. yarnpkg/yarn#4489
Just stumbled upon this issue. The lead problem is in Long answer is detailed in the following article: Dependencies done right. (As a side note, there's also another issue in Yarn which should do a better job at hoisting those dependencies, but that's unrelated: |
@arcanis thanks for clarifying. so unless developers use the peer dependency field correctly we keep having this issue and the only workaround is by using
Is this right? Besides, I think this is a serious issue for quite a few people (apart from react + typescript) and it would be nice if there was an option in yarn to either disable the hoisting or at least behave similarily to NPM in this regard, at least up to the point where the peerDependencies are done right;) |
That unfortunately won't solve the issue (at least not in theory - maybe it does in practice, I haven't checked). The
In fact we're going the opposite direction, and have various plans to enforce correctness more and more. Fix the affected packages now! 🙂 |
- update dev-dependencies and `@types` packages; - update CI node version to stable; - use `--strict` compiler option by default (with `--strictNullChecks=false`); - add `@types/react` resolutions for yarn, see [yarnpkg/yarn#4489](yarnpkg/yarn#4489) - increase default warning limit for bundle size in webpack.
@jkanczler unfortunately this does not work with yarn workspaces :( |
Where does this stand currently? As far as I understand this apparently incorrect interpretation of what version However from the TypeScript side it seems like the dependencies are somehow automatically generated, based on this PR microsoft/types-publisher#371 And they don't want to make the dep a peerDependency because tools like VSCode are running eg |
it worked for me by removing yarn.lock and having the resolutions block in the root package.json (I even included it in the workspace package.json, I am bored) |
Now, in 2022, I am using yarn 3.2.1 and React 17. I still had to add the following block to the root "resolutions": {
"@types/react": "17.0.38"
} |
Still weird that after a long time yarn doesn't hoist * versioning correctly |
This comment was marked as spam.
This comment was marked as spam.
Thank you very much, I used this and it worked with yarn workspaces, but does it mean that yarn is supporting the "resolutions" field in package.json ? Is this documented somewhere ? |
https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/ |
Well yes, we kinda invented it 😄 Regarding the initial issue which I only see now (we don't really look at this repository, development for modern releases of Yarn is on yarnpkg/berry),
It may look a purely theoretical issue, but keep in mind:
In any case, I'm going to lock this thread as this isn't a Yarn issue. Modern versions of Yarn let you bypass this third-party issue by either:
|
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have some projects in typescript and when I install type dependencies (
@types
packages) I get weird errors. Those errors mean that there are at least two conflicting versions of those type definitions that I installed.I don't get those errors when I use
npm
.If the current behavior is a bug, please provide the steps to reproduce.
When you have the following package.json
yarn install
gives the following node_modulesWhat is the expected behavior?
npm install
gives:Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: