Skip to content

fix(vscode-typescript): activate for content-mapped-only workspaces - #64365

Closed
snehasish (snhsish) wants to merge 2 commits into
microsoft:mainfrom
snhsish:fix/64355-content-mapper-activation
Closed

snehasish (snhsish) wants to merge 2 commits into
microsoft:mainfrom
snhsish:fix/64355-content-mapper-activation

Conversation

@snhsish

@snhsish snehasish (snhsish) commented Sep 20, 2026 •

Copy link
Copy Markdown

Fixes #64355

Analysis

The TypeScript 7 VS Code extension only declares onLanguage activation events for javascript/typescript modes, so opening a workspace containing only content-mapped files (e.g. .tsrx with contentMappers in tsconfig.json) never activates the extension and no language server starts.

Activation alone is not sufficient (per the issue discussion): the server only registers mapper file extensions with the client after the project declaring contentMappers has loaded, and that project only loads when one of its own files is opened. The extension's custom/setContentMapperContributions sync filtered openDocuments down to files matching API-registered (registerContentMappers) extensions, so tsconfig-declared mapped files were never reported, the configured project never loaded, and already-open mapped buffers stayed unserved — including projects that contain only mapped files.

Fix

  • packages/vscode-typescript/package.json: also activate on workspaceContains:**/tsconfig.json and workspaceContains:**/jsconfig.json so mapped-only workspaces start the extension. (onStartupFinished was deliberately avoided to keep activation scoped.)
  • packages/vscode-typescript/src/session.ts: report already-open non-JS/TS file:/untitled: documents as candidate mapped files in the openDocuments hint (single shouldSyncForDocument predicate used by both onDidOpen and the post-start sync, gated on js/ts.contentMappers.enabled). This loads the declaring configured project, after which the server's dynamic registration delivers sync/diagnostics to the open buffers.
  • packages/vscode-typescript/src/contentMapperContributions.ts: new pure documentIsContentMapperCandidate predicate; jsTsLanguageModes now lives here (re-exported from util.ts) so the unit-test bundle stays free of the extension-host vscode runtime import.
  • packages/vscode-typescript/test/contentMapperContributions.test.ts: covers candidate inclusion/exclusion.

With useTsgo off the extension still early-returns as before, and existing JS/TS activation paths are unchanged. #64356 is not included.

Copilot Checklist

I successfully ran the applicable command at the end of my session, and it completed without error:

  • npx hereby validate
  • npx hereby validate --api (for TypeScript API changes)

AI disclosure: this patch was authored with AI assistance and reviewed by the operator, who will shepherd it through review.

Copilot AI balanced review requested due to automatic review settings September 20, 2026 20:31
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 20, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The protocol documentation is inconsistent with the new behavior, and the mapped-only synchronization regression lacks integration coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

Enables TypeScript 7 for workspaces containing only configured content-mapped files.

Changes:

  • Activates on TypeScript/JavaScript config files.
  • Synchronizes open non-JS/TS candidate documents.
  • Adds candidate-filtering unit tests.
File Description
packages/​vscode-typescript/​package.json Adds configuration-based activation events.
packages/​vscode-typescript/​src/​session.ts Synchronizes candidate mapped documents.
packages/​vscode-typescript/​src/​contentMapperContributions.ts Adds candidate detection and language modes.
packages/​vscode-typescript/​src/​util.ts Re-exports shared language modes.
packages/​vscode-typescript/​test/​contentMapperContributions.test.ts Tests candidate filtering.

Comment on lines 151 to +152
const openDocuments = vscode.workspace.textDocuments
.filter(document => documentMatchesContentMapperContributions(document, this.contentMapperRegistrations))
.filter(document => this.shouldSyncForDocument(document))
Comment on lines +34 to +38
test("content mapper candidates are non-js/ts file and untitled documents", () => {
assert.equal(documentIsContentMapperCandidate({ uri: { scheme: "file" }, languageId: "plaintext" }), true);
assert.equal(documentIsContentMapperCandidate({ uri: { scheme: "file" }, languageId: "unknown" }), true);
assert.equal(documentIsContentMapperCandidate({ uri: { scheme: "untitled" }, languageId: "plaintext" }), true);
});
@snhsish

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The activation and synchronization changes are cohesive and covered by focused unit and end-to-end tests.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
Files not reviewed (1)
  • tsc/internal/lsp/lsproto/lsp_generated.go: Generated file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TypeScript 7 VS Code extension never activates for workspaces where only content-mapped files are opened

3 participants