Command Palette

Search for a command to run...

Назад к скиллам
скилл № 68326

TypeScript

Writes, reviews, and debugs type-safe TypeScript: type errors, narrowing, generics, tsconfig strictness, and declaration files. Use when a build hits type…

БесплатноБез исполняемых скриптов
clawicот clawic★ 23 звезды на GitHub

Установить TypeScript в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

User preferences and memory live in ~/Clawic/data/typescript/ (see setup.md on first use, memory-template.md for the file format). If you have data at an old location (~/typescript/ or ~/clawic/typescript/), move it to ~/Clawic/data/typescript/, and say in one line that you moved it and from where.

When To Use

  • Decoding type errors: "not assignable" walls, narrowing failures, inference surprises, errors that appear only in CI
  • Designing types for an API surface: generics, discriminated unions, utility types, branded types
  • tsconfig decisions: strict flags, module resolution, target/lib, monorepo project references, JS-to-TS migration order
  • Writing or fixing declaration files (.d.ts, module augmentation, publishing types)
  • Code that compiles green but fails at runtime — ESM/CJS interop crashes, unvalidated external data — or tsc/editor slowness
  • Not for runtime JavaScript semantics (closures, event loop, coercion) — that is the javascript skill

Quick Reference

Situation Play
Value of unknown shape (API, JSON.parse, catch) unknown + narrow before use; never any
Config/lookup object losing literal types satisfies (TS >=4.9), not a type annotation
Union variant not narrowing Add a literal discriminant field + exhaustive never check
40-line "not assignable" error Read the deepest Types of property ... are incompatible line first — root cause is at the bottom; full decoder → errors.md
Cryptic diagnostic (TS2589, TS2742, "no overload matches"), error only in CI errors.md
Generic won't infer / variance confusion / overload design generics.md
Partial/Omit/Record behaving oddly utility-types.md
Untyped npm package, globals, augmentation, publishing types declarations.md
JS conversion, strict-flag rollout, as debt, TS version upgrade migration.md
target/module/paths choices, monorepo, project references tsconfig.md
Green compile, runtime crash (x is not a function, ERR_REQUIRE_ESM) modules.md
External data crossing a trust boundary Validate at runtime at the boundary; static types only downstream → boundaries.md
tsc slow, editor lag, compiler out of memory performance.md
Anything else typed Default: full strict, infer locals, annotate exports

Depth on demand: errors.md diagnostic decoding · generics.md inference, variance, conditional types, overloads · utility-types.md built-in type traps · declarations.md .d.ts, augmentation, publishing · migration.md JS-to-TS, strictness ratchets, TS upgrades · tsconfig.md compiler configuration · modules.md ESM/CJS interop · boundaries.md runtime validation · performance.md compile and editor speed.

Core Rules

  1. Full strict or you are reviewing half the code. Every flag off is a bug class the checker won't report. Greenfield: strict: true day one plus noUncheckedIndexedAccess (TS >=4.1). Legacy: stage flags with a ratchet (migration.md).
  2. unknown in, typed out. Data you didn't construct (network, JSON, env, storage) enters as unknown and gets validated once at the boundary (boundaries.md); past that point no any and no re-checking.
  3. Annotate exports, infer locals. Annotated parameters and return on every exported function put errors at the boundary that caused them, not at 30 call sites downstream; inference inside bodies keeps the noise down.
  4. Make illegal states unrepresentable. n independent optional fields admit 2^n combinations: { data?: T; error?: E } is 4 states of which 2 are illegal. A discriminated union with one variant per legal state encodes exactly the truth.
  5. Every as carries a proof. A cast overrides the checker — attach the runtime guard that makes it true, or a one-line comment saying why it cannot be wrong. An unexplained cast is a deferred bug report.
  6. Exhaustive by construction. Every switch over a union ends in default: x satisfies never (TS >=4.9) — adding a variant then becomes a compile error at every site that must handle it, which is the entire point of the union.
  7. Errors read bottom-up. The first lines of a long diagnostic are wrappers; the root cause is the deepest Types of property ... are incompatible line (errors.md).

Stop Using any

  • any is viral both directions: it silences errors on reads AND poisons everything it's assigned to. unknown only blocks reads until you narrow — same flexibility, none of the spread
  • catch (e) is unknown under strict since TS 4.4 (useUnknownInCatchVariables) — check e instanceof Error before .message
  • Every remaining cast (as) gets either a runtime guard above it or a one-line comment saying why it's safe (rule 5)
  • Ratchet, don't boil the ocean: count anys (typescript-eslint no-explicit-any + no-unsafe-*), record the baseline, fail CI when the count rises

Inference & Widening

Widening:

  • let x = "hello" is `string
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • _meta.json
  • boundaries.md
  • declarations.md
  • errors.md
  • generics.md
  • memory-template.md
  • migration.md
  • modules.md
  • performance.md
  • setup.md
  • tsconfig.md
  • utility-types.md

FAQ

Что делает скилл TypeScript?

Writes, reviews, and debugs type-safe TypeScript: type errors, narrowing, generics, tsconfig strictness, and declaration files. Use when a build hits type errors ("not assignable", "possibly undefined", "excessively deep", "cannot find module"), when eliminating any or unchecked as casts, designing generics or discriminated unions, writing .d.ts files or typing untyped npm packages, configuring tsconfig or module resolution, fixing ESM/CJS import crashes ("ERR_REQUIRE_ESM", "x is not a function"), validating API or JSON data at runtime, migrating JavaScript to TypeScript or upgrading the TypeScript version, or when tsc or the editor gets slow or runs out of memory.

Как установить скилл TypeScript?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл TypeScript запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить TypeScript с