-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't workingrefactorCode refactoring and technical debtCode refactoring and technical debt
Description
Problem
Multiple files use as any type casts to bypass TypeScript's type checking, defeating the purpose of strict mode enabled in the project.
Files affected:
actions/maintenance.ts:75, 108-criteria: validated.criteria as anylib/maintenance/scanner.ts:230-const criteria = rule.criteria as anylib/maintenance/rule-evaluator.ts:219-return (item as any)[fieldKey]
Root cause: Prisma's JSON type doesn't recognize Zod's validated types, leading developers to use as any as a workaround.
Impact
- Type safety violations could cause runtime errors
- Defeats TypeScript strict mode guarantees
- Could access undefined properties without compile-time warnings
- Makes refactoring more dangerous
Solution
Replace as any casts with proper type assertions:
For Prisma JSON fields
// ❌ Wrong
criteria: validated.criteria as any
// ✅ Correct
criteria: validated.criteria as Prisma.JsonValueFor dynamic property access
// ❌ Wrong
return (item as any)[fieldKey]
// ✅ Correct
return (item as Record<string, unknown>)[fieldKey]Files to Fix
actions/maintenance.ts- Lines 75, 108lib/maintenance/scanner.ts- Line 230lib/maintenance/rule-evaluator.ts- Line 219
Acceptance Criteria
- All
as anycasts replaced with proper types - TypeScript compilation passes with no errors
- All existing tests still pass
- No new type errors introduced
Reference
- CLAUDE.md: TypeScript strict mode enabled with all checks
- Project uses TypeScript strict mode:
noUnusedLocals,noUnusedParameters,noImplicitReturns
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingrefactorCode refactoring and technical debtCode refactoring and technical debt