Skip to content

Properly handle same name types from different packages - #29

Merged
satvik007 merged 2 commits into
mainfrom
dev/himanshu/type-name-clashes
Sep 25, 2026
Merged

satvik007 merged 2 commits into
mainfrom
dev/himanshu/type-name-clashes

Conversation

@hi-rai

@hi-rai hi-rai commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed: Added schema name collision detection and WithPackagePrefixes to distinguish types from different packages. Fixed generic type naming and added regression coverage for Zod v3 and v4.

Why: Types with the same name could silently reuse an incorrect schema, while package-qualified generic arguments could produce invalid TypeScript identifiers.

Impact: Name collisions now cause a clear panic. Applications with conflicting type names must configure package prefixes. Anonymous structs require AddTypeWithName with a non-empty name.

Fixes #27 (comment)

@hi-rai
hi-rai requested a review from satvik007 September 24, 2026 08:03
@hi-rai hi-rai self-assigned this Sep 24, 2026
@github-actions github-actions Bot deleted a comment from claude Bot Sep 24, 2026
Base automatically changed from dev/himanshu/fix-get-type-name-with-generics to main September 25, 2026 08:37
@hi-rai
hi-rai force-pushed the dev/himanshu/type-name-clashes branch from 1e6fc43 to b4e95a6 Compare September 25, 2026 08:59
@github-actions github-actions Bot deleted a comment from claude Bot Sep 25, 2026
Comment thread README.md Outdated
Comment on lines +386 to +390
c.Convert(Account{
Owner api.User
Record db.User
History Page[db.User]
})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This probably won't compile

It should declare the struct first, then convert it:

type Account struct {
    Owner   api.User
    Record  db.User
    History Page[db.User]
}
c.Convert(Account{})

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@satvik007
satvik007 merged commit 469f4c0 into main Sep 25, 2026
2 checks passed
@satvik007
satvik007 deleted the dev/himanshu/type-name-clashes branch September 25, 2026 09:53
@github-actions github-actions Bot deleted a comment from claude Bot Sep 25, 2026
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