Using Intellisense with Esri's JavaScript API in Visual Studio
03 Mar 2013We all love Intellisense in Visual Studio, but with JavaScript is a little difficult to do that given it’s a dynamic language. However, most JavaScript libraries now comes with VSDoc files that provide a way to add intellisense to JavaScript in Visual Studio (and other IDEs). This post describe how to add the VSDoc files of any JavaScript library to your project in Visual Studio (Some of the images in this post are from here). In this post, I’ll expand on that to add intellisense for the Esri JavaScript API (JSAPI). First, download the VSDoc file for the JSAPI from here (direct link to Zip file). Updated version of the file could be found here. Thanks to Ken Buja who provided the updated file on Esri JSAPI forum.
Visual Studio 2012
Open the Options Dialog
Under Text Editor > JavaScript > Intellisense > References, switch to Implicit (Web) in the drop down list, and make sure that “~/Scripts/_references.js” is added.
This will tell Visual Studio that in any project, you will place a file named “_references.js” under a folder named “Scripts” at the root of the project, and in that file you will add references to the JavaScript API files with intellisense. You can change the file name or folder to anything you like.
Now, let’s add the _references.js file. Add a new item under the Scripts folder.
Then, name the new file _references.js
In the new file, add references to the VSDoc file you included in your project. You can simply drag the file from the Solution Explorer and drop it on to the file.
You can see in this file, I’ve added references to jQuery, SignalR, and the JSAPI. Now, you’ll get intellisense in your JavaScript file.
Visual Studio 2010
In Visual Studio 2010, there’s no section in Options to add a reference to the _references.js file. So, you’ll need to add a reference to that file in each file you’re working on.
You’ll get the same results.
Update: I’ve updated the links to VSDoc file to the latest version.