Correct way to document open-ended argument functions in JSDoc

后端 未结 4 1416
粉色の甜心
粉色の甜心 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:46

    From the JSDoc users group:

    There isn't any official way, but one possible solution is this:

    /**
     * @param [...] Zero or more child nodes. If zero then ... otherwise ....
     */
    

    The square brackets indicate an optional parameter, and the ... would (to me) indicate "some arbitrary number."

    Another possibility is this...

    /**
     * @param [arguments] The child nodes.
     */
    

    Either way should communicate what you mean.

    It's a bit dated, though (2007), but I'm not aware of anything more current.

    If you need to document the param type as 'mixed', use {*}, as in @param {*} [arguments].

提交回复
热议问题