A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rustwasm/wasm-bindgen/issues/3213 below:

Cannot inherit from structs created via `#[wasm_bindgen]` attribute as expected · Issue #3213 · wasm-bindgen/wasm-bindgen · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4