好好爱自己!

typescript 的一种引入文件的方式 Triple-Slash Directives

---恢复内容开始---

/// reference 

原文: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

The /// <reference path="..." /> directive is the most common of this group. It serves as a declaration of dependency between files.

Triple-slash references instruct the compiler to include additional files in the compilation process.

They also serve as a method to order the output when using --out or --outFile. Files are emitted to the output file location in the same order as the input after preprocessing pass.

 

log.ts

function logMsg(){
    console.log('logMsg');
}

main.ts

///<reference path="./log.ts" />
logMsg();

编译出来的结果:out.js的内容为

function logMsg() {
    console.log('logMsg');
}
///<reference path="./log.ts" />
logMsg();

 

---恢复内容结束---

posted @ 2018-11-09 15:22  立志做一个好的程序员  阅读(991)  评论(0)    收藏  举报

不断学习创作,与自己快乐相处