I am writing a module for NodeJS in Typescript. I am 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 trying to make sure that the parameter of the incoming req request is such an instance, I found that I could not refer to anything from the http module. I think to myself "good, so I need to import it because it's just an alias." However, when I do this, I get: "Imported queries in the namespace cannot reference the 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 bad decision, importing globally, only to get "it is impossible to compile modules if the flag flag is not specified"
/// <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 that I am fundamentally lacking in how such a link should be made. It seems that I did not need to import the module in order to use the definitions included in node.d.ts. Can someone shed some light on this?
TheToolBox Jun 22 '15 at 19:30 2015-06-22 19:30
source share