Skip to content

Content mappers round 2 - #63936

Merged
Andrew Branch (andrewbranch) merged 18 commits into
microsoft:mainfrom
andrewbranch:content-mappers-2
Aug 21, 2026
Merged

Content mappers round 2#63936
Andrew Branch (andrewbranch) merged 18 commits into
microsoft:mainfrom
andrewbranch:content-mappers-2

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

This finishes out microsoft/typescript-go#4712 with some additional bug fixes and a couple missing features.

Protocol/Contract/API changes

  • Removed protocolVersion from initialize params and response: protocol changes will be handled with LSP-like capabilities rather than specifying a version.
  • Diagnostic code is now required.
  • Removed the restriction on overlapping original-text spans. (cc Remco Haszing (@remcohaszing) Lyu, Wei-Da (@jasonlyu123))
  • The VS Code API registration takes an inferredProjectContribution property, not an inferredProject property. (Previously shipped with an incomplete rename.)
  • Previously, when go-to-definition or references returned a result in virtual text with no mapping, a fake result at the top of the file was returned as a fallback. This was done so default exports representing components/templates could be synthesized with no mapping, but going to the definition of an imported component was guaranteed to navigate the user to the file. However, this breaks the ability for the content mapper to opt out of those LSP features, and in the case where a 3rd party extension might provide a better implementation, the stub result from TypeScript would still be returned. I decided it’s better not to synthesize this fallback, because it can be done by the mapper. If your content mapper synthesizes any module exports, ensure those exports at least have a mapping to a zero-length range at the top of the file with SpanMapFeature.Definition.

Features

Bug fixes

Several, see individual commits.

Copilot AI balanced review requested due to automatic review settings August 20, 2026 22:33
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 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.

Pull request overview

Completes the second content-mapper integration round across compiler emit, span mapping, language services, protocol handling, and VS Code registration.

Changes:

  • Emits declaration maps composed through content-mapper mappings.
  • Adds multi-projection support for hover, formatting, folding, CodeLens, signature help, and navigation.
  • Updates mapper contracts, extension matching, diagnostics, build watching, tests, and baselines.

Reviewed changes

