Skip to content

fix(typescript): reject subpackage method collisions - #17636

Open
dimitropoulos wants to merge 2 commits into
fern-api:mainfrom
dimitropoulos:fix/typescript-subpackage-method-collision
Open

fix(typescript): reject subpackage method collisions#17636
dimitropoulos wants to merge 2 commits into
fern-api:mainfrom
dimitropoulos:fix/typescript-subpackage-method-collision

Conversation

@dimitropoulos

@dimitropoulos dimitropoulos commented Sep 3, 2026

Copy link
Copy Markdown

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 (TS2300 at both c declarations): https://github.com/dimitropoulos/scratchpad/actions/runs/33697294169


Devin Review

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:03

@nitpickybot nitpickybot 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.

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Copilot AI 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.

🟡 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.

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