Skip to content

Improve Type Safety in profiles.ts and Remove Remaining any Usage #552

@Harxhit

Description

@Harxhit

Summary

Improve type safety in profiles.ts by removing remaining usages of any and replacing them with proper Fastify, TypeScript, Prisma, and application-specific types.

Contexts

The profile routes currently contain several usages of any that bypass TypeScript's type checking and reduce maintainability.

Examples include:

const server = request.server as any;
(app as any).authenticate
(request.user as any).id
catch (err: any)

Some of these usages are related to authentication, Fastify route handlers, Prisma errors, and shared request/user typings. Existing shared Fastify/JWT type definitions should be reused where available instead of introducing duplicate definitions.

Removing these usages will improve maintainability, reduce unsafe casts, and make future refactoring easier.

Tasks

  • Identify all remaining any usages in profiles.ts
  • Use existing Fastify/JWT type definitions where available
  • Replace server as any with appropriate Fastify types
  • Replace app as any with appropriate Fastify types
  • Replace request.user as any with properly typed user access
  • Replace err: any with safer error handling patterns
  • Improve authentication-related typing where applicable
  • Verify TypeScript passes without introducing new type errors
  • Update tests if required

Acceptance Criteria

  • No any usages remain in profiles.ts
  • Existing shared Fastify/JWT types are reused where applicable
  • Authenticated user access is properly typed
  • Authentication-related code uses proper Fastify types
  • Error handling avoids unsafe any usage
  • TypeScript checks pass successfully
  • Existing profile functionality continues to work
  • Tests pass successfully

Area

backend

Difficulty

Good First Issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions