Description
Describe the Bug
The typescript bindings generated for the below function are inconsistent with themselves.
#[wasm_bindgen]
pub fn receive_bytes(file: &mut [u8]) -> Result<(), JsValue> {
Ok(())
}
Steps to Reproduce
- Clone https://github.com/cam-narzt/rust-was-bug
- Run
wasm-pack build --target web
- Run
fgrep -RHie receive_ pkg
- See mismatched function signatures
Expected Behavior
Type signatures of functions should be consistent in exported bindings, per https://github.com/rustwasm/wasm-bindgen/blob/main/examples/without-a-bundler/index.html#L41-L43 the value returned by the init
function should be the same as the exports from the module. Using the value returned by init
is very preferable because then you know that you haven't introduced a race between the wasm module loading and using it's exports, but the InitOutput
interface has what I assume are the internal details function's signatures.
Actual Behavior
The signature of the function is inconsistent.
If I import { receive_bytes } from 'pkg/wasm_bug';
I get function receive_bytes(file: Uint8Array): void
, as expected.
If I import init, { InitOutput } from 'pkg/wasm_bug';
and use the result of init
, I get receive_bytes: (a: number, b: number, c: number, d: number) => void
, which seems to be some internal implementation function for converting between the js and rust types.