microsoft / microsoft/TypeScript

Add a stable module target for top-level await

Open
#37,709 4 comments 0 reactions 1 assignee View on GitHub

@rbuckton is already working on this.

Since Oct 28, 2022.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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:

https://github.com/microsoft/TypeScript/pull/35813 - Add top-level await for esnext and system modules

Basically, just add "es2020" to the list.
Easy to fix, bro.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.