Skip to content

Commit fc82e44

Browse files
shayanYousefidarrachequesne
authored andcommitted
refactor(typings): export Event type (#4215)
So that it can be used by the end users: ```ts const myMiddleware = ([eventName, ...args]: Event, next: (err?: Error) => void) => { console.log(eventName); // inferred as string next(); } io.on("connection", (socket) => { socket.use(myMiddleware); }); ```
1 parent c840bad commit fc82e44

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,3 +830,4 @@ module.exports.Namespace = Namespace;
830830
module.exports.Socket = Socket;
831831

832832
export { Socket, ServerOptions, Namespace, BroadcastOperator, RemoteSocket };
833+
export { Event } from "./socket";

lib/socket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export interface Handshake {
107107
auth: { [key: string]: any };
108108
}
109109

110-
type Event = [eventName: string, ...args: any[]];
110+
export type Event = [eventName: string, ...args: any[]];
111111

112112
export class Socket<
113113
ListenEvents extends EventsMap = DefaultEventsMap,

0 commit comments

Comments
 (0)