【问题标题】:Visual Studio javascript intellisense customizationVisual Studio javascript 智能感知自定义
【发布时间】:2014-11-25 05:25:41
【问题描述】:

我正在尝试在 Visual Studio 中的 javascript 函数中自定义智能感知,而不对函数进行注释。

我尝试推送我自己的项目:

但不幸的是,当 toto 没有在某处初始化时,这没有效果。 但如果 toto 存在:

所以...简单的问题,有没有办法让 toto 完成表现得好像它已经被定义了?有没有我错过的标志?

这是我在事件参数“e”中找到的字段,

  • 关于未定义的 toto:
    • 目标:空(未定义)
    • 目标名称:toto(字符串)
    • 项目:(数组)
    • 范围:成员(字符串)
    • _$items:(数组)

  • 在已定义的 toto 上:
    • 目标:1(数字)
    • 目标名称:toto(字符串)
    • 项目:[对象对象],...(数组)
    • 范围:成员(字符串)
    • _$items: [object Object],...(数组)

我尝试更改了几个字段值,我似乎没有任何效果。 我正在使用 VS2013

【问题讨论】:

    标签: javascript visual-studio autocomplete intellisense javascript-intellisense


    【解决方案1】:

    好的,我找到了一种在没有参数注释的情况下将智能感知添加到函数参数的方法。 如果在智能感知运行时生命周期中调用了该函数,它会存储传递给参数的值的类型。 这里我用数字 5 调用我的方法,完成的行为就像 toto 是 Number 类型一样。

    此外,我发现了这个:

    来自 msdn:http://msdn.microsoft.com/en-us/library/hh395059.aspx

    声明了一个参数,但在其他地方没有调用它 活动文档,如下例所示。

    function illuminate(light) {
             light.  // Accurate statement completion is not available 
                     // unless illuminate is called elsewhere with a 
                     // parameter that has a value. If it is called only
                     // in a function that is a sibling to 
                     // illuminate(light) in the call hierarchy, the 
                     // IntelliSense engine also cannot determine the 
                     // parameter type.
         }
    

    【讨论】:

      猜你喜欢
      • 2016-03-20
      • 2013-05-18
      • 2011-10-14
      • 2018-02-06
      • 2010-12-03
      • 2021-01-07
      • 2015-03-08
      • 2012-03-06
      • 2017-08-22
      相关资源
      最近更新 更多