use lib="es2015" and not lib=".ts", etc.).įor declaration file authors who rely on built-in types, e.g. This directive allows a file to explicitly include an existing built-in lib file.īuilt-in lib files are referenced in the same fashion as the lib compiler option in tsconfig.json (e.g. See using typeRoots and types in tsconfig.json files for more details. ts file, use types on the command line or in your tsconfig.json instead. Use these directives only when you’re authoring a d.ts file by hand.įor declaration files generated during compilation, the compiler will automatically add /// for you Ī /// in a generated declaration file is added if and only if the resulting file uses any declarations from the referenced package.įor declaring a dependency on an package in a. The process of resolving these package names is similar to the process of resolving module names in an import statement.Īn easy way to think of triple-slash-reference-types directives are as an import for declaration packages.įor example, including /// in a declaration file declares that this file uses names declared in thus, this package needs to be included in the compilation along with the declaration file. Similar to a /// directive, which serves as a declaration of dependency, a /// directive declares a dependency on a package. If the compiler flag noResolve is specified, triple-slash references are ignored they neither result in adding new files, nor change the order of the files provided. It is an error for a file to have a triple-slash reference to itself. It is an error to reference a file that does not exist. Triple-slash references are resolved in a depth-first manner, in the order they have been seen in the file.Ī triple-slash reference path is resolved relative to the containing file, if a relative path is used. These root files are preprocessed in the same order they are specified.īefore a file is added to the list, all triple-slash references in it are processed, and their targets included. These are the file names specified on the command-line or in the files list in the tsconfig.json file. The process starts with a set of root files The compiler performs a preprocessing pass on input files to resolve all triple-slash reference directives.ĭuring this process, additional files are added to the compilation. They also serve as a method to order the output when using out or outFile.įiles are emitted to the output file location in the same order as the input after preprocessing pass. Triple-slash references instruct the compiler to include additional files in the compilation process. It serves as a declaration of dependency between files. The /// directive is the most common of this group. If they are encountered following a statement or a declaration they are treated as regular single-line comments, and hold no special meaning. Triple-slash directives are only valid at the top of their containing file.Ī triple-slash directive can only be preceded by single or multi-line comments, including other triple-slash directives. The contents of the comment are used as compiler directives. Triple-slash directives are single-line comments containing a single XML tag.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |