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.
If you are writing a module, nothing you write is in the global scope - the file itself is a module, and everything inside it is scoped to that module.
import http = require('http');
export function processRequest(req : http.IncomingMessage) : boolean {
return false;
};
In the example above, the file, rateLimiter.ts
is the module. http
is imported into the rateLimiter
module.
You need to compile with the module flag - for example:
tsc --module commonjs rateLimiter.ts
Most editors and IDEs supply a way to set this too.