Click here to Skip to main content
15,867,851 members
Articles / Web Development / ASP.NET
Tip/Trick

Use IntelliSense in JavaScript Files

Rate me:
Please Sign up or sign in to vote.
4.88/5 (5 votes)
6 Jul 2010CPOL1 min read 17.5K   7   3
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)


Written By
Software Developer (Senior)
Canada Canada
For almost 30 years I have been working with computers, learning a myriad of languages and participating in various computing environments.

Though I have been mentoring other developers for the last decade, I have recently found a strong interest in writing and am learning to translate the fun of in-person teaching to something I can get into article form.

I enjoy following technology trends, new gadgets and trying to guess where innovation will lead us next (I'm kinda holding out for a robot-served utopia, but willing to submit to our future robot leaders).

I am a guy who is passionate about my faith, my family and a cure for Juvenile Diabetes (my son lives with this disease).

Comments and Discussions

 
GeneralWhat about VS 2008 ? Pin
AntounPG6-Jul-10 3:20
AntounPG6-Jul-10 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.