Given the following rust code:
#[derive(serde::Serialize, serde::Deserialize, tsify::Tsify)]
#[serde(rename_all = "camelCase")]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct Bar {
content: String,
}
#[derive(serde::Serialize, serde::Deserialize, tsify::Tsify)]
#[serde(rename_all = "camelCase")]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct Foo {
#[serde(flatten)]
bar: Bar,
more: String,
}
#[wasm_bindgen]
pub fn foobar() -> Foo {
Foo {
bar: Bar {
content: "hello".to_string(),
},
more: "world".to_string(),
}
}
Calling foobar TS side will give me a map, not a JS Object. So doing
will print
Map(2) { 'content' => 'hello', 'more' => 'world' }
this is rather problematic as it means the value cannot be accessed via the normal object property access syntax.
I am not sure if this is relevant (have not tested without), but I am using serde-wasm-bindgen via the js feature.
Given the following rust code:
Calling
foobarTS side will give me a map, not a JS Object. So doingwill print
this is rather problematic as it means the value cannot be accessed via the normal object property access syntax.
I am not sure if this is relevant (have not tested without), but I am using serde-wasm-bindgen via the
jsfeature.