Skip to content

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

Closed

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

  1. divysam commented on Aug 26, 2026

    @divysam

    @divysam has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hello
    I would love to work on this issue please

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @divysam to this issue.

  2. shadrackmanfred commented on Aug 26, 2026

    @shadrackmanfred
    Contributor

    @shadrackmanfred has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi Maintainer! I'm a senior developer with experience building high-quality, production-ready software. I'd love to take on this issue and deliver a clean, well-tested solution that aligns with the project's standards. Please assign it to me—I'm ready to get started and contribute effectively.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @shadrackmanfred to this issue.

  3. drips-wave commented on Aug 26, 2026

    @drips-wave

    Congratulations, @shadrackmanfred! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @shadrackmanfred: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  4. shadrackmanfred commented on Aug 28, 2026

    @shadrackmanfred
    Contributor

    Resolved on branch fix/type-safety-and-admin-tests (commit 1f932bf): all 56 as any casts across src/admin, src/search, src/backup, src/transactions replaced with real Prisma/enum/DTO types (56 → 0). Verified: tsc --noEmit clean, 71 suites / 515 unit tests pass.

  5. shadrackmanfred commented on Sep 1, 2026

    @shadrackmanfred
    Contributor

    Addressed by #1172.

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