fix(no-unnecessary-condition): handle null overlap in narrowed generic intersections#891
Conversation
How to use the Graphite Merge QueueAdd 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. |
There was a problem hiding this comment.
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 !== nullon 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.
Merge activity
|
…c intersections (#891) fixes oxc-project/oxc#21429
9cb4368 to
f1049e4
Compare

fixes oxc-project/oxc#21429