Skip to content

[TypeScript] socket/index.ts uses Record<string, any> for event data — replace with discriminated union #799

Description

@RUKAYAT-CODER

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

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions