Skip to content

TypeScript Core#8861

Open
chharvey wants to merge 4 commits into
WebAssembly:mainfrom
chharvey:feat/ts-core
Open

TypeScript Core#8861
chharvey wants to merge 4 commits into
WebAssembly:mainfrom
chharvey:feat/ts-core

Conversation

@chharvey

@chharvey chharvey commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The first of several PRs in an attempt to break up #8826 into smaller parts. This PR sets up core typescript functionality and ports over only the top-level types, constants, and enums of the JS API.

Changes:

  • adds root-level ts/ folder with README.md, package.json, tsconfig.json, and other project files
  • updates root-level CMakeLists.txt, exporting needed variables & methods (like HEAP8) from Emscripten into the JS build
  • ts/src/-pre.ts imports the Emscripten-built Binaryen function, calls and awaits it, and exports that as an internal object called BinaryenObj (AssemblyScript calls this object binaryen and exports that publicly).
  • ts/src/**: the typescript library sits on top of the Emscripten artifact. it accesses the WASM bindings on BinaryenObj imported from -pre.ts.
  • entrypoint ts/src/binaryen.ts for users, exporting all the parts of the public-facing API. Users use a namespace import instead of a default import:
    import * as binaryen from "binaryen.ts";
    
    (this better aligns with the ES Modules standard since it’s no longer a proper object).
    users will still use the same API (binaryen.ExpressionRef, binaryen.i32, binaryen.Module, etc.)
  • starting some Node.JS tests at ts/tests/. hopefully this will take some of the weight off the python tests

Non-Changes:

  • original binaryen.js-post.js file has not been touched; the tentative plan is to complete the TS migration before phasing out the JS code (unless decided otherwise by repo maintainers)
  • python tests also haven’t been touched for now, but maybe a future PR will work on migrating them to Node.JS

API Deprecations (see ts/src/-deprecations.ts for full list; will evolve with more PRs):

  • enum names have been singularized (e.g. binaryen.Featuresbinaryen.Feature)
  • deprecations are still accessible as their old symbols (users can still use binaryen.Features, but there is a doc-comment @deprecated warning for intellisense support)

Get started:

brew install node # includes npm
cd ts/
npm ci          # downloads dependencies
npm run make    # rebuilds out-of-tree into ../build/ and copies the built js to ./build/
npm run check   # runs the python tests
npm run compile # compiles typescript to ./dist/
npm run test    # runs the node tests

See ts/package.json, ts/README.md, and ts/docs/API-Overview.md (in this PR) for details.

@chharvey chharvey requested a review from a team as a code owner June 19, 2026 02:09
@chharvey chharvey requested review from tlively and removed request for a team June 19, 2026 02:09
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.

1 participant