Skip to content

[JS API] organize types into enums - #9098

Open
chharvey wants to merge 1 commit into
WebAssembly:mainfrom
chharvey:feat/jsonapi-type-enums
Open

[JS API] organize types into enums#9098
chharvey wants to merge 1 commit into
WebAssembly:mainfrom
chharvey:feat/jsonapi-type-enums

Conversation

@chharvey

Copy link
Copy Markdown
Contributor

Alternative to #9085, which renamed binaryen.none to binaryen.void
and added a new binaryen.none referring to the heap type.
There were concerns that binaryen.void mapping to
the C API BinaryenTypeNone() might be confusing.

This PR moves all types from the top-level binaryen.* namespace
into respective enums called Type, HeapType, and PackedType.

This change plays nicely with AssemblyScript’s established
TypeScript typings
because now types are scoped in an enum space.
This is not a breaking change for the TS typings file —
e.g., a function that accepts a Type (previously just number)
now accepts a member of the new Type enum.

This change also follows well-established patterns of existing enums
such as ExpressionIds and Features.

binaryen.Type.none now uses BinaryenTypeNone() and
binaryen.HeapType.none uses BinaryenHeapTypeNone(),
so there’s no conflict across enums.

This is a breaking change for JS/TS users:
they will now have to reference types from the enum space
instead of at the top level.
E.g. binaryen.i32 becomes binaryen.Type.i32,
binaryen.any becomes binaryen.HeapType.any,
binaryen.i8 becomes binaryen.PackedType.i8, etc.

@chharvey
chharvey requested a review from a team as a code owner September 10, 2026 23:28
@chharvey
chharvey requested review from aheejin and removed request for a team September 10, 2026 23:28
@kripken

kripken commented Sep 11, 2026

Copy link
Copy Markdown
Member

lgtm, but let's see what others think about the API and TypeScript stuff here. cc @brendandahl

@tlively

tlively commented Sep 11, 2026

Copy link
Copy Markdown
Member

This seems like a good direction to me.

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