fix(typescript): reject subpackage method collisions - #17636
fix(typescript): reject subpackage method collisions#17636dimitropoulos wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
AI Review Summary
Adds a collision check between endpoint method names and subpackage client property names in the TS SDK generator. The logic is reasonable, but the hasWebSocketInTree cast smells, and throwing a bare Error deep in a constructor may produce a poor generator error experience. Also worth verifying that the check mirrors the actual naming/skip logic used at generation time (e.g. exported/inlined subpackages, hasEndpointsInTree semantics).
- 🟡 1 warning(s)
- 🔵 2 suggestion(s)
To request another review, comment /ai-review on this pull request.
There was a problem hiding this comment.
🟡 Changes recommended
The collision check currently ignores other generated public client members (e.g. root fetch() and websocket connect), so it can still emit invalid TypeScript for certain subpackage names.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the TypeScript SDK client-class generator to proactively reject name collisions between generated endpoint methods and generated subpackage client accessors, preventing invalid TypeScript output (e.g. duplicate member declarations).
Changes:
- Add a constructor-time validation that detects endpoint-method vs subpackage-client name collisions and throws early.
- Add unit test coverage for the collision scenario.
- Add an unreleased generator changelog entry documenting the fix.
File summaries
| File | Description |
|---|---|
| generators/typescript/sdk/client-class-generator/src/GeneratedSdkClientClassImpl.ts | Adds early validation for endpoint/subpackage client naming collisions during client generation. |
| generators/typescript/sdk/client-class-generator/src/test/GeneratedSdkClientClassImpl.test.ts | Adds a regression test asserting collisions are rejected with a helpful error. |
| generators/typescript/sdk/changes/unreleased/reject-subpackage-method-collisions.yml | Records the fix in the generator’s unreleased changelog. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fern generates invalid TypeScript (that can't typecheck) when an endpoint/subpackage client name collisions occurs.
Repro: https://github.com/dimitropoulos/scratchpad/tree/fern-nested-group-method-collision
CI (
TS2300at bothcdeclarations): https://github.com/dimitropoulos/scratchpad/actions/runs/33697294169