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

  1. Create a struct A in rust and export the struct via #[wasm_bindgen]
  2. In javasript, create a class B that inherits the Rust struct A
  3. Create an instance of your derived javascript class. let obj = new B()
  4. 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.