简体   繁体   English

自动引用的打字稿定义

[英]Automatically referenced typescript definition

Is there a way to create a typescript definition file that will be automatically referenced by all compiled typescript files? 有没有一种创建打字稿定义文件的方法,该文件将被所有已编译的打字稿文件自动引用?

Context: 内容:

I am setting some global configuration variables server-side and setting them as global window properties. 我正在服务器端设置一些全局配置变量,并将它们设置为全局窗口属性。 I would like to have a definition file that would define the types of those variables as an extension of window object. 我想有一个定义文件,这些文件将这些变量的类型定义为window对象的扩展。 I would like this file (something like global.d.ts) to be automatically referenced by all compiled scripts without specifically writing ///<reference .... in each file. 我希望此文件(类似global.d.ts)由所有已编译的脚本自动引用,而无需在每个文件中专门编写/// <reference....。

I am currently using angular 6 cli to compile the project. 我目前正在使用angular 6 cli来编译项目。

Oh, I found out the answer :) I just needed to add the global.d.ts to the "includes" section in tsconfig.app.js and all was good to go :) 哦,我找到了答案:)我只需要将global.d.ts添加到tsconfig.app.js中的“ includes”部分,一切就很好了:)

Now every file has it referenced :). 现在每个文件都引用了:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM