Correct way to document open-ended argument functions in JSDoc

后端 未结 4 1417
粉色の甜心
粉色の甜心 2020-11-29 00:49

Let\'s say you have something like the following:

var someFunc = function() {
    // do something here with arguments
}

How would you corre

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 01:35

    I futzed with this for quite some time. Here's how to do it with Google Closure Compiler:

    /**
    * @param {...*} var_args
    */
    function my_function(var_args) {
        // code that accesses the magic 'arguments' variable...
    }
    

    The key is to give your function a var_args parameter (or whatever you call it in your @param statement) even though the function doesn't actually use that parameter.

提交回复
热议问题