I'm writing a module for NodeJS in Typescript. I'm trying to process a request (which should be an IncomingMessage object) using this module.
/// <reference path="typings/node/node.d.ts"/>
module rateLimiter {
export function processRequest(req : http.IncomingMessage) : Boolean {
return false;
};
}
When attempting to ensure that the incoming request parameter req
is such an instance, I find that I cannot reference anything from the http module. I think to myself "okay, so I need to import it because that's just an alias". When I do so however, I receive "import delcarations in a namespace cannot reference a module."
/// <reference path="typings/node/node.d.ts"/>
module rateLimiter {
import http = require('http');//IMPORT DECLARATIONS IN A NAMESPACE CANNOT REFERENCE A MODULE
export function processRequest(req : http.IncomingMessage) : Boolean {
return false;
};
}
So I try what seems like a poor decision, importing in the global scope, only to receive "cannot compile modules unless --module flag is provided"
/// <reference path="typings/node/node.d.ts"/>
import http = require('http');//CANNOT COMPILE MODULES UNLESS --MODULE FLAG IS PROVIDED
module rateLimiter {
export function processRequest(req : http.IncomingMessage) : Boolean {
return false;
};
}
I feel like I'm fundamentally missing how this sort of reference is supposed to be made. It feels like I shouldn't have to import a module just to use the definitions included in node.d.ts. Could someone shed some light on this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…