← ClaudeAtlas

typescriptlisted

Write type-safe TypeScript that catches bugs at compile time — strict config, type narrowing, discriminated unions, generics, utility types, and avoiding the any/!-escape-hatches that silently disable the checker. Use when setting up tsconfig, modeling a domain with types, fixing "type X is not assignable", deciding unknown vs any, narrowing a union, writing a generic, or reviewing TS for type-safety holes. Underpins React/Next/React-Native/Node. Triggers — "tsconfig", "type error", "TypeScript", "any vs unknown", "generic", "discriminated union", "type narrowing", any `*.ts`/`*.tsx`. Pairs with clean-code (naming/structure), nextjs-react + react-native-mobile (the frameworks), node-backend (server TS), state-management (typed stores).
kouroshez/coding-os · ★ 6 · AI & Automation · score 77
Install: claude install-skill kouroshez/coding-os
# TypeScript TypeScript is only as safe as its strictness lets it be. With `strict` off (or `any`/`!` sprinkled in) it's JavaScript with extra syntax — the checker is on but blindfolded. The craft is letting the type system *prove* the bug can't happen, not narrating types after the fact. > Check a tsconfig for the strict flags that actually matter: > `python3 scripts/check_tsconfig.py tsconfig.json` ## Strict is the floor ```jsonc // tsconfig.json — the flags that catch real bugs { "compilerOptions": { "strict": true, // the umbrella — turn it on, always "noUncheckedIndexedAccess": true, // arr[i] is T | undefined (it really is!) "noImplicitOverride": true, "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true } } ``` `strict: true` enables `noImplicitAny`, `strictNullChecks`, and more — without it, `null`/`undefined` are assignable everywhere and the #1 class of runtime crash goes uncaught. `noUncheckedIndexedAccess` is the highest-value non-default: it makes `arr[i]` honestly `T | undefined`. Full rationale → [references/strictness.md](references/strictness.md). ## `unknown`, never `any` ```typescript // Wrong — any disables the checker for everything downstream; the bug ships function parse(json: string): any { return JSON.parse(json); } const u = parse(s); u.naem.toUpperCase(); // typo compiles, crashes at runtime // Correct — unknown forces you to narrow before use function parse(json: string):