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 top-level await for esnext and system modules #35813

Merged
merged 1 commit into from Dec 22, 2019
Merged

Add top-level await for esnext and system modules #35813

merged 1 commit into from Dec 22, 2019

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Dec 21, 2019

This removes our restriction around using an await expression at the top level of a file when the following conditions are met:

  • The containing file is an external module (or --isolatedModules is provided)
  • The --target is >= ScriptTarget.ES2017 (minimum version required for await keyword)
  • The --module is either esnext or system.

This is not currently supported for earlier script targets (e.g., ES2016, ES2015, ES5, ES3) as the system transform currently happens after async functions and generators have been transformed, so it is too late to transform the async function that is created as part of the system module transform. This also ensures it is consistent with --target es5 --module esnext, as there would be no way to down-level the await in that context either.

Fixes #25988, #32793

@rbuckton rbuckton merged commit 114dad7 into master Dec 22, 2019
8 checks passed
@rbuckton rbuckton deleted the topLevelAwait branch Dec 22, 2019
@mightyiam
Copy link

@mightyiam mightyiam commented Dec 23, 2019

Thank you, @rbuckton. I'm looking forward to using this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants