[][src]Macro ts_rs::export

macro_rules! export {
    ($($($p:path),+ => $l:literal),* $(,)?) => { ... };
}

Expands to a test function which exports typescript bindings to one or multiple files when running cargo test.
If a type depends on an other type which is exported to a different file, an appropriate import will be included.
If a file already exists, it will be overriden.
Missing parent directories of the file(s) will be created.
Paths are interpreted as being relative to the project root.

#[derive(TS)] struct A;
#[derive(TS)] struct B;
#[derive(TS)] struct C;

export! {
    A, B => "bindings/a.ts",
    C => "bindings/b.ts"
}

When running cargo test, bindings for A, B and C will be exported to bindings/a.ts and bindings/b.ts.