Skip to content

Add support for setting emit flags and synthetic comments - #65447

Open
Andrew Branch (andrewbranch) wants to merge 8 commits into
microsoft:mainfrom
andrewbranch:emit-flags-continuation
Open

Andrew Branch (andrewbranch) wants to merge 8 commits into
microsoft:mainfrom
andrewbranch:emit-flags-continuation

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Continuation of #64500
Fixes #64429

  • Addresses Wesley Wigham (@weswigham)'s review comment
  • Extracts non-async-specific code out of async files for deduplication
  • Fixes merge conflicts
  • The Copilot review comments were pre-existing flaws in the emitter. I'll open a follow-up PR for them.

…nodes

# Conflicts:
#	packages/typescript/src/api/async/api.ts
#	packages/typescript/src/api/proto.generated.ts
#	packages/typescript/src/api/sync/api.ts
#	packages/typescript/test/async/api.test.ts
#	packages/typescript/test/sync/api.test.ts
- Null and unknown emitNodes entries are rejected as client errors
  instead of panicking.
- EmitFlags exposes None and the composed flags, and None resets a node.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 23:30
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 11, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 11, 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.

🟢 Approval recommended

No active review issues were identified for the emit-flag and synthetic-comment API changes.

No open issues 🎉

1 file not reviewed
  • tsc/internal/api/enum_values_generated.go: Generated file
What changed in this PR

Adds emit flags and synthetic-comment support to the native TypeScript compiler’s JavaScript printer API, addressing #64429 and continuing #64500.

Changes:

  • Introduces a shared EmitContext for attaching flags and comments to nodes through both async and sync APIs.
  • Transfers node metadata to the native printer, validates incoming metadata, and handles comment-induced line breaks.
  • Adds API and printer tests, plus generated EmitFlags exports.
File Description
tsc/​internal/​printer/​printer.go Enables source-less synthetic comments and handles line breaks safely.
tsc/​internal/​printer/​printer_test.go Tests comment-induced line breaks after return and throw.
tsc/​internal/​printer/​emitflags.go Groups flag constants for enum generation.
tsc/​internal/​api/​session.go Validates and applies client metadata before printing.
tsc/​internal/​api/​session_printnode_test.go Tests metadata decoding, validation, and comment printing.
tsc/​internal/​api/​proto.go Defines protocol fields for emit flags and comments.
tsc/​internal/​api/​enum_values_generated.go Includes native emit-flag values in generated enum data.
tsc/​internal/​api/​encoder/​decoder.go Adds a callback for associating metadata with decoded nodes.
tools/​scripts/​tsc/​generate-enums.ts Registers EmitFlags for generation.
packages/​typescript/​test/​sync/​api.test.ts Adds generated sync tests for flags and comments.
packages/​typescript/​test/​async/​api.test.ts Tests emit contexts, formatting flags, and synthetic comments.
packages/​typescript/​src/​api/​sync/​api.ts Exposes emit contexts through the generated sync printer API.
packages/​typescript/​src/​api/​proto.generated.ts Adds generated protocol types for printing metadata.
packages/​typescript/​src/​api/​printer.ts Centralizes emit-context storage and print-request encoding.
packages/​typescript/​src/​api/​node/​encoder.ts Exposes encoded node indices through a callback.
packages/​typescript/​src/​api/​async/​api.ts Integrates shared emit contexts into the async printer API.
packages/​typescript/​enums/​emitFlags.js Provides the generated runtime EmitFlags enum.
packages/​typescript/​enums/​emitFlags.d.ts Provides generated EmitFlags type declarations.

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 Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

[api] Add back missing: setEmitFlags and addSynthetic*Comment

3 participants