Replace unchecked as-any casts in admin, backup, search, and transactions modules
Labels / Complexity: bug · Medium Complexity — Medium
Problem
Four modules carry the heaviest as any usage in the repo (verified by grep): src/admin/ (15), src/search/ (15), src/backup/ (12), and src/transactions/ (12). Each cast erases a type check at exactly the point where the code meets Prisma models, request payloads, or provider responses — the surfaces most likely to drift from their declared types. When the runtime shape changes, the cast compiles and the mismatch surfaces as a confusing runtime failure.
Why this is architecturally hard
- Each cast needs the real type. The fix is replacing
as any with the actual Prisma/generated type or a locally defined shape; for provider responses that means declaring the external contract explicitly.
- The four modules differ. Admin (service/controller types), search (query shapes), backup (status unions), and transactions (Prisma unions) each need their own type strategy; slicing per module keeps PRs reviewable.
- Some casts mask genuine union problems. Where the underlying types disagree, the fix is a type refactor, not a narrower cast — that is the design work of the issue.
Acceptance criteria
- All
as any casts in the four named modules are replaced with real types or locally declared shapes.
npx tsc --noEmit passes with strict unchanged; npm test passes with no behavior change.
- The PR description reports the repository-wide
as any count before and after.
Out of scope
as any in other modules; the @ts-nocheck migrations (#890).
Getting started
grep -rn "as any" src/admin src/search src/backup src/transactions --include=*.ts — the sites
src/types/prisma.types.ts — the Prisma-generated types to use
Commands: npx tsc --noEmit, npm test.
Good first files to read: src/backup/backup.service.ts (status unions), src/types/prisma.types.ts.
Replace unchecked as-any casts in admin, backup, search, and transactions modules
Labels / Complexity: bug · Medium Complexity — Medium
Problem
Four modules carry the heaviest
as anyusage in the repo (verified by grep):src/admin/(15),src/search/(15),src/backup/(12), andsrc/transactions/(12). Each cast erases a type check at exactly the point where the code meets Prisma models, request payloads, or provider responses — the surfaces most likely to drift from their declared types. When the runtime shape changes, the cast compiles and the mismatch surfaces as a confusing runtime failure.as anyand breaks at runtime.tsconfig.jsonstrict; these casts are the deliberate holes in it, independent of the@ts-nocheckdirectives (Remove// @ts-nocheckfrom all source files and fix underlying type errors #890).Why this is architecturally hard
as anywith the actual Prisma/generated type or a locally defined shape; for provider responses that means declaring the external contract explicitly.Acceptance criteria
as anycasts in the four named modules are replaced with real types or locally declared shapes.npx tsc --noEmitpasses withstrictunchanged;npm testpasses with no behavior change.as anycount before and after.Out of scope
as anyin other modules; the@ts-nocheckmigrations (#890).Getting started
grep -rn "as any" src/admin src/search src/backup src/transactions --include=*.ts— the sitessrc/types/prisma.types.ts— the Prisma-generated types to useCommands:
npx tsc --noEmit,npm test.Good first files to read:
src/backup/backup.service.ts(status unions),src/types/prisma.types.ts.