gents is a tool for generating Typescript interfaces from Rust code.
We can easily use serde-json to communicate between Rust and Typescript,
without writing Typescript stubs trivially.
It is designed for LogiSheets and
is inspired by ts-rs. Many thanks to them!
Your issues and PRs are welcome!
gents?grpc-webts-rs?ts-rs generates the files when running cargo test and in this way we must
commit those generated files into our repo.
It is not necessary and is even an obstacle when we use other build tools like bazel.
gents acts as a binary to generate Typescript files.
gents introduces a concept Group that from all the members in
this group files generated will be placed in the same directory. Group is seperate from the others even though they can share some
dependecies. Therefore, gents requires you specify the file_name on structs
or enums and specify the dir on group, while ts-rs requires specifing the path on every item.
gents helps you manage the export files. gents gathers all the dependencies automatically.
Code generated by ts-rs is not match our coding style.
gents?In your Rust code:
You should import gents in your Cargo.toml.
toml
gents = "0.3.0"
gents_derives = "0.3.0"
```rust use gents_derives::TS;
pub struct Person { pub age: u16, pub en_name: String, }
pub struct Group {
pub name: String,
pub capacity: u16,
pub members: Vec
And you should make a binary to generate the files like below:
```rust use gents::FileGroup;
fn main() {
let mut group = FileGroup::new();
group.add::
After running the binary, there are 2 files generated in outdir:
Check more cases and usage in the tests folder.