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();
---恢复内容结束---

浙公网安备 33010602011771号