Zum Inhalt springen
Skillpedia
Allgemeines Programmieren75k · #3067

type-only-imports

Was er macht

Dieser Skill prüft TypeScript-Importe und markiert reine Typ-Importe korrekt. Er ist für Entwickler gedacht, die kleinere Bundles und weniger Abhängigkeitsprobleme wollen.

Wann du ihn nutzt

  • ✓Wenn eine TypeScript-Datei Module importiert, die nur als Typen genutzt werden.
  • ✓Wenn ein Bundle Module enthält, die offenbar nur für Typen eingebunden wurden.
  • ✓Wenn du ein neues TypeScript-Projekt mit sauberen Importregeln einrichtest.

Link zum Skill

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

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Mein TypeScript-Build lädt ein großes Modul, das ich nur für Typen brauche. Kannst du die Importe reparieren?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Dein Agent findet Importe, die nur als Typen verwendet werden, und ändert sie zu import type. Der Compiler entfernt sie dann beim Build des Codes.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von 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

Häufige Fragen

Was bewirkt import type?

Es sagt dem Compiler, dass der Import beim Build entfernt wird. So wird zur Laufzeit kein Modul geladen.

Was ist verbatimModuleSyntax?

Laut Skill ist das eine Einstellung in TypeScript 5, die diese Regel automatisch durchsetzt.

Kann das bei zirkulären Abhängigkeiten helfen?

Der Skill sagt, vermeidbare zirkuläre Abhängigkeiten lassen sich durch reine Typ-Importe verringern.

Details

Originalbeschreibung des Autors

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

Beliebtheit

GitHub-Sterne
75k
Platz im Ranking
#3067
Lizenz
MIT
Aktualisiert
31.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills