-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
Description
The using keyword does not work properly when combined with async. Take the following typescript code:
async function getResource(): Promise<AsyncDisposable> {
return {
[Symbol.asyncDispose]: async () => {
console.log("Dispose async!");
}
};
}
async function someOtherAsync() {
// Do async work...
}
async function main() {
await using resource = await getResource();
await someOtherAsync();
}
main();This code compiles and works as expected. However, attempting to compile this with tstl results in the following errors:
Await can only be used inside async functions.(typescript-to-lua)
The error happens at await someOtherAsync(), presumably because the way tstl compiles the using keyword does not account for the function being async in the protected call.
Reactions are currently unavailable