typescript-best-practices
Installation
SKILL.md
TypeScript Best Practices
Type Safety
- Enable
strict: trueintsconfig.json— never disable strict checks in production code. - Prefer
unknownoverany. Ifanyis unavoidable, add a comment explaining why and narrow it immediately. - Use
satisfiesto validate a value matches a type while preserving its narrowed literal type:
const config = {
endpoint: "/api/users",
timeout: 3000,
} satisfies Config;
- Prefer type narrowing (type guards,
inoperator,instanceof) over type assertions (as).