Skip to content

fix(linter/no-unused-vars): correctly detect unused symbols in TypeScript namespaces#17129

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces
Dec 19, 2025
Merged

fix(linter/no-unused-vars): correctly detect unused symbols in TypeScript namespaces#17129
graphite-app[bot] merged 1 commit intomainfrom
c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 19, 2025

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

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Dec 19, 2025
Copy link
Contributor Author

camc314 commented Dec 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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-hq
Copy link

codspeed-hq bot commented Dec 19, 2025

CodSpeed Performance Report

Merging #17129 will not alter performance

Comparing c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces (6faf625) with main (adb41ba)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 self-assigned this Dec 19, 2025
@camc314 camc314 force-pushed the c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces branch 2 times, most recently from 9523f0f to 6faf625 Compare December 19, 2025 19:05
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 19, 2025
@camc314 camc314 marked this pull request as ready for review December 19, 2025 19:05
Copilot AI review requested due to automatic review settings December 19, 2025 19:05
Copy link
Contributor Author

camc314 commented Dec 19, 2025

Merge activity

Copy link
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

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
@graphite-app graphite-app bot force-pushed the c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces branch from 6faf625 to 5a7fcd1 Compare December 19, 2025 19:11
@graphite-app graphite-app bot merged commit 5a7fcd1 into main Dec 19, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/12-19-fix_linter_no-unused-vars_correctly_detect_unused_symbols_in_typescript_namespaces branch December 19, 2025 19:16
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: no-unused-vars shouldn't raise on ambient namespace declarations

2 participants