Problem Statement
The Convex directory contains approximately 900+ as type assertions that bypass TypeScript's type system. This violates the project guidelines: "DO NOT use type casting. Avoid any, and unknown whenever possible."
Many of these assertions are unnecessary and can be replaced with proper type annotations following Convex best practices.
Current State
Type assertions are used in several problematic patterns:
- Better Auth Integration - Returns
any types, causing cascading assertions
- Schema fields via
as any - Accessing existing schema fields unnecessarily
- External API responses - Untyped JSON responses (RAG, IMAP)
- Metadata field access - Repeated casts for same structure
- Handler return types - Missing explicit type annotations
Proposed Solution
Replace type assertions with proper TypeScript typing:
- Create typed interfaces for Better Auth adapter responses
- Create typed interfaces for external API responses (RAG, IMAP, etc.)
- Create document metadata type definitions
- Add explicit return type annotations to Convex handlers
- Use direct property access instead of
as any casts for schema-defined fields
Affected Components
Acceptance Criteria
🤖 Generated with Claude Code
Problem Statement
The Convex directory contains approximately 900+
astype assertions that bypass TypeScript's type system. This violates the project guidelines: "DO NOT use type casting. Avoidany, andunknownwhenever possible."Many of these assertions are unnecessary and can be replaced with proper type annotations following Convex best practices.
Current State
Type assertions are used in several problematic patterns:
anytypes, causing cascading assertionsas any- Accessing existing schema fields unnecessarilyProposed Solution
Replace type assertions with proper TypeScript typing:
as anycasts for schema-defined fieldsAffected Components
convex/member.ts- Better Auth member operationsconvex/documents.ts- Document managementconvex/model/documents/transform_to_document_item.ts- Document transformationconvex/workflow/actions/rag/helpers/upload_file_direct.ts- RAG uploadconvex/workflow/actions/rag/helpers/get_document_info.ts- RAG infoconvex/workflow/actions/imap/helpers/get_imap_credentials.ts- IMAP credentialsconvex/model/conversations/transform_conversation.ts- Conversation transformationconvex/workflow_assistant_agent.ts- Workflow agentAcceptance Criteria
as anycasts removed (except where strictly necessary)npx convex dev --once)npm run build)🤖 Generated with Claude Code