Function into_js_option

Source
pub fn into_js_option<T, U>(val: Option<U>) -> T
where JsValue: From<U>, T: JsCast,
Expand description

Converts the given optional typed value into a JS value with the custom type T.

The type T would be defined in an extern "C" block, e.g.

use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(typescript_type = "MyType | undefined")]
    pub type OptionMyType; // <-- this would be `T`
}

If the typed value is None, the result is JS underfined.