| Crates.io | wasm-typescript-definition |
| lib.rs | wasm-typescript-definition |
| version | 0.1.4 |
| created_at | 2018-11-21 07:20:53.506944+00 |
| updated_at | 2018-12-12 01:52:49.133871+00 |
| description | serde support for exporting Typescript definitions using wasm-bindgen |
| homepage | |
| repository | https://github.com/tcr/wasm-typescript-definition |
| max_upload_size | |
| id | 97905 |
| size | 66,861 |
Exports serde-serializable structs and enums to Typescript definitions when used with wasm-bindgen.
#[derive(Serialize, TypescriptDefinition)]
enum Enum {
#[allow(unused)]
V1 {
#[serde(rename = "Foo")]
foo: bool,
},
#[allow(unused)]
V2 {
#[serde(rename = "Bar")]
bar: i64,
#[serde(rename = "Baz")]
baz: u64,
},
#[allow(unused)]
V3 {
#[serde(rename = "Quux")]
quux: String,
},
}
With the patched version of wasm-bindgen that supports typescript_custom_section (TODO), this will output in your .d.ts definition file:
export type Enum =
| {"tag": "V1", "fields": { "Foo": boolean, }, }
| {"tag": "V2", "fields": { "Bar": number, "Baz": number, }, }
| {"tag": "V3", "fields": { "Quux": string, }, }
;
Forked from rust-serde-schema by @srijs.
MIT or Apache-2.0, at your option.