Skip to content

Move @typescript/api and @typescript/ast into @typescript/native-preview for publishing#3430

Merged
andrewbranch merged 13 commits intomicrosoft:mainfrom
andrewbranch:api/publish
Apr 22, 2026
Merged

Move @typescript/api and @typescript/ast into @typescript/native-preview for publishing#3430
andrewbranch merged 13 commits intomicrosoft:mainfrom
andrewbranch:api/publish

Conversation

@andrewbranch
Copy link
Copy Markdown
Member

To avoid version compatibility issues between the JS API client and Go API server, we decided not to separate them into different packages. This PR moves the contents of @typescript/api and @typescript/ast into the @typescript/native-preview package, which will eventually become typescript.

I'd like to merge this after the TypeScript 7.0 beta release.

Copilot AI review requested due to automatic review settings April 16, 2026 20:11
Comment thread _packages/native-preview/package.json
}

export function resolveExePath(options: ClientSpawnOptions): string {
return options.tsserverPath ?? getExePath();
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 kept the option only because I feel like it will be useful for us in local development/debugging, but maybe not—I could remove it from the declaration emit types, or remove it altogether, or remove it once we're ready to RC. Thoughts?

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.

I don't think it's a big deal to leave in for now

Comment thread _packages/native-preview/package.json
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

This PR consolidates the JavaScript API client (@typescript/api) and AST surface (@typescript/ast) into @typescript/native-preview to avoid version skew between the JS client and the Go server, aligning with the longer-term plan for native-preview to become typescript.

Changes:

  • Move generated AST + API client codegen outputs into _packages/native-preview/src/{ast,api} and update generators accordingly.
  • Update @typescript/native-preview to be publishable as a JS API package (exports map, build/test scripts, dist output, enums generation).
  • Remove the standalone _packages/api and _packages/ast package manifests/tsconfigs and update tests/imports to use @typescript/native-preview/*.

Reviewed changes

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

Show a summary per file
File Description
package-lock.json Marks removed workspace packages as extraneous; updates native-preview deps/devDeps metadata.
_scripts/generate-ts-ast.ts Redirects AST codegen outputs into native-preview/src/ast.
_scripts/generate-encoder.ts Redirects encoder/protocol codegen outputs into native-preview/src/api/node and updates AST imports to relative paths.
_packages/native-preview/tsconfig.json Switches native-preview to a composite build that emits dist/ + declarations.
_packages/native-preview/tsconfig.dev.json Adds dev/test-oriented TS settings (noEmit, nodenext, TS extension imports).
_packages/native-preview/tsconfig.base.json Introduces shared TS defaults for the package (target/lib/strict/composite, etc.).
_packages/native-preview/test/types.d.ts Adds local type shim for tinybench compilation.
_packages/native-preview/test/tsconfig.json Removes reference to the old ../../ast project and references only the package root.
_packages/native-preview/test/sync/astnav.test.ts Updates imports from @typescript/api/@typescript/ast to @typescript/native-preview/*; relies on default exe path.
_packages/native-preview/test/sync/ast.test.ts Updates imports to @typescript/native-preview/ast and related subpaths; updates fs/api imports.
_packages/native-preview/test/sync/api.test.ts Updates imports to @typescript/native-preview/*; removes explicit tsserverPath usage.
_packages/native-preview/test/sync/api.bench.ts Updates imports and internal paths for moved node API implementation.
_packages/native-preview/test/encoder.test.ts Updates AST/factory imports and node encoder/protocol import paths.
_packages/native-preview/test/async/astnav.test.ts Updates async API + AST imports; removes explicit tsserverPath.
_packages/native-preview/test/async/api.test.ts Updates async API + AST imports; removes explicit tsserverPath.
_packages/native-preview/test/async/api.bench.ts Updates async benchmark imports and internal node API path.
_packages/native-preview/test/api.bench.ts Adds a unified entrypoint to run both async and sync benchmarks.
_packages/native-preview/src/enums/typePredicateKind.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/typePredicateKind.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/typeFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/typeFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/tokenFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/tokenFlags.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/syntaxKind.enum.ts Adds generated SyntaxKind enum into native-preview.
_packages/native-preview/src/enums/symbolFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/symbolFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/signatureKind.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/signatureKind.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/signatureFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/signatureFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/scriptTarget.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/scriptTarget.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/scriptKind.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/scriptKind.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/regularExpressionFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/regularExpressionFlags.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/outerExpressionKinds.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/outerExpressionKinds.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/objectFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/objectFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/nodeFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/nodeFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/modifierFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/modifierFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/languageVariant.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/languageVariant.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/elementFlags.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/elementFlags.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/diagnosticCategory.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/diagnosticCategory.enum.ts Adds generated typed enum declaration in native-preview.
_packages/native-preview/src/enums/commentDirectiveType.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/commentDirectiveType.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/enums/characterCodes.ts Adds generated runtime enum mirror in native-preview.
_packages/native-preview/src/enums/characterCodes.enum.ts Adds generated typed const-enum declaration in native-preview.
_packages/native-preview/src/ast/visitor.ts Adds handwritten visitor/forEachChild implementations needed by generated AST code.
_packages/native-preview/src/ast/utils.ts Adds syntax kind formatting + cast helpers into native-preview AST surface.
_packages/native-preview/src/ast/is.ts Adds handwritten AST type guards and re-exports generated guards.
_packages/native-preview/src/ast/index.ts Adds the public AST barrel export for @typescript/native-preview/ast.
_packages/native-preview/src/ast/clone.ts Adds deep-clone utilities (ported) into native-preview AST surface.
_packages/native-preview/src/ast/astnav.ts Adds token navigation helpers into native-preview AST surface.
_packages/native-preview/src/ast/ast.ts Adds handwritten core AST types (Node, SourceFile, etc.) and exports generated AST types.
_packages/native-preview/src/api/syncChannel.ts Adds a pure-JS sync RPC channel implementation replacing the native addon.
_packages/native-preview/src/api/sync/types.ts Updates sync types header paths and regenerate comment to new layout.
_packages/native-preview/src/api/sync/client.ts Uses resolveExePath() so tsserverPath becomes optional and defaults to bundled tsgo.
_packages/native-preview/src/api/sync/api.ts Updates AST imports to use the in-package AST entrypoint.
_packages/native-preview/src/api/sourceFileCache.ts Updates AST imports to in-package relative path.
_packages/native-preview/src/api/proto.ts Adds API protocol types and helper utilities (DocumentIdentifier, snapshot change types, etc.).
_packages/native-preview/src/api/path.ts Adds path/URI helpers used by the API protocol surface.
_packages/native-preview/src/api/options.ts Makes tsserverPath optional + adds resolveExePath() and updates spawn/socket discrimination.
_packages/native-preview/src/api/objectRegistry.ts Adds per-snapshot identity registry for symbol/type/signature objects.
_packages/native-preview/src/api/node/protocol.ts Adds protocol constants and re-exports generated child-properties in new location.
_packages/native-preview/src/api/node/protocol.generated.ts Updates generated protocol TS import to relative in-package AST path.
_packages/native-preview/src/api/node/node.ts Updates AST imports to in-package AST barrel.
_packages/native-preview/src/api/node/node.infrastructure.ts Updates AST imports to in-package AST barrel.
_packages/native-preview/src/api/node/node.generated.ts Updates AST imports to in-package AST barrel.
_packages/native-preview/src/api/node/msgpack.ts Adds a minimal msgpack codec used by node/encoder + sync channel.
_packages/native-preview/src/api/node/encoder.ts Updates AST imports to in-package AST barrel.
_packages/native-preview/src/api/node/encoder.generated.ts Updates AST imports to in-package AST barrel.
_packages/native-preview/src/api/fs.ts Adds in-package virtual FS + callback list used by the client.
_packages/native-preview/src/api/async/types.ts Adds async type surface (Types, Diagnostics, etc.) into new layout.
_packages/native-preview/src/api/async/client.ts Uses resolveExePath() for default bundled tsgo behavior.
_packages/native-preview/src/api/async/api.ts Updates AST imports to use the in-package AST entrypoint.
_packages/native-preview/scripts/generateSync.ts Updates sync-wrapper generation to read from src/api and updates regenerate comment.
_packages/native-preview/package.json Makes native-preview publish the JS API + AST (exports map, build/test scripts, dependencies).
_packages/native-preview/lib/getExePath.d.ts Adds type declarations for getExePath.
_packages/ast/tsconfig.json Removes standalone @typescript/ast build config.
_packages/ast/package.json Removes standalone @typescript/ast package manifest.
_packages/api/tsconfig.json Removes standalone @typescript/api build config.
_packages/api/package.json Removes standalone @typescript/api package manifest.
Herebyfile.mjs Redirects enum generation to native-preview, updates build/test tasks, and packages dist/ into the publish output.

Comment thread _packages/native-preview/package.json
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 7.0 RC milestone Apr 17, 2026
@andrewbranch andrewbranch requested a review from jakebailey April 22, 2026 16:17
Comment thread _packages/native-preview/package.json
@jakebailey
Copy link
Copy Markdown
Member

Can we exclude the vendored code from formatting so it's just a pure copy?

I'm also wondering if we should bundle their code with esbuild or something instead of shipping it as-is, but it's "only" 10% of the package size, so probably not really a problem

Copy link
Copy Markdown
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

So long, subpackages

@andrewbranch andrewbranch added this pull request to the merge queue Apr 22, 2026
Merged via the queue into microsoft:main with commit effd0f8 Apr 22, 2026
21 checks passed
@andrewbranch andrewbranch deleted the api/publish branch April 22, 2026 20:08
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.

4 participants