-
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
Installing Typescript definitions for react and react-addons-test-utils is inconsistent with npm #4226
Comments
It also happens on other packages like react-bootstrap,
|
I have encountered this same issue with
|
Have had similar problems with yarn install with package.json that calls for @types\react-select and @types\react-dom - similar in that after yarn install a @types\react-select\node_modules@types\react folder is created where as in npm install this folder is not created. tsc fails with a bunch of TS1005 errors (expected ",", expected ">" etc) on the yarn install - specifically on the @types\react-select\node_modules@types\react\react.d.ts file. Removing the offending folder (@types/react-select/node_modules) will fix the tsc problem. We've implemented a .yarnclean file to do this on yarn install but would like a solution that avoids the creation of those folders in the first place. FWIW found similar question on stackoverflow - https://stackoverflow.com/questions/45715891/why-does-yarn-install-node-modules-folder-for-types-angular-dependencies |
/me googles ".yarnclean" |
I think the core issue is listing |
I'm not sure what is technically correct. I thought that |
With the new selective version resolution feature #4105 in 1.0.0 you can work around this by specifying the resolutions property in package.json "resolutions": {
"**/@types/react": "15.0.26"
} Also mentioned in the announcement of 1.0 |
That assumption is not correct. We are aiming to be compatible when it makes sense. If npm's resolution is technically incorrect, Yarn is not going to try emulate that. Even if it is correct, Yarn doesn't strive to get you the same directory structure with npm. |
@BYK I think the issue is to do with how yarn is handling a dependency of @types/react: "*" because at the moment it seems to install @latest (16.x.x) which causes an extra copy to get installed when another package has specified 15.x.x. According to semver: |
It really depends on the order you resolve them. In this case, Yarn encounters |
@BYK thanks for the clarification. I can use the workaround and that fixes my problems. Should we file issues with the repositories that cause a need for the workaround and cite this issue? You said they should list react as peer dependency instead? |
@BYK is that correct though - are we saying that dependency: '*' only relates to packages underneath that package and not to packages above? It seems to me that yarn should do the full resolution before working out which version to use for '*'? I'm not familiar with the yarn resolution process so I don't understand the impact of this but that seems to be what npm is doing. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Performing a
yarn add
of@types/react@^15.6.1
and@types/react-addons-test-utils
creates output that is inconsistent withnpm install
of the same packages.The
package.json
of@types/react-addons-test-utils
listsreact@*
for it's dependency. I'm assuming this is the root of the issue.If the current behavior is a bug, please provide the steps to reproduce.
yarn add @types/react@^15.6.1 @types/react-addons-test-utils --save-dev
Creates the following..
What is the expected behavior?
yarn add @types/react@^15.6.1 @types/react-addons-test-utils --save-dev
as compared to..
npm install @types/react@^15.6.1 @types/react-addons-test-utils --save-dev
Creates the following..
Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: