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
- Create proper TypeScript interfaces in
packages/shared-types/ for:
- API response types
- Socket event payloads
- Profile/User/Post shapes
- Replace
Map<string, any> with properly typed Maps
- Add proper type augmentation for
global.io instead of as any
- Use
unknown instead of any for error catches and narrow appropriately
- 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
Description
The codebase has 176 occurrences of
anytype 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 occurrencespackages/frontend/components/Feed/PostItem.tsx— 8 occurrencespackages/frontend/services/feedService.ts— multiplepackages/frontend/services/socketService.ts— multiplepackages/backend/src/controllers/posts.controller.ts— multiplepackages/backend/src/controllers/feed.controller.ts— multiplepackages/backend/server.ts:637—(global as any).io = ioExamples
Expected Behavior
packages/shared-types/for:Map<string, any>with properly typed Mapsglobal.ioinstead ofas anyunknowninstead ofanyfor error catches and narrow appropriatelyImpact