diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 91eedb55..ef3921be 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -1203,6 +1203,7 @@ extern { #[wasm_bindgen] extern "C" { #[derive(Clone, Debug)] + #[wasm_bindgen(extends = Object)] pub type Math; /// The Math.abs() function returns the absolute value of a number, that is diff --git a/crates/js-sys/tests/wasm/Math.rs b/crates/js-sys/tests/wasm/Math.rs index a46ded34..c6047fca 100644 --- a/crates/js-sys/tests/wasm/Math.rs +++ b/crates/js-sys/tests/wasm/Math.rs @@ -1,9 +1,22 @@ use std::f64::consts::PI; use std::f64::{NEG_INFINITY, NAN}; +use wasm_bindgen::{JsCast, prelude::*}; use wasm_bindgen_test::*; use js_sys::*; +#[wasm_bindgen_test] +fn math_extends() { + #[wasm_bindgen] + extern { + #[wasm_bindgen(js_name = Math)] + static math: Math; + } + + assert!(math.is_instance_of::()); + let _: &Object = math.as_ref(); +} + macro_rules! assert_eq { ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b);