tsify
tsify copied to clipboard
Customizing struct name / namespace?
I have two files that each define a struct with the same "basename", e.g.:
// a.rs
#[derive(Tsify)]
pub struct Foo {
pub n: usize,
}
// b.rs
#[derive(Tsify)]
pub struct Foo {
pub s: String,
}
They end up as duplicate, top-level Foo
declarations in the exported .d.ts
file:
// my_package.d.ts
export interface Foo {
n: number;
}
export interface Foo {
s: string;
}
Is there a way to namespace, or otherwise rename them?
- I see
#[tsify(namespace)]
, but it can only be applied toenum
s. - I also looked at
#[wasm_bindgen(js_name = "…")]
, but that seems orthogonal (and also doesn't work for my structures, which have generic type arguments that wasm_bindgden doesn't support).
+1