|
@ -44,7 +44,7 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions. |
|
|
## Type Safety Enforcement |
|
|
## Type Safety Enforcement |
|
|
|
|
|
|
|
|
### Core Type Safety Rules |
|
|
### Core Type Safety Rules |
|
|
<<<<<<< HEAD |
|
|
|
|
|
- **No `any` Types**: Use explicit types or `unknown` with proper type guards |
|
|
- **No `any` Types**: Use explicit types or `unknown` with proper type guards |
|
|
- **Error Handling Uses Guards**: Implement and reuse type guards from `src/interfaces/**` |
|
|
- **Error Handling Uses Guards**: Implement and reuse type guards from `src/interfaces/**` |
|
|
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe property access |
|
|
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe property access |
|
@ -58,31 +58,6 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions. |
|
|
- **Avoid Type Assertions**: Replace `as any` with proper type guards and interfaces |
|
|
- **Avoid Type Assertions**: Replace `as any` with proper type guards and interfaces |
|
|
- **Narrow Types Properly**: Use type guards to narrow `unknown` types safely |
|
|
- **Narrow Types Properly**: Use type guards to narrow `unknown` types safely |
|
|
- **Document Type Decisions**: Explain complex type structures and their purpose |
|
|
- **Document Type Decisions**: Explain complex type structures and their purpose |
|
|
======= |
|
|
|
|
|
|
|
|
|
|
|
- **No `any` Types**: Use explicit types or `unknown` with proper type guards |
|
|
|
|
|
- **Error Handling Uses Guards**: Implement and reuse type guards from |
|
|
|
|
|
`src/interfaces/**` |
|
|
|
|
|
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe |
|
|
|
|
|
property access |
|
|
|
|
|
|
|
|
|
|
|
### Type Guard Patterns |
|
|
|
|
|
|
|
|
|
|
|
- **API Errors**: Use `isApiError(error)` guards for API error handling |
|
|
|
|
|
- **Database Errors**: Use `isDatabaseError(error)` guards for database |
|
|
|
|
|
operations |
|
|
|
|
|
- **Axios Errors**: Implement `isAxiosError(error)` guards for HTTP error |
|
|
|
|
|
handling |
|
|
|
|
|
|
|
|
|
|
|
### Implementation Guidelines |
|
|
|
|
|
|
|
|
|
|
|
- **Avoid Type Assertions**: Replace `as any` with proper type guards and |
|
|
|
|
|
interfaces |
|
|
|
|
|
- **Narrow Types Properly**: Use type guards to narrow `unknown` types |
|
|
|
|
|
safely |
|
|
|
|
|
- **Document Type Decisions**: Explain complex type structures and their |
|
|
|
|
|
purpose |
|
|
|
|
|
>>>>>>> master |
|
|
|
|
|
|
|
|
|
|
|
## Minimal Special Cases (document in PR when used) |
|
|
## Minimal Special Cases (document in PR when used) |
|
|
|
|
|
|
|
|