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

"Go To Definition" in VS Code does not work for Typescript projects using Yarn 2 PnP #940

Open
abrenneke opened this issue Apr 9, 2021 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@abrenneke
Copy link

abrenneke commented Apr 9, 2021

Describe the bug
When you're using Yarn 2 PnP with a typescript project, an error occurs when using "Go To Definition" on an imported symbol.

To Reproduce

  • Take the template app, npx degit sveltejs/template svelte-typescript-app
  • Install typescript support node scripts/setupTypeScript.js
  • Install Yarn 2 yarn set version berry
  • Make sure ZipFS extension is installed in VS Code
  • Follow svelte-language-tools yarn pnp setup steps
  • (Maybe some steps I'm forgetting to get things working normally)
  • Import anything in the App.svelte file
  • Control-click your import

Error:

Unable to open 'index.d.ts': Unable to read file '.../.yarn/cache/svelte-npm-3.37.0-87abf2d623-fc7a1e9b64.zip/node_modules/svelte/types/runtime/index.d.ts' (EntryNotADirectory (FileSystemError): Error: ENOTDIR: not a directory, stat '.../.yarn/cache/svelte-npm-3.37.0-87abf2d623-fc7a1e9b64.zip/node_modules/svelte/types/runtime/index.d.ts').

Note that this works when control-clicking a file in a .ts file in the same project. That makes me think that there's something going on in the transition between VS Code and tsserver, which would be svelte-language-server I think. I've looked around but haven't seen any discussion on this yet, but lots of discussions which enabled this support in the Typescript language server - something about passing file paths around that aren't literal paths on the system.

Expected behavior
Same behavior as in a .ts file.

System (please complete the following information):

  • OS: Mac OS
  • Plugin/Package: svelete-language-server
@abrenneke abrenneke added the bug Something isn't working label Apr 9, 2021
@jasonlyu123
Copy link
Member

Have you tried following this doc for yarn 2 pnp ?

@abrenneke
Copy link
Author

Yeah I was the one that noticed they didn't work any more with a recent change. Forgot to add that step into this issue description.

@jasonlyu123
Copy link
Member

You can try setting logging the message between language-server and the extension:

  1. add this config "svelte.trace.server": "verbose"
  2. open the output channel near the integrated terminal, chose svelte, and clear it
  3. reproduce and post the output.

@dummdidumm dummdidumm added the help wanted Extra attention is needed label Jun 3, 2021
@hmnd
Copy link

hmnd commented Nov 1, 2021

Hey there, I am experiencing a similar issue on vscode v1.61.2, with a clean SvelteKit project. For me, it only affects go to definition for HTML elements. See below for the error I get and relevant verbose log output.

This may be related to yarnpkg/berry#3539. Happy to provide any further details that could help :).

Screenshot of the error

Logs
[Trace - 3:59:02 AM] Received response 'textDocument/definition - (133)' in 6ms.
Result: [
    {
        "targetUri": "file:///home/hmnd/dev/redacted/redacted-project/.yarn/__virtual__/svelte2tsx-virtual-0efbfe4338/0/cache/svelte2tsx-npm-0.4.8-c7d7e3a3e4-af29b3db62.zip/node_modules/svelte2tsx/svelte-jsx.d.ts",
        "targetRange": {
            "start": {
                "line": 1018,
                "character": 6
            },
            "end": {
                "line": 1018,
                "character": 8
            }
        },
        "targetSelectionRange": {
            "start": {
                "line": 1018,
                "character": 6
            },
            "end": {
                "line": 1018,
                "character": 8
            }
        },
        "originSelectionRange": {
            "start": {
                "line": 13,
                "character": 2
            },
            "end": {
                "line": 13,
                "character": 4
            }
        }
    }
]

@movy
Copy link

movy commented Jun 14, 2022

It does not work with anything as it's Yarn 2 related. All modules are zipped, not in dirs. Installing zipfs does not help :(

image

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

No branches or pull requests

5 participants