Skip to content

Commit 0d74f29

Browse files
refactor(typings): export Socket class
In order to be able to cast it on the argument of the "connect" event: ```js import { Socket } from "socket.io"; io.on("connect", (socket: Socket) => { // ... }); ```
1 parent 7603da7 commit 0d74f29

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,3 +709,5 @@ emitterMethods.forEach(function(fn) {
709709

710710
module.exports = (srv?, opts?) => new Server(srv, opts);
711711
module.exports.Server = Server;
712+
713+
export { Socket }; // for "connect" event typing

test/socket.io.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
import { Server } from "..";
3+
import { Server, Socket } from "..";
44
import { createServer } from "http";
55
import fs = require("fs");
66
import { join } from "path";
@@ -357,7 +357,7 @@ describe("socket.io", () => {
357357
const sio = new Server(srv);
358358
srv.listen(() => {
359359
const socket = client(srv);
360-
sio.on("connection", socket => {
360+
sio.on("connection", (socket: Socket) => {
361361
expect(socket).to.be.a(Socket);
362362
done();
363363
});

0 commit comments

Comments
 (0)