Skip to content

Disallow [await] using statements under case/default clauses#2742

Merged
jakebailey merged 3 commits intomainfrom
copilot/disallow-await-using-case-default
Feb 11, 2026
Merged

Disallow [await] using statements under case/default clauses#2742
jakebailey merged 3 commits intomainfrom
copilot/disallow-await-using-case-default

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

Port of microsoft/TypeScript#62709.

Per tc39/ecma262@8e5d501, using and await using variable statements cannot be immediate children of case/default clauses—they must be wrapped in a block.

switch (x) {
    case 0:
        using d = expr;     // TS1547: not allowed
        break;
    case 1: {
        using d = expr;     // ok, wrapped in block
        break;
    }
}
  • Checker: Added grammar check in checkGrammarVariableDeclarationList emitting TS1547/TS1548 when using/await using declarations appear directly under case/default clauses
  • Transformer: Removed visitSwitchStatement, visitCaseOrDefaultClause, and getUsingKindOfCaseOrDefaultClauses from 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.

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 [await] using statements under case/default clauses Feb 11, 2026
Copilot AI requested a review from jakebailey February 11, 2026 00:06
@jakebailey jakebailey marked this pull request as ready for review February 11, 2026 00:16
Copilot AI review requested due to automatic review settings February 11, 2026 00:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 checkGrammarVariableDeclarationList to emit TS1547/TS1548 for using/await using directly under case/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.

@jakebailey jakebailey enabled auto-merge February 11, 2026 01:34
@jakebailey jakebailey added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 08cb84c Feb 11, 2026
20 checks passed
@jakebailey jakebailey deleted the copilot/disallow-await-using-case-default branch February 11, 2026 06:20
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants