Skip to content

Report unused locals in class static blocks - #64485

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
Andarist:fix-unused-locals-static-block
Sep 28, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
Andarist:fix-unused-locals-static-block

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #64484

Copilot AI balanced review requested due to automatic review settings September 27, 2026 18:24
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 27, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused checker change correctly addresses the reported behavior and includes matching regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Enables unused-local diagnostics within class static blocks.

Changes:

  • Registers static blocks for unused-identifier analysis.
  • Adds static blocks to local/parameter checking.
  • Adds compiler test coverage and updated baselines.
File Description
tsc/​internal/​checker/​checker.go Implements unused-local checking for static blocks.
tsc/​testdata/​tests/​cases/​compiler/​unusedLocalsAndParameters.ts Adds the regression case.
tsc/​testdata/​baselines/​reference/​compiler/​unusedLocalsAndParameters.errors.txt Captures expected diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​unusedLocalsAndParameters.js Updates emit baseline.
tsc/​testdata/​baselines/​reference/​compiler/​unusedLocalsAndParameters.symbols Updates symbol baseline.
tsc/​testdata/​baselines/​reference/​compiler/​unusedLocalsAndParameters.types Updates type baseline.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test top1000

@typescript-automation

typescript-automation Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top1000 ✅ Started ✅ Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 1000 repos with tsc comparing main and refs/pull/64485/merge:

Everything looks good!

// Grammar checking
c.checkGrammarModifiers(node)
node.ForEachChild(c.checkSourceElement)
if len(node.Locals()) != 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this if?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 28, 2026
Merged via the queue into microsoft:main with commit f00be21 Sep 28, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Unused locals in class static block declarations are not reported

3 participants