Skip to content

Disallow async constructors #3976

Closed
@benthecarman

Description

@benthecarman

Describe the Bug

wasm_bindgen allows you to create an async constructor even though this is not supported by typescript.

Steps to Reproduce

#[wasm_bindgen]
pub struct MyStruct {
	data: u32
}

#[wasm_bindgen]
impl MyStruct {
  #[wasm_bindgen(constructor)]
  pub async fn new(data: u32) -> Self {
     // do something async
     Self { data }
  }
}

This compiles and actually works, however seems like undefined behavior and should just fail to compile

Expected Behavior

Unknown, probably fail to compile

Actual Behavior

Works

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