Skip to content

Conversation

@Enchan1207
Copy link
Contributor

summary

Modified import to Type-Only Imports explicitly.

// from
import { AppType } from '.'

// to
import type { AppType } from '.'

details

In most cases, its difference is not a problem.

conditions that cause problems

If compiler option verbatimModuleSyntax is enabled, type import must be written as follows:

// A. NG
import { AppType } from '.'

// B. OK
import type { AppType } from '.'

// C. it is also OK
import { type AppType } from '.'

However, in pattern C, server-side code may be mixed into client-side .

why this happen

It is caused by rewriting rule of TypeScript.

The statement import { type AppType } from '@/module' is rewritten into import {} from '@/module'.
It means @/module will still be imported as a value after compilation.

I created the repository (Enchan1207/hono_rpc_import_style_differences) for reproducing its behavior.

The option verbatimModuleSyntax is not enabled as default, so it might be nitpick.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

@Enchan1207

Thanks! It should only import the types. I'll merge this.

@yusukebe yusukebe merged commit 8e2c668 into honojs:main Mar 26, 2025
@Enchan1207 Enchan1207 deleted the Enchan1207-patch-1 branch March 26, 2025 07:32
codeOwlAI pushed a commit to codeOwlAI/website that referenced this pull request Jun 29, 2025
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