I recently started switching form PHP to Node.js, and since I'm a huge Typescript fan, I'm using Typescript + Node.js. I had my sample compiling just fine when I started to scale up and really build my code. But then I ran into an issues. Whenever node.d.ts is referenced (with the reference doc comment) in one of my .ts files, the Typescript compiler in Node.js complains about duplicated definitions. Two of my .ts files complain about not having the node.d.ts definitons, but my main.js file doesn't. (Files below:)
search_request.ts
/// <reference path="definitions/mustache.d.ts" />
import url = module("url");
import mu = module("mu2");
export function handler(request, response) {
//code..
}
main.ts
/// <reference path="servers/search_request.ts" />
import search_request = module("./servers/search_request");
import express = module("express");
var app = express();
app.get("/search.html", search_request.handler);
app.listen(3000);
If I add <reference path="node.d.ts" /> to the top of search_request.ts, it compiles fine. If I remove it, I get warnings about missing definitions. However, if I include it in either file, compiling main.ts will give me hundreds of warnings about duplicated identifiers.
I'm not new to Typescript, but I'm new to Node.js and new to using the tsc compiler directly rather than through VS2012. What exactly am I doing wrong? Does the compiler implicitly include node.d.ts like lib.d.ts? And if so, why do I get errors when compiling search_request.ts?