Title
Replace Remaining any Types in auth.ts with Proper TypeScript Types.
Summary
Remove remaining usages of any in the authentication module and replace them with proper TypeScript interfaces, Fastify types, and request/user type definitions to improve type safety and maintainability.
Contexts
The authentication system still contains several any usages that bypass TypeScript's type checking. While the current implementation works, these areas can hide bugs and make refactoring more difficult.
Examples include:
request: any
reply: any
(request.user as any).id
(request.user as any)?.id
These should be replaced with proper interfaces and type declarations.
Tasks
Acceptance Criteria
Suggested Implementation
Create a dedicated JWT payload interface:
interface AuthenticatedUser {
id: string;
username: string;
}
Extend Fastify request typings:
declare module 'fastify' {
interface FastifyRequest {
user: AuthenticatedUser;
}
}
Replace:
with:
Replace:
with:
request: FastifyRequest
reply: FastifyReply
Area
backend
Difficulty
Medium
Title
Replace Remaining
anyTypes in auth.ts with Proper TypeScript Types.Summary
Remove remaining usages of
anyin the authentication module and replace them with proper TypeScript interfaces, Fastify types, and request/user type definitions to improve type safety and maintainability.Contexts
The authentication system still contains several
anyusages that bypass TypeScript's type checking. While the current implementation works, these areas can hide bugs and make refactoring more difficult.Examples include:
These should be replaced with proper interfaces and type declarations.
Tasks
anyusages in the auth.ts.request: anywith proper Fastify request typesreply: anywith proper Fastify reply typesrequest.user(request.user as any)Acceptance Criteria
anytypes remain in the auth.ts file.request.useris properly typed through Fastify type augmentationanySuggested Implementation
Create a dedicated JWT payload interface:
Extend Fastify request typings:
Replace:
with:
Replace:
with:
Area
backendDifficulty
Medium