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 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 force-pushed the topLevelAwait branch from e3e8b0c to 1a30b10 Dec 21, 2019
@rbuckton rbuckton merged commit 114dad7 into master Dec 22, 2019
8 checks passed
8 checks passed
build (8.x)
Details
build (10.x)
Details
build (12.x)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details
node10 Build #58450 succeeded
Details
node12 Build #58448 succeeded
Details
node8 Build #58449 succeeded
Details
@rbuckton rbuckton deleted the topLevelAwait branch Dec 22, 2019
@mightyiam

This comment has been minimized.

Copy link

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
Projects
None yet
3 participants
You can’t perform that action at this time.