TypeScript Development
When to Use
- •Writing new TypeScript code (modules, functions, types, public API).
- •Adding or changing types, interfaces, or type utilities.
- •Designing or evolving public APIs and module boundaries.
- •Adding dependencies and updating package.json or tsconfig.
Principles
- •Types: Prefer strict TypeScript; avoid
any. Use explicit types for public APIs and boundaries. Useunknownwhen the type is truly unknown; narrow with type guards. - •Modules: Use ES modules (
import/export). Prefer destructuring for named imports:import { foo } from 'bar'. - •Style: Follow the project's TypeScript style and idiom rules (CLAUDE.md or
.cursor/rules/.mdc files). Use camelCase for variables and functions; PascalCase for types and classes. - •Layout: Keep functions and modules focused; prefer small, testable units. Place tests per project convention (
*.test.ts,__tests__/, ortest/).
Verification
- •
npm run typecheckornpx tsc --noEmit. - •
npm test(or project test command). - •
npm run lintwhen available (fix or allow with justification). - •
npm run formator Biome (or rely on the format hook).