houserules/packages/chess/src/net
Joey Yakimowich-Payne a39b9921c6
refactor(net): type listener table as mapped type, drop double-casts
The listener map was typed as Map<GameClientEventType, AnyListener[]>, which
erased the per-type Listener<T> relationship and forced `as unknown as
AnyListener` double-casts at every on()/off()/emit() site.

Replace with a mapped-type record `{ [T in GameClientEventType]?: Listener<T>[] }`.
TS index lookup preserves the per-key relationship, so:

- off() has no cast
- emit() becomes generic over T and dispatches without casts
- on() retains a single scoped `Record<T, …>` projection at the write site
  (TS can't prove writes to a mapped-type index are safe under a generic T;
  this is a known limitation and the smallest workaround)

Also drops the now-unused LifecycleConnected/LifecycleDisconnected interfaces
(they existed only as emit() overload signatures, no longer needed with the
generic emit).
2026-04-19 16:48:35 -06:00
..
client.test.ts feat(chess): add WebSocket client library with reconnect (P4.9) 2026-04-16 17:44:13 -06:00
client.ts refactor(net): type listener table as mapped type, drop double-casts 2026-04-19 16:48:35 -06:00
lobby-request.ts feat(ui): lobby profile picker integration 2026-04-18 23:11:11 -06:00
prediction.test.ts feat(chess): add client prediction + server reconciliation (P4.10) 2026-04-16 17:48:33 -06:00
prediction.ts test(e2e): unblock the 3 fixme tests in modifier-profiles spec 2026-04-19 13:15:15 -06:00
types.ts test(e2e): unblock the 3 fixme tests in modifier-profiles spec 2026-04-19 13:15:15 -06:00