Skip to content

Import autocompletion with project references and yarn workspaces doesn't work #38955

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
elitvinchuk opened this issue Jun 5, 2020 · 4 comments · Fixed by #39679
Closed

Import autocompletion with project references and yarn workspaces doesn't work #38955

elitvinchuk opened this issue Jun 5, 2020 · 4 comments · Fixed by #39679
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@elitvinchuk
Copy link

TypeScript Version: 3.9.5

Search Terms:
"project references" import
"project references" import autocomplete
"project references" monorepo

Description
Hello! First of all, thank you for all amazing work!

I've been trying to befriend yarn workspaces, project references and import autocompletion for a while. It was a relief to see that caveat mentioned in docs is resolved, but didn't manage to do it myself. I've even tried example repo provided by maintainers, but no luck.

When using only yarn workspaces there're no issues at all - all packages listed in workspaces are imported with no issue. After adding ts and project references autocomplete disappears, though Go to Definition works as expected.

I'm is using @babel/preset-typescript so don't actually rely on d.ts.

Could you please point to whether I'm doing anything wrong or the issue really takes place?

Thanks in advance!

Code
I've created example repo. Initial commit illustrates how things didn't work initially, and second commit is updates due to maintainer's example.

Expected behavior:
Import autocomplete is available without building with tsc -d

Actual behavior:
not-working

Related Issues:

@sheetalkamat
Copy link
Member

I think #38923 by @andrewbranch will help with this

@elitvinchuk
Copy link
Author

Thank you @sheetalkamat for pointing me! Subscribed to the issue.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 15, 2020
@RyanCavanaugh RyanCavanaugh added this to the Typescript 4.0.1 milestone Jun 15, 2020
@andrewbranch
Copy link
Member

@sheetalkamat, my PR almost solved this, but module resolution through node_modules fails when the referenced project isn’t built because index.d.ts/index.js doesn’t exist yet—the resolution host needs to use [your version of fileExists] that recognizes project reference redirect sources, but it’s not accessible in its current location. I remember you originally had that function in Project, but later moved it to Program, but can’t remember why... do you think moving it out to a common utility would make sense?

@sheetalkamat
Copy link
Member

I think you could imprelement getCompilerHost of autoImport provider as configuredProjectInQuestion.getCcompilerHost() and that should fix this. (Note you would want to remove unsetting compiler host of the configured project after updateGraph is complete.)

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

Successfully merging a pull request may close this issue.

5 participants