API emit support to generate .d.ts / .js files from sources#3616
Open
pfumagalli wants to merge 25 commits intomicrosoft:mainfrom
Open
API emit support to generate .d.ts / .js files from sources#3616pfumagalli wants to merge 25 commits intomicrosoft:mainfrom
emit support to generate .d.ts / .js files from sources#3616pfumagalli wants to merge 25 commits intomicrosoft:mainfrom
Conversation
(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>
…Files`) as null (by Copilot)
(by Copilot) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
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 callsProgram.Emitwith anEmitOnlymode and optional target source file. - Extended callback-based virtual filesystem support with a
writeFilecallback for capturing emitted outputs. - Exposed
program.emit(sync + async) in native-preview, generatedEmitFlags, 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. |
(by Copilot)
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.
Pull request overview
Adds initial end-to-end support for invoking the compiler’s
emitthrough 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:
emit(protocol + session handler) that callsProgram.EmitwithEmitOnlyand optional target source file.writeFileso emitted outputs can be captured by clients.program.emit), generatedEmitFlagsenum, and sync/async tests covering emit scenarios.