Copilot reviewed 80 out of 83 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsc/testdata/tests/cases/compiler/contentMapperDeclarationEmitFailure.ts Tests declaration emit after mapper failure.
tsc/testdata/tests/cases/compiler/contentMapperDeclarationEmit.ts Expands mapped declaration-map coverage.
tsc/testdata/baselines/reference/fourslash/vsFindAllReferences/contentMapperDisabledNavigationTargets.baseline Baselines disabled VS references.
tsc/testdata/baselines/reference/fourslash/state/codeLensAcrossProjects.baseline Records CodeLens virtual positions.
tsc/testdata/baselines/reference/fourslash/quickInfo/contentMapperHoverConcatenatesProjections.baseline Baselines combined hover output.
tsc/testdata/baselines/reference/fourslash/goToDefinition/contentMapperDisabledNavigationTargets.baseline.jsonc Baselines disabled definitions.
tsc/testdata/baselines/reference/fourslash/goToDefinition/contentMapperDeclarationMapNavigation.baseline.jsonc Baselines declaration-map definitions.
tsc/testdata/baselines/reference/fourslash/findAllReferences/contentMapperDisabledNavigationTargets.baseline.jsonc Baselines disabled references.
tsc/testdata/baselines/reference/fourslash/findAllReferences/contentMapperDeclarationMapNavigation.baseline.jsonc Baselines mapped references.
tsc/testdata/baselines/reference/fourslash/codeLenses/contentMapperSupplementalImplementationCodeLens.baseline.jsonc Baselines supplemental implementation lenses.
tsc/testdata/baselines/reference/fourslash/codeLenses/contentMapperSupplementalCodeLens.baseline.jsonc Baselines supplemental reference lenses.
tsc/testdata/baselines/reference/fourslash/codeLenses/contentMapperDisabledSupplementalCodeLens.baseline.jsonc Baselines disabled supplemental lenses.
tsc/testdata/baselines/reference/fourslash/codeLenses/contentMapperDeduplicatesProjectedCodeLens.baseline.jsonc Baselines deduplicated lenses.
tsc/testdata/baselines/reference/compiler/contentMapperSupplementalModule.errors.txt Uses original filenames in diagnostics.
tsc/testdata/baselines/reference/compiler/contentMapperSupplementalDiagnostics.errors.txt Updates supplemental diagnostic filenames.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.types Adds failed-map type baseline.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.symbols Adds failed-map symbol baseline.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.sourcemap.txt Adds empty declaration-map record.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.js.map Adds failed-map output.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.js Adds failed declaration output.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmitFailure.contentmapper Baselines mapper failure details.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.types Updates declaration types.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.symbols Updates declaration symbols.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.sourcemap.txt Baselines composed mappings.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.js.map Adds mapped declaration source map.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.js Updates declaration output.
tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.contentmapper Updates transformed-content baseline.
tsc/internal/tsoptions/tsconfigparsing.go Canonicalizes mapper extensions.
tsc/internal/tsoptions/tsconfigparsing_test.go Tests extension casing rules.
tsc/internal/testutil/tsbaseline/sourcemap_baseline.go Supports mapped declaration-map baselines.
tsc/internal/testutil/tsbaseline/error_baseline.go Counts renamed supplemental diagnostics.
tsc/internal/testutil/harnessutil/harnessutil.go Uses original text for map records.
tsc/internal/testutil/contentmappertest/protocol.go Removes protocol-version fixtures.
tsc/internal/testutil/contentmappertest/editing.go Adds supplemental feature fixtures.
tsc/internal/testutil/contentmappertest/duplicate.go Adds hover/signature projections.
tsc/internal/testutil/contentmappertest/component.go Anchors synthesized default exports.
tsc/internal/spanmap/spanmap.go Supports overlaps and exact position mapping.
tsc/internal/spanmap/spanmap_test.go Tests overlap and endpoint behavior.
tsc/internal/sourcemap/generator.go Handles generated-only mapping precedence.
tsc/internal/sourcemap/generator_test.go Tests same-position mapping precedence.
tsc/internal/printer/printer.go Adds source-position composition hook.
tsc/internal/outputpaths/outputpaths.go Allocates mapped declaration maps.
tsc/internal/lsp/server.go Makes contributed extensions case-insensitive.
tsc/internal/lsp/server_contentmapper_internal_test.go Tests contribution extension casing.
tsc/internal/lsp/lsproto/lsp_generated.go Adds CodeLens projection metadata.
tsc/internal/lsp/lsproto/_generate/generate.mts Generates new CodeLens fields.
tsc/internal/ls/signaturehelp.go Tries multiple signature projections.
tsc/internal/ls/rename.go Adapts cross-project invocation.
tsc/internal/ls/lsconv/converters.go Converts original-document ranges.
tsc/internal/ls/hover.go Combines hover projections.
tsc/internal/ls/format.go Formats mapped verbatim ranges.
tsc/internal/ls/folding.go Aggregates mapped folding ranges.
tsc/internal/ls/findallreferences.go Applies feature-aware navigation mapping.
tsc/internal/ls/definition.go Removes synthetic navigation fallbacks.
tsc/internal/ls/crossproject.go Accepts precomputed symbol data.
tsc/internal/ls/codelens.go Supports supplemental CodeLens resolution.
tsc/internal/ls/callhierarchy.go Adapts cross-project invocation.
tsc/internal/ls/autoimport/registry.go Excludes supplemental auto-import targets.
tsc/internal/fourslash/tests/contentMapperSignatureHelp_test.go Tests signature projection fallback.
tsc/internal/fourslash/tests/contentMapperHover_test.go Tests hover fallback and concatenation.
tsc/internal/fourslash/tests/contentMapperEditSafety_test.go Tests folding, CodeLens, and formatting.
tsc/internal/fourslash/tests/contentMapperDuplicateMappings_test.go Tests disabled navigation targets.
tsc/internal/fourslash/tests/contentMapperDeclarationMapNavigation_test.go Tests declaration-map navigation.
tsc/internal/fourslash/tests/contentMapperAutoImports_test.go Tests supplemental auto-import exclusion.
tsc/internal/execute/tsctests/contentmapper_watch_test.go Tests diagnostics, collisions, and symlink watching.
tsc/internal/execute/build/orchestrator.go Resolves watched mapper manifests.
tsc/internal/execute/build/buildtask.go Detects physical supplemental-file conflicts.
tsc/internal/diagnosticwriter/diagnosticwriter.go Presents canonical supplemental filenames.
tsc/internal/diagnostics/extraDiagnosticMessages.json Removes obsolete diagnostics.
tsc/internal/diagnostics/diagnostics_generated.go Regenerates diagnostic definitions.
tsc/internal/contentmapper/hostimpl.go Revises mapper protocol contracts.
tsc/internal/contentmapper/host.go Removes protocol-version errors.
tsc/internal/contentmapper/host_test.go Updates host protocol tests.
tsc/internal/compiler/fileloader.go Removes obsolete mapper diagnostics.
tsc/internal/compiler/emitter.go Composes declaration source maps.
packages/vscode-typescript/test/tsconfig.json Configures extension tests.
packages/vscode-typescript/test/index.test.ts Aggregates extension tests.
packages/vscode-typescript/test/contentMapperContributions.test.ts Tests contribution serialization and matching.
packages/vscode-typescript/src/contentMapperContributions.ts Completes API rename and casing support.
packages/vscode-typescript/package.json Builds and runs aggregated tests.
packages/typescript/test/spanMap.test.ts Tests public span-map overlap behavior.
packages/typescript/src/ast/spanMap.ts Mirrors overlapping span-map support.
.github/skills/compiler-and-fourslash-tests/SKILL.md Documents content-mapper test expectations.
Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
Suppressed comments (1)

