Skip to content

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

Open
@dtruffaut

Description

@dtruffaut

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.

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions