You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A triple-slash reference path is resolved relative to the containing file, if a relative path is used.
27
+
当使用相对路径时,三斜线引用路径将相对于包含该引用的文件进行解析。
38
28
39
-
### Errors
29
+
### 错误
40
30
41
-
It is an error to reference a file that does not exist.
42
-
It is an error for a file to have a triple-slash reference to itself.
31
+
引用不存在的文件将导致错误。文件包含对自身的三斜线引用也会导致错误。
43
32
44
-
### Using`--noResolve`
33
+
### 使用`--noResolve`
45
34
46
-
If the compiler flag [`noResolve`](/tsconfig#noResolve) is specified, triple-slash references are ignored; they neither result in adding new files, nor change the order of the files provided.
Similar to a `/// <reference path="..." />`directive, which serves as a declaration of _dependency_, a `/// <reference types="..." />`directive declares a dependency on a package.
Use these directives only when you're authoring a `d.ts`file by hand.
45
+
这些指令仅在手动编写 `d.ts`文件时使用。
59
46
60
-
For declaration files generated during compilation, the compiler will automatically add `/// <reference types="..." />` for you;
61
-
A `/// <reference types="..." />` in a generated declaration file is added _if and only if_ the resulting file uses any declarations from the referenced package.
For declaring a dependency on an `@types` package in a `.ts` file, use [`types`](/tsconfig#types) on the command line or in your `tsconfig.json` instead.
64
-
See [using `@types`, `typeRoots` and `types` in `tsconfig.json` files](/zh/docs/handbook/tsconfig-json.html#types-typeroots-and-types) for more details.
This directive allows a file to explicitly include an existing built-in _lib_file.
53
+
该指令允许文件显式包含现有的内置 _lib_文件。
69
54
70
-
Built-in_lib_files are referenced in the same fashion as the [`lib`](/tsconfig#lib)compiler option in _tsconfig.json_ (e.g. use `lib="es2015"`and not `lib="lib.es2015.d.ts"`, etc.).
For declaration file authors who rely on built-in types, e.g. DOM APIs or built-in JS run-time constructors like `Symbol`or`Iterable`, triple-slash-reference lib directives are recommended. Previously these .d.ts files had to add forward/duplicate declarations of such types.
57
+
对于依赖内置类型的声明文件作者,例如 DOM API 或内置 JS 运行时构造函数(如 `Symbol`或`Iterable`),建议使用三斜线引用 lib 指令。以前,这些 .d.ts 文件必须添加这些类型的前向/重复声明。
73
58
74
-
For example, adding `/// <reference lib="es2017.string" />`to one of the files in a compilation is equivalent to compiling with `--lib es2017.string`.
Also note that when passing [`skipDefaultLibCheck`](/tsconfig#skipDefaultLibCheck), the compiler will only skip checking files with `/// <reference no-default-lib="true"/>`.
> **Note**: this directive has been deprecated. Use `import "moduleName";`statements instead.
104
+
> **注意**: 此指令已被弃用。请改用 `import "moduleName";`语句。
123
105
124
-
`/// <amd-dependency path="x" />`informs the compiler about a non-TS module dependency that needs to be injected in the resulting module's require call.
0 commit comments