type-only-imports
Fungsinya
Skill ini memeriksa pernyataan impor TypeScript dan menandai impor khusus tipe dengan benar. Skill ini cocok untuk developer yang menginginkan bundle lebih kecil dan lebih sedikit masalah dependensi.
Kapan dipakai
- ✓Saat file TypeScript mengimpor modul yang hanya dipakai sebagai tipe.
- ✓Saat bundle menyertakan modul yang tampaknya hanya ditarik untuk tipe.
- ✓Saat menyiapkan proyek TypeScript baru dengan aturan impor yang rapi.
Link skill
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Build TypeScript saya menarik modul besar yang hanya saya pakai untuk tipe. Bisakah Anda memperbaiki impornya?”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent menemukan impor yang hanya dipakai sebagai tipe dan mengubahnya menjadi import type. Kompiler kemudian menghapusnya saat kode dibangun.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apa fungsi import type?
Ini memberi tahu kompiler bahwa impor tersebut dihapus saat build, sehingga tidak ada modul runtime yang dimuat.
Apa itu verbatimModuleSyntax?
Itu adalah pengaturan TypeScript 5 yang menerapkan aturan ini secara otomatis, menurut skill.
Bisakah ini membantu dependensi sirkular?
Skill menyatakan dependensi sirkular yang dapat dihindari bisa dikurangi dengan memakai impor khusus tipe.
Detail
Deskripsi asli dari pembuat
Use when auditing import statements in TypeScript files, setting up a new TypeScript project, or investigating unexpected bundle inclusions from type-only dependencies.
Popularitas
- Bintang GitHub
- 75k
- Peringkat
- #3067
- Lisensi
- MIT
- Diperbarui
- 31/10/2026
Komentar
- …
Skill lain dari repositori ini
frontendchecklist
75kMemeriksa kode frontend dan halaman langsung terhadap lebih dari 380 aturan untuk aksesibilitas, kecepatan, SEO, dan keamanan, dengan alat baris perintah.
frontend-checklist-global
75kMengaudit proyek frontend terhadap seluruh 386 aturan Front-End Checklist, dan memberikan perbaikan spesifik untuk setiap masalah yang ditemukan.
404-page
75kMemeriksa bahwa halaman tidak ditemukan Anda menawarkan tautan yang membantu dan mengembalikan status 404 yang sebenarnya, untuk membantu pengunjung yang tersesat.
about-page
75kMeninjau apakah situs Anda memiliki halaman Tentang yang jelas yang menjelaskan siapa yang mengelolanya, untuk membangun kepercayaan pengunjung dan mesin pencari.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.