Skip to content

Commit 591a4d6

Browse files
committed
fix: correctly install nested types dependencies
when there are implicit peer dep types closes #6442
1 parent 2c69552 commit 591a4d6

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

.pnp.cjs

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = require(`./package.json`);
2+
3+
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) {
4+
for (const dep of Object.keys(module.exports[key] || {})) {
5+
module.exports[key][dep] = require(dep);
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "peer-deps-implicit-types-conflict",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"@types/no-deps": "2.0.0"
6+
},
7+
"peerDependencies": {
8+
"no-deps": "1.0.0"
9+
}
10+
}

packages/acceptance-tests/pkg-tests-specs/sources/features/peerDependenciesMeta.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ describe(`Features`, () => {
100100
},
101101
),
102102
);
103+
104+
test(
105+
`it should correctly resolve nested dependencies with different versions of types packages`,
106+
makeTemporaryEnv(
107+
{
108+
dependencies: {
109+
'peer-deps-implicit-types-conflict': `1.0.0`,
110+
'@types/no-deps': `1.0.0`,
111+
},
112+
},
113+
async ({path, run, source}) => {
114+
await run(`install`);
115+
116+
await expect(
117+
source(`require('@types/no-deps').version`),
118+
).resolves.toEqual(`1.0.0`);
119+
120+
await expect(
121+
source(`require(require.resolve('@types/no-deps', { paths: [require.resolve('peer-deps-implicit-types-conflict/package.json')] })).version`),
122+
).resolves.toEqual(`2.0.0`);
123+
},
124+
),
125+
);
103126
});
104127
});
105128

packages/yarnpkg-core/sources/Configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ export class Configuration {
19711971
const typesIdent = structUtils.makeIdent(`types`, typesName);
19721972
const stringifiedTypesIdent = structUtils.stringifyIdent(typesIdent);
19731973

1974-
if (pkg.peerDependencies.has(typesIdent.identHash) || pkg.peerDependenciesMeta.has(stringifiedTypesIdent))
1974+
if (pkg.peerDependencies.has(typesIdent.identHash) || pkg.peerDependenciesMeta.has(stringifiedTypesIdent) || pkg.dependencies.has(typesIdent.identHash))
19751975
continue;
19761976

19771977
pkg.peerDependencies.set(typesIdent.identHash, structUtils.makeDescriptor(typesIdent, `*`));

0 commit comments

Comments
 (0)