If I define the function as a variable object, then PhpStorm will show the auto-complete for the item
parameter.
/**
* @param {Rules.FolderGroupItem} item
**/
var forEach = function(item) {
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
};
_.each(items,forEach,this);
If I write the same thing as an inline parameter for the _.each()
function. Then it doesn't work.
_.each(items,forEach,
/**
* @param {Rules.FolderGroupItem} item
**/
function(item)
{
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
});
I found the answer. Here it is.
_.each(items,forEach,function(/*Rules.FolderGroupItem*/item)
{
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With