-
Notifications
You must be signed in to change notification settings - Fork 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
enum in return position have wrong type #3864
Comments
Weird. I think this is the bit of the generated code causing the issue: /**
* @returns {A}
*/
export function b() {
const ret = wasm.b();
return ret;
}
/**
*/
export const A = Object.freeze({ B:0,"0":"B",C:1,"1":"C", }); It seems like TypeScript is interpreting the Is this happening in Deno? I can reproduce it with Deno, but not with plain TSC, I think because TSC automatically checks for // @deno-types="./dist/b.d.ts"
import { b } from "./dist/b.js";
console.log(typeof b()); //number
console.log(b() === 0); There are 2 approaches to solving this properly:
Probably we should do both, since the JSDoc declarations should work if necessary (e.g. |
Yes it's in Deno, I didn't think it's related thank fo investigating, is Deno behavior correct here or should I open a bug report ? |
No, Deno's behaviour is correct. One of their goals is not to magically look up extra files since that might be wasting extra network requests, and so they differ from |
Describe the Bug
rust enums in return position are typed as object, but at runtime they're just a number
Steps to Reproduce
wasm-bindgen 0.2.91
The text was updated successfully, but these errors were encountered: