JavaScript Intellisense Issue in App for SharePoint 2013 VS Template

I found that Intellisense was not working properly in Visual Studio 2012 for a SharePoint 2013 app using the template that gets installed with the Microsoft Office Developer Tools for Visual Studio 2012 (Preview 2).

These screenshots help illustrate the issue:

The above screenshot shows Intellisense working correctly for the web object directly after the web object is assigned via context.get_web().  The code that is hidden by the Intellisense dialog is calling that the JavaScript function onGetUserNameSuccess() via callback when the Asynchronous query returns with the user information.

Also notice the web variable is initialized outside of the function scope, meaning that Intellisense should still work for the web object inside the onGetUserNameSuccess() function.

As you can see from the screenshot above, I was not getting the correct Intellisense.  Using Yammer, I reached out to the SharePoint Developer community inside Microsoft to see if this was a known issue.

I received a reply from a SDE (louri) on the Office Tools Dev team with steps on how to workaround this known issue.

First open the Default.aspx page in the Pages module.  Cut the following text:

$(document).ready(function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

Next, paste it into App.js at the bottom of the file.  Be sure to go back and delete the now empty script tags in Default.aspx.

Now add init.js to the _references.js file so it looks like this:

/// <reference name="MicrosoftAjax.js" />
/// <reference path="~/_layouts/15/init.js" />

/// <reference path="~/_layouts/15/SP.Core.js" />
/// <reference path="~/_layouts/15/SP.Runtime.js" />
/// <reference path="~/_layouts/15/SP.UI.Dialog.js" />
/// <reference path="~/_layouts/15/SP.js" />
/// <reference path="jquery-1.6.2.js"/>

Your _references.js file should look like the above assuming this is a new project and you haven't added Knockout.js or any other libraries yet.

After making this change, Intellisense should now work properly.

Hopefully this will help someone else and keep them from scratching their head wondering why it is not working properly.  Many thanks to louri for the assistance.  Without his assistance, I would have been doing some crazy code transplantation techniques to work around this.  I am spoiled and need my Intellisense, especially in these early days with SharePoint 2013.

Now it's time to grab some Mountain Dew, crank up the tunes and play with the SharePoint 2013!

Happy coding!


Comments (1)

  1. Michele says:

    Thank you very much!!!

Skip to main content