Skip to content

fix(js): use FixedArray at the JS FFI boundary - #34

Open
hackwaly wants to merge 1 commit into
oboard:mainfrom
hackwaly:fix/js-ffi-fixedarray
Open

hackwaly wants to merge 1 commit into
oboard:mainfrom
hackwaly:fix/js-ffi-fixedarray

Conversation

@hackwaly

Copy link
Copy Markdown
Contributor

Hi! I'm @hackwaly, a MoonBit core developer.

We deprecated Array at the JavaScript FFI boundary ahead of the planned change
to Array's runtime layout, and I'm going through the ecosystem to help packages
migrate before that lands. This PR does that for this repo.

Disclosure: AI assistance was used to scan the ecosystem for affected
declarations and prepare this patch. I reviewed the resulting diff. Please
double-check anything that looks off.

Background

On the JS backend, Array[T] and FixedArray[T] are both plain JS arrays today.
This migration removes reliance on that shared representation: once Array's
runtime layout changes, an extern "js" declared in terms of Array will no
longer line up with the plain arrays JavaScript produces or expects. FixedArray
is the representation we ask FFI code to use.

moon check --target js reports Warning: [0020] Warning (deprecated): Using 'Array' in JavaScript FFI is deprecated. Use 'FixedArray' instead. for the
declarations below. The scanner also migrated nested occurrences such as
Nullable[Array[T]] or (Array[T]) -> U, which do not trigger the same warning
but sit on the same boundary.

Changes

Each migrated FFI keeps its JavaScript body unchanged. The boundary now uses
FixedArray, and a thin wrapper keeps the original signature and converts, so no
call site and no public signature changes.

Declarations touched: __ws_state_js_export_ffi

Files:

  • mocket.js.mbt

Verification

  • moon check --target js — 0 [0020] warnings for the touched files, 0 errors.
  • moon test --target js — 101 passed, 0 failed.

The JS bodies are unchanged; only the boundary type and the wrapper are new.

@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@hackwaly is attempting to deploy a commit to the oboard's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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