Crates.io | typescript-wasm-bindgen-macros |
lib.rs | typescript-wasm-bindgen-macros |
version | 0.1.1 |
source | src |
created_at | 2021-03-05 11:25:46.343684 |
updated_at | 2021-03-31 06:29:31.405362 |
description | Parse typescript file and generates wasm-bindgen javascript import on the fly |
homepage | |
repository | https://github.com/dlunch/typescript-wasm-bindgen |
max_upload_size | |
id | 364295 |
size | 2,805 |
WIP, many aspects not yet implemented.
Import typescript definitions directly in your wasm rust app.
// src/index.ts
export function test(): void {
console.log("test");
}
// build.rs
use std::path::PathBuf;
use typescript_wasm_bindgen::build_typescript_wasm_binding;
fn main() {
build_typescript_wasm_binding(&PathBuf::from("./ts/test_function.ts"), "test").unwrap();
}
// lib.rs
use typescript_wasm_bindgen::import_typescript_wasm_binding;
use wasm_bindgen::prelude::{wasm_bindgen, JsValue};
import_typescript_wasm_binding!("test_function");
// wasm/src/lib.rs
use typescript_wasm_bindgen::typescript;
use wasm_bindgen::prelude::wasm_bindgen;
typescript!("../src/index.ts", "index");
// `typescript!` macro expands like following:
//
// #[wasm_bindgen(module = "index")]
// extern "C" {
// fn test();
// }