prefer-type-annotations
Installation
SKILL.md
Prefer Type Annotations to Type Assertions
Overview
Type annotations (: Type) verify that values conform to types. Type assertions (as Type) tell TypeScript to trust you.
Annotations check your work. Assertions bypass checks. When you have a choice, prefer annotations.
When to Use This Skill
- Assigning values to variables
- Defining function return types
- Working with object literals
- Tempted to use
as Typeto fix errors - Getting "not assignable" errors