title: Using typescript in node.js
body: <p>here is my code</p>
  
  <pre><code>/// &lt;reference path="typings/node/node.d.ts"/&gt;
  
  var net = require('net');
  var x:net.net.Socket;
  </code></pre>
  
  <p>I wanna declare variable <code>x</code> as type <code>Socket</code>,but an error is reported
  <strong>TS2503: cannot find namespace net</strong> </p>
  
  <p>this is a portion of node.d.ts</p>
  
  <pre><code>declare module "net" {
      import stream = require("stream");
  
      export interface Socket extends stream.Duplex {
          // Extended base methods
          write(buffer: Buffer): boolean;
          write(buffer: Buffer, cb?: Function): boolean;
          write(str: string, cb?: Function): boolean;
          write(str: string, encoding?: string, cb?: Function): boolean;
          write(str: string, encoding?: string, fd?: string): boolean;
  
          connect(port: number, host?: string, connectionListener?: Function): void;
          connect(path: string, connectionListener?: Function): void;
          bufferSize: number;
          setEncoding(encoding?: string): void;
          write(data: any, encoding?: string, callback?: Function): void;
          destroy(): void;
          pause(): void;
          resume(): void;
          setTimeout(timeout: number, callback?: Function): void;
          setNoDelay(noDelay?: boolean): void;
          setKeepAlive(enable?: boolean, initialDelay?: number): void;
          address(): { port: number; family: string; address: string; };
          unref(): void;
          ref(): void;
  </code></pre>