typescript 打字稿 .d.ts 文件的搜索路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18091724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:50:41  来源:igfitidea点击:

Search path for typescript .d.ts files

typescript

提问by Travis

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++.

有没有办法让打字稿编译器在给定目录中搜​​索声明文件?类似于 C++ 的 INCLUDE_PATH。

采纳答案by Fenton

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).

您可以使用references.ts 技巧来简化程序中的引用(只需将所有引用放在一个文件中,以便所有其他文件都指向该文件)。

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...

从 TypeScript 0.9.1 开始,Visual Studio 模板只允许您访问项目中的所有 TypeScript 文件和 TypeScript 定义文件。我已经测试过这个并且它有效......

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

您可以在我的博客文章中查看有关此功能的示例和说明

Update for Visual Studio 2013 Update 3

Visual Studio 2013 更新 3 的更新

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

我已经更新了上面的文章,指出您必须将构建操作设置TypeScriptCompile为要包含在此自动发现中的文件。