-
Notifications
You must be signed in to change notification settings - Fork 47
Expand name collision detection to include enums #1813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
There was a problem hiding this 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 bug in name collision detection when package prefixes are trimmed from TypeSpec-generated Go types. Previously, only model types were checked for collisions, but union-derived enums were missed. This could result in a model like SearchIndexerStatus being renamed to IndexerStatus and colliding with an existing enum of the same name without any error being raised.
Key changes:
- Enhanced the
nameCollisionfunction to check againstsdkPackage.enumsin addition tosdkPackage.models - Updated inline comment to reflect that both model and enum types are now checked
- Incremented package version from 0.9.0 to 0.9.1
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/typespec-go/src/tcgcadapter/adapter.ts | Added enum collision detection loop in nameCollision function and updated comment |
| packages/typespec-go/package.json | Bumped version from 0.9.0 to 0.9.1 for bug fix release |
| packages/typespec-go/CHANGELOG.md | Added entry documenting the union type collision fix |


Name collision detection during package prefix trimming only checked against model types, missing collisions with union-derived enums.
Changes
nameCollisionfunction to check against:sdkPackage.enums- catches unions that become enumsExample
The collision check now aligns with the comment that previously claimed "clients and enums get a suffix" - it verifies they won't collide during the rename phase.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.