Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

dlunch/typescript-wasm-bindgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

typescript-wasm-bindgen

WIP, many aspects not yet implemented.

Import typescript definitions directly in your wasm rust app.

Usage

// src/index.ts

export function test(): void {
  console.log("test");
}

build.rs

// 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");

proc_macro

// 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();
// }

Examples

simple

About

Rust definition generator for typescript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published