TypeScript Development Guidelines
Basic Principles
- Type safety first: Avoid
any— define types explicitly - Never leave errors: Address all TypeScript errors immediately
- Strict mode: Use strict type checking whenever possible
Coding Conventions
- Prefer explicit type declarations over relying on inference
- Use
@types/*packages for third-party type definitions - Use
typeofor type guards forunknowntypes - Express optional properties with
?
Error Handling Priority
- Fix type errors on the spot
- Resolve warnings whenever possible
- If a warning must remain, document the reason in a comment
Lint / Format
- If
biome.jsonexists at project root, usebiome check - Otherwise use
eslint . --ext .ts - If neither exists, ask the user
What to Verify
- Confirm no errors with
tsc --noEmit - Check the project's lint rules before starting