Overview
socket/index.ts types WebSocket event data as Record<string, any>, bypassing all type checking for incoming messages. A discriminated union based on the type field would catch serialization mismatches at compile time.
Specifications
Features:
- Define a
SocketEvent discriminated union covering all event types (lesson progress, notification, etc.)
- Replace all
any usages in the socket service with the union type
Tasks:
- Audit all emitted and received event types
- Define
SocketEvent union in src/types/socket.ts
- Replace parameter types in
socket/index.ts
- Fix resulting TypeScript errors in consumers
Impacted Files:
src/services/socket/index.ts
src/types/socket.ts (new)
Acceptance Criteria
- No
any types in socket service
- All event types are compile-time verified
- No runtime errors from type mismatches
Overview
socket/index.tstypes WebSocket event data asRecord<string, any>, bypassing all type checking for incoming messages. A discriminated union based on thetypefield would catch serialization mismatches at compile time.Specifications
Features:
SocketEventdiscriminated union covering all event types (lesson progress, notification, etc.)anyusages in the socket service with the union typeTasks:
SocketEventunion insrc/types/socket.tssocket/index.tsImpacted Files:
src/services/socket/index.tssrc/types/socket.ts(new)Acceptance Criteria
anytypes in socket service