我有一个带有大量选项的函数:
/**
* Show dialog in a blocking manner.
*
* @param {object} opts
* @param {string} opts.msg "Body" of the dialog.
* @param {number} opts.timeout Seconds - floating point values are rounded. (ActiveX imposes this)
* @param {string} opts.title Title of the dialog.
* @param {number} opts.icon Use constants for this. (See docs)
* @param {number} opts.buttons Use constants for this. (See docs)
* @param {number} opts.defaultButton Use constants for this. (See docs)
* @returns {number} Use our constants to check for what the user chose.
*/
const showSync = (opts) => {
...
}
但是我也有一个非阻塞版本的函数,显然采用相同的选项并返回一个Promise。直接复制粘贴文档似乎很不好,这会降低可维护性和意外不一致性的可能性。
因此,以下内容将是更好的:
/**
* Shows dialog in a non-blocking manner.
*
* @inheritdoc showSync
* @returns {Promise<number>} Use our constants to check for what the user chose.
*/
const show = (opts) => {
...
}
这是否可能以某种方式实现?
[更新]
这不是与 JSDoc for reused Function interface 重复,因为那个问题仅涉及重用相同的定义,而这个问题涉及重用但也部分重写该定义。因此,那里的答案无法回答这里的问题。
@inheritdoc
对于普通类型也不起作用。它的文档说:“您在 JSDoc 注释中包含的任何其他标记都将被忽略。” - Joshua Coady