Skip to main content

to_ts

Function to_ts 

Source
pub fn to_ts<T: Tsify + Serialize>(value: &T) -> Result<Ts<T>>
Expand description

Convert a value to tsify::Ts<T> for returning across the wasm boundary.

Replaces the deprecated #[tsify(into_wasm_abi)]: serialization now happens inside our function as an ordinary Result, so a failure unwinds normally instead of leaking the wasm heap (https://github.com/madonoharu/tsify/issues/65). tsify::Error wraps a serde_wasm_bindgen::Error holding a JsValue (not Send + Sync), hence the string conversion rather than a plain ?.