How to solve JavaScript IntelliSense problems in VS2010

VS2010 should support all of the VS2008 JavaScript functionalities as shown in Scott Guthrie’s VS2008 JavaScript IntelliSense blog.  It includes:

1. Basic type inference

2. IntelliSense from referenced external JavaScript libraries

3. IntelliSense from XML comments for functions, parameters and return types

4. Calling web services using ASP.NET AJAX

 

Additionally, VS2010 RTM had some improvement, including:

1. IntelliSense when manipulating browser objects

2. Dynamic generated variable IntelliSense

3. Default JavaScript snippets within IntelliSense to help you code faster

Scott Guthrie has a brief blog covering some of these.

 

Due to the dynamic feature of our JavaScript engine, we may run info conflicts between XML commented return types and inferred return types in some cases.  For example:

1. Dynamically generated IntelliSense will override the XML commented return types. 

    For example, the following code snippet shows string IntelliSense, instead of number IntelliSense:

image

This may lead to a confusing result sometimes.  The best way to solve this is to create a vsdoc commenting file, and remove the conflicting return statement from such functions, just like jquery-1.4.1-vsdoc.js in VS2010 RTM:

image 

2. Sometimes, the JavaScript engine may meet an exception internally during dynamic function execution in the current or referenced document.  The cause could be a JavaScript function syntax error, logic bug, or the VS2010 JavaScript engine bug. The corresponding IntelliSense at this time will be shown as a simple object or not shown at all.  To support good IntelliSense behavior in this case, try build a VSDoc file, add XML comments and remove the offending code.

 

Some useful links:

Format of JavaScript doc comments

VSDoc file look up orders

 

Thanks

Xinyang Qiu

Web Platform and Tools