TypeScript and Socket.io

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/typescript-node-definitions/blob/master/socket.io.d.ts

It shows how to use TypeScript in combination with Socket.io. However on the client side it uses JavaScript.

What I need is a .d.ts file for client-side TypeScript, that resolves the error message from this line:

var socket=io.connect("localhost");

The name "io" does not exist in the current scope

Where can I find the appropriate definition file?

I created my own .d.ts file, it's rather short but it works good:

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");

Browsers don't know how to deal with .d.ts files.

You should include the socket.io client in your client side:

<script src="/socket.io/socket.io.js"></script>

This script is embedded and served by a socket.io server, so if you already have a socket.io server running, you shouldn't worry about finding the script, just assume it is served by the server.

EDIT

According to TypeScript's language scpecification, you need an "Ambient Declaration" on the files which use external code, in your case, the socket.io client.

declare var io;