fix(no-unnecessary-type-arguments): preserve shadowed type arguments#908
Merged
graphite-app[bot] merged 1 commit intoApr 25, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts no-unnecessary-type-arguments to avoid false positives when a generic’s default type would erase useful typing (notably when defaults involve any, as in the h3 useSession case from #875).
Changes:
- Refines the rule’s “default type equals provided type argument” detection by preferring identity/instantiation matching and narrowing when structural equivalence is allowed.
- Adds coverage for the reported
useSession<SessionData>(...)scenario and updates existing test cases/snapshots accordingly. - Reclassifies a previously-invalid structural-assignability case (
Bar extends Foo) as valid, and replaces the invalid case with a true-alias-to-default scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments.go | Updates the equivalence logic to prevent removals when defaults involve any / unsafe structural matches. |
| internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments_test.go | Adds a regression test for #875 and updates test expectations/cases for the new behavior. |
| internal/rule_tester/snapshots/no-unnecessary-type-arguments.snap | Updates snapshot positions/output for the modified invalid test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1d87709 to
95ba779
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
Merge activity
|
d20a140 to
42a817b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #875