# Typescript

> Use when: write or review TypeScript that maximizes type safety without fighting the compiler.

- Skill: `kimtth/typescript` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kimtth/typescript`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kimtth/typescript/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: kimtth (https://skillmd.com/u/kimtth)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kimtth/typescript

---


Goal: catch errors at compile time with types that aid, not obstruct.

Use for:
- new TypeScript code or migrating from JavaScript
- reviewing type usage, strictness, and module structure
- removing `any`, casts, and unsafe escape hatches

Workflow:
1. Enable strict mode and treat its warnings as errors.
2. Type module and function boundaries; let locals infer.
3. Model data with unions and interfaces, not loose objects.
4. Narrow with type guards before using union members.
5. Replace `any` with `unknown` and narrow deliberately.
6. Verify with tsc, eslint, and tests.

Idioms:
- `satisfies` to validate without widening
- discriminated unions for variant data
- readonly and const assertions for immutability
- utility types (Pick, Omit, Partial, Record)

Rules:
- strict mode on; no implicit any
- avoid type assertions; prove the type instead
- do not export inferred wide types from APIs
- a type that lies is worse than no type

