Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search path for typescript .d.ts files

Tags:

typescript

Is there any way to get the typescript compiler to search for declaration files in a given directory? Something like the INCLUDE_PATH for C++.

like image 407
Travis Avatar asked Aug 06 '13 22:08

Travis


People also ask

Where does TypeScript look for D ts files?

The . d. ts file is usually placed adjacent to the . ts file, it is providing the typings for.

What are TypeScript D ts files?

The "d. ts" file is used to provide typescript type information about an API that's written in JavaScript. The idea is that you're using something like jQuery or underscore, an existing javascript library. You want to consume those from your typescript code.


1 Answers

Not currently.

You have to reference the file explicitly using:

///<reference path="path/to/file.d.ts" /> 

You can use the references.ts trick to ease the referencing in your program (just put all your references in a single file so all your other files just point to that one).

UPDATE

As of TypeScript 0.9.1, the Visual Studio template just gives you access to all of the TypeScript files and TypeScript definition files in your project. I have tested this and it works...

You can see the example and notes about this feature in my blog post.

Update for Visual Studio 2013 Update 3

I have updated the above article to point out that you must have the build action set to TypeScriptCompile for a file to be included in this automatic discovery.

like image 178
Fenton Avatar answered Sep 20 '22 23:09

Fenton