# Typescript

> TypeScript Coding Skill

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

---

# TypeScript Coding Skill

- Use strict, type-safe TypeScript.
- Prefer explicit types for public APIs, function parameters, and complex data structures.
- Avoid `any`; use `unknown` when the type is genuinely unknown.
- Prefer type inference for simple local variables.
- Use interfaces or type aliases consistently with existing project conventions.
- Reuse existing types instead of duplicating definitions.
- Use discriminated unions for state and variant-based logic when appropriate.
- Handle `null` and `undefined` explicitly.
- Avoid unsafe type assertions (`as`) unless necessary and justified.
- Prefer type guards over casting.
- Use generics when they improve type safety and reusability.
- Keep types simple, readable, and close to where they are used.
- Avoid over-engineering types for simple code.
- Preserve existing TypeScript configuration and project conventions.
- Run TypeScript checks, lint, tests, or build after significant changes when available.