tsc/internal/contentmapper/hostimpl.go:213

  • This also does not make diagnostics[].code required when decoding: a mapper can omit it and the Go JSON decoder supplies 0, which is then emitted as the diagnostic code. Please validate field presence during response decoding rather than relying on the serialization tag.
	Code   int32 `json:"code"`

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Path []json.Value `json:"path"`
MessageText string `json:"messageText"`
Code int32 `json:"code,omitempty"`
Code int32 `json:"code"`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe controversial, but this was intentional. It didn't seem worth erroring over a missing code, but coalescing to 0 means it's visible when diagnostics are reported, so appears obvious as a mapper misconfiguration. It's more work and more code to validate and return a diagnostic.

Comment thread tsc/internal/spanmap/spanmap.go
Comment thread tsc/internal/execute/build/orchestrator.go Outdated
Comment thread tsc/internal/ls/format.go Outdated
Comment thread tsc/internal/spanmap/spanmap.go Outdated
Comment thread packages/typescript/src/ast/spanMap.ts
if mapper.PackageDirectory == "" || mapper.ContributionID != "" {
continue
}
if _, changed := changedPaths[w.sys.FS().Realpath(tspath.CombinePaths(mapper.PackageDirectory, "package.json"))]; changed {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this is now fine because fswatch handles this?

@andrewbranch Andrew Branch (andrewbranch) Aug 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, this was explained by #63936 (comment)mapper.PackageDirectory is already a realpath.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Aug 21, 2026
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Aug 21, 2026
Merged via the queue into microsoft:main with commit d6c4afd Aug 21, 2026
23 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the content-mappers-2 branch August 21, 2026 20:35
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(contentmapper): emit declaration maps for mapped inputs

3 participants