Microsoft/vscode

typescript.tsdk not resolved correctly when it starts with the same name as the parent directory

Open

#272,761 创建于 2025年10月22日

在 GitHub 查看
 (1 评论) (0 反应) (1 负责人)TypeScript (10,221 fork)batch import
bughelp wantedtypescript

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.105.1
  • OS Version: Windows 11

Steps to Reproduce:

  1. Create a directory called x and open it in VS Code
  2. Create a .vscode/settings.json with "typescript.tsdk": "x/.yarn/sdks/typescript/lib"
  3. Press ctrl+shift+p, choose "Select TypeScript Version", then Pick "Use Workspace Version"
  4. Note that the error message says

The path c:\path\to\x.yarn\sdks\typescript\lib\tsserver.js doesn't point to a valid tsserver install. Falling back to bundled TypeScript version.

when it should should be c:\path\to\x\x\.yarn\sdks\typescript\lib\tsserver.js

It's because of https://github.com/microsoft/vscode/blob/81a9252210bc64a201449a75995c708aa7a5db96/extensions/typescript-language-features/src/utils/relativePathResolver.ts#L11-L15

Originally introduced in https://github.com/microsoft/vscode/commit/733e208be4cfa85e5a1b2e2ea415843f0a9a7b6d

Workaround: "typescript.tsdk": ".//x/.yarn/sdks/typescript/lib", note the double slash at the start.

I could submit a PR that deletes that code to solve it, but I don't understand what it's there for in the first place.

CC @mjbvz

贡献者指南