I would like to use socket.io in my Typescript project, but I\'ve only found .d.ts files for server-side typescript.
This is a nice example: https://github.com/soywiz/ty
I created my own .d.ts file, it's rather short but it works well:
declare var io : {
connect(url: string): Socket;
};
interface Socket {
on(event: string, callback: (data: any) => void );
emit(event: string, data: any);
}
This declaration file can be imported to client side Typescript and the socket.io standard example will work, here's my Typescript version:
var socket=io.connect("localhost");
socket.on("news",(data:any)=>alert(data));
socket.emit("news","hello");