【发布时间】:2019-11-13 19:30:33
【问题描述】:
我一直在处理一个 Node.js 项目,只是注意到 Visual Studio Code 提供了有关基本 EventEmitter 对象的信息。所以我想应该可以为自定义提供 JSDoc。
我已经尝试遵循 JSDoc http://usejsdoc.org/tags-event.html 文档,但似乎没有成功。
我不知道这是否会影响它,但我使用的是 ES6 类,其中事件在它外部的函数中处理,但它在同一个脚本内。
这是测试代码。
// voice
if (voice) {
try {
/**
* Voice event.
*
* @event TelegramBot#voice
* @type {object}
* @property {object} chat - [object Chat]
* @property {number} date - Date when content was sent.
* @property {object} from - [object User]
* @property {number} message_id - Message id.
* @property {string} caption - Caption added to message. Value is undefined if none is added.
* @property {object} voice - [object Voice]
*/
context.emit('voice', chat, date, from, message_id, caption, voice)
} catch (error) {
context.emit('error', error)
}
}
【问题讨论】:
-
我很想知道这个。
标签: node.js visual-studio-code jsdoc eventemitter es6-class