wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

TypeScript type for number slices parameters should accept array of number

Open upsuper opened this issue 6 months ago • 0 comments

For Rust type like Box<[u32]> in parameter, wasm-bindgen generates Uint32Array as type in the TypeScript declaration. However, the glue code generated uses TypedArray.set internally to pass the content into the linear memory, and that method actually accepts array of number as well.

Having the type being only TypedArray forces consumer to create an extra TypedArray and copy content into it first, which should be unnecessary.

upsuper avatar May 05 '25 11:05 upsuper