Open
Description
Motivation
From this Rust program:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub enum MyEnum {
A,
B,
}
#[wasm_bindgen]
pub fn foo() -> Vec<MyEnum> {
unimplemented!()
}
#[wasm_bindgen]
pub fn bar(values: Vec<MyEnum>) -> MyEnum {
unimplemented!()
}
the following TS code is generated:
export function foo(): any[];
export function bar(values: any[]): MyEnum;
export enum MyEnum {
A = 0,
B = 1,
}
Proposed Solution
The binding code is functional, but for the sake of improved type-safety on the TypeScript side it would be nice if:
foo
would returnMyEnum[]
instead ofany[]
bar
would takeMyEnum[]
instead ofany[]
for thevalues
argument.
Note that the return value of bar
is indeed MyEnum
already.
Alternatives
I can't think of any other sensible alternatives to what is proposed.
Additional Context
None.