--- name: TypeScript Strict description: Enforce strict TypeScript patterns and conventions for all TS/TSX files. paths: src/**/*.ts, src/**/*.tsx tags: typescript, conventions author: Alejandro Martinez author-email: amartinez2@certinia.com --- # TypeScript Strict Rules When working with TypeScript files, always follow these conventions: ## Type Safety - Never use `any` — prefer `unknown` with type narrowing - Always define return types for exported functions - Use `readonly` for arrays and objects that shouldn't be mutated - Prefer `interface` over `type` for object shapes (except unions/intersections) ## Imports - Use named imports, not default imports - Group imports: external libs, then internal modules, then relative paths - No circular dependencies ## Naming - `camelCase` for variables and functions - `PascalCase` for types, interfaces, and classes - `SCREAMING_SNAKE_CASE` for constants - Prefix boolean variables with `is`, `has`, `should`, `can` ## Error Handling - Never swallow errors silently (empty catch blocks) - Use custom error classes for domain errors - Always type error parameters in catch blocks