Skip to content

fix(no-unnecessary-type-arguments): preserve shadowed type arguments#908

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-no-unnecessary-type-arguments-875
Apr 25, 2026
Merged

fix(no-unnecessary-type-arguments): preserve shadowed type arguments#908
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-no-unnecessary-type-arguments-875

Conversation

@camc314

@camc314 camc314 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #875

Copilot AI review requested due to automatic review settings April 24, 2026 19:48
@camc314 camc314 self-assigned this Apr 24, 2026
@camc314 camc314 changed the title fix: preserve explicit session type arguments fix(no-unnecessary-type-arguments): preserve shadowed type arguments Apr 24, 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

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.

Comment thread internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments.go Outdated
Comment thread internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments.go Outdated
@camc314 camc314 force-pushed the codex/fix-no-unnecessary-type-arguments-875 branch 2 times, most recently from 1d87709 to 95ba779 Compare April 24, 2026 20:02
@camc314 camc314 requested a review from Copilot April 24, 2026 21:36

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

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.

Comment thread internal/rules/no_unnecessary_type_arguments/no_unnecessary_type_arguments.go Outdated

camc314 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

@graphite-app graphite-app Bot force-pushed the codex/fix-no-unnecessary-type-arguments-875 branch from d20a140 to 42a817b Compare April 25, 2026 09:07
@graphite-app graphite-app Bot merged commit 42a817b into main Apr 25, 2026
9 checks passed
@graphite-app graphite-app Bot removed the 0-merge label Apr 25, 2026
@graphite-app graphite-app Bot deleted the codex/fix-no-unnecessary-type-arguments-875 branch April 25, 2026 09:14
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.

no-unnecessary-type-arguments false positive in v0.20.0

2 participants