You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject using and await using declarations in switch case/default clauses
Fixes#62708
This change implements parser validation to reject `using` and `await using`
declarations when directly nested within `case` or `default` clauses of switch
statements, as per the updated ECMAScript spec.
The spec was updated to disallow this pattern (see rbuckton/ecma262#14) because:
- It makes the number of resource declarations statically knowable
- All major JS engines agreed to this restriction
- The pattern is rarely used in practice
Changes:
- Add new diagnostic (TS95198) for the error message
- Add validation in parseVariableDeclarationList() to check parsingContext
- Add error baseline for existing test case that now produces errors
Valid workaround: Wrap using declarations in a block statement:
case 0: {
using x = ...; // OK
}
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments