Skip to content

fix: support array form of tsconfig "extends" in document links#318263

Open
unrevised6419 wants to merge 2 commits into
microsoft:mainfrom
unrevised6419:fix-tsconfig-extends-array-links
Open

fix: support array form of tsconfig "extends" in document links#318263
unrevised6419 wants to merge 2 commits into
microsoft:mainfrom
unrevised6419:fix-tsconfig-extends-array-links

Conversation

@unrevised6419
Copy link
Copy Markdown

@unrevised6419 unrevised6419 commented May 25, 2026

Description

TsconfigLinkProvider (in extensions/typescript-language-features/src/languageFeatures/tsconfig.ts) only created a document link when the extends field was a string. TypeScript 5.0 added support for an array of base configs:

{
  "extends": ["./tsconfig.base.json", "@tsconfig/strictest/tsconfig.json"]
}
image

In that case, the existing code asked jsonc.findNodeAtLocation(root, ['extends']) and handed the resulting node straight to tryCreateTsConfigLink. isPathValue requires node.type === 'string', so the array case was silently dropped — Cmd+Click did nothing on any of the entries.

This change renames getExtendsLink to getExtendsLinks and:

  • returns [] when no extends is present
  • iterates array children via the existing mapChildren helper when extends is an array
  • falls through to the original single-string behavior otherwise

Each element is resolved through the unchanged tryCreateTsConfigLinkopenExtendsLinkCommandIdgetTsconfigPath pipeline, so relative paths, absolute paths, and node_modules package resolution continue to work per element.

For consistency, all three sibling getters (getExtendsLinks, getFilesLinks, getReferencesLinks) now carry an explicit (vscode.DocumentLink | undefined)[] return type. The outer coalesce in provideDocumentLinks is unchanged and still filters the undefined entries.

Reference: TypeScript 5.0 release notes – Supporting Multiple Configuration Files in extends.

How to test

  1. Open a workspace containing a tsconfig.json such as:
    {
      "extends": ["./tsconfig.base.json", "./tsconfig.strict.json"]
    }
    with both referenced files present next to it.
  2. Hover each string inside the extends array — a "Follow link" tooltip should appear.
  3. Cmd+Click (Ctrl+Click on Windows/Linux) each entry and confirm the correct file opens.
  4. Confirm the existing single-string form still works:
    { "extends": "./tsconfig.base.json" }
  5. Confirm files and references links are unaffected.

TypeScript 5.0 allows `"extends": ["./a.json", "./b.json"]`. The
TsconfigLinkProvider only handled the string form, so Cmd+Click silently
did nothing on array entries. Iterate over array children and resolve
each through the existing tryCreateTsConfigLink path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 23:51
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.

Updates the tsconfig document link provider to support multiple extends entries by handling extends as either a single value or an array.

Changes:

  • Replace single extends link generation with multi-link generation.
  • Add support for extends: [] by iterating array children and creating links per entry.

Comment thread extensions/typescript-language-features/src/languageFeatures/tsconfig.ts Outdated
unrevised6419 added a commit to unrevised6419/vscode that referenced this pull request May 25, 2026
…getters

Addresses Copilot review feedback on microsoft#318263. Each get*Links method now
returns vscode.DocumentLink[] and filters undefined entries via coalesce
internally, so provideDocumentLinks no longer needs an outer coalesce.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…getters

Addresses Copilot review feedback on microsoft#318263. Each get*Links method now
returns vscode.DocumentLink[] and filters undefined entries via coalesce
internally, so provideDocumentLinks no longer needs an outer coalesce.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@unrevised6419 unrevised6419 force-pushed the fix-tsconfig-extends-array-links branch from a7986f2 to 0e1d78c Compare May 25, 2026 23:58
@unrevised6419
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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