Skip to content

Content mapper diagnostic code selectors - #65613

Open
Andrew Branch (andrewbranch) wants to merge 8 commits into
microsoft:mainfrom
andrewbranch:diagnostic-code-selectors
Open

Andrew Branch (andrewbranch) wants to merge 8 commits into
microsoft:mainfrom
andrewbranch:diagnostic-code-selectors

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Continues #65517 with my review suggestions applied.

Closes #65516

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

The schema now accepts negative original ranges for expect directives that normalization rejects, allowing schema-valid mapper output to fail transformation.

1 open issue
2 files not reviewed
  • tsc/internal/contentmapper/protocol_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR

Extends content-mapper ignore directives to select diagnostic codes, addressing #65516 without hiding unrelated errors in the same generated range.

Changes:

  • Supports one or more diagnostic codes in ignore tuples and filters diagnostics by both range and code.
  • Carries selectors through the Go and TypeScript APIs using binary protocol version 10.
  • Adds invalid-selector diagnostics, compiler baselines, and API coverage.
File Description
tsc/​testdata/​tests/​cases/​compiler/​contentMapperInvalidDiagnosticDirectives.ts Adds an invalid-code case.
tsc/​testdata/​tests/​cases/​compiler/​contentMapperDiagnosticDirectiveCodes.ts Tests single- and multiple-code suppression.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperInvalidDiagnosticDirectives.contentmapper Records the invalid-selector error.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDiagnosticDirectiveCodes.contentmapper Confirms unrelated errors remain visible.
tsc/​internal/​testutil/​contentmappertest/​transforming.go Parses selectors in test directives.
tsc/​internal/​diagnostics/​diagnostics_generated.go Adds the generated diagnostic definition.
tsc/​internal/​diagnostics/​diagnosticMessages.json Defines the invalid-selector message.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Adds the generated message entry.
tsc/​internal/​contentmapper/​protocol_generated.go Encodes and decodes selector tuples.
tsc/​internal/​contentmapper/​hostimpl.go Validates and normalizes diagnostic codes.
tsc/​internal/​contentmapper/​host.go Adds an invalid-code error kind.
tsc/​internal/​contentmapper/​host_test.go Updates tuple-length validation coverage.
tsc/​internal/​compiler/​program.go Filters by range and diagnostic code.
tsc/​internal/​compiler/​fileloader.go Reports invalid-selector transform errors.
tsc/​internal/​ast/​ast.go Stores normalized diagnostic selectors.
tsc/​internal/​api/​encoder/​encoder.go Encodes code lists and advances the protocol.
tsc/​internal/​api/​encoder/​encoder_test.go Updates binary-format assertions.
tools/​scripts/​tsc/​generate-contentmapper.ts Generates policy-specific tuple handling.
packages/​typescript/​test/​sync/​api.test.ts Verifies selectors through the synchronous API.
packages/​typescript/​test/​encoder.test.ts Tests skipping unknown trailing fields.
packages/​typescript/​test/​async/​api.test.ts Verifies selectors through the asynchronous API.
packages/​typescript/​src/​ast/​ast.ts Exposes diagnostic codes on directives.
packages/​typescript/​src/​api/​node/​protocol.ts Advances the client protocol to version 10.
packages/​typescript/​src/​api/​node/​node.ts Decodes diagnostic code lists.
packages/​typescript/​src/​api/​node/​msgpack.ts Adds MessagePack value skipping.
packages/​typescript/​schemas/​contentmapper.schema.json Defines separate ignore and expect tuple variants.

Review effort: Balanced

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.

🔵 Needs a closer look

Missing diagnostic-selector capability negotiation prevents compliant mappers from emitting selected ignores, while unconditional emission can suppress unrelated diagnostics on older hosts.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Advertise diagnostic directive code selector capability

packages/​typescript/​schemas/​contentmapper.schema.json:453

InitializeParams and handshake still omit capabilities.diagnosticDirectiveCodeSelectors, so a mapper following #65516's negotiation contract will never emit these selected ignores. Sending them unconditionally is unsafe because the previous host interprets a six-element ignore tuple as range-only suppression, hiding unrelated diagnostics. Add the capability to the initialization schema/generated type, advertise it in hostimpl.go's handshake, and test that advertisement.

1 resolved since last review
2 files not reviewed
  • tsc/internal/contentmapper/protocol_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Review effort: Balanced

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 Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Content mapper ignore directives need diagnostic-code selectors

3 participants