简体   繁体   中英

What is this JavaScript reference syntax used in Visual Studio?

In Visual Studio 2012, I created a web application then found the following line in the default _references.js script that came with the project:

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

What is this reference notation doing? This is confusing - isn't this just a comment, which shouldn't do anything? As I understand, a double slash (//) comments out a line in JavaScript. Is there anything special about triple-slash comments?

see this article

http://msdn.microsoft.com/en-us/library/vstudio/bb385682.aspx

and find Reference Directives

A reference directive enables Visual Studio to establish a relationship between the script you are currently editing and other scripts. The reference directive lets you include a script file in the scripting context of the current script file. This enables IntelliSense to reference externally defined functions, types, and fields as you code.

It's a Triple Slash Directive and has many uses.

See this article

https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

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

Very useful in linking typings definitions... for example, the mysql.d.ts typings has the following reference to the node.js typings...

///<reference path='../node/node.d.ts' />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM