Disallow [await] using statements under case/default clauses#62709
Disallow [await] using statements under case/default clauses#62709jakebailey merged 2 commits intomicrosoft:mainfrom
[await] using statements under case/default clauses#62709Conversation
[await] using declarations under case/default clauses[await] using statements under case/default clauses
npm go brrrrr
| ); | ||
| } | ||
| else if (isVariableStatement(declarationList.parent) && isCaseOrDefaultClause(declarationList.parent.parent)) { | ||
| return grammarErrorOnNode( |
There was a problem hiding this comment.
Surprised that this is not a parser error, but I guess the error above it isn't either. Fun that this means that we leave the bad node in the tree, but, that's what happens already:
//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts] ////
//// [awaitUsingDeclarationsInForIn.ts]
async function main() {
for (await using x in {}) {
}
}
//// [awaitUsingDeclarationsInForIn.js]
async function main() {
for (await using x in {}) {
}
}
There was a problem hiding this comment.
Aye. Technically it is allowed in the ES grammar, it just triggers an early error.
jakebailey
left a comment
There was a problem hiding this comment.
I think this is correct to my eye.
|
@typescript-bot test it |
|
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
|
Babel and acorn already did this, so I'll merge this. Thanks for the PR! |
Port of microsoft/TypeScript#62709. As per tc39/ecma262@8e5d501, [await] using VariableStatements cannot be immediate children of case/default clauses; they must be contained within a block. - Add grammar check for TS1547/TS1548 in checker/grammarchecks.go - Remove switch statement using-declaration transform from estransforms/using.go - Accept baseline changes for new test files Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
As per tc39/ecma262@8e5d501,
[await] usingVariableStatements cannot be immediate children of case/default clauses; they must be contained within a block.Resolves #62708.