fix: replace as any casts in admin, backup, search, and transactions - #1172
Merged
nanaf6203-bit merged 1 commit intoSep 1, 2026
Merged
Conversation
Remove every `as any` cast in the four modules (58 sites including specs; repository-wide count drops 171 -> 113) so contract drift surfaces at compile time instead of at runtime. - admin: declare the cursor query param on the pagination DTOs and use it directly; remove the last-item index casts - backup: use the real BackupStatus/BackupTrigger/RestoreStatus enum constants instead of string literals cast to any - search: drop the prisma delegate casts (models exist on the client) and type the $queryRaw location query with its row shape - transactions: type milestone status with MilestoneStatus, add cursor to TransactionListQueryDto, use UserRole.ADMIN for @roles, and narrow the audit log status to TransactionStatus (the previous 'STATUS_TRANSITION' literal was rejected by the DB enum at runtime) - specs: type prisma/service mocks with interfaces or Partial mocks instead of casting literals to any
|
@shadrackmanfred Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
nanaf6203-bit
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces every
as anycast in the four modules named in the issue (admin,backup,search,transactions) with real Prisma types, declared DTOs, or locally defined shapes, so contract drift fails compilation instead of exploding at runtime.as anycount before/after:src/)What changed, by module
cursorwas being read off the query DTOs via(query as any).cursor. The three pagination DTOs (AdminUsersQueryDto,ModerationQueueQueryDto,TransactionMonitoringQueryDto) now declarecursor?: string(validated), and the service readsquery.cursordirectly. Theitems[items.length - 1]casts were unnecessary and are removed.'RUNNING' as anyreplaced with the real Prisma enum constants (BackupStatus.RUNNING,RestoreStatus.RUNNING/COMPLETED/FAILED,BackupTrigger.MANUAL/SCHEDULED). Runtime values are identical (string enums).(this.prisma as any).access onproperty/searchHistory/popularSearch/$queryRawremoved (all delegates exist on the generated client, verified innode_modules/.prisma/client). The$queryRawlocation query is now typed with its declared row shape (Array<{ city; state; zip_code }>) instead of returningunknown.transaction-reminders:MilestoneStatus.PENDINGinstead of'PENDING' as any; the where-object cast removed;prefs?.optOutReminders(the field exists onUserPreferences) instead of(prefs as any)?.optOutReminders.transactions.service:cursoradded toTransactionListQueryDto; the(query as any).cursorread is nowquery.cursor.disputes.controller:@Roles(UserRole.ADMIN)instead of@Roles('ADMIN' as any).transaction-audit.service: thestatuscolumn is aTransactionStatusenum, butlog()accepted an arbitrarystringand cast it. The parameter is now typedTransactionStatusand the caller passes the transitioned-to status. Note: the old'STATUS_TRANSITION'literal was not a valid enum member, so Prisma would reject that row at runtime — this refactor also fixes that latent failure.MockPrisma-style interfaces orjest.Mocked<Partial<…>>; the six} as anyobject casts insearch.service.spec.ts, two inbackup.service.spec.ts, and five string/enum casts intransactions.service.spec.tsare gone.Verification
npx tsc --noEmit— no new errors vsmain(the 2 baseline errors in untouched files remain)npm test— 96 tests acrosssrc/admin,src/backup,src/search,src/transactions,test/admin,test/backup,test/transactionsall passCloses #1084