Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a stable module target for top-level await #37709

Open
dtruffaut opened this issue Mar 31, 2020 · 4 comments
Open

Add a stable module target for top-level await #37709

dtruffaut opened this issue Mar 31, 2020 · 4 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@dtruffaut
Copy link

dtruffaut commented Mar 31, 2020

TypeScript Version:
3.9-beta

Search Terms:
top level await es2020 module

tsconfig.json
"target":"es2020"
"module":"es2020"

Code

await 1;

Expected behavior:

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.

@RyanCavanaugh RyanCavanaugh added the Waiting for TC39 Unactionable until TC39 reaches some conclusion label Mar 31, 2020
@RyanCavanaugh
Copy link
Member

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.

@DanielRosenwasser DanielRosenwasser changed the title Easy: Add top-level await for es2020 modules Add top-level await for es2020 modules Mar 31, 2020
@DanielRosenwasser DanielRosenwasser changed the title Add top-level await for es2020 modules Add top-level await for es2021 modules Mar 31, 2020
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 31, 2020

It definitely won't be in ES2020 - it isn't up for any new features, and top-level await is still stage 3.

@DanielRosenwasser DanielRosenwasser changed the title Add top-level await for es2021 modules Add a stable module target for top-level await Mar 31, 2020
@DanielRosenwasser
Copy link
Member

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.

@mitar
Copy link
Contributor

mitar commented Oct 28, 2022

So, top-level await has been standardized. What this means for this issue?

@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. and removed Waiting for TC39 Unactionable until TC39 reaches some conclusion labels Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

5 participants