Repository navigation
Closed
Labels
priority: mediumMedium priority
Description
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
anytypes, 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 anycasts for schema-defined fields
Affected Components
-
convex/member.ts- Better Auth member operations -
convex/documents.ts- Document management -
convex/model/documents/transform_to_document_item.ts- Document transformation -
convex/workflow/actions/rag/helpers/upload_file_direct.ts- RAG upload -
convex/workflow/actions/rag/helpers/get_document_info.ts- RAG info -
convex/workflow/actions/imap/helpers/get_imap_credentials.ts- IMAP credentials -
convex/model/conversations/transform_conversation.ts- Conversation transformation -
convex/workflow_assistant_agent.ts- Workflow agent - ~40-50 other Convex files
Acceptance Criteria
- All
as anycasts removed (except where strictly necessary) - Better Auth response types defined and used
- RAG API response types defined and used
- Document metadata types defined and used
- All Convex handlers have explicit return type annotations
- TypeScript compiles without errors (
npx convex dev --once) - Build succeeds (
npm run build)
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
priority: mediumMedium priority
Activity
larryro commentedon Jan 6, 2026
Implementation Plan
Phase 1: Create Type Definitions
1.1 Better Auth Types (
convex/model/members/types.ts)1.2 Document Metadata Types (
convex/model/documents/types.ts)1.3 RAG API Response Types (
convex/workflow/actions/rag/helpers/types.ts)Phase 2: Fix High Priority Files
(m: any)with typedBetterAuthMemberinterfaceas any, use direct property access forragInfoRagUploadResponseinterface for API responseRagDocumentInfointerfacePhase 3: Fix Medium Priority Files
Work through remaining files systematically:
ascasts with proper typingFiles to Modify (Grouped by Domain)
member.tsdocuments.ts,transform_to_document_item.tswf_definitions.ts,workflow_assistant_agent.tsupload_file_direct.ts,get_document_info.tsget_imap_credentials.ts,email_provider_action.tstransform_conversation.ts,streaming.tsproduct_action.ts,onedrive_action.tspptx_tool.ts,generate_agent_response.tsauth.tsPhase 4: Validation
npx convex dev --onceafter each group (Convex type generation + validation)npm run typecheckfor full TypeScript validationnpm run buildfor production build verificationPotential Risks
?to handle variationsTesting Strategy
🤖 Generated with Claude Code