Skip to content

fix(no-unnecessary-condition): handle null overlap in narrowed generic intersections#891

Merged
graphite-app[bot] merged 1 commit into
mainfrom
c/04-14-fix_no-unnecessary-condition_handle_null_overlap_in_narrowed_generic_intersections
Apr 14, 2026
Merged

fix(no-unnecessary-condition): handle null overlap in narrowed generic intersections#891
graphite-app[bot] merged 1 commit into
mainfrom
c/04-14-fix_no-unnecessary-condition_handle_null_overlap_in_narrowed_generic_intersections

Conversation

@camc314

@camc314 camc314 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

camc314 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

How to use the Graphite Merge Queue

Add the label 0-merge to this PR to add it to 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.

@camc314 camc314 marked this pull request as ready for review April 14, 2026 15:17
Copilot AI review requested due to automatic review settings April 14, 2026 15:17
@camc314 camc314 self-assigned this Apr 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a false-positive in no-unnecessary-condition when checking null/undefined overlap for equality comparisons involving narrowed generic intersection types (per oxc-project/oxc#21429).

Changes:

  • Update the rule’s internal “type comparability” logic to properly traverse union and intersection types when detecting “no overlap” comparisons.
  • Add a regression test ensuring typeof value === 'object' && value !== null on a generic parameter is treated as necessary (no lint error).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/rules/no_unnecessary_condition/no_unnecessary_condition.go Refines overlap/comparability checking by recursively handling unions and intersections to avoid incorrect “no overlap” diagnostics.
internal/rules/no_unnecessary_condition/no_unnecessary_condition_test.go Adds a valid test case covering a narrowed generic intersection scenario involving null.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

camc314 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

@graphite-app graphite-app Bot force-pushed the c/04-14-fix_no-unnecessary-condition_handle_null_overlap_in_narrowed_generic_intersections branch from 9cb4368 to f1049e4 Compare April 14, 2026 15:30
@graphite-app graphite-app Bot merged commit f1049e4 into main Apr 14, 2026
8 checks passed
@graphite-app graphite-app Bot deleted the c/04-14-fix_no-unnecessary-condition_handle_null_overlap_in_narrowed_generic_intersections branch April 14, 2026 15:37
@graphite-app graphite-app Bot removed the 0-merge label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: no-unnecessary-condition false positive on null equality check in generic function

2 participants