# Typescript Best Practice

> TypeScript best practices and patterns for writing clean, type-safe, and maintainable code. Use when implementing TypeScript code, refactoring for better type safety, or teaching TypeScript patterns.

- Skill: `xiaoland/typescript-best-practice` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add xiaoland/typescript-best-practice`
- Raw SKILL.md: https://api.skillmd.com/api/skills/xiaoland/typescript-best-practice/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: Apache-2.0
- Author: xiaoland (https://skillmd.com/u/xiaoland)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/xiaoland/typescript-best-practice

---


# TypeScript Best Practices

## When to use this skill

Use this skill when you need to:

- Implement TypeScript code following best practices
- Refactor JavaScript to TypeScript
- Improve type safety and code maintainability
- Choose between different TypeScript patterns
- Teach or explain TypeScript best practices
- Review code for TypeScript anti-patterns

## Instructions

1. **Identify the pattern**: Which best practice applies to your situation?
2. **Apply the pattern**: Follow the code examples provided
3. **Verify types**: Ensure TypeScript infers the correct types
4. **Test usage**: Confirm autocomplete and type checking work as expected

## Best Practices

- Use `as const` Instead of Enums: read at [as-const-pattern](assets/as-const-pattern.ts)

