Tech Story
As a platform engineer, I want all explicit and implicit any types replaced with proper TypeScript types so that the compiler can catch type errors at the boundaries where security-sensitive data flows (JWT payloads, request objects, auth guards).
Context
Audit found any types concentrated in auth-critical code paths:
auth.service.ts: validateUser(): Promise<any>, login(user: any)
jwt.strategy.ts: validate(payload: any)
auth.controller.ts: @Request() req: any on refresh, logout, change-password
org-inventory.controller.ts: @Request() req: any, @Query() query: Record<string, any>
base-uex.repository.ts: multiple as any casts
audit-log.entity.ts / audit-logs.service.ts: Record<string, any> on metadata columns
http-exception.filter.ts, audit-log.interceptor.ts: assorted any casts
Acceptance Criteria
Technical Elaboration
Add to auth/interfaces/:
jwt-payload.interface.ts: { sub: number; username: string; iat?: number; exp?: number }
authenticated-request.interface.ts: extends Express Request with user: { userId: number; username: string }
Enable @typescript-eslint/no-explicit-any: 'error' in ESLint config once all instances resolved.
Notes
- Each file fixed should be a separate commit for easy review
- Some TypeORM/Passport internals may require
unknown + narrowing rather than a direct type
Tech Story
As a platform engineer, I want all explicit and implicit
anytypes replaced with proper TypeScript types so that the compiler can catch type errors at the boundaries where security-sensitive data flows (JWT payloads, request objects, auth guards).Context
Audit found
anytypes concentrated in auth-critical code paths:auth.service.ts:validateUser(): Promise<any>,login(user: any)jwt.strategy.ts:validate(payload: any)auth.controller.ts:@Request() req: anyon refresh, logout, change-passwordorg-inventory.controller.ts:@Request() req: any,@Query() query: Record<string, any>base-uex.repository.ts: multipleas anycastsaudit-log.entity.ts/audit-logs.service.ts:Record<string, any>on metadata columnshttp-exception.filter.ts,audit-log.interceptor.ts: assortedanycastsAcceptance Criteria
JwtPayloadinterface defined and used inJwtStrategy.validate()andAuthService.login()AuthenticatedRequestinterface (extending ExpressRequest) used in place ofreq: anyin all controllersOrgInventoryControllerquery params typed with a proper DTO classAuditLogmetadata columns typed asRecord<string, unknown>base-uex.repository.tsas anycasts replaced with typed generics or explicit interfacespnpm typecheckpasses with zero errors@typescript-eslint/no-explicit-anyrule enabled and passingTechnical Elaboration
Add to
auth/interfaces/:jwt-payload.interface.ts:{ sub: number; username: string; iat?: number; exp?: number }authenticated-request.interface.ts: extends ExpressRequestwithuser: { userId: number; username: string }Enable
@typescript-eslint/no-explicit-any: 'error'in ESLint config once all instances resolved.Notes
unknown+ narrowing rather than a direct type