Skip to content

[HIGH] Reduce widespread any type usage (176 occurrences across 55 files) #112

@NateIsern

Description

@NateIsern

Description

The codebase has 176 occurrences of any type across 55 files, undermining TypeScript's primary value of catching bugs at compile time.

Affected Files (highest counts)

  • packages/frontend/components/Feed/Feed.tsx — 12 occurrences
  • packages/frontend/components/Feed/PostItem.tsx — 8 occurrences
  • packages/frontend/services/feedService.ts — multiple
  • packages/frontend/services/socketService.ts — multiple
  • packages/backend/src/controllers/posts.controller.ts — multiple
  • packages/backend/src/controllers/feed.controller.ts — multiple
  • packages/backend/server.ts:637(global as any).io = io

Examples

// Backend - unsafe global
(global as any).io = io;

// Backend - untyped maps
const profilesMap = new Map<string, any>();

// Backend - unsafe casts
return await (feedController as any).transformPostsWithProfiles(...);

// Frontend - untyped event handlers
catch (error: any) { ... }

// Frontend - untyped API responses
const results: any = { posts: [] };

Expected Behavior

  1. Create proper TypeScript interfaces in packages/shared-types/ for:
    • API response types
    • Socket event payloads
    • Profile/User/Post shapes
  2. Replace Map<string, any> with properly typed Maps
  3. Add proper type augmentation for global.io instead of as any
  4. Use unknown instead of any for error catches and narrow appropriately
  5. Prioritize high-traffic files first (Feed.tsx, PostItem.tsx, feedService.ts)

Impact

  • Severity: High (long-term maintainability)
  • Risk: Bugs slip through compilation, harder to refactor, less IDE assistance

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High prioritycode-qualityCode quality improvementtech-debtTechnical debttype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions