typescript
TypeScript: strict compiler, ESM, generics, unions/discriminated unions, narrowing, promise hygiene, parse-dont-cast at boundaries. Types do not validate runtime.
SKILL.mdskills/languages/typescript/SKILL.md
GitHubtypescript
Strict types at compile time, runtime parsing at boundaries — types evaporate, validation doesn't.
Activate when
- Writing, reviewing, or configuring TypeScript; type design, module, or async decisions.
Do NOT activate for
- Runtime behavior of JS (see languages/javascript); framework specifics (see frameworks/*).
Inspection
Check tsconfig strictness, module mode (ESM vs CJS), existing type patterns (unions, generics, zod schemas), and boundary casts (as, any, @ts-ignore).
Decision rules
strict: trueminimum;noUncheckedIndexedAccesswhere index safety matters; ESM for new code.- Model states as discriminated unions; narrow with guards, never with casts.
asis allowed only with a comment proving safety;anyonly at a validated boundary being parsed immediately. - Generics constrained to what call sites need; utility types over hand-rolled mappings;
unknownin, validated types out (parse, don't cast — Zod or equivalent). - Promises: no floating promises (lint it), explicit rejection paths,
Promise.allSettledwhere partial failure is real.
Procedure
- Fix the strictness baseline first (no new
any/casts without justification). - Type the domain with unions + narrowing; validate all external input at runtime.
- Remove existing casts by parsing or restructuring; each removal covered by a test.
- Verify:
tsc --noEmitclean, lint clean, noas/@ts-ignorewithout justification comments, boundary tests green.
Failure modes
aslaundering untrusted data; enums where unions fit;anycreeping through generics; floating promises; strict off "temporarily" forever.
Escalation
Version behavior questions → research/documentation-search with package.json version; monorepo layout → architecture/language-modularity.
References
- Registry:
../../research/documentation-search/references/framework-registry.yaml(typescript, zod, eslint). - Related:
../javascript/,../../tooling/type-checking/.