Typescript - is there a way to specify a global reference?

3k views Asked by At

I'm developing a node.js script using typescript and in order to tsc not to complain about non-browser-js code like require or module.exports, I have to include /// <reference path="lib/node.d.ts" /> in every file. To make things worse, the location to that file needs to be relative to the code file, so I can't easily put it to a template.

Is there a way to just tell tsc that each file in a specified dir conforms to node definition?

1

There are 1 answers

3
basarat On BEST ANSWER

I have to include /// <reference path="lib/node.d.ts" /> in every file

No you don't. Just use a tsconfig.json file : https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md