Defining parameters in JSDoc for built-in anonymous functions

If I define the function as a variable object, then PhpStorm will show autocomplete 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 the built-in parameter for the _.each() function. Then it will not 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); } }); 
+4
source share
1 answer

I have 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); } }); 
+11
source

All Articles