Skip to content

API emit support to generate .d.ts / .js files from sources#3616

Open
pfumagalli wants to merge 25 commits intomicrosoft:mainfrom
pfumagalli:feature/emit-support
Open

API emit support to generate .d.ts / .js files from sources#3616
pfumagalli wants to merge 25 commits intomicrosoft:mainfrom
pfumagalli:feature/emit-support

Conversation

@pfumagalli
Copy link
Copy Markdown

Pull request overview

Adds initial end-to-end support for invoking the compiler’s emit through the TSGO API, wiring it through the Go API server and exposing it in the native-preview TypeScript client (sync + async), with virtual-FS write support to capture outputs.

Changes:

  • Added a new API method emit (protocol + session handler) that calls Program.Emit with EmitOnly and optional target source file.
  • Extended callback-based virtual filesystem support to include writeFile so emitted outputs can be captured by clients.
  • Added native-preview client API surface (program.emit), generated EmitFlags enum, and sync/async tests covering emit scenarios.

pfumagalli and others added 24 commits April 26, 2026 23:55
(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…itter


(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(by Copilot)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 00:27
@pfumagalli
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end support for invoking the compiler’s emit via the TSGO API, plumbing it through the Go API server and exposing it in the native-preview TypeScript client, including virtual-FS write support so emitted outputs can be captured by clients.

Changes:

  • Added a new API method emit (protocol + session handler) that calls Program.Emit with an EmitOnly mode and optional target source file.
  • Extended callback-based virtual filesystem support with a writeFile callback for capturing emitted outputs.
  • Exposed program.emit (sync + async) in native-preview, generated EmitFlags, and added sync/async tests for emit scenarios.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/compiler/emitter.go Adds EmitOnlyFromByte validation helper for API inputs.
internal/api/session.go Wires new emit method to snapshot/program resolution and Program.Emit, routing writes through session FS.
internal/api/proto.go Adds emit method constant, request/response types, and NewEmitResponse adapter.
internal/api/callbackfs.go Adds callbackFS support for delegating WriteFile to the client.
_packages/native-preview/src/api/fs.ts Adds writeFile to the supported FS callback list and virtual FS implementation.
_packages/native-preview/src/api/sync/client.ts Registers writeFile callback plumbing for sync transport.
_packages/native-preview/src/api/async/client.ts Registers writeFile callback plumbing for async JSON-RPC transport.
_packages/native-preview/src/api/sync/types.ts Introduces EmitResult type for sync API surface.
_packages/native-preview/src/api/async/types.ts Introduces EmitResult type for async API surface.
_packages/native-preview/src/api/sync/api.ts Exposes EmitFlags, exports EmitResult, and adds Program.emit() (sync).
_packages/native-preview/src/api/async/api.ts Exposes EmitFlags, exports EmitResult, and adds Program.emit() (async).
_packages/native-preview/src/enums/emitFlags.ts Adds generated runtime enum for emit mode selection.
_packages/native-preview/src/enums/emitFlags.enum.ts Adds generated const enum variant for emit mode selection.
_packages/native-preview/test/sync/api.test.ts Adds sync emit tests covering all/js/dts/single-file emit cases.
_packages/native-preview/test/async/api.test.ts Adds async emit tests covering all/js/dts/single-file emit cases.
Herebyfile.mjs Registers EmitFlags for enum generation from Go sources.

Comment thread internal/api/session.go
Comment thread internal/api/proto.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants