client: properly type the emit method

This breaks the world -.-
This commit is contained in:
Reto Brunner 2024-04-07 14:36:56 +02:00
parent bf7eb0e727
commit 35e38d13c4

View file

@ -24,6 +24,7 @@ import {StorageCleaner} from "./storageCleaner";
import {SearchQuery, SearchResponse} from "../shared/types/storage"; import {SearchQuery, SearchResponse} from "../shared/types/storage";
import {SharedChan, ChanType} from "../shared/types/chan"; import {SharedChan, ChanType} from "../shared/types/chan";
import {SharedNetwork} from "../shared/types/network"; import {SharedNetwork} from "../shared/types/network";
import {ServerToClientEvents} from "../shared/types/socket-events";
const events = [ const events = [
"away", "away",
@ -222,9 +223,12 @@ class Client {
return chan; return chan;
} }
emit(event: string, data?: any) { emit<Ev extends keyof ServerToClientEvents>(
event: Ev,
...args: Parameters<ServerToClientEvents[Ev]>
) {
if (this.manager !== null) { if (this.manager !== null) {
this.manager.sockets.in(this.id).emit(event, data); this.manager.sockets.in(this.id).emit(event, ...args);
} }
} }