tsify icon indicating copy to clipboard operation
tsify copied to clipboard

Tsify without wasm_bindgen

Open Alfred-Mountfield opened this issue 2 years ago • 2 comments

Hello, I was just wondering if it's possible to decouple this from wasm_bindgen.

I understand that the original purpose of the library was to focus on wasm_bindgen but I was wondering if this could become a more generalised library for creating cross-language type definitions, similar to https://github.com/1Password/typeshare

Alfred-Mountfield avatar Dec 15 '22 14:12 Alfred-Mountfield

Judging from the readme, the intent seems to be that this library is used with wasm bindgen

https://github.com/madonoharu/tsify#crate-features

stefnotch avatar Apr 17 '23 10:04 stefnotch

If you put a "web" feature in your crate, you can do

#[cfg(feature = "web")]
use tsify::Tsify;
#[cfg(feature = "web")]
use wasm_bindgen::prelude::*

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "web", derive(Tsify))]
pub struct MyStruct {
   ...
}

then compile with wasm-bindgen and copy out the types. Not exactly what you want, but you can maintain a non-wasm version of your crate.

siefkenj avatar Jan 11 '24 21:01 siefkenj