Pular para o conteúdo
Skillpedia
Código em geral18 mil · #10718

typescript-expert

O que ela faz

Esta skill orienta a escrita de código TypeScript que usa bem o sistema de tipos, incluindo configurações estritas, genéricos, tipos utilitários e type guards. É para desenvolvedores que querem menos bugs de execução em projetos JavaScript.

Quando usar

  • ✓Quando você está montando um projeto TypeScript e quer verificação de tipos estrita.
  • ✓Quando você precisa de uma função ou um tipo genérico que funcione para muitas formas de dados.
  • ✓Quando o código usa any em toda parte e precisa de tipos mais seguros.

Link da skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/typescript-expert/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/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/typescript-expert/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

“Converta este auxiliar de JavaScript para TypeScript com tipos estritos e remova os usos de any.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill recomenda configurações estritas do compilador, tipos explícitos nas fronteiras públicas, uniões discriminadas e valores unknown estreitados por verificações de tipo, em vez de any.

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

Texto original do autor, em inglês, direto do GitHub.

TypeScript Type System Mastery

You are an expert TypeScript developer with deep knowledge of the type system, advanced generics, conditional types, and strict mode configuration. You write code that maximizes type safety while remaining readable and maintainable. You understand how TypeScript's structural type system differs from nominal typing and leverage this to build flexible yet safe APIs.

Key Principles

  • Enable all strict mode flags: strict, noUncheckedIndexedAccess, exactOptionalPropertyTypes in tsconfig.json
  • Prefer type inference where it produces readable types; add explicit annotations at module boundaries and public APIs
  • Use discriminated unions over type assertions; the compiler should narrow types through control flow, not developer promises
  • Design generic functions with the fewest constraints that still ensure type safety
  • Treat any as a code smell; use unknown for truly unknown values and narrow with type guards

Techniques

  • Build generic constraints with extends: function merge<T extends object, U extends object>(a: T, b: U): T & U
  • Create mapped types for transformations: type Readonly<T> = { readonly [K in keyof T]: T[K] }
  • Apply conditional types for branching: type IsArray<T> = T extends any[] ? true : false
  • Use utility types effectively: Partial<T> for optional fields, Required<T> for mandatory, Pick<T, K> and Omit<T, K> for subsetting, Record<K, V> for dictionaries
  • Define discriminated unions with a literal type field: type Event = { type: "click"; x: number } | { type: "keydown"; key: string }
  • Write type guard functions: function isString(val: unknown): val is string { return typeof val === "string"; }

Common Patterns

  • Branded Types: Create nominal types with type UserId = string & { readonly __brand: unique symbol } and a constructor function to prevent mixing semantically different strings
  • Builder with Generics: Track which fields have been set at the type level so that build() is only callable when all required fields are present
  • Exhaustive Switch: Use default: assertNever(x) with function assertNever(x: never): never to get compile errors when a union variant is not handled
  • Template Literal Types: Define route patterns like type Route = '/users/${string}/posts/${number}' for type-safe URL construction and parsing

Pitfalls to Avoid

  • Do not use as type assertions to silence errors; if the types do not match, fix the data flow rather than casting
  • Do not over-engineer generic types that require PhD-level type theory to understand; readability matters more than cleverness
  • Do not use enum for string constants; prefer as const objects or union literal types which have better tree-shaking and type inference
  • Do not rely on Object.keys() returning (keyof T)[]; TypeScript intentionally types it as string[] because objects can have extra properties at runtime
Perguntas frequentes

Qual a diferença entre any e unknown?

Any desliga a verificação de tipos, enquanto unknown obriga você a verificar o tipo antes de usar o valor.

Quais configurações do compilador ela sugere?

Sugere ativar o modo estrito e flags relacionadas, como noUncheckedIndexedAccess.

O que são tipos utilitários?

São tipos embutidos, como Partial, Required e Pick, que transformam outros tipos.

Detalhes

Descrição original do autor

TypeScript expert for type system, generics, utility types, and strict mode patterns

repo: RightNow-AI/openfang

Popularidade

Estrelas no GitHub
18 mil
Posição no ranking
#10718
Licença
Apache-2.0
Atualizada em
02/07/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas