You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 8, 2021. It is now read-only.
It's surprising to me that this forbids await. I'd expect to be able to do anything I could do in the surrounding code, including initialization of the class itself which might require waiting for some asynchronous operation.
Note that you can already await in computed property names:
(async()=>class{[await0](){}})()
is legal today.
This can't just be legalized in a followup because it interacts with parsing: if the await flag is not passed to the static block, then
classA{static{console.log(await);}}
is syntactically legal even in an async context. To keep the possibility of legalizing this open, at the very least we'd need to pass the correct grammar flag today and just make AwaitExpression an error. But it seems both simpler and more useful to inherit async-ness from the surrounding context.
(Edit: I should mention that similar concerns apply to yield, though the parsing isn't as tricky.)
It's surprising to me that this forbids
await. I'd expect to be able to do anything I could do in the surrounding code, including initialization of the class itself which might require waiting for some asynchronous operation.Note that you can already
awaitin computed property names:is legal today.
This can't just be legalized in a followup because it interacts with parsing: if the
awaitflag is not passed to the static block, thenis syntactically legal even in an async context. To keep the possibility of legalizing this open, at the very least we'd need to pass the correct grammar flag today and just make
AwaitExpressionan error. But it seems both simpler and more useful to inheritasync-ness from the surrounding context.(Edit: I should mention that similar concerns apply to
yield, though the parsing isn't as tricky.)