fix(linter/no-unused-vars): correctly detect unused symbols in TypeScript namespaces#17129
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #17129 will not alter performanceComparing Summary
Footnotes
|
9523f0f to
6faf625
Compare
Merge activity
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the detection of unused symbols in TypeScript namespaces and declared modules to correctly identify unused functions, types, and interfaces according to their context.
Key changes:
- Functions inside non-declared namespaces are now correctly reported as unused
- Type aliases inside declared modules with explicit exports are now correctly reported as unused
- Symbols inside exported namespaces are no longer incorrectly considered exported by virtue of the namespace being exported
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 |
|---|---|
crates/oxc_linter/src/snapshots/eslint_no_unused_vars@oxc-namespaces.snap |
Updated snapshot to include detection of unused function foo in exported namespace |
crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/typescript_eslint.rs |
Re-enabled test case for declare module 'foo' with unused type to verify fix |
crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs |
Added comprehensive test cases for various namespace and module scenarios, including exported declared namespaces and modules |
crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs |
Extended type alias handling to match interface declaration behavior in declared modules |
crates/oxc_linter/src/rules/eslint/no_unused_vars/ignored.rs |
Refined function ignoring logic to check for ambient context when TypeScript syntax or body-less functions are encountered |
crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs |
Enhanced namespace checking to distinguish between ambient namespaces with and without explicit exports, ensuring only truly ambient symbols without exports are automatically allowed |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ript namespaces (#17129) Fix detection of unused symbols inside TypeScript namespaces and declared modules: - Functions inside non-declared namespaces are now correctly reported as unused - Types inside declared modules with explicit exports are now correctly reported as unused - Symbols inside exported namespaces are no longer incorrectly considered exported fixes #17122
6faf625 to
5a7fcd1
Compare

Fix detection of unused symbols inside TypeScript namespaces and declared modules:
fixes #17122