-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Always error on an attempt to use await
as an identifier in modules
#55503
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
base: main
Are you sure you want to change the base?
Always error on an attempt to use await
as an identifier in modules
#55503
Conversation
else if (node.flags & NodeFlags.AwaitContext) { | ||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, declarationNameToString(node))); | ||
} | ||
else if (originalKeywordKind === SyntaxKind.AwaitKeyword && (node.flags & NodeFlags.AwaitContext || isExternalModule(file))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this would deserve a new diagnostic. The other one (with node.flags & NodeFlags.AwaitContext
) didn't have a specific diagnostic meant for it so I skipped adding one here as well.
I think though that it could be nice to add a specific diagnostic here (and maybe add a specific one for that other case as well while at it). If you agree - should this be a complete new diagnostic code or could the existing code be reused? Probably a new one makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe technically this is allowed in non-strict CJS, but I'd rather not make weird exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it only technically has to be disallowed in modules 😉 Isn't allowing it in TS files with script targets a weird exception already? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not allowed in non-strict CJS, it's always allowed there. The actual rule is that this is disallowed in modules - not that it's disallowed in strict mode 🤷
@typescript-bot pack this |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 1c1316e. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the diff-based user code test suite on this PR at 1c1316e. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the diff-based top-repos suite on this PR at 1c1316e. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the parallelized Definitely Typed test suite on this PR at 1c1316e. You can monitor the build here. Update: The results are in! |
Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@DanielRosenwasser Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Something interesting changed - please have a look. Details
|
@DanielRosenwasser Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @DanielRosenwasser, it looks like the DT test run failed. Please check the log for more details. |
fixes #8559