Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing struct name / namespace? #36

Open
ryan-williams opened this issue Oct 9, 2023 · 1 comment
Open

Customizing struct name / namespace? #36

ryan-williams opened this issue Oct 9, 2023 · 1 comment

Comments

@ryan-williams
Copy link

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).
@Swolebrain
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants