TypeScript
Writes, reviews, and debugs type-safe TypeScript: type errors, narrowing, generics, tsconfig strictness, and declaration files. Use when a build hits type…
от 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
- Full
strictor you are reviewing half the code. Every flag off is a bug class the checker won't report. Greenfield:strict: trueday one plusnoUncheckedIndexedAccess(TS >=4.1). Legacy: stage flags with a ratchet (migration.md). unknownin, typed out. Data you didn't construct (network, JSON, env, storage) enters asunknownand gets validated once at the boundary (boundaries.md); past that point noanyand no re-checking.- 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.
- 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. - Every
ascarries 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. - Exhaustive by construction. Every
switchover a union ends indefault: 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. - Errors read bottom-up. The first lines of a long diagnostic are wrappers; the root cause is the deepest
Types of property ... are incompatibleline (errors.md).
Stop Using any
anyis viral both directions: it silences errors on reads AND poisons everything it's assigned to.unknownonly blocks reads until you narrow — same flexibility, none of the spreadcatch (e)isunknownunder strict since TS 4.4 (useUnknownInCatchVariables) — checke instanceof Errorbefore.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-eslintno-explicit-any+no-unsafe-*), record the baseline, fail CI when the count rises
Inference & Widening
Widening:
let x = "hello"is `string
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- _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), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…