Skip to content

Group type-only imports and fix missing type keyword on PDA seeds imports - #176

Open
macalinao wants to merge 1 commit into
codama-idl:mainfrom
macalinao:verbatim-import-type
Open

Group type-only imports and fix missing type keyword on PDA seeds imports#176
macalinao wants to merge 1 commit into
codama-idl:mainfrom
macalinao:verbatim-import-type

Conversation

@macalinao

@macalinao macalinao commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Two small fixes that make generated clients cleaner under verbatimModuleSyntax, which every e2e fixture tsconfig already enables.

Group type-only imports

When every identifier a generated file imports from a given module is type-only, the import is now rendered as a single import type { ... } statement rather than inlining a type marker on each specifier. The two forms are equivalent to the type checker, but they differ in what TypeScript emits: under verbatimModuleSyntax the inline form erases the specifiers and leaves an empty import {} from '...' side-effect statement behind in the emitted JavaScript, while the grouped form is erased entirely. Modules that mix value and type imports keep the existing inline form, since only a fully type-only group can be hoisted to import type.

Fix the PDA seeds type import

getAccountPdaHelpersFragment imported the PDA seeds type (e.g. BarSeeds) without a type keyword, even though it is only ever referenced in type position on the seeds parameter. Any generated client with an account linked to a PDA that has variable seeds therefore failed to compile with TS1484 under verbatimModuleSyntax. The identifier is now imported as type BarSeeds; mergeImportMaps already lets a value import win over a type import, so this stays correct if the same name is also needed as a value.

Notes for consumers

Regenerating a client will produce cosmetic import { type A }import type { A } diffs. No runtime behavior changes.

The checked-in e2e fixtures were regenerated as part of this change to keep CI's clean-working-tree invariant satisfied; the only resulting diff is a single import statement in the dummy client.

Related work

Part of #180 — running generated clients natively on Node.js 24+ TypeScript (type stripping), with no separate compilation step:

…orts

When every identifier a generated file imports from a given module is type-only, the import is now rendered as a single `import type { ... }` statement instead of inlining a `type` marker on each specifier. Under `verbatimModuleSyntax` the inline form leaves behind an empty `import {} from '...'` side-effect statement in the emitted JavaScript, which the grouped form erases entirely. Modules that mix value and type imports keep the existing inline form.

Separately, account PDA helpers imported the PDA seeds type without a `type` keyword even though it is only ever referenced in type position, so generated clients tripped TS1484 under `verbatimModuleSyntax` whenever an account was linked to a PDA with variable seeds.

The checked-in e2e fixtures were regenerated; the only resulting change is one import statement in the dummy client.
@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c9cdbe5

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

This PR includes changesets to release 1 package
Name Type
@codama/renderers-js 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

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.

1 participant