The problem of using typescript in node.js

  node.js, question

This is my code

/// <reference path="typings/node/node.d.ts"/>
 var net = require('net');

I want to put variablesxDeclare asSocketType, but it is wrong
TS2503: cannot find namespace net
The following is a partial code of node.d.ts

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;

This net module needs to be “imported”:
import net = require(‘net’);