Skip to content

Fix getTypeNameWithGenerics for package-qualified type arguments - #27

Merged
satvik007 merged 1 commit into
mainfrom
dev/himanshu/fix-get-type-name-with-generics
Sep 25, 2026
Merged

satvik007 merged 1 commit into
mainfrom
dev/himanshu/fix-get-type-name-with-generics

Conversation

@hi-rai

@hi-rai hi-rai commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Generic type arguments containing defined types included package paths and compiler-generated suffixes in generated schema names, producing invalid or unstable TypeScript identifiers. This change strips package qualifiers and compiler suffixes while retaining nested generic argument names.

For example: GenericPair[int,github.com/example/models.User] previously generated: GenericPairIntGithubComExampleModelsUserSchema. It now generates: GenericPairIntUserSchema

@hi-rai
hi-rai requested a review from satvik007 August 19, 2026 10:41
@hi-rai hi-rai self-assigned this Aug 19, 2026

@claude claude Bot 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.

Overall this is a well-structured fix with good test coverage. The parsing logic in getTypeNameWithGenerics is sound and handles the complex type syntax correctly. One defensive guard for empty partName after package stripping would make it more robust. A few minor suggestions inline.

Comment thread zod.go Outdated
Comment thread zod.go
Comment thread zod.go Outdated
Comment thread zod_test.go
@github-actions github-actions Bot deleted a comment from claude Bot Aug 19, 2026
@hi-rai
hi-rai force-pushed the dev/himanshu/fix-get-type-name-with-generics branch from c86438a to 13a144d Compare August 19, 2026 10:51
@github-actions github-actions Bot deleted a comment from claude Bot Aug 19, 2026

@satvik007 satvik007 left a comment

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.

Can we have a better way to handle name clashes, when 2 structs have same name but they are present in different packages.

@hi-rai

hi-rai commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Can we have a better way to handle name clashes, when 2 structs have same name but they are present in different packages.

The issue already exists for non-generic types and should be fixed separately. I will open a separate PR for that

@satvik007
satvik007 merged commit 7c63086 into main Sep 25, 2026
2 checks passed
@satvik007
satvik007 deleted the dev/himanshu/fix-get-type-name-with-generics branch September 25, 2026 08:37
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