Skip to content

Project references result in multiple dual publish module resolutions #59456

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

Closed
remcohaszing opened this issue Jul 29, 2024 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@remcohaszing
Copy link

🔎 Search Terms

“module resolution dual references”

🕗 Version & Regression Information

  • This changed between versions 4.9 and 5.0
  • I was unable to test this on prior versions because `"moduleResolution": "bundler" was introduced in TypeScript 5.0.

⏯ Playground Link

https://github.com/remcohaszing/typescript-resolution-bug

💻 Code

See the repo. It’s not big, but it contains a bunch of small files that’s inconvenient and not useful to paste in the issue report.

Steps to reproduce:

git clone https://github.com/remcohaszing/typescript-resolution-bug.git
cd typescript-resolution-bug
npm install
npx tsc -b repro

🙁 Actual behavior

$ tsc -b repro
repro/test/test.ts:4:12 - error TS2345: Argument of type 'import("/home/remco/Projects/typescript-resolution-bug/repro/node_modules/some-lib/index").SomeType' is not assignable to parameter of type 'import("/home/remco/Projects/typescript-resolution-bug/repro/node_modules/some-lib/index").SomeType'.
  Types have separate declarations of a private property 'property'.

4 myFunction(new SomeType())
             ~~~~~~~~~~~~~~


Found 1 error.

🙂 Expected behavior

One of the following:

  1. The reproduction is considered valid: does not contain type errors.
  2. The error shows the actual path of the resolved paths instead of stripping the file extension. Currently the paths in the error message are exactly the same. A nice side effect of this, is that the path becomes clickable in some terminal emulators.

Additional information about the issue

Removing references from tsconfig.json resolves the issue.

A real world example is found in https://github.com/remcohaszing/codemirror-languageservice. Just search for @ts-expect-error.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jul 29, 2024
@andrewbranch andrewbranch added this to the TypeScript 5.6.1 milestone Jul 29, 2024
remcohaszing added a commit to remcohaszing/codemirror-languageservice that referenced this issue Jul 30, 2024
The TypeScript `module` option `preserve` is more correct for use with
bundlers or vitest, but it causes a TypeScript issue. As a result, the
code had to be scattered with `@ts-expect-error` comments, which is a
trade-off worse than setting `module` to `node16`.

Refs microsoft/TypeScript#59456
@remcohaszing
Copy link
Author

I applied a workaround to the real world project: I set the module option to node16, even though preserve is more correct for use with a bundler.

@remcohaszing remcohaszing changed the title Project references resolt in multiple dual publish module resolutions Project references result in multiple dual publish module resolutions Jul 30, 2024
@andrewbranch
Copy link
Member

Confirmed this is fixed by #60039, so I think this is a duplicate of #57553 (or at least has the same root cause).

@andrewbranch andrewbranch added Duplicate An existing issue was already created and removed Needs Investigation This issue needs a team member to investigate its status. labels Oct 15, 2024
@andrewbranch andrewbranch removed their assignment Oct 15, 2024
@andrewbranch andrewbranch removed this from the TypeScript 5.7.0 milestone Oct 15, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants