Skip to content

Replace unchecked as-any casts in admin, backup, search, and transactions modules #1084

Description

@nanaf6203-bit

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

  1. 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.
  2. 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.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions