// working
const asyncFunc = async () => {
return someValue;
}
let someValue = await asyncFunc();
// prefered but not working
let someValue = await (async () => {
return someValue
})();
syntactically it is correct, but still it returns error Cannot find name 'await'.ts(2304)
Note: It works perfectly fine with .js files, it's the TS compiler throwing that error.
Seems to have to do with top-level await, since the following does not break (So don't know if it's a TS issue or Deno TS config)
async function get() {
let someValue = await (async() => {
return 5;
})();
}
get();
I thought we had an issue for it open here, but it is an upstream TypeScript bug. Ref: https://github.com/microsoft/TypeScript/issues/38483
@kitsonk You mentioned this issue before in https://github.com/denoland/deno/issues/471, which is a general issue about top-level await. Might be good to keep this one open just for this specific issue.
Most helpful comment
I thought we had an issue for it open here, but it is an upstream TypeScript bug. Ref: https://github.com/microsoft/TypeScript/issues/38483