Skip to content

TypeScript globals & Module class#8881

Draft
chharvey wants to merge 10 commits into
WebAssembly:mainfrom
chharvey:feat/ts-globals
Draft

TypeScript globals & Module class#8881
chharvey wants to merge 10 commits into
WebAssembly:mainfrom
chharvey:feat/ts-globals

Conversation

@chharvey

@chharvey chharvey commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Second PR as part of #8826. This PR adds global functions, accessible from the binaryen namespace. Also sets up the Module class and some instance methods.

import * as binaryen from "binaryen.ts";
binaryen.getExpressionType(your_expr);
const mod = new binaryen.Module();
mod.validate();

This PR is stacked on #8861 (i.e. it depends on that being merged first. the diff will be easier to compare once that happens, or you can compare here).

Adds 1 deprecation: the global function getSideEffects() is deprecated in favor of the instance method Module#getSideEffects(). The global function is still supported but it will log a warning to console:

"Global function getSideEffects(expr, mod) is deprecated; use mod.getSideEffects(expr) instead."

Some global functions are still commented out as they depend on Expression classes: the Expression() function (called without new), returns a class instance containing information about a wasm expression, and the getExpressionInfo function, which similarly returns a JSON object. Internally they depend on an EXPRESSION_TYPE_REGISTRY map. These will be uncommented once the Expression class & subclasses are added in a future PR (for a preview, see #8826).

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