← ClaudeAtlas

javascript-typescriptlisted

Use this skill when TypeScript type narrowing misfires, when Promise or async/await ordering and rejection handling go wrong, or when ES6+ / JavaScript module and generics semantics are in doubt. Claim ANY language-level JS/TS question proactively — even a single snippet, even when no framework is named. Trigger on "type narrowing", "unhandled promise" or "ES6+ module".
ProjAnvil/MindForge · ★ 3 · AI & Automation · score 76
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