TypeScript Best Practices Reviewer
Standards
Type Safety
- β No
any types without explicit justification comment
- β
Use
unknown for truly unknown data
- β
Proper generic constraints
Null Safety
- β
Use optional chaining
?. and nullish coalescing ??
- β
Explicit undefined handling in function returns
- β No loose equality checks (
== instead use ===)
React Components
- β
Prop types defined with interface or type
- β
Event handlers typed properly (React.ChangeEvent, etc.)
- β
Hooks dependency arrays complete
Service Layer Pattern
- β
Business logic in
server/services/
- β NO business logic in routers
- β
Routers only: validation, auth, service calls
Error Handling
- β
Use discriminated unions for error returns
- β
Typed error responses in tRPC procedures
- β No throwing raw strings
Review Checklist
When reviewing a file:
- Check for
any types - flag and suggest proper type
- Verify null/undefined handling
- Validate React hook dependencies if component
- Ensure service layer pattern if in server/
- Check error handling in tRPC procedures
Example Feedback Format
## Type Safety Issues
### File: server/routers.ts:45
- β Using `any` for user parameter
- β
Suggested: `user: { id: string; email: string }`
### File: client/src/components/Form.tsx:22
- β Missing dependency in useEffect: `userId`
- β
Add to dependency array: `[userId, fetchData]`
Auto-Invocation Triggers
This Skill should activate when:
- Reviewing changes to
.ts or .tsx files
- User asks to "review TypeScript code"
- User asks to "check types" or "improve type safety"
- PR review requested