Triple-slash directives

Triple-slash directives are single-line comments containing a single XML tag. The contents of the comment are used as compiler directives.

Triple-slash directives are only valid at the top of their containing file.Triple-slash directives are single-line comments containing a single XML tag. The contents of the comment are used as compiler directives.

Triple-slash directives are only valid at the top of their containing file.

///

Similar to a /// directive, which serves as a declaration of dependency, a /// directive declares a dependency on a package.

For example, including /// in a declaration file declares that this file uses names declared in @types/node/index.d.ts; and thus, this package needs to be included in the compilation along with the declaration file.

///

This directive allows a file to explicitly include an existing built-in lib file.

Built-in lib files are referenced in the same fashion as the lib compiler option in tsconfig.json (e.g. use lib=“es2015” and not lib=“lib.es2015.d.ts”, etc.).

For example, adding /// to one of the files in a compilation is equivalent to compiling with —lib es2017.string.

/// <reference lib="es2017.string" />
"foo".padStart(4);

///

The /// directive is the most common of this group. It serves as a declaration of dependency between files.

Triple-slash references instruct the compiler to include additional files in the compilation process.