tsify icon indicating copy to clipboard operation
tsify copied to clipboard

Customizing struct name / namespace?

Open ryan-williams opened this issue 1 year ago • 1 comments

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 to enums.
  • 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).

ryan-williams avatar Oct 09 '23 18:10 ryan-williams

+1

Swolebrain avatar Dec 08 '23 00:12 Swolebrain