fix(noUnusedImports): edge case ambient type#9359
Conversation
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
WalkthroughFixes a false positive in the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_js_semantic/src/events.rs (1)
1019-1033: Please add a dedicated parameter-shadowing regression test.This branch explicitly handles the
(stream: stream.T)shape; adding a matchingvalid-issue-7516-parameter.tswould lock the behaviour down and avoid future drift.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_js_semantic/src/events.rs` around lines 1019 - 1033, Add a regression test that covers the parameter-shadowing case handled by the new logic: create a new test file (e.g., valid-issue-7516-parameter.ts) containing a type import and a function/arrow parameter that shadows the import name but uses the import in a type position (the `(stream: stream.T)` shape), ensuring the analyzer accepts it (valid test). The test should exercise the code path where reference.is_ambient_read() && !info.is_imported() leads to promoting the reference into the parent scope (verify behavior tied to self.scopes.last_mut(), parent.references and Reference::AmbientRead). Ensure the test asserts no error is reported so future changes to the promotion logic are caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_js_semantic/src/events.rs`:
- Around line 1019-1033: Add a regression test that covers the
parameter-shadowing case handled by the new logic: create a new test file (e.g.,
valid-issue-7516-parameter.ts) containing a type import and a function/arrow
parameter that shadows the import name but uses the import in a type position
(the `(stream: stream.T)` shape), ensuring the analyzer accepts it (valid test).
The test should exercise the code path where reference.is_ambient_read() &&
!info.is_imported() leads to promoting the reference into the parent scope
(verify behavior tied to self.scopes.last_mut(), parent.references and
Reference::AmbientRead). Ensure the test asserts no error is reported so future
changes to the promotion logic are caught.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8d857a24-a300-4a5d-b20e-cc395a73cff6
⛔ Files ignored due to path filters (5)
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-const.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-let.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-nested.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-non-type.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-var.ts.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (7)
.changeset/rude-pets-enjoy.mdcrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-const.tscrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-let.tscrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-nested.tscrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-non-type.tscrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-7516-var.tscrates/biome_js_semantic/src/events.rs
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Closes #7516
Code and tests added by Claude Code
Test Plan
Added new tests
Docs