Skip to content

Content mapper docs - #65582

Open
Gabriela Araujo Britto (gabritto) wants to merge 6 commits into
mainfrom
gabritto/docs
Open

Gabriela Araujo Britto (gabritto) wants to merge 6 commits into
mainfrom
gabritto/docs

Conversation

@gabritto

Copy link
Copy Markdown
Member

No description provided.

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.

Thank you so much for doing this! I feel so much better about my odds of getting everything done by our release 😄

One additional short section in the implementation doc should be about compatibility:

  • The protocol will only change in backward-compatible ways after 7.1 is officially released. New features may be added with an LSP-like capabilities negotiation in initialize.
  • For forward compatibility, tuples should be considered open-ended. A mapper should not assert an exact tuple length or read elements beyond ones it knows how to handle.

}
```

This is useful when the original content mapped files will be emitted to a different format, rather than left as-is.

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.

Do you think this is helpful here?

output-extensions

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.

I think it's useful for understanding output extensions, but I wouldn't want to get into details here. We could either revisit output extensions with a bit more detail in the emit section, and add the diagram, or add that to your PR, which I link to.

@gabritto
Gabriela Araujo Britto (gabritto) marked this pull request as ready for review November 25, 2026 20:01
Copilot AI balanced review requested due to automatic review settings November 25, 2026 20:01

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.

🟡 Changes recommended

Unresolved documentation errors in compiler prerequisites, STDIO framing, request handling, position mapping, and the public API property name can cause configuration failures, stalled cleanup, or incorrect mapper implementations.

5 open issues
What changed in this PR

This documentation-only PR explains how content mappers integrate specialized file formats with TypeScript’s compiler and language server.

Changes:

  • Introduces mapper configuration, file inclusion, and CLI/editor support.
  • Documents implementation protocols, span mappings, diagnostics, compilation, and API integration.
  • Adds diagrams illustrating atom, verbatim, and alias mappings.
File Description
docs/​content_mappers/​intro_content_mappers.md Getting-started guide for configuring and using content mappers.
docs/​content_mappers/​impl_content_mappers.md Implementation guide covering protocols and compiler/editor integration.
docs/​content_mappers/​add-span-mappings.svg Illustrates atom and verbatim mappings and diagnostic locations.
docs/​content_mappers/​add-span-mappings-alias.svg Illustrates alias mappings and diagnostic name substitution.

Review effort: Balanced


This is useful when the original content mapped files will be emitted to a different format, rather than being left as-is.
In the example above, the `.gts` files are Ember components that Ember will emit to `.js` files.
With this information, TypeScript emits declaration files with the correct file extensions (i.e. `Component.gts` -> `Component.d.ts` instead of `Component.d.gts.ts`) and also permits `.gts` import paths to resolve to `.js` files at runtime via `--rewriteRelativeImportExtensions`.

### `closeProject`

TypeScript will send a `closeProject` notification containing the project handle of the project that should be closed.

Span mappings also optionally contain a `features` mask specifying which language server features can use that mapping.
This can be combined with the ability of mapping an original span to many virtual spans.
Broadly speaking, when a language server request is received for a position in a content-mapped virtual file, TypeScript maps it to every original file projection whose features mask includes the requested operation, performs analysis on the transformed content, and maps visible results back through spans that participate in the same feature.
// See packages/typescript/src/ast/spanMap.ts for details.
```

If the content mapper provided supplemental outputs for a file, the file names are set on `file.supplementalOutputs` and can be retrieved with `program.getSourceFile(fileName)`.

This branch has not been deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants