【问题标题】:What's wrong with this -vsdoc file?这个 -vsdoc 文件有什么问题?
【发布时间】:2013-02-17 04:55:30
【问题描述】:

我有一个脚本 retry.js,其中包含:

function retryAjax(load, count, config) {
}

显然它有一个主体,但这并不重要,因为无论我是否在脚本中有主体,都会出现这个问题。

为了记录这个函数返回的对象,我还有一个辅助的-vsdoc.js文件,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>
    }
};

奇怪的是,如果我删除 -vsdoc.js 文件,Visual Studio 2012 中的 Intellisense 对 retry.js 工作正常(当然,我对它返回的内容没有真正的帮助)。如果我将 -vsdoc.js 保留在原位,则 Intellisense 不再可以使用 retryAjax 函数 - 它不会在键入参数时自动完成或显示 Intellisense 信息。然而,RetryAjaxDeferred 函数确实在 Intellisense 中变得活跃。

很明显,-vsdoc.js 文件中的某些内容以某种方式破坏了 retry.js 的 Intellisense,而没有破坏到足以防止其自身内容消失的程度。我做错了什么?

【问题讨论】:

    标签: visual-studio-2012 javascript-intellisense vsdoc


    【解决方案1】:

    找到了 - 在为 Visual Studio 添加额外的仅 Intellisense 类等时,您需要参考实际的源文件:

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

    现在,当我在其他脚本和页面中引用 retry.js 时,它及其 -vsdoc 文件的内容都是 Intellisense 结果的一部分。

    【讨论】:

      猜你喜欢
      • 2014-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-09
      • 2012-07-10
      相关资源
      最近更新 更多