Skip to content

Add Cmd+Click navigation for tsconfig lib entries#318350

Open
unrevised6419 wants to merge 2 commits into
microsoft:mainfrom
unrevised6419:andrei/tsconfig-lib-goto-definition
Open

Add Cmd+Click navigation for tsconfig lib entries#318350
unrevised6419 wants to merge 2 commits into
microsoft:mainfrom
unrevised6419:andrei/tsconfig-lib-goto-definition

Conversation

@unrevised6419
Copy link
Copy Markdown

Description

Adds document links for entries in compilerOptions.lib[] inside tsconfig.json / jsconfig.json, so that Cmd+Click on a value like "DOM" or "ES2020" opens the corresponding lib.<name>.d.ts file. This mirrors the existing behavior for extends, files, and references.

The target lib file is resolved from the same TypeScript version the language service is currently using:

  1. The active version (honors typescript.tsdk and the "Use Workspace Version" picker selection — reads the same typescript.useWorkspaceTsdk workspace state the version manager writes).
  2. Any other locally available TypeScript install (workspace node_modules/typescript, configured tsdk).
  3. The bundled TypeScript shipped with VS Code.

Implementation reuses the existing _typescript.openExtendsLink command and TsConfigLinkType enum (new Lib variant) rather than introducing a parallel command + args type.

How to test

  1. Open a tsconfig.json containing:
    {
      "compilerOptions": {
        "lib": ["DOM", "DOM.Iterable", "ESNext"]
      }
    }
  2. Cmd+Click (or Ctrl+Click on Linux/Windows) on any of the lib entries → the corresponding lib.dom.d.ts, lib.dom.iterable.d.ts, lib.esnext.d.ts opens.
  3. Toggle "TypeScript: Select TypeScript Version…" between bundled and workspace versions → Cmd+Click target should follow the active selection.
  4. In a workspace with no local TypeScript install, links should still resolve to the bundled VS Code TypeScript.

🤖 Generated with Claude Code

Entries in `compilerOptions.lib[]` now resolve to the matching
`lib.<name>.d.ts` file, mirroring the existing document links for
`extends`, `files`, and `references`.

The target file is picked from the same TypeScript version the
language service is using: respects `typescript.tsdk` and the
"Use Workspace Version" picker selection, falling back to any
locally available TS install and finally the bundled TypeScript.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 26, 2026 12:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for navigating from tsconfig.json compilerOptions.lib entries to their corresponding TypeScript lib .d.ts files, using the currently active TypeScript version when possible.

Changes:

  • Exported the workspace TSDK storage key so it can be reused outside the version manager.
  • Added compilerOptions.lib document links and resolution logic (preferring active/local TS versions, then bundled).
  • Updated extension activation to pass versionProvider and workspaceState into the tsconfig feature registration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
extensions/typescript-language-features/src/tsServer/versionManager.ts Exports the workspace TSDK storage key for cross-module use.
extensions/typescript-language-features/src/languageFeatures/tsconfig.ts Adds lib links + resolution via TS versions; updates register signature and open-link handling.
extensions/typescript-language-features/src/extension.ts Passes required dependencies to tsconfig.register.
extensions/typescript-language-features/src/extension.browser.ts Passes required dependencies to tsconfig.register in browser activation.

Comment thread extensions/typescript-language-features/src/languageFeatures/tsconfig.ts Outdated
Comment thread extensions/typescript-language-features/src/languageFeatures/tsconfig.ts Outdated
- Rename `extendsValue` -> `pathValue` since the field is now used for
  both `extends` paths and `compilerOptions.lib` values.
- Tailor the resolution error message per link type so lib failures
  say "Failed to resolve TypeScript lib X" instead of "as module".
- Detect URI version paths with a scheme regex (excluding Windows
  drive paths) instead of a naive `://` substring check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants