Time for an update on the JQuery IntelliSense story.
Since I last updated the blog on this subject, things have moved on enormously:
- Microsoft started shipping JQuery 1.2.6 with ASP.NET MVC, and announced their intention to do the same with VS 2010.
- Alongside that, they handed over their own annotated intellisense file to the JQuery project to support intellisense in VS 2008
- To make that even easier to use, they released a patch for VS2008 SP1 that allows the intellisense parser to read an alternate –vsdoc.js file instead of a real .js file to get intellisense hints.
- Then today, John Resig announced the release of JQuery 1.3. Great news!
But then, not-so-great news: reference JQuery 1.3 from a file in VS2008, and intellisense falls over in a heap. Looks like there’s something in the new Sizzle CSS selector library component of JQuery that VS just doesn’t like. That disables all JavaScript intellisense in the referencing file. It’s a real shame; MS went above and beyond releasing a pre-SP1 hotfix that enabled intellisense to be compatible with jQuery 1.2, and I know the VS guys have a completely overhauled intellisense engine coming in the next version of VS. But right now, it looks like something in Sizzle’s capability detection code throws the current VS2008SP1 code for a wobbler.
Luckily, if you’re using a –vsdoc.js file to augment jQuery, intellisense doesn’t fail because it ignores the actual jQuery source file. Unfortunately, there’s no intellisense file for JQuery 1.3.
Until now.
Thanks to the fact that up to date API docs have been published immediately on http://api.jquery.com/, I’ve updated the generator script and posted a new JQuery 1.3 intellisense header file up, so you can drop in a jquery–vsdoc.js beside your jquery.js file and get fully-functional, chainable intellisense, including all the latest function signatures.
Note that my file is slightly different to Microsoft’s 1.2.6 file in its structure, and contains no actual jQuery code; it’s likely mine won’t function as well in co-ordination with jQuery extensions, for example. No warranty express or implied, your mileage may vary, etc.
If you need more information on getting JavaScript intellisense working in visual studio, Jeff King’s FAQ is a must-read.