sveltejs/language-tools

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

Open

#940 opened on Apr 9, 2021

 (5 comments) (1 reaction) (0 assignees)TypeScript (247 forks)auto 404
bughelp wanted

Repository metrics

Stars
 (1,437 stars)
PR merge metrics
 (PR metrics pending)

Description

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

Contributor guide