Skip to content

Improve Type Safety in cards.ts and Remove Remaining any Usage #547

@Harxhit

Description

@Harxhit

Summary

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

Contexts

The card 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
catch (error: any)

Additional type assertions and authentication-related typings may also be improved by reusing shared Fastify/JWT type definitions where available.

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

Tasks

  • Identify all remaining any usages in cards.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 error: 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 cards.ts
  • Existing shared Fastify/JWT types are reused where applicable
  • Authentication-related code uses proper Fastify types
  • Error handling avoids unsafe any usage
  • TypeScript checks pass successfully
  • Existing card 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
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions