Pular para o conteúdo
Skillpedia
Código em geral75 mil · #3067

type-only-imports

O que ela faz

Esta skill verifica os imports do TypeScript e marca corretamente os que servem apenas para tipos. É para desenvolvedores que querem pacotes menores e menos problemas de dependência.

Quando usar

  • ✓Quando um arquivo TypeScript importa módulos usados apenas como tipos.
  • ✓Quando um bundle inclui módulos que parecem estar lá só por causa de tipos.
  • ✓Quando você está montando um projeto TypeScript novo com regras de import limpas.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-only-imports/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Meu build do TypeScript está trazendo um módulo grande que eu uso só para tipos. Você pode corrigir os imports?”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente encontra imports usados só como tipos e os troca por import type. Depois, o compilador os remove quando o código é construído.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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

Perguntas frequentes

O que faz o import type?

Ele diz ao compilador que o import é apagado na hora do build, então nenhum módulo é carregado em tempo de execução.

O que é verbatimModuleSyntax?

É uma configuração do TypeScript 5 que aplica essa regra automaticamente, segundo a skill.

Isso pode ajudar com dependências circulares?

A skill diz que dependências circulares evitáveis podem ser reduzidas usando imports apenas de tipos.

Detalhes

Descrição original do 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

Popularidade

Estrelas no GitHub
75 mil
Posição no ranking
#3067
Licença
MIT
Atualizada em
31/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas