Repository navigation
feat(content-mapper): add diagnostic-code selectors - #65517
ubugeeei (ubugeeei) wants to merge 2 commits into
Conversation
Co-authored-by: miyaoka <1443118+miyaoka@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
API construction and encoding omit diagnosticCode, causing a TypeScript type-checking error and preventing selectors from reaching clients, while invalid selectors produce only a generic error without the rejection reason or directive index.
2 open issues
What changed in this PR
Adds diagnostic-code selectors to content-mapper ignore directives for #65516, allowing targeted suppression without hiding unrelated diagnostics in the same generated range.
Changes:
- Advertises selector support and decodes an optional sixth ignore-tuple element while preserving legacy ignore and expect encodings.
- Filters diagnostics by both range and code, with selector fields added to the Go and TypeScript AST mirrors.
- Adds protocol, normalization, capability, and compiler filtering tests.
| File | Description |
|---|---|
tsc/internal/contentmapper/hostimpl.go |
Advertises, decodes, and validates code selectors. |
tsc/internal/contentmapper/host.go |
Adds an invalid-selector error kind. |
tsc/internal/contentmapper/host_test.go |
Tests selector encoding, normalization, and capability advertisement. |
tsc/internal/compiler/program.go |
Matches diagnostic codes as well as ranges when filtering. |
tsc/internal/compiler/contentmapper_test.go |
Tests suppressing TS2353 while preserving TS2322. |
tsc/internal/ast/ast.go |
Adds the selector to the Go AST directive. |
packages/typescript/src/ast/ast.ts |
Declares the selector in the TypeScript AST interface. |
Review effort: Balanced
Co-authored-by: miyaoka <1443118+miyaoka@users.noreply.github.com>
|
@microsoft-github-policy-service agree |
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
Do you foresee any utility in making diagnosticCodes variadic, being able to suppress multiple codes within the same range?
| const directives = Array<MappedDiagnosticDirective>(count); | ||
| for (let i = 0; i < count; i++) { | ||
| if (reader.readArrayHeader() !== 6) throw new Error("Invalid diagnostic directive"); | ||
| if (reader.readArrayHeader() !== 7) throw new Error("Invalid diagnostic directive"); |
There was a problem hiding this comment.
I intended tuples to be open-ended, not even needing a capability advertisement in order to grow the length. If you move diagnosticCode after unusedCode, and change this to be >= 7, it seems like that would work.


Fixes #65516
Related producer work: ubugeeei-prod/vize#13065 (tracked by ubugeeei-prod/vize#13057)
Summary
diagnosticDirectiveCodeSelectorsin content-mapper initialize capabilitiesCompatibility
Legacy five-element ignore tuples and all expect tuples keep their existing content-mapper encoding and behavior. A mapper only emits the selected form after the host advertises support, so an older host never falls back to range-only suppression.
The internal API packet changes from a six-field directive record to a seven-field record and bumps the binary protocol version from 9 to 10, keeping its encoder and decoder in lockstep.
Validation