当前位置:网站首页>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 import
The 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.ts
The name declared inside; 并且,This package needs to be included along with the declaration file at compile time.
Only if you need to write oned.ts
file 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="..." />
语句.
若要在.ts
A pair is declared in the file@types
包的依赖,使用--types
命令行选项或在tsconfig.json
里指定.
/// <reference no-default-lib="true"/>
This directive marks a file as 默认库. 你会在 lib.d.ts
See 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-module
The 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-dependency
Directives 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()
});
边栏推荐
- 【New Edition】DeepFakes: Creation, Detection and Influence
- Geoffery Hinton:深度学习的下一个大事件
- 软件工程国考总结——选择题
- 日元疲软令游戏机在日本变身“理财产品”:黄牛大赚
- 李航《统计学习方法》笔记之朴素贝叶斯法
- 牛客网项目17节生成验证码 刷新验证码一直没反应
- DVWA 通关记录 2 - 命令注入 Command Injection
- qq邮箱日发5万邮件群发技术(qq邮箱怎样定时发送邮件)
- Long battery life or safer?Seal and dark blue SL03 comparison shopping guide
- LayaBox---TypeScript---命名空间和模块
猜你喜欢
Application scenarios of js anti-shake function and function throttling
npm ERR! 400 Bad Request - PUT xxx - Cannot publish over previously published version “1.0.0“.
利用二维数据学习纹理三维网格生成(CVPR 2020)
【技术分享】OSPFv3基本原理
李航《统计学习方法》笔记之朴素贝叶斯法
阿里巴巴 CTO 程立:开源是基础软件的源头!
21年毕业转行软件测试,从0收入到月薪过万,我真的很幸运...
日元疲软令游戏机在日本变身“理财产品”:黄牛大赚
Implementation of mysql connection pool
【New Edition】DeepFakes: Creation, Detection and Influence
随机推荐
阿里CTO程立:阿里巴巴开源的历程、理念和实践
瑞萨RZ/G2L处理器详细测评
DVWA 通关记录 2 - 命令注入 Command Injection
matlab-day02
LayaBox---TypeScript---声明合并
LayaBox---TypeScript---命名空间和模块
MySql千万级分页优化,快速插入千万数据方法
LayaBox---TypeScript---三斜线指令
HikariCP数据库连接池,太快了!
Mistakes in Brushing the Questions 1-Implicit Conversion and Loss of Precision
食品安全 | 鱼肝油不是鱼油,家有宝宝的注意了
从零开始Blazor Server(5)--权限验证
Verilog的随机数系统任务----$random
云原生应用平台的核心模块有哪些
如何选择一块真正“好用的、性能高”的远程控制软件
第十六章 协程
软件测试H模型
Chapter 15 Generics
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
Shell script realizes multi-select DNS simultaneous batch resolution of domain name IP addresses (new update)