diff --git a/packages/socket.io-client/lib/socket.ts b/packages/socket.io-client/lib/socket.ts index 973bafb32f..425af41e03 100644 --- a/packages/socket.io-client/lib/socket.ts +++ b/packages/socket.io-client/lib/socket.ts @@ -7,6 +7,8 @@ import { EventParams, EventsMap, Emitter, + ReservedOrUserEventNames, + ReservedOrUserListener, } from "@socket.io/component-emitter"; import debugModule from "debug"; // debug() @@ -18,6 +20,8 @@ type PrependTimeoutError = { : T[K]; }; +interface ReservedEvents extends EventsMap {} + /** * Utility type to decorate the acknowledgement callbacks with a timeout error. * @@ -1145,6 +1149,22 @@ export class Socket< } } } + + /** + * @param ev Name of the event + * @param listener Callback function + * @reserved + * - `connect`: This event is fired by the Socket instance upon connection **and** reconnection. + * - `connect_error`: This event is fired upon connection failure. + * - `disconnect`: This event is fired upon disconnection. + * @see [client-api-events](https://socket.io/docs/v4/client-api/#events-1) + */ + public on>( + ev: Ev, + listener: ReservedOrUserListener, + ): this { + return super.on(ev, listener); + } } export namespace Socket {