Skip to content

fix: print aliased inline type import specifiers as 'type X as Y'#119

Open
leonidaz wants to merge 1 commit into
sveltejs:mainfrom
Ripple-TS:fix-type-import
Open

fix: print aliased inline type import specifiers as 'type X as Y'#119
leonidaz wants to merge 1 commit into
sveltejs:mainfrom
Ripple-TS:fix-type-import

Conversation

@leonidaz
Copy link
Copy Markdown

Fixes printing of TS inline-type import specifiers that also have an alias.

Before:
AST: { type: 'ImportSpecifier', imported: Foo, local: Bar, importKind: 'type' }
Output: import { Foo as type Bar } from '...' // invalid TS

After:
Output: import { type Foo as Bar } from '...' // valid TS

The type keyword now precedes the imported identifier rather than the local.
Non-aliased cases (import { type Foo }) are unchanged.

Coverage added to test/samples/ts-typed-imports.

`ImportSpecifier` with both `importKind: 'type'` and an alias (e.g.
`import { type Foo as Bar } from '...'`) was being printed as
`Foo as type Bar`, which is not valid TypeScript. The `type` keyword now
precedes the imported identifier instead of the local.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 480df0f

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

This PR includes changesets to release 1 package
Name Type
esrap 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