-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed as duplicate of#5368
Labels
questionFurther information is requestedFurther information is requested
Description
The Typsecript annotations for emitWithAck seem to be off. Following the docs, my types are as follows:
export interface ClientToServerEvents {
"game:join": (args: {
gameName: GameID;
color: ColorID;
}) => void;
"game:connect": (args: {
gameName: GameID;
}) => void;
"board:place-marble": (args: {
gameName: GameID;
position: BoardPosition;
color: ColorID;
}) => void;
}
When I call emitWithAck()
, it shows an error:
const result = await this.socket.emitWithAck("game:join", {
gameName,
color,
});
Expected 1 arguments, but got 2.
If I add an extra argument to the "game:join" callback type, the error disappears.
The type for emitWithAck
is
emitWithAck<Ev extends EventNames<EmitEvents>>(ev: Ev, ...args: AllButLast<EventParams<EmitEvents, Ev>>): Promise<FirstArg<Last<EventParams<EmitEvents, Ev>>>>;
It seems like AllButLast
should not be there; it should just take all parameters of the event handler.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested