Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@taga3s
Copy link
Contributor

@taga3s taga3s commented Dec 10, 2025

Summary

Currently, lint/suspicous/noRedeclare wrongly reports redeclarations for infer type in conditional types. So, I added checking if the declaration is infer type or not, and fixed not to report multiple usage of them.

This is my first contribution to this project. Please let me know if there's anything I should do.

Test Plan

I added a new test to valid-conditional-type.ts that demonstarates multiple infer declarations in conditional types.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

šŸ¦‹ Changeset detected

Latest commit: 34ddf2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages labels Dec 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

This change adds a const helper is_infer_type() to AnyJsBindingDeclaration and updates the lint/suspicious/noRedeclare logic to treat two infer type declarations as non-redeclarations when both sides are infer types. A test case introducing TestMultipleInfer<T extends readonly string[]> was added to validate conditional-type scenarios. No public API signatures were otherwise altered.

Suggested reviewers

  • ematipico
  • dyc3
  • arendjr

Pre-merge checks and finishing touches

āœ… Passed checks (4 passed)
Check name Status Explanation
Title check āœ… Passed The title accurately describes the main change: fixing the noRedeclare rule to not report redeclarations for infer types in conditional types.
Description check āœ… Passed The description clearly explains the issue being fixed (issue #7809), the solution implemented, and mentions test coverage added.
Linked Issues check āœ… Passed The PR fully addresses issue #7809 by adding an infer type check to prevent false positives when the same infer identifier appears multiple times in conditional types.
Out of Scope Changes check āœ… Passed All changes are directly scoped to fixing the noRedeclare rule: the lint rule logic, a public helper method on AnyJsBindingDeclaration, a changeset, and a test case.
✨ Finishing touches
  • šŸ“ Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

šŸ“œ Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

šŸ“„ Commits

Reviewing files that changed from the base of the PR and between 158d8ee and 34ddf2f.

ā›” Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts.snap is excluded by !**/*.snap and included by **
šŸ“’ Files selected for processing (4)
  • .changeset/breezy-groups-hope.md (1 hunks)
  • crates/biome_js_analyze/src/lint/suspicious/no_redeclare.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts (1 hunks)
  • crates/biome_js_syntax/src/binding_ext.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/biome_js_analyze/src/lint/suspicious/no_redeclare.rs
  • crates/biome_js_syntax/src/binding_ext.rs
  • .changeset/breezy-groups-hope.md
🧰 Additional context used
šŸ““ Path-based instructions (1)
**/*.ts

šŸ“„ CodeRabbit inference engine (CONTRIBUTING.md)

For Node.js package development, build WebAssembly bindings and JSON-RPC bindings; run tests against compiled files after implementing features or bug fixes

Files:

  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts
🧠 Learnings (3)
šŸ““ Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements
šŸ“š Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts
šŸ“š Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements

Applied to files:

  • crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts
šŸ”‡ Additional comments (1)
crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-conditional-type.ts (1)

5-9: Excellent test case for the issue!

This correctly demonstrates the scenario from #7809 where multiple infer Base declarations in a conditional type union should be valid. The test will verify that the lint rule no longer incorrectly flags this pattern as a redeclaration.

Welcome aboard, and nice first contribution! šŸŽ‰


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

ā¤ļø Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@taga3s taga3s force-pushed the fix-noredeclare-infer-type branch from 158d8ee to 34ddf2f Compare December 10, 2025 13:49
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 15, 2025

CodSpeed Performance Report

Merging #8417 will not alter performance

Comparing taga3s:fix-noredeclare-infer-type (34ddf2f) with main (c96dcf2)

Summary

āœ… 58 untouched
ā© 95 skipped1

Footnotes

  1. 95 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. ↩

@ematipico ematipico merged commit c3a2557 into biomejs:main Dec 16, 2025
19 checks passed
@github-actions github-actions bot mentioned this pull request Dec 16, 2025
@taga3s taga3s deleted the fix-noredeclare-infer-type branch December 16, 2025 07:54
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

šŸ’… lint/suspicious/noRedeclare wrongly reported on double type inferrence

3 participants