Skip to content

refactor: use import type for type-only imports#3052

Open
bennypowers wants to merge 2 commits into
masterfrom
node24/import-type
Open

refactor: use import type for type-only imports#3052
bennypowers wants to merge 2 commits into
masterfrom
node24/import-type

Conversation

@bennypowers
Copy link
Copy Markdown
Member

@bennypowers bennypowers commented Mar 26, 2026

Summary

Add import type / export type annotations to type-only imports across 85 source files. No runtime effect.

PR 1/4 in the Node 24 migration:

  1. refactor: use import type for type-only imports #3052 -- import type annotations
  2. chore: upgrade TypeScript to 5.9.3 and enable .ts imports #3043 -- TS 5.9, nodenext, .ts imports
  3. feat!: migrate tests to node:test and require Node 24 #3049 -- node:test, ESM output, Node 24
  4. feat!: migrate parse5 to v8 and convert JSDoc packages to TypeScript #3046 -- parse5 v8, JSDoc->TS, koa 3, ws 8

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: 5f48b6c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@bennypowers
Copy link
Copy Markdown
Member Author

We should be able to ignore the test failures on node 22:

@bennypowers bennypowers marked this pull request as ready for review March 26, 2026 12:50
@bennypowers bennypowers requested a review from web-padawan March 26, 2026 12:50
Add explicit `type` annotations to all type-only imports and exports.
This is a pure TypeScript syntax change with no runtime effect -- the
compiled JavaScript output is identical. It prepares for Node 24's
type stripping, which requires `import type` for type-only imports
since they are erased at runtime.

93 files changed across dev-server, test-runner, rollup-plugin, and
storybook packages.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bennypowers bennypowers force-pushed the node24/import-type branch 3 times, most recently from 366c890 to 33a92c0 Compare May 13, 2026 19:45
Node 22.18+ enables type stripping by default, preempting ts-node
and causing __dirname to be undefined when detect-module reparses
test files as ESM. Disable native strip-types so ts-node handles
.ts files until mocha is replaced with node:test.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bennypowers bennypowers force-pushed the node24/import-type branch from 33a92c0 to 5f48b6c Compare May 14, 2026 08:25
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