Skip to content

Port transpileModule, transpileDeclaration - #4849

Open
Andrew Branch (andrewbranch) wants to merge 5 commits into
microsoft:mainfrom
andrewbranch:api-transpile
Open

Port transpileModule, transpileDeclaration#4849
Andrew Branch (andrewbranch) wants to merge 5 commits into
microsoft:mainfrom
andrewbranch:api-transpile

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Aug 7, 2026

Copy link
Copy Markdown
Member

In the TS API, these are exposed as

  • transpileModule(input: string, options?: TranspileOptions)
  • transpileModuleFromFile(fileName: string, options?: TranspileOptions)
  • transpileDeclaration(input: string, options?: TranspileOptions)
  • transpileDeclarationFromFile(fileName: string, options?: TranspileOptions)

Part of #4830 (cc John Reilly (@johnnyreilly))

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 7, 2026 22:03

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.

Pull request overview

Adds single-file JavaScript and declaration transpilation to the native compiler API.

Changes:

  • Implements transpilation with diagnostics, source maps, cancellation, and minimal declaration libraries.
  • Exposes synchronous and asynchronous string/file APIs.
  • Clarifies builder-only declaration emit naming and adds coverage.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/transpile/transpile.go Implements transpilation.
internal/transpile/transpile_test.go Tests core behavior.
internal/execute/incremental/affectedfileshandler.go Uses renamed signature emit mode.
internal/compiler/program.go Updates emit-mode handling.
internal/compiler/emitter.go Renames builder signature mode.
internal/api/session.go Handles transpilation requests.
internal/api/proto.go Defines protocol methods and types.
_packages/native-preview/test/sync/api.test.ts Tests synchronous APIs.
_packages/native-preview/test/async/api.test.ts Tests asynchronous APIs.
_packages/native-preview/src/api/sync/api.ts Exposes generated synchronous APIs.
_packages/native-preview/src/api/async/api.ts Exposes asynchronous APIs.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

EmitOnlyJs
EmitOnlyDts
EmitOnlyForcedDts
EmitOnlyBuilderSignature

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I renamed this internal enum member because it's intended to be used as an opaque description of what the builder needs, which is specifically .d.ts files without declaration maps. The other ForceDTS option (inherited from Strada) includes declaration maps.

Comment thread internal/transpile/transpile_test.go Outdated
"gotest.tools/v3/assert"
)

func TestTranspileModule(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we port over the transpile test runner instead of relying on unit tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This exposed a couple real emit diffs, which I don’t have time to address here before the beta.

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.

3 participants