Skip to content
Search

TypeScript:TripleSlash

lastmod 2022-12-15created 2022-12-151 edits

Comments starting with /// at the top of a file.

/// <reference path="..." />

The most common directive. It is used to declare dependencies between files.

/// <reference types="..." />

Similar to the ///<reference path="..." /> directive, which serves to declare a dependency, the ///<reference types="..." /> directive declares a dependency on a package.

The process of resolving package names is similar to the process of resolving module names in an import statement. It is easiest to think of triple-slash-reference-types directives as an import for declaration packages.

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

/// <reference lib="..." />

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

/// <reference no-default-lib="true"/>

This directive marks a file as a default library. You will see this comment at the very top of lib.d.ts and its different variants.

/// <amd-module />

By default, AMD modules are generated anonymously. This can cause problems when other tools such as bundlers (e.g. r.js) are used in the process of producing modules.

/// <amd-dependency />

WARNING

This directive has been deprecated. Use import "moduleName"; statements instead.

///<amd-dependency path="x" /> informs the compiler about a non-TS module dependency that needs to be added to the resulting module's require call.

See also

Favorite site

author Zer0 sitemap