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).
|
||
|---|---|---|
| .. | ||
| client.test.ts | ||
| client.ts | ||
| lobby-request.ts | ||
| prediction.test.ts | ||
| prediction.ts | ||
| types.ts | ||