| name | typescript-expert |
| description | TypeScript gotchas and decision criteria covering nullish coalescing pitfalls (|| vs ??), strict tsconfig settings (noUncheckedIndexedAccess, exactOptionalPropertyTypes), type guard patterns, discriminated unions, and as const vs enum. Use when writing TypeScript, configuring tsconfig, implementing type guards, or debugging null/undefined errors. |
| autoInvoke | false |
| priority | high |
| triggers | ["typescript","type error","tsconfig","strict mode"] |
| paths | ["**/*.ts","**/*.tsx","tsconfig.json","tsconfig.*.json"] |
| allowed-tools | Read, Grep, Glob, Edit, Write |
| user-invocable | false |
AI-consumed reference. Optimized for Claude to read during execution.
Human-readable explanation: see docs/architecture/HIERARCHICAL_PLANNING.md
or docs/getting-started/ depending on topic.
TypeScript Expert — Gotchas & Decisions
Use Context7 for TypeScript docs.
Strict Config (Always Enable)
{ "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true }
Nullish Patterns
nullish[5]{bad,good,why}:
"if (x)",if (x != null),"Empty string/0 are falsy but valid"
"x || default","x ?? default","?? only catches null/undefined not falsy"
"x!.prop",Type narrowing or optional chain,"! asserts non-null — hides bugs"
"as Type",Type guard function,"as bypasses type checker"
"any","unknown + narrowing","any disables ALL checking"
Type Guards
function isUser(x: unknown): x is User {
return typeof x === 'object' && x !== null && 'id' in x;
}
type Result<T> = { ok: true; data: T } | { ok: ; : };