What does /// actually do?

I see this line of code in some of the JavaScript Files I work with, at the very top of the file ( first line ), but its not clear to me exactly what this does.

Google wasn’t much help on this.

/// <reference path="jquery-1.8.3.js" />

What is the purpose of it?

To add more details, I am using Visual Studio 2015.

This is most likely for Visual Studio’s JavaScript intellisense. Mads Kristensen has a nice article you can read to learn more about the history of this and how to use it correctly.

That is a triple-slash directive for the Typescript compiler. Since tsc will happily compile JS as well, this should work in either language and will reference a dependency.

The /// <reference .../> directive shows a dependency (for compiler symbols) without necessarily importing and actually loading the file. That is useful when you have a large library (like React) that exports a lot of interfaces or type symbols, but you don’t want to actually include (since they might be vendored at runtime). From the docs:

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.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   How to get size of an element/list in Firebase without get it all?

Similar Posts