facebook/flow

"Unxepcted identifier, expected the token ;" when using await inside of ES module

DanielBaulig opened this issue · 3 comments

When using await at the top level of an ES module flow flags that as an invalid use of await. I tried naming the file x.js as well as x.jsm and x.mjs and included an export statement to indicate that it's a ES module, without success. I searched the flow documentation for anything relating to module, es module and await, but didn't find anything relevant.

Flow version: v0.220.0

Expected behavior

Pass the type check.

According to MDN await is legal at the top level of a module.

Actual behavior

Error: Unexpected identifier, expected the token ;

Found a bug report from 2019 (!) on this:
#7710

:-/

gkz commented

We don't currently support top-level await, but it's on the backlog of items to do

That's sad to hear. Is there a timeline for when we can expect support for top-level await to land in Flow? I'm starting a new project and might consider trying out TS, since I believe it does support top-level await. I'd prefer to stick with Flow if I can though.