Skip to content

Content mappers: report a mapper's diagnostics without stopping type checking #65462

Closed as not planned

Description

🔍 Search Terms

content mapper, diagnostics, syntactic, semantic, noCheck

✅ Viability Checklist

⭐ Suggestion

transform diagnostics are added to the virtual file's parse diagnostics (ParseResult in internal/contentmapper/transform.go), and tsc reports semantic diagnostics only when no file has a syntactic one. So one mapper diagnostic anywhere hides every type error in the project for that run.

Many mapper diagnostics aren't syntax errors. A mapper that types .sql files from a database reports column "emial" does not exist, and the virtual file it returns parses and checks fine.

A field on the diagnostic, say "phase": "semantic", could report it with the file's semantic diagnostics, the way an Expect directive's unused diagnostic already is.

📃 Motivating Example

-- queries/get_user.sql
select emial from users
// src/main.ts
import getUser from "../queries/get_user.sql";
const n: number = "x";

tsc --noEmit prints only the SQL error. The src/main.ts error shows up on the next run, once the SQL is fixed.

A mapper can get this today by returning each error as an Expect diagnostic directive over an empty statement appended to its virtual text, with the error as the unused diagnostic. That works on 7.1.0-beta, but it uses directives for something they weren't made for.

💻 Use Cases

  • CI runs that print every error at once
  • Mappers whose errors are about meaning (unknown names, type mismatches) rather than syntax

Activity

  1. andrewbranch commented on Nov 13, 2026

    @andrewbranch
    Member

    This is super intentional and documented in microsoft/typescript-go#4712:

    interface TransformResult extends MappedOutput {
       /** Parse errors in the original content. */
       diagnostics?: MapperDiagnostic[];

    It's implemented the way it is specifically to discourage content mappers from doing semantic checks during transforming, which should be as fast as possible, with single-file context. What you're looking for is #45886. I think the existence of content mappers adds a good new reason to want an integration like that, but I'm not sure it needs to be content-mapper-specific.

  2. colinhacks commented on Nov 14, 2026

    @colinhacks
    ContributorAuthor

    Understood, thanks 👍

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions