Skip to content

Improve Type Safety in team.ts and Remove Remaining any Usage #554

@Harxhit

Description

@Harxhit

Summary

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

Contexts

The team 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
(request as any).user = payload

Several routes currently rely on unsafe casts for authentication, request user access, and middleware execution. Existing shared Fastify/JWT type definitions should be reused where available instead of introducing duplicate definitions.

This file contains a large number of authenticated routes, making it a good candidate for consolidating authentication-related typings and removing unsafe casts throughout the module.

Tasks

  • Identify all remaining any usages in team.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 (request as any).user with proper request typing
  • Improve authentication middleware typing
  • Reuse shared authentication types instead of creating duplicates
  • Verify TypeScript passes without introducing new type errors
  • Update tests if required

Acceptance Criteria

  • No any usages remain in team.ts
  • Existing shared Fastify/JWT types are reused where applicable
  • Authenticated user access is properly typed
  • Authentication middleware uses proper Fastify types
  • Request objects no longer require unsafe casts
  • TypeScript checks pass successfully
  • Existing team functionality continues to work
  • Tests pass successfully

Area

backend

Difficulty

Good First Issue

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions