本文へスキップ
Skillpedia
一般的なプログラミング75k · #3067

type-only-imports

できること

このスキルは TypeScript のインポート文を確認し、型だけに使うインポートを正しく印を付けます。バンドルを小さくし、依存関係の問題を減らしたい開発者向けです。

使う場面

  • ✓型としてだけ使うモジュールを、TypeScript ファイルがインポートしているとき。
  • ✓型のためだけに読み込まれている大きなモジュールがバンドルに含まれているとき。
  • ✓クリーンなインポートのルールで新しい TypeScript プロジェクトを設定するとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“TypeScript のビルドで、型にしか使わない大きなモジュールが読み込まれています。インポートを直してもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、型としてだけ使われているインポートを見つけ、import type に変更します。ビルド時にコンパイラがそれらを取り除きます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Use import type for type-only imports

Regular imports cause the JavaScript runtime to evaluate and execute the imported module even when only a TypeScript type from that module is used. This can increase bundle size, introduce unintended side effects, and create circular dependency issues that are otherwise avoidable. Using import type makes the erased-at-runtime nature of type imports explicit and enables bundlers and the TypeScript compiler to handle them optimally.

Quick Reference

  • import type is erased entirely at compile time — no runtime module evaluation
  • Prevents accidentally importing a value when only a type is needed
  • Reduces circular dependency issues caused by type-only relationships
  • verbatimModuleSyntax in TypeScript 5 enforces this automatically

Check

Review the import statements in this TypeScript file and identify any imports where only types or interfaces are used. These should use import type instead of a regular import.

Fix

Convert the identified regular imports to import type where the imported binding is only used as a TypeScript type annotation and not as a runtime value.

Explain

Explain the difference between import and import type in TypeScript, why type-only imports should be declared explicitly, and how verbatimModuleSyntax enforces this at the compiler level.

Code Review

Inspect all import statements in this file. For each import, check whether the imported name appears only in type positions (annotations, generics, implements clauses) versus runtime positions (function calls, new, typeof). Flag any regular import that is used only as a type.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/type-only-imports

よくある質問

import type は何をしますか?

そのインポートがビルド時に消されることをコンパイラに伝え、実行時のモジュールが読み込まれないようにします。

verbatimModuleSyntax とは何ですか?

このスキルによると、この規則を自動的に強制する TypeScript 5 の設定です。

循環依存を減らせますか?

避けられる循環依存は、型専用のインポートを使うことで減らせるとこのスキルは説明しています。

詳細

作者による元の説明

Use when auditing import statements in TypeScript files, setting up a new TypeScript project, or investigating unexpected bundle inclusions from type-only dependencies.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#3067
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル