Skip to content

Commit

Permalink
test: add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Aug 15, 2021
1 parent 90d7eeb commit fc6b1c3
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions packages/plugin-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@yarnpkg/plugin-patch": "^3.0.0"
},
"devDependencies": {
"@types/lodash-es": "4.17.4",
"@types/resolve": "^1.17.1",
"@yarnpkg/cli": "workspace:*",
"@yarnpkg/core": "workspace:*",
Expand Down
19 changes: 19 additions & 0 deletions packages/plugin-compat/typescript-tests/similar-basename.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test for https://github.com/yarnpkg/berry/issues/3058
// Fixed by https://github.com/merceyz/TypeScript/commit/98866a5a740b487c20046d4ffaa36aa1f202dde9

// The PnP patch returned the packageLocation with a trailing `/` which
// caused TypeScript to calculate the `subModuleName` incorrectly[1].
// This caused different files where only the first character of their
// basename was different to end up with the same packageIdKey[2].
// In this test the affected files were
// @types/lodash-es/find.d.ts -> @types/lodash-es/[email protected]
// @types/lodash-es/bind.d.ts -> @types/lodash-es/[email protected]
//
// 1: https://github.com/microsoft/TypeScript/blob/98866a5a740b487c20046d4ffaa36aa1f202dde9/src/compiler/moduleNameResolver.ts#L20
// 2: https://github.com/arcanis/TypeScript/blob/36225c32609137d29008e9d3ecf48c6f51456eb5/src/compiler/program.ts#L2625

import {find} from 'lodash-es';

find([``], () => true);

// This test is tested by typechecking the repository
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4238,6 +4238,22 @@ __metadata:
languageName: node
linkType: hard

"@types/lodash-es@npm:4.17.4":
version: 4.17.4
resolution: "@types/lodash-es@npm:4.17.4"
dependencies:
"@types/lodash": "*"
checksum: acffe910e8cffe475b854d74f4372549ec700ac00d9ed885fd85ec34c3f9af1a262bf667000ea9126dc39a05a75f64593d8a5f312cfd7d90e91294d458be08a7
languageName: node
linkType: hard

"@types/lodash@npm:*":
version: 4.14.172
resolution: "@types/lodash@npm:4.14.172"
checksum: 5fc51ea40d7e455bd1c760bcc60c9e81f82d85988666d4d4969bd8311367c63bbf1fe2be48755ba87836710e45fff94014ec164ebe6ccaa72815014981152434
languageName: node
linkType: hard

"@types/lodash@npm:^4.14.136, @types/lodash@npm:^4.14.165, @types/lodash@npm:^4.14.92":
version: 4.14.168
resolution: "@types/lodash@npm:4.14.168"
Expand Down Expand Up @@ -5618,6 +5634,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@yarnpkg/plugin-compat@workspace:packages/plugin-compat"
dependencies:
"@types/lodash-es": 4.17.4
"@types/resolve": ^1.17.1
"@yarnpkg/cli": "workspace:*"
"@yarnpkg/core": "workspace:*"
Expand Down

0 comments on commit fc6b1c3

Please sign in to comment.