Apply these rules when migrating files from JavaScript to TypeScript
- Do not introduce unrelated logic changes while adding types
- Favor type safety over convenience (
anyis a last resort) - Use existing project patterns and types when available
- Prefer inference when it is clear and sufficient
- Use existing types/interfaces from the codebase
- Define minimal types/interfaces when needed
- Use
unknownoveranywhen type is unclear - Use
anyonly as a temporary fallback - Organize types in dedicated files (
types.ts) or alongside implementations - Create a central
types.tsfile or asrc/typesdirectory for shared types
- Type props explicitly using
typeorinterface - Use typed hooks (
useAppDispatch,useAppSelector) instead of raw Redux hooks - Type event handlers (
React.ChangeEvent, etc.)
- Avoid initializing empty arrays/objects without types (
useState<Type[]>([])) - Prevent
never[]by explicitly typing initial state - Use union types for nullable/optional values (
string | null)
- Type all API requests and responses
- If API request/response types are unclear, ask for the API spec instead of guessing