Disallow [await] using statements under case/default clauses#2742
Merged
jakebailey merged 3 commits intomainfrom Feb 11, 2026
Merged
Disallow [await] using statements under case/default clauses#2742jakebailey merged 3 commits intomainfrom
[await] using statements under case/default clauses#2742jakebailey merged 3 commits intomainfrom
Conversation
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>
Copilot
AI
changed the title
[WIP] Port disallow await using statements under case default clauses
Disallow Feb 11, 2026
[await] using statements under case/default clauses
Contributor
There was a problem hiding this comment.
Pull request overview
Ports TypeScript behavior to treat using / await using variable statements as grammar errors when they appear directly under case/default clauses (must be wrapped in a block), aligning the Go port’s checker and emit pipeline with upstream TS.
Changes:
- Added a grammar check in
checkGrammarVariableDeclarationListto emit TS1547/TS1548 forusing/await usingdirectly undercase/default. - Removed switch/clause-specific handling from the ESNext using-declaration transformer since such constructs are now grammar errors.
- Updated reference baselines for affected submodule conformance tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/checker/grammarchecks.go |
Emits TS1547/TS1548 when a using/await using variable statement is directly under a case/default clause. |
internal/transformers/estransforms/using.go |
Removes switch/case-clause transformation logic that is no longer reachable for valid programs. |
testdata/baselines/reference/submodule/conformance/usingDeclarations.17.errors.txt.diff |
Removes obsolete diff baseline output. |
testdata/baselines/reference/submodule/conformance/usingDeclarations.17.errors.txt |
Adds/updates expected TS1547 error baseline. |
testdata/baselines/reference/submodule/conformance/awaitUsingDeclarations.17.errors.txt.diff |
Removes obsolete diff baseline output. |
testdata/baselines/reference/submodule/conformance/awaitUsingDeclarations.17.errors.txt |
Adds/updates expected TS1548 error baseline. |
DanielRosenwasser
approved these changes
Feb 11, 2026
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of microsoft/TypeScript#62709.
Per tc39/ecma262@8e5d501,
usingandawait usingvariable statements cannot be immediate children of case/default clauses—they must be wrapped in a block.checkGrammarVariableDeclarationListemitting TS1547/TS1548 whenusing/await usingdeclarations appear directly under case/default clausesvisitSwitchStatement,visitCaseOrDefaultClause, andgetUsingKindOfCaseOrDefaultClausesfrom the esnext using-declaration transformer, since these are now grammar errors and never reach emit✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.