【发布时间】:2018-01-10 11:30:33
【问题描述】:
我有一个可以接受可变数量参数的函数。
根据Google Closure Compiler wiki,这是使用@param注解的方式。
/**
* Takes 2 or more strings and do something cool with them.
* @param {...string} var_args
* @return {string} the processed result
*/
function doSomethingCool() {
var len = arguments.length;
if (len < 2) {
throw Error('Need at least 2 arguments');
}
...
}
问题
当我尝试编译它时,我看到了这个警告:JSC_INEXISTENT_PARAM: parameter var_args does not appear in doSomethingCool's parameter list at line 6 character 1
所以我尝试了@param {string} arguments,但同样的错误。
我还尝试了@param {string} 没有变量名。我得到了:JSC_TYPE_PARSE_ERROR: Bad type annotation. expecting a variable name in a @param tag.
问题
我做错了什么,如何为 Closure Compiler 注释可变参数?
【问题讨论】:
标签: javascript annotations google-closure-compiler jsdoc