I'm writing this code in the editor
///<reference path='../node/express3.d.ts' />
///<reference path='../node/node.d.ts' />
import http = module('http');
var reqRecieved = function (req, res): void {
res.end();
};
var server = http.createServer(reqRecieved);
server.listen("1337");
console.log("server started");
And the problem is that the TypeScript vs2012 plugin is not generating the JavaScript code for the same. but if I change line:
import http = module('http');
to line
var http = require('http');
then it generates fine.
what am I doing wrong here?
I would check you have the latest version of WebEssentials 2012 installed, as there were some issues with module import code not generating in builds 1.8.*
Also, there's an oddity in TS where imports inside a module generate no code:
export module test {
import myMod = module("MyMod"); // Generates no JS output
var class = myMod.someClass;
}
But:
import myMod = module("MyMod"); // Outside the module. Generates JS as expected.
export module test {
var class = myMod.someClass;
}
If you aren't getting an explanation via Visual Studio, it can sometimes help to hit the command line and see that is going on:
tsc --debug c:\path\to\yourfile.ts
This may give you more detailed errors.