Skip to content
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

Type resolution in linked packages - Updated Repro #36866

Closed
simonfox opened this issue Feb 18, 2020 · 7 comments · Fixed by #37438
Closed

Type resolution in linked packages - Updated Repro #36866

simonfox opened this issue Feb 18, 2020 · 7 comments · Fixed by #37438
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@simonfox
Copy link

I am still suffering from the issue described in #32970

I that issue I provided a repro and that repro was resolved by #33567

However in my actual application I still face the original issue described (the repro was intentionally simplified). Get error TS2742: The inferred type of 'actions' cannot be named without a reference to 'drive-common/node_modules/typescript-fsa'. This is likely not portable. A type annotation is necessary. when using yarn link to link packages for dev.

I have updated my original repro to re-expose the problem. Follow steps below...
clone https://github.com/simonfox/repro-plugin-one
clone https://github.com/simonfox/repro-plugin-two
run yarn for both
run yarn link in plugin two root
run yarn link plugin-two in plugin one root
you will see the issue in src/features/feature-one/actions.ts (you may need to reload the VS Code window after linking).

cc @sheetalkamat

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 20, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.0 milestone Feb 20, 2020
@imt-jaime
Copy link

imt-jaime commented Feb 24, 2020

I will refer my closed issue as related here. It seems to be the same problem: #33137

Lastly I've discovered this may happens even inside node modules (when there are more than one package that depends on another module (C) in different major versions).

TypeScript compiler cache is not handling NodeJS module resolution described in:

I also think that the pull request #33567 is a close approach to the solution.

@ericmdantas
Copy link

@imt-jaime

Lastly I've discovered this may happens even inside node modules (when there are more than one package that depends on another module (C) in different major versions).

That's pretty much what happens to me. It's an issue even when the packages are not linked, just being a dependency already triggers this. Also, it doesn't have to be a major version difference, any version difference causes the issue.

@imt-jaime
Copy link

imt-jaime commented Feb 26, 2020

@imt-jaime

Lastly I've discovered this may happens even inside node modules (when there are more than one package that depends on another module (C) in different major versions).

That's pretty much what happens to me. It's an issue even when the packages are not linked, just being a dependency already triggers this. Also, it doesn't have to be a major version difference, any version difference causes the issue.

You're right, it is a different problem. @simonfox Have you tried to set 'preserveSymlinks' true in tsconfig.json?
I think the problem in your case is you're not specifying to TypeScript that you want to resolve dependencies with relative paths.

You can find more information in official documentation

@simonfox
Copy link
Author

@imt-jaime preserveSymlinks does not resolve the issue

sheetalkamat added a commit that referenced this issue Mar 17, 2020
@sheetalkamat sheetalkamat added Bug A bug in TypeScript Fix Available A PR has been opened for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels Mar 17, 2020
sheetalkamat added a commit that referenced this issue Mar 17, 2020
…37438)

* Convert symlink scenarios to virtual FS where its symlinks are correctly maintained
Adds test for #36866

* Fix the casing issue when redirects differ in casing of the file

* Make ModuleSpecifierResolutionHost internal

* Refactoring for ModuleSpecifierResolutionHost

* If any of the file path option is from node_modules folder, consider only paths in node_modules folder

* Update src/services/utilities.ts

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
@tpluscode
Copy link

If anyone find this issue, it seems fixed on the next package today :)

@ericmdantas
Copy link

I'm still having this issue even when using typescript 3.9.x. I'll set up a repository to make it easier to simulate the problem.

@TamingOfTheShru
Copy link

TamingOfTheShru commented Jun 21, 2021

I'm still having this issue even when using typescript 3.9.x. I'll set up a repository to make it easier to simulate the problem.
@ericmdantas
Hi, commenting after exactly (almost) 1 year. Were you able to resolve this issue? Because I'm still running into the same problem even after upgrading typescript version to 3.9.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants