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

wasm_bindgen_test syntax error at :: in .d.ts ("Expected type") #4449

Open
lynn opened this issue Mar 11, 2025 · 0 comments
Open

wasm_bindgen_test syntax error at :: in .d.ts ("Expected type") #4449

lynn opened this issue Mar 11, 2025 · 0 comments
Labels

Comments

@lynn
Copy link
Contributor

lynn commented Mar 11, 2025

When I define a test like

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
async fn screen_example() {
    // ...
}

in my wasm-bindgen module screening_wasm/src/lib.rs, the resulting screening_wasm/pkg/screening_wasm.d.ts contains

// ...

export interface InitOutput {
  readonly memory: WebAssembly.Memory;
  readonly __wbg_screenconfig_free: (a: number, b: number) => void;
  readonly __wbg_enumerationsettings_free: (a: number, b: number) => void;
  readonly __wbg_fixeddomains_free: (a: number, b: number) => void;
  readonly start: () => void;
  readonly screen: (a: any, b: any) => any;
  readonly __wbgt__screening_wasm::screen_example: (a: number) => void;

//                               ^ Expected a type but instead found ':'.
// ...

I'm not sure how this is supposed to work, but I guess the cause of this behavior is that wasm-bindgen-test-macro generates

#[export_name = ::core::concat!("__wbgt_", #ignore_name, "_", ::core::module_path!(), "::", ::core::stringify!(#ident))]

and then wasm2es6js.rs uses that name when making the .d.ts file, but it contains :: which is not valid in a TypeScript identifier.

@lynn lynn added the bug label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant