TypeScript Version: 3.8.3
Search Terms:
top level for await
Code
const arr = [ Promise.resolve() ];
for await (const item of arr) {
item;
}
export {};
Expected behavior:
To compile without issue.
Actual behavior:
A 'for-await-of' statement is only allowed within an async function or async generator. (1103)
In the Stage 3 proposal, tc39/proposal-top-level-await#133 was specifically added to address that for await is valid. Therefore the TypeScript implementation is incomplete. While it was implemented in V8 separately, V8 now supports it (as well as potentially other engines).
Playground Link: link
Related Issues: #25988
TypeScript Version: 3.8.3
Search Terms:
top level for await
Code
Expected behavior:
To compile without issue.
Actual behavior:
In the Stage 3 proposal, tc39/proposal-top-level-await#133 was specifically added to address that
for awaitis valid. Therefore the TypeScript implementation is incomplete. While it was implemented in V8 separately, V8 now supports it (as well as potentially other engines).Playground Link: link
Related Issues: #25988