Skip to content

fix: use workspace version of typescript server in yarn pnp mode #1763

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
wants to merge 1 commit into from

Conversation

ld210
Copy link

@ld210 ld210 commented Sep 23, 2022

In Yarn PnP mode, the language service must use the workspace version of the typescript server. Because of the lack of node_modules folder, it falls back to its own version. This PR allows the language service to work in Yarn PnP environment. That being said, the user still has to disable automatic ngcc in the plugin options.

This PR fixes issue #1748

@google-cla
Copy link

google-cla bot commented Sep 23, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

allow the language service to use workspace version of typescript server, by fixing the resolve function. automatic ngcc must be disabled in plugin options

Fixes angular#1748
@ld210 ld210 force-pushed the fix-yarn-pnp-compatibility branch from 9e7bf4b to d07d68a Compare September 23, 2022 10:15
@devversion devversion self-requested a review September 26, 2022 16:12
export function resolve(packageName: string, location: string, rootPackage?: string): NodeModule |
undefined {
const isYarnModule = location.startsWith('.yarn/sdks');
location = isYarnModule ? '.yarn/sdks' : location;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix looks reasonable to me- but would there also be a way of just respecting the VSCode typescript.tsdk setting? This is the one that Yarn sets as well and this would be more flexible without hard-coding to Yarn.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why i was a little hesitant to make a PR, it's a bit of a dirty fix. I went for the jugular ^^
Anyway, thanks @atscott for the proper fix !

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ld210 PRs serve to get the ball rolling :) Thanks for the detailed information in your issue report. It helped a lot to reproduce things on my end.

@atscott
Copy link
Collaborator

atscott commented Sep 27, 2022

Superseded by #1765. The comment from @devversion made me remember that we already look at the tsdk from the settings. It just needed to be updated to support a relative path.

@atscott atscott closed this Sep 27, 2022
@ld210 ld210 deleted the fix-yarn-pnp-compatibility branch September 28, 2022 07:18
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants