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 }}
Repository navigation
Add a stable module target for top-level await #37709
OK if "module":"esnext" in tsconfig.json
OK if "module":"es2020" in tsconfig.json
Actual behavior:
OK if "module":"esnext" in tsconfig.json
KO if "module":"es2020" in tsconfig.json <----- :'(
Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. ts(1378)
Playground Link:
"module":"es2020" is not available on Typescript playground.
"module":"es2020" is not available in documentation.
Related Issues:
#35813 - Add top-level await for esnext and system modules
Basically, just add "es2020" to the list.
Easy to fix, bro.
The ES2020 feature list has not been ratified yet, so we can't definitively say TLA will be part of it, but we're expecting that to happen at the upcoming TC39 meeting.
I have misspoken slightly - Ryan is right, and that combined with the spec ratification timeline, means that some features that hit stage 4 at the current meeting might make it into ES2020 (e.g. import.meta). But top-level await isn't up for discussion at this meeting.
Activity
RyanCavanaugh commentedon Mar 31, 2020
The ES2020 feature list has not been ratified yet, so we can't definitively say TLA will be part of it, but we're expecting that to happen at the upcoming TC39 meeting.
[-]Easy: Add top-level await for es2020 modules[/-][+]Add top-level await for es2020 modules[/+][-]Add top-level await for es2020 modules[/-][+]Add top-level await for es2021 modules[/+]DanielRosenwasser commentedon Mar 31, 2020
It definitely won't be in ES2020 - it isn't up for any new features, and top-level
awaitis still stage 3.[-]Add top-level await for es2021 modules[/-][+]Add a stable module target for top-level await[/+]DanielRosenwasser commentedon Apr 1, 2020
I have misspoken slightly - Ryan is right, and that combined with the spec ratification timeline, means that some features that hit stage 4 at the current meeting might make it into ES2020 (e.g.
import.meta). But top-levelawaitisn't up for discussion at this meeting.mitar commentedon Oct 28, 2022
So, top-level await has been standardized. What this means for this issue?