TypeScript/JavaScript Development Guide
Code Style
- •Use strict TypeScript (
"strict": truein tsconfig.json) - •Prefer
constoverlet, avoidvar - •Use async/await over raw Promises
- •Export types alongside functions
Common Patterns
- •Use discriminated unions for state management
- •Prefer composition over inheritance
- •Use
unknowninstead ofanywhen type is uncertain
Testing
- •Co-locate tests with source files or use
__tests__directories - •Use descriptive test names:
it('should return empty array when input is null') - •Mock external dependencies, not internal modules
Error Handling
- •Create custom error classes extending Error
- •Always include error context in messages
- •Use Result pattern for expected failures
Biome/ESLint
- •Run
biome check --apply .before committing - •Address all lint warnings, don't disable rules without justification