Report unused locals in class static blocks - #64485
Jake Bailey (jakebailey) merged 2 commits into
Conversation
There was a problem hiding this comment.
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.
|
TypeScript Bot (@typescript-bot) test top1000 |
cc86352 to
3936da7
Compare
|
Jake Bailey (@jakebailey) Here are the results of running the top 1000 repos with tsc comparing Everything looks good! |
| // Grammar checking | ||
| c.checkGrammarModifiers(node) | ||
| node.ForEachChild(c.checkSourceElement) | ||
| if len(node.Locals()) != 0 { |
There was a problem hiding this comment.
Just to match the same kind of checks elsewhere, like in the checkBlock:
https://github.com/microsoft/TypeScript/blob/2f10683c4fccf62c027d7ca38b1ff4ecb3ed3318/tsc/internal/checker/checker.go#L3823-L3825
fixes #64484