scott


Comments:

(Better) JQuery IntelliSense in VS2008

posted by scottscott(0) 4 years ago 0

JavaScript is a typeless language that is super flexible, and there is often no way to determine API shapes without executing/evaluating the actual code of the API. The VS 2008 intellisense engine actually executes the JavaScript library at parse time to get a good idea of what the shape looks like. That is why you get basic intellisense with JQuery, Prototype and other libraries without doing anything.

However, for cases where you are dynamically chaining methods together with dynamic objects/methods it is often impossible to infer how the code will evaluate without additional metadata. Both VS 2008 and Aptana (the other popular JavaScript intellisense tool) have this issue. That is why they both use intellisense friendly versions of the JavaScript libraries that have additional metadata comments for tools to use to provide extra code hints and better code completion.

The above article shows a cool trick where you can reference both the real JQuery as well as the meta-data version (within a placeholder control that will hide it at runtime) and get full intellisense for the library at design-time while using the trimmed down version at runtime.

Hope this helps,

Scott

Reply