Fix TypeScript type errors and upgrade code to strict mode with proper type narrowing and generics.
Fix all TypeScript errors in this file and improve type safety:
1. Replace 'any' types with proper specific types
2. Add return type annotations to all functions
3. Use type narrowing (typeof, instanceof, in, discriminated unions) instead of type assertions
4. Replace non-null assertions (!) with proper null checks
5. Add generics where functions work with multiple types
6. Use 'as const' for literal type inference where appropriate
7. Fix strict null checks — handle undefined/null properly
8. Use Record<K,V> instead of {[key: string]: any}
9. Export types that consumers of this module need
10. Use utility types (Partial, Required, Pick, Omit) appropriately
Explain each type decision briefly in comments when the type is non-obvious.
If a type requires a new interface/type, define it in the same file or suggest where it should live.Generate optimized .cursorrules files tailored to your project's tech stack, conventions, and team preferences. Covers TypeScript, Python, Rust, Go, and more.
Leverage Cursor's Agent mode to build complete features end-to-end. Handles file creation, terminal commands, dependency installation, and multi-file edits in one flow.
Generate complete React components with TypeScript types, props interface, stories, and unit tests in one prompt.
Generate robust Next.js API routes with Zod validation, error handling, rate limiting, and TypeScript types.
Design database tables with proper types, constraints, indexes, and migration files for PostgreSQL/Supabase.
Generate FastAPI endpoints with Pydantic request/response models, dependency injection, and async database operations.