Skip to content

static_method_of shows unexpected behavior #2040

Open
@anlumo

Description

@anlumo

Describe the Bug

Take this code:

#[wasm_bindgen(module = "my-great-module")]
extern "C" {
    #[wasm_bindgen(js_name = default)]
    pub type Module;

    #[wasm_bindgen(static_method_of = Module)]
    pub fn init();
}

Expected Behavior

Generated index.js:

import { default as default1 } from 'my-great-module';

Actual Behavior

import { Module } from 'my-great-module';

Additional Context

The problem is that static_method_of binds to the type name given instead of the js_name defined for that type. static_method_of = default also doesn't work, because the type default is not known.

This produces the expected behavior:

#[wasm_bindgen(module = "my-great-module")]
extern "C" {
    #[wasm_bindgen(js_name = default)]
    pub type Module;

    #[wasm_bindgen(static_method_of = Module, js_class = "default")]
    pub fn init();
}

but this double specification shouldn't be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions