Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 22, 2025

The TypeScript renderer was not properly replacing symbol placeholders in default imports, causing generated code to contain internal placeholder names instead of the resolved symbol names.

Problem:
When generating default imports, the renderer used value.defaultBinding directly without processing it through renderIds to replace symbol placeholders. This resulted in imports like:

import _heyapi_95_ from 'foo';

Instead of the expected:

import foo from 'foo';

Solution:
Applied the same renderIds processing to default bindings that was already being used for namespace bindings. This ensures that symbol placeholders are properly resolved to their final names during import generation.

Changes:

  • Modified getImportLines method in packages/openapi-ts/src/generate/renderer.ts to process default binding placeholders
  • Added focused test coverage to verify the fix and prevent regressions

Testing:
The fix is verified by a new test that creates a symbol with a placeholder and confirms it gets replaced with the resolved name in the generated import statement.

Fixes #2673.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link

vercel bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
hey-api-docs Ready Ready Preview Comment Sep 22, 2025 1:00pm

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Sep 22, 2025

🦋 Changeset detected

Latest commit: 762b20e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mrlubos
Copy link
Member

mrlubos commented Sep 22, 2025

@copilot I think the problem is that the renderer doesn't handle replacing symbols for default imports yet

@Copilot Copilot AI changed the title [WIP] [openapi-ts] Default import don't replace placeholder Fix default import placeholder replacement in TypeScript renderer Sep 22, 2025
@Copilot Copilot AI requested a review from mrlubos September 22, 2025 12:48
Copilot finished work on behalf of mrlubos September 22, 2025 12:48
Copy link
Contributor Author

Copilot AI commented Sep 22, 2025

@copilot I think the problem is that the renderer doesn't handle replacing symbols for default imports yet

Exactly right! I've fixed this by adding renderIds processing to default bindings in the getImportLines method, making it consistent with how namespace bindings are handled. The fix is in commit 8098b5f and includes test coverage to verify that default import placeholders are now properly replaced with resolved symbol names.

Copilot finished work on behalf of mrlubos September 22, 2025 12:56
@mrlubos mrlubos marked this pull request as ready for review September 22, 2025 13:00
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 22, 2025
@dosubot dosubot bot added lgtm This PR has been approved by a maintainer bug 🔥 Something isn't working labels Sep 22, 2025
Copy link

pkg-pr-new bot commented Sep 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/codegen-core@2674
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2674
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2674
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2674

commit: 762b20e

@mrlubos mrlubos merged commit b59afd5 into main Sep 22, 2025
14 of 15 checks passed
@mrlubos mrlubos deleted the copilot/fix-2673 branch September 22, 2025 14:17
@hey-api hey-api bot mentioned this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[openapi-ts] Default import don't replace placeholder
2 participants