From 85cba9f9b8f1d8526279f64823dcb9780c10e2aa Mon Sep 17 00:00:00 2001 From: Andrew Gaspar Date: Thu, 15 Aug 2013 14:43:56 -0500 Subject: [PATCH] Updated socket.io to have better function typing on SocketNamespace.on --- socket.io/socket.io-tests.ts | 10 ++++++++++ socket.io/socket.io.d.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 socket.io/socket.io-tests.ts diff --git a/socket.io/socket.io-tests.ts b/socket.io/socket.io-tests.ts new file mode 100644 index 000000000..841266610 --- /dev/null +++ b/socket.io/socket.io-tests.ts @@ -0,0 +1,10 @@ +import io = require('socket.io'); + +var socketManager = io.listen(80); + +socketManager.sockets.on('connection', socket => { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', data => { + console.log(data); + }); +}); \ No newline at end of file diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index d20b0540a..2b44ff6ab 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -40,7 +40,7 @@ interface SocketNamespace { json: any; volatile: any; in(room: string): SocketNamespace; - on(evt: string, fn: Function): SocketNamespace; + on(evt: string, fn: (socket: Socket) => void): SocketNamespace; to(room: string): SocketNamespace; except(id: any): SocketNamespace; send(data: any): any;