0

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?

Fenton
  • 241,084
  • 71
  • 387
  • 401
Parv Sharma
  • 12,581
  • 4
  • 48
  • 80
  • 2
    Are you using WebEssentials, or just the plain vanilla VS2012 plug-in? – Jude Fisher Nov 28 '12 at 09:59
  • Do you know which version(s) of TS and of WE? There were some issues with TS 0.8.1 + WE builds 1.8.* and module generation. I'm now using TS 0.8.1 + WE 1.9 (http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6) and `import http = module('path-to-module');` works fine for me, subject to the path oddity noted here: http://stackoverflow.com/q/13574843/1014822 – Jude Fisher Nov 29 '12 at 11:26
  • i downloaded it from the same link but it appears theres a newer version out and i have 0.8.1. what is WE? – Parv Sharma Nov 29 '12 at 11:30
  • TS = TypeScript. WE = WebEssentials. I would upgrade to the latest build of WebEssentials (1.9.1 at the time of writing), and see if that helps. – Jude Fisher Nov 29 '12 at 11:31
  • When something fails it's advisable to complement that fact with all the error messages. – Oleg Mihailik Dec 06 '12 at 08:03
  • @OlegMihailik - There was not error message. nothing – Parv Sharma Dec 06 '12 at 09:21

2 Answers2

1

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;
}
Jude Fisher
  • 11,138
  • 7
  • 48
  • 91
0

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.

Fenton
  • 241,084
  • 71
  • 387
  • 401