Skip to content

Conversation

jakebailey
Copy link
Member

When I added this type, I forgot to mention K and V in the struct fields, meaning that any SyncMap was convertible to any other one structurally. That's a mistake.

Nothing fails, thankfully.

@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 21:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a type safety issue in the generic SyncMap struct by adding phantom fields to reference the K and V type parameters. Without these fields, different SyncMap instantiations with different type parameters would be structurally equivalent, allowing unintended type conversions.

  • Adds phantom fields _ [0]K and _ [0]V to ensure type parameter usage in the struct definition
  • Prevents structural convertibility between SyncMap instances with different type parameters

@jakebailey jakebailey enabled auto-merge September 5, 2025 21:21
@jakebailey jakebailey added this pull request to the merge queue Sep 5, 2025
Merged via the queue into main with commit d2c442d Sep 5, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/sync-map-kv-mention branch September 5, 2025 21:46
Harsh1925 pushed a commit to Harsh1925/typescript-go that referenced this pull request Sep 9, 2025
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.

2 participants