← ClaudeAtlas

typescript-patternslisted

TypeScript type system patterns — strict mode, generics, discriminated unions, branded types, inference, utility types.
jjackkun/claude-harness-hermes · ★ 1 · AI & Automation · score 74
Install: claude install-skill jjackkun/claude-harness-hermes
# TypeScript Patterns Type-system-first TypeScript. Assume `strict: true`. Runtime patterns live in `node-patterns`; UI patterns live in `frontend-patterns` / `svelte-patterns`. ## When to Activate - Designing types, interfaces, or type-level APIs - Writing generic functions / classes - Modeling domain data with discriminated unions - Debugging type errors or fighting inference - Configuring `tsconfig.json` ## tsconfig Baseline ```jsonc { "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "Bundler", // or "NodeNext" for Node libraries "strict": true, "noUncheckedIndexedAccess": true, // arr[i] is T | undefined "noImplicitOverride": true, "exactOptionalPropertyTypes": true, "verbatimModuleSyntax": true, "skipLibCheck": true, "esModuleInterop": true, "resolveJsonModule": true, "isolatedModules": true } } ``` **`noUncheckedIndexedAccess` is the single biggest correctness win** — forces you to handle undefined on array/object lookups. ## `type` vs `interface` - **`type`** for unions, intersections, mapped types, conditional types, tuples, primitives. - **`interface`** for object shapes that might be extended or declaration-merged (React props, API contracts). - When in doubt, `type`. Interfaces are mostly legacy affordance. ## Discriminated Unions The single most important domain-modeling tool. ```ts type Result<T, E = Error> = | { ok: true; value: T } | { ok: false; error: E }; f