-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 import
in the non-module description
#2374
Conversation
I think this is previously accurate because only modules are allowed top level await but I think it's reasonable to add |
Thank you @orta, I was not aware of the "top level await" case. Thanks for mentioning it. Today I learned something new. |
await
with import
import
in the non-module description
I think this one is tricky; having a top-level await doesn't cause TS to treat the file as a module. Instead, we use But, I think this section is already awkward... it's not that the JavaScript spec says anything about these things, right? |
I’m not an expert on the ECMAScript grammar but I suspect the wording is a little weird here. The spec does distinguish between the grammars for script bodies and module bodies, and these three things are indeed relevant, but I think our wording probably implies the wrong causality. My understanding is that spec-compliant engines know ahead of time whether they should be parsing a script or a module (via |
await
doesn't play a role in deciding whether a JS file is a module or a script.