fix(no-unnecessary-type-assertion): avoid contextual generic inference for call expressions#824
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 false positives in no-unnecessary-type-assertion where type assertions on call-like expressions could incorrectly influence contextual generic inference during type comparison.
Changes:
- Use a context-free expression type for call-like expressions before comparing against the asserted type.
- Add a regression test covering
querySelectoroverloads where contextual typing previously leaked through an assertion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/rules/no_unnecessary_type_assertion/no_unnecessary_type_assertion.go | Adjusts the rule’s type acquisition to avoid contextual inference for call-like expressions. |
| internal/rules/no_unnecessary_type_assertion/no_unnecessary_type_assertion_test.go | Adds a regression test for overload + assertion inference leakage (issue #20656). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
…e for call expressions (#824) For call-like expressions, the assersion was infering the actual type. This is fixed by asking the checker for the context-free expression type before comparing it withith the asserted type. fixes oxc-project/oxc#20656
701cd88 to
599e150
Compare

For call-like expressions, the assersion was infering the actual type.
This is fixed by asking the checker for the context-free expression type before comparing it withith the asserted type.
fixes oxc-project/oxc#20656