Repository navigation
Add support for setting emit flags and synthetic comments - #65447
Open
Andrew Branch (andrewbranch) wants to merge 8 commits into
Open
Andrew Branch (andrewbranch) wants to merge 8 commits into
Andrew Branch (andrewbranch) wants to merge 8 commits into
Conversation
…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>
Contributor
There was a problem hiding this comment.
🟢 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
EmitContextfor 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
EmitFlagsexports.
| 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
Andrew Branch (andrewbranch)
requested a review
from Wesley Wigham (weswigham)
November 11, 2026 23:41
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuation of #64500
Fixes #64429