visual-studio-2012javascript-intellisensevsdoc

What's wrong with this -vsdoc file?


I have a script, retry.js, that contains this:

function retryAjax(load, count, config) {
}

There's a body to it obviously, but it doesn't matter because this problem occurs whether I have the body in the script or not.

To document the object this function returns, I also have an auxiliary -vsdoc.js file, retry-vsdoc.js:

function RetryAjaxDeferred() {
    /// <summary>Returned from retryAjax. A jQuery Ajax Deferred object extended to support failWillRetry()</summary>

    this.done = function (success) {
        /// <summary>A callback when the Ajax call succeeds.</summary>
        /// <param name="success" type="Function">Success callback</param>
    }

    this.fail = function (error) {
        /// <summary>A callback when the Ajax call fails permanently.</summary>
        /// <param name="error" type="Function">Fail callback</param>
    }

    this.failWillRetry = function (willRetry) {
        /// <summary>A callback when the Ajax call fails with retries pending.</summary>
        /// <param name="willRetry" type="Function">Fail callback</param>
    }
};

What's odd is that if I delete the -vsdoc.js file, Intellisense in Visual Studio 2012 works fine for retry.js (except of course, I get no real help on what it returns). If I leave the -vsdoc.js in place, the retryAjax function is no longer available to Intellisense - it doesn't autocomplete or show Intellisense info while typing its parameters. The RetryAjaxDeferred function however does become active in Intellisense.

Clearly something in the -vsdoc.js file is breaking the Intellisense for retry.js somehow, without breaking it enough to prevent its own contents from disappearing. What am I doing wrong?


Solution

  • Found it - you need to reference the actual source file when adding extra Intellisense-only classes etc for Visual Studio:

    /// <reference path="~/ui/retry.js"/>
    function RetryAjaxDeferred() {
        . . .
    

    Now when I reference retry.js in other scripts and pages, the contents of both it and its -vsdoc file are a part of Intellisense results.