JSDoc - 如何为参数记录有限数量的值及其类型?

时间:2016-03-05 16:27:00

标签: javascript documentation jsdoc3

我正在使用JSDoc来记录方法;如下所示,我需要描述我需要记录的参数var submodel_id = req.body.submodel_id, query = { "someArray": submodel_id }; Model.findOneAndUpdate( query, { "$pull": { "someArray": submodel_id } }, { "new": false }, function(err, doc) { var removedIndex = doc.someArray.indexOf(submodel_id); console.log(removedIndex); } ); ,该值的类型为tostring 且已接受值只是这一个:

number

如何将此信息传递给JSDoc?

TYPE:     VALUES ONLY ACCEPTED:
string - 'move:next'
string - 'move:prev'
number -  any number

1 个答案:

答案 0 :(得分:0)

只需用'|'分隔可接受的字符串,如下所示:

/**
 * ...
 * @param {'move:next'|'move:prev'|number} to - Some description.
 * ...
 */