Open b-zee opened 1 month ago
I think you can use js_class
to fix this.
That said, wasm bindgen should still be better here IMO.
I tried adding it both to the method and struct:
warning: unused variable: `js_class`
But I forgot trying to add it to the impl
, that works!
So, in short, this works:
#[wasm_bindgen(js_name = Data)]
pub struct JsData(u8);
#[wasm_bindgen(js_class = Data)]
impl JsData {
#[wasm_bindgen(js_name = toString)]
pub fn to_string(&self) -> String {
self.0.to_string()
}
}
Describe the Bug
When using the
js_name
on anenum
, a method does not get exported.Steps to Reproduce
Consider this snippet:
Compiled with
wasm-pack build --dev --target=web
.Expected Behavior
The
Data
class to include thetoString
method.Actual Behavior
Additional Context
When the
js_name
attribute is not used, e.g.:The
.d.ts
file will include the method: