javascript-typescriptlisted
Install: claude install-skill ProjAnvil/MindForge
# JavaScript & TypeScript — Language Skill
Language-first guidance: JS/TS syntax, the type system, concurrency, and idioms. Framework-specific code lives in `references/` and is linked below; keep language answers framework-neutral.
## Gotchas
Each trap is written as Symptom -> Why -> Fix. Scan these before writing any async or typed code.
### 1. `any` propagation
- Symptom: One `any` (e.g. from untyped JSON) silently strips types from everything downstream; checks and autocomplete vanish.
- Why: `any` opts out of checking and is contagious — it propagates through inference, assignments, and return types.
- Fix: Type external data as `unknown` and narrow at the boundary; keep `any` out of public signatures.
### 2. `as` assertions vs narrowing
- Symptom: `const u = data as User` compiles, then `u.name` throws because the runtime shape differs.
- Why: `as` only silences the compiler — there is no runtime check. Narrowing (`typeof`, `in`, discriminant unions, type guards) actually proves the shape; `satisfies` validates literals without widening.
- Fix: Replace assertions with a type guard or control-flow narrowing; reserve `as` for uncheckable cases such as `as const`.
### 3. Unhandled promise rejection
- Symptom: An async failure is swallowed, or the process reports an opaque unhandled rejection with no useful stack.
- Why: A rejected promise with no `catch`/`try` escapes; `await` outside try/catch rethrows into the caller chain.
- Fix: Wrap `await` in try/catch, attach