Skip to content

d.ts type imports are not resolved correctly in dependencies #40581

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

Open
dkjii-g opened this issue Sep 16, 2020 · 4 comments
Open

d.ts type imports are not resolved correctly in dependencies #40581

dkjii-g opened this issue Sep 16, 2020 · 4 comments
Labels
Needs Investigation This issue needs a team member to investigate its status.
Milestone

Comments

@dkjii-g
Copy link

dkjii-g commented Sep 16, 2020

TypeScript Version: 4.1.0-dev.20200915

Search Terms:

path module resolution

Code

Please check this repo: https://github.com/dkjii-g/tsc-ref-bug

Check the README for bugs/instructions.

Expected behavior:

  • The 4 folders compile correctly (they are slight variations to better explain the bug - you don't have to check them all).
  • Typescript should not use the current project's module resolution when importing a different project's definitions.

Actual behavior:

Typescript tries to import repo2's modules from repo1's project.

This prevents the compiler from finding the type definition in dependencies.

Related Issues: #38111 #39117 (not sure)

@dkjii-g
Copy link
Author

dkjii-g commented Sep 16, 2020

As a workaround, changing all the imports into relative paths makes it work.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Sep 16, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Sep 16, 2020
@RyanCavanaugh
Copy link
Member

A concise description of the problem may allow us to respond to this sooner, but generally these are misconfigurations or misunderstandings and will be looked at later.

@dkjii-g
Copy link
Author

dkjii-g commented Sep 16, 2020

Non-relative imports in dependent projects resolve according to the main project's baseUrl/tsconfig. That means that if a package uses non-relative imports and builds correctly (because resolution is done according to its own tsconfig), importing that package from another package will not work, since the generated files of that package will have import directives which point to modules that are not resolvable from the importing package's POV.

This might be a "work as intended," but it's really weird to have a package compile correctly, but being unable to import it in another because it uses non-relative imports.

@rblaa
Copy link

rblaa commented Nov 23, 2022

I am running into this issue now myself.
Any progress or plans to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants