Cannot inherit from structs created via #[wasm_bindgen]
attribute as expected (original) (raw)
Describe the Bug
If I create a struct in rust and export the struct via #[wasm_bindgen]
attribute, and if I then inherit this struct from javascript space, my Javascript derived class will only be recognized as the parent class. For example, if I override any methods of the parent class, only the parent class methods are called. Also, obj instanceof DerivedClass == false
and obj instance ParentClass == true
, where i would expect both instanceof
conditions to be true.
Steps to Reproduce
- Create a struct
A
in rust and export the struct via#[wasm_bindgen]
- In javasript, create a class
B
that inherits the Rust structA
- Create an instance of your derived javascript class.
let obj = new B()
- test
expect(obj instanceof B).toBe(true)
Expected Behavior
Step 4 should pass
Actual Behavior
Step 4 will fail (obj is not an instance of B)
Additional Context
Why this matters is because when I override any methods of the Base class, the override methods are not being called, but instead only the base methods are being called.