Saltar al contenido
Skillpedia
Programación general75 mil · #3067

type-only-imports

Qué hace

Esta skill revisa las sentencias import de TypeScript y marca correctamente los imports que son solo de tipos. Es para desarrolladores que quieren paquetes más pequeños y menos problemas de dependencias.

Cuándo usarla

  • ✓Cuando un archivo de TypeScript importa módulos que solo se usan como tipos.
  • ✓Cuando un paquete incluye módulos que parecen añadidos solo por los tipos.
  • ✓Cuando se configura un proyecto nuevo de TypeScript con reglas de import limpias.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Mi compilación de TypeScript incluye un módulo grande que solo uso para tipos. ¿Puedes arreglar los imports?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente encuentra los imports que se usan solo como tipos y los cambia a import type. Después el compilador los elimina al compilar el código.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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

Preguntas frecuentes

¿Qué hace import type?

Indica al compilador que el import se borra al compilar, así que no se carga ningún módulo en tiempo de ejecución.

¿Qué es verbatimModuleSyntax?

Según la skill, es una opción de TypeScript 5 que aplica esta regla de forma automática.

¿Esto ayuda con las dependencias circulares?

La skill dice que las dependencias circulares evitables pueden reducirse usando imports solo de tipos.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
75 mil
Posición en el ranking
#3067
Licencia
MIT
Actualizada
31/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas