Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Use IntelliSense in JavaScript Files

4.88/5 (5 votes)
6 Jul 2010CPOL1 min read 1  
Leverage VSDoc and DEBUG file documentation in VS2010
By adding a simple reference tag to your JavaScript files you can enable IntelliSense support for external files in Visual Studio 2010 (most functionality is also available in Visual Studio 2008).

For example, the following line will add IntelliSense for jQuery for a script located in the same directory:

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


You can also have the IDE create this tag for you automatically (with the correct path) by dragging scripts into the file you're working on.

This gives you the basic IntelliSense - like code completion, object members and method signatures. VS2010 is also able to determine members exposed through closures as well as through any prototype methods.

If you also put a VSDoc file (or a debug file with the "dot debug" convention) in the same directory, you get full IntelliSense with summary information for functions and parameter type information. You needn't reference this file, you simply need to have it beside your production version. Visual Studio will look first for a -vsdoc.js file, then a .debug.js file, then finally the file you've referenced (in this case, jquery-1.4.1.js.

Instead of using the local copy, you can also reference a script out on the cloud, such as jQuery hosted on Microsoft's CDN. Visual Studio 2010 will also look there, to see if any of the conventions for documentation exist at that address. (Visual Studio 2008 can only do this on local files).

Cheers!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)