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

[Bug?]: Invalid typescript types resolved with yarn 3 #3299

Closed
1 task
Js-Brecht opened this issue Aug 16, 2021 · 4 comments
Closed
1 task

[Bug?]: Invalid typescript types resolved with yarn 3 #3299

Js-Brecht opened this issue Aug 16, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Js-Brecht
Copy link
Contributor

Js-Brecht commented Aug 16, 2021

Self-service

  • I'd be willing to implement a fix

Describe the bug

There seems to be some issue with resolving typescript types for a package when importing modules from subdirectories/exports.

A couple screenshots that might help explain:

  • The error displayed in vscode
    image
  • The type selected when I use Go To Definition
    image

If I import get first, then the types for set will point to get.

Perhaps this has to do with arcanis.vscode-zipfs, because I remember that you didn't used to be able to use Go To Definition when using yarn 2.

The problem does not exist when I use Typescript with a more common package manager.

To reproduce

Reproduction repository: https://github.com/Js-Brecht/yarn3-tsc-type-resolution-issue

Should be able to run yarn from the repository, and then try running yarn tsc... it throws an error where it shouldn't.

image

Environment

  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (8) x64 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
  Binaries:
    Node: 12.21.0 - /tmp/xfs-43d13f8b/node
    Yarn: 3.0.1 - /tmp/xfs-43d13f8b/yarn
    npm: 6.14.11 - ~/.nvm/versions/node/v12.21.0/bin/npm
@Js-Brecht Js-Brecht added the bug Something isn't working label Aug 16, 2021
@merceyz
Copy link
Member

merceyz commented Aug 16, 2021

Duplicate of #3058

@merceyz merceyz marked this as a duplicate of #3058 Aug 16, 2021
@merceyz merceyz closed this as completed Aug 16, 2021
@merceyz
Copy link
Member

merceyz commented Aug 16, 2021

It's a bug in the PnP patch for TypeScript, you can disable PnP and go back to node_modules by running

yarn config set nodeLinker node-modules && yarn

or you can try the fix in #3297 by running

yarn set version from sources --branch 3297 && yarn

@Js-Brecht
Copy link
Contributor Author

Duplicate of #3058

Oh, my bad. I tried to find an existing ticket, but was looking for the wrong thing 😆.

or you can try the fix in #3297 by running

That works. I get an initial error when using Go To Definition, but I think it has to do with the zipfs (nothing to do with that update, either).

Unable to open 'object.d.ts': Unexpected model for TextResourceEditorInput: zip:/home/jeremy/dev/test/yarn3-erroneous-types/.yarn/cache/%40types-lodash-npm-4.14.172-e52063c461-5fc51ea40d.zip/node_modules/%40types/lodash/common/object.d.ts.

It works on the second try. I can open a new ticket for that; just don't know if it should be on this repo, or somewhere else? I can reproduce it pretty reliably.

@WoodyWoodsta
Copy link

@Js-Brecht I'm getting this error fairly consistently. It would be great if you could open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants