当前位置:网站首页>LayaBox---TypeScript---Three slash instructions
LayaBox---TypeScript---Three slash instructions
2022-08-02 10:11:00 【Gamla granite】
目录
1介绍
三斜线指令是包含单个xml标签的单行注释.The content of the comment is used as a compiler directive.
A triple-slash directive can only be placed at the top of the file that contains it.如果它们出现在一个语句或声明之后,那么它们会被当做普通的单行注释,并且不具有特殊的涵义.
/// <reference path="..." />指令是三斜线指令中最常见的一种. 它用于声明文件间的 依赖.
当使用--out或--outFile时,It can also be used as a way to adjust the order of output content. The position of the files in the output file content is consistent with the preprocessed input order.
2.预处理输入文件
The compiler preprocesses the input file to resolve all triple-slash quoting directives. 在这个过程中,Additional files are added to the compilation process.
This process will take some根文件开始; They are files specified on the command line or in tsconfig.json中的"files"files in the list. These root files are preprocessed in the specified order. Before a file is added to the list,All triple-slash references it contains are processed,And the goals they contain. Triple-slash references are in the order in which they appear in the file,Use depth-first parsing.
3.错误
Referencing a file that does not exist will result in an error. A file that references itself with a triple slash directive will report an error.
4.使用 --noResolve
如果指定了--noResolve编译选项,Triple-slash references are ignored;They do not add new files,Also does not change the order of the given files.
与 /// <reference path="..." />指令相似,这个指令是用来声明 依赖的; 一个 /// <reference types="..." />指令则声明了对某个包的依赖.
Parsing the names of these packages and in importThe parsing of the module name in the statement is similar. You can simply think of triple-slash type reference directives as import声明的包.
例如,把 /// <reference types="node" />Imported into the declaration file,Indicates that this file is used @types/node/index.d.tsThe name declared inside; 并且,This package needs to be included along with the declaration file at compile time.
Only if you need to write oned.tsfile only use this command.
For those declaration files generated during the compilation phase,The compiler will add it automatically/// <reference types="..." />; 当且仅当Declarations from the referenced package are only added to the generated declarations file when the resulting file uses them/// <reference types="..." />语句.
若要在.tsA pair is declared in the file@types包的依赖,使用--types命令行选项或在tsconfig.json里指定.
/// <reference no-default-lib="true"/>
This directive marks a file as 默认库. 你会在 lib.d.tsSee this note at the top of the file and its different variants.
This directive tells the compiler during the compilation process不要Include this default library(比如,lib.d.ts). This is the same as using on the command line --noLib相似.
还要注意,当传递了--skipDefaultLibCheck时,The compiler just ignores the check with /// <reference no-default-lib="true"/>的文件.
/// <amd-module />
默认情况下生成的AMDModules are anonymous. 但是,Problems arise when some tools need to process the generated modules,比如 r.js.
amd-moduleThe directive allows an optional module name to be passed to the compiler:
//amdModule.ts
///<amd-module name='NamedModule'/>
export class C {
}
这会将NamedModule传入到AMD define函数里:
//amdModule.js
define("NamedModule", ["require", "exports"], function (require, exports) {
var C = (function () {
function C() {
}
return C;
})();
exports.C = C;
});
/// <amd-dependency />注意:This directive is deprecated.使用
import "moduleName";语句代替.
/// <amd-dependency path="x" />tells the compiler that there is a nonTypeScriptModule dependencies need to be injected,as the target modulerequire调用的一部分.
amd-dependencyDirectives can also take an optionalname属性;它允许我们为amd-dependencyPass in an optional name:
/// <amd-dependency path="legacy/moduleA" name="moduleA"/>
declare var moduleA:MyType
moduleA.callStuff()
生成的JavaScript代码:
define(["require", "exports", "legacy/moduleA"], function (require, exports, moduleA) {
moduleA.callStuff()
});边栏推荐
- R语言时间序列数据的平滑:使用KernSmooth包的dpill函数和locpoly函数对时间序列数据进行平滑以消除噪声
- The love-hate relationship between C language volatile keyword, inline assembly volatile and compiler
- The realization of the list
- 练习-17
- 2022.7.25-7.31 AI行业周刊(第108期):值钱比赚钱更重要
- 开源一夏 | GO语言框架中如何快速集成日志模块
- List-based queuing and calling system
- 如何封装微信小程序的 wx.request() 请求
- LayaBox---TypeScript---装饰器
- 如何选择一块真正“好用的、性能高”的远程控制软件
猜你喜欢

第十七章 Excel操作

如何选择一块真正“好用的、性能高”的远程控制软件

软件工程国考总结——选择题

后管实现面包屑功能

周杰伦新歌发布,爬取《Mojito》MV弹幕,看看粉丝们都说的些啥!

Naive Bayesian Method of Li Hang's "Statistical Learning Methods" Notes

Facebook's automated data analysis solution saves worry and effort in advertising

用汇编实现爱心特效【七夕来袭】

The k-nearest neighbor method in the notes of Li Hang's "Statistical Learning Methods"

DVWA 通关记录 2 - 命令注入 Command Injection
随机推荐
【技术分享】OSPFv3基本原理
用汇编实现爱心特效【七夕来袭】
开源一夏 | GO语言框架中如何快速集成日志模块
Facebook's automated data analysis solution saves worry and effort in advertising
Facebook自动化数据分析方案,广告投放省心省力
后管实现面包屑功能
LayaBox---TypeScript---模块解析
wireshark的安装教程(暖气片安装方法图解)
李航《统计学习方法》笔记之监督学习Supervised learning
食品安全 | 鱼肝油不是鱼油,家有宝宝的注意了
Long battery life or safer?Seal and dark blue SL03 comparison shopping guide
Pytorch的LSTM参数解释
李航《统计学习方法》笔记之感知机perceptron
刷题错题录1-隐式转换与精度丢失
R语言时间序列数据算术运算:使用log函数将时间序列数据的数值对数化、使用diff函数计算对数化后的时间序列数据的逐次差分(计算价格的对数差分)
Re22:读论文 HetSANN An Attention-based Graph Neural Network for Heterogeneous Structural Learning
c#反射和特性
QT专题:事件机制event基础篇
yolov7 innovation point
R语言使用ggpubr包的ggtexttable函数可视化表格数据(直接绘制表格图或者在图像中添加表格数据)、设置theme主题参数自定义表格中表头内容的填充色(使用colnames.style参数)