当前位置:网站首页>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()
});边栏推荐
- QT专题:自定义部件
- 用汇编实现爱心特效【七夕来袭】
- Application scenarios of js anti-shake function and function throttling
- Linux system uninstall, install, upgrade, migrate clickHouse database
- LayaBox---TypeScript---声明合并
- Re22:读论文 HetSANN An Attention-based Graph Neural Network for Heterogeneous Structural Learning
- Shell脚本实现多选DNS同时批量解析域名IP地址(新更新)
- logo 图标(php图片加文字水印)
- 第十五章 多线程
- Shell script realizes multi-select DNS simultaneous batch resolution of domain name IP addresses (new update)
猜你喜欢

周鸿祎称微软抄袭 360 安全模式后发文否认;英特尔CEO基辛格回应市值被AMD超越:股价下跌是咎由自取|极客头条...

阿里CTO程立:阿里巴巴开源的历程、理念和实践

神通数据库,批量插入数据的时候失败

Use compilation to realize special effects of love

用正向迭代器封装实现反向迭代器

QT专题:自定义部件

李航《统计学习方法》笔记之感知机perceptron

基于列表的排队与叫号系统

yolov7创新点

iNFTnews | Seeing the two sides of the metaverse, what is the true Internet and the Internet of value?
随机推荐
LayaBox---TypeScript---装饰器
HikariCP数据库连接池,太快了!
Linux system uninstall, install, upgrade, migrate clickHouse database
【技术分享】OSPFv3基本原理
R语言时间序列数据算术运算:使用log函数将时间序列数据的数值对数化、使用diff函数计算对数化后的时间序列数据的逐次差分(计算价格的对数差分)
开源一夏 | GO语言框架中如何快速集成日志模块
win10打印服务无法启动(运行时错误automation)
In the whole development of chi V853 board tried to compile QT test
R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化水平柱状图(条形图)、使用orientation参数设置柱状图转置为条形图
Shell脚本实现多选DNS同时批量解析域名IP地址(新更新)
LayaBox---TypeScript---JSX
QT专题:事件机制event基础篇
使用较广泛的安全测试工具有哪些?
瑞萨RZ/G2L处理器详细测评
R language ggplot2 visualization: based on the fill parameter and shape parameter in the aes function, custom draw a grouped line chart and add data points (scatter points), use the legend.position fu
未知内容监控
The R language uses the ggtexttable function of the ggpubr package to visualize the table data (draw the table directly or add the table data to the image), set the theme parameter to customize the fi
The R language uses the rollapply function in the zoo package to apply the specified function to the time series in a rolling manner and the window moves, and set the align parameter to specify that t
MySql千万级分页优化,快速插入千万数据方法
Do you agree with this view?Most businesses are digitizing just to ease anxiety