-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disallow async constructors #3976
Comments
We considered removing support for this in #3562, since it was originally a bug, but discovered that people had started relying on it and so left it to avoid breakage. You can see lots of instances of people doing this with https://github.com/search?q=%2F%23%5C%5Bwasm_bindgen%5C%28constructor%5C%29%5C%5D%5B+%5Cn%5D*pub+async+fn%2F&type=code. |
Do you know what actually ends up happening under the hood, is it safe? |
Yes; This is what the generated JS code ends up looking like: export class MyStruct {
// ...
constructor(data) {
const ret = wasm.mystruct_new(data);
return takeObject(ret);
}
} JS actually supports |
Maybe we should investigate if we can emit a warning in this case (with the help of |
Describe the Bug
wasm_bindgen allows you to create an async constructor even though this is not supported by typescript.
Steps to Reproduce
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
The text was updated successfully, but these errors were encountered: