# Vp Typescript Best Practices

> Guide TypeScript implementation, review, refactoring, error fixes, runtime validation, and type-level API design in .ts, .tsx, and .test-d.ts files.

- Skill: `vdustr/vp-typescript-best-practices` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add vdustr/vp-typescript-best-practices`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vdustr/vp-typescript-best-practices/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: VdustR (https://skillmd.com/u/vdustr)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/vdustr/vp-typescript-best-practices

---


# TypeScript Best Practices

Follow the repository's compiler settings, style, supported runtime, and public
API conventions before applying fallback preferences.

## Principles

- Prefer inference for local implementation and explicit types at meaningful
  contracts.
- Validate untrusted runtime data; a type assertion does not make data safe.
- Model valid states and exhaustive branches instead of widening types to
  suppress errors.
- Preserve literal precision with the narrowest appropriate mechanism.
- Use generics only when they express a real relationship.
- Avoid `any`, unchecked double assertions, wrapper object types, and duplicate
  source-of-truth types.
- Add type-level tests for reusable or subtle type contracts.

Read only the relevant reference for the problem:

- `references/setup.md`
- `references/code-style.md`
- `references/type-patterns.md`
- `references/union-exhaustive.md`
- `references/type-testing.md`
- `references/branded-types.md`
- `references/template-literals.md`

Verify with the repository's actual TypeScript and test configuration.

