Skip to content

fix: keep the import attributes of an import type - #250

Merged
dummdidumm merged 3 commits into
sveltejs:mainfrom
GBra-4-669:fix/import-type-attributes
Nov 17, 2026
Merged

dummdidumm merged 3 commits into
sveltejs:mainfrom
GBra-4-669:fix/import-type-attributes

Conversation

@GBra-4-669

Copy link
Copy Markdown

Closes #231

TSImportType never visits options, so import attributes are dropped:

type B = import("pkg", { with: { "resolution-mode": "require" } }).Mode<string>;
// printed as: type B = import("pkg").Mode<string>;

That changes the meaning, not just the formatting, since resolution-mode affects which declarations TypeScript resolves.

The fix prints options inside the parens, same as the ImportExpression visitor already does. I also checked it against typescript-estree (the reporter's parser), not just oxc. The repro goes from 1 identical / 4 wrong to 5 identical / 0 wrong.

The tests use oxc-parser because acorn-typescript can't parse attributes on an import type.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Install the latest version of esrap from 1a6381b:

pnpm add https://pkg.svelte.dev/esrap/c/1a6381b547224d8200ea02fb7c26cc01ed33bfc9

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/esrap/pr/250

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1a6381b

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

@dummdidumm
dummdidumm merged commit 1712810 into sveltejs:main Nov 17, 2026
6 of 7 checks passed
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.

TSImportType drops the import attributes (options)

2 participants