diff --git a/CHANGELOG.md b/CHANGELOG.md index d8ddf5e0076..57f901940e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Released 2020-03-03. * Optional struct fields are now reflected idiomatically in TypeScript. [#1990](https://github.com/rustwasm/wasm-bindgen/pull/1990) -* Typed arrays in `js_sys` onw have `get_index` and `set_index` methods. +* Typed arrays in `js_sys` now have `get_index` and `set_index` methods. [#2001](https://github.com/rustwasm/wasm-bindgen/pull/2001) * The `web_sys::Blob` type has been updated with `arrayBuffer` and `text` @@ -40,6 +40,12 @@ Released 2020-03-03. `#[wasm_bindgen]` annotations instead of expanded code. [#2012](https://github.com/rustwasm/wasm-bindgen/pull/2012) +* A new `typescript_type` attribute can be used to specify the TypeScript type + for an `extern` type. [#2012](https://github.com/rustwasm/wasm-bindgen/pull/2012) + +* It is now possible to use string values with `#[wasm_bindgen]` `enum`s. + [#2012](https://github.com/rustwasm/wasm-bindgen/pull/2012) + * A new `skip_tyepscript` attribute is recognized to skip generating TypeScript bindings for a function or type. [#2016](https://github.com/rustwasm/wasm-bindgen/pull/2016) diff --git a/examples/guide-supported-types-examples/src/imported_types.rs b/examples/guide-supported-types-examples/src/imported_types.rs index ed5674a6789..39d20d6b82f 100644 --- a/examples/guide-supported-types-examples/src/imported_types.rs +++ b/examples/guide-supported-types-examples/src/imported_types.rs @@ -1,5 +1,25 @@ use wasm_bindgen::prelude::*; +#[wasm_bindgen] +pub enum NumberEnum { + Foo = 0, + Bar = 1, + Qux = 2, +} + +#[wasm_bindgen] +pub enum StringEnum { + Foo = "foo", + Bar = "bar", + Qux = "qux", +} + +#[wasm_bindgen] +pub struct Struct { + pub number: NumberEnum, + pub string: StringEnum, +} + #[wasm_bindgen] extern "C" { pub type SomeJsType;