简体   繁体   English

Visual Studio 2015中的JavaScript函数参数Intellisense

[英]JavaScript Function Parameter Intellisense in Visual Studio 2015

I read this article ( https://blogs.msdn.microsoft.com/visualstudio/2015/06/10/javascript-editor-improvements-in-visual-studio-2015/ ) and it looks like they made some good improvements to JS intellisense in 2015, but I was wondering if there was a way to get full intellisense for an object I pass as a parameter into a function. 我阅读了这篇文章( https://blogs.msdn.microsoft.com/visualstudio/2015/06/10/javascript-editor-improvements-in-visual-studio-2015/ ),看来他们对2015年的JS intellisense,但我想知道是否有办法对我作为参数传递给函数的对象获得完整的intellisense。

For instance, if I define a type (Cat) using JSDoc's typedef syntax and then use their syntax to say that the parameter to my PetTheCat function is a Cat type, is there some way for me to get intellisense on the cat parameter inside the function body of PetTheCat? 例如,如果我使用JSDoc的typedef语法定义类型(Cat),然后使用其语法说出我的PetTheCat函数的参数是Cat类型,那么有什么办法让我对函数内部的cat参数进行智能感知PetTheCat的尸体?

/**@typedef Cat
@property {string} Name*/
Cat = function()
{
    this.Name = null;
}

/**@method PetTheCat
@param {Cat} cat: The cat to pet.
*/
PetTheCat = function(cat)
{
    console.log(cat.Name + " is purring.");
}

I can get full intellisense if I declare an object with the new operator (ie var kitty = new Cat()), and I can now get intellisense for the members of cat if I call PetTheCat({}), but I can't seem to get it inside the actual function, typing "cat." 如果我使用new运算符声明一个对象(例如var kitty = new Cat()),则可以获得完整的智能感知,如果我调用PetTheCat({}),现在可以获取cat成员的智能感知,但是我做不到似乎在实际函数中输入了“ cat”。 just results in the standard list of unresolved symbols. 只会生成未解析符号的标准列表。 Is there some way to get intellisense on "cat" inside the function body? 有什么办法可以让函数体内的“猫”获得智能感知?

When I learned about JS intellisense in VS, I learned about it via the XML documentation. 当我了解VS中的JS intellisense时,我通过XML文档了解了它。 To provide parameter intellisense you need the <param> XML tag. 要提供参数智能感知,您需要<param> XML标记。

function Cat(name)
{
    this.Name = name || "Cat";
}

var x = new Cat("kitty");

function PetTheCat(cat)
{
    /// <param name='cat' type='Cat' />
    console.log(cat.Name + " is purring!");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM