feat(extends): extend promise

This commit is contained in:
Roberto Huertas 2018-08-24 01:25:43 +02:00
parent 045138f397
commit 042cfad5ce
3 changed files with 13 additions and 0 deletions

View File

@ -3783,6 +3783,7 @@ extern {
/// an asynchronous operation, and its resulting value. /// an asynchronous operation, and its resulting value.
/// ///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
#[wasm_bindgen(extends = Object)]
pub type Promise; pub type Promise;
/// Creates a new `Promise` with the provided executor `cb` /// Creates a new `Promise` with the provided executor `cb`

View File

@ -0,0 +1,11 @@
use wasm_bindgen_test::*;
use wasm_bindgen::JsCast;
use js_sys::*;
#[wasm_bindgen_test]
fn promise_inheritance() {
let promise = Promise::new(&mut |_, _| ());
assert!(promise.is_instance_of::<Promise>());
assert!(promise.is_instance_of::<Object>());
let _: &Object = promise.as_ref();
}

View File

@ -26,6 +26,7 @@ pub mod MapIterator;
pub mod Math; pub mod Math;
pub mod Number; pub mod Number;
pub mod Object; pub mod Object;
pub mod Promise;
pub mod Proxy; pub mod Proxy;
pub mod RangeError; pub mod RangeError;
pub mod ReferenceError; pub mod ReferenceError;