如何在JSDOC中扩展typedef参数? [英] How to extend a typedef parameter in JSDOC?
本文介绍了如何在JSDOC中扩展typedef参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设您在ES6类(文档)中有以下代码:
Assuming you have the following code inside a ES6 class (documentation):
/**
* @typedef Test~options
* @type {object.<string>}
* @property {array} elements - An array containing elements
* @property {number} length - The array length
*/
/**
* @param {Test~options} opt - Option object
*/
test(opt){
}
现在我想记录另一个函数,让它命名为 TEST2
。此函数使用完全相同的选项
对象,但需要另一个属性 parent
。
Now I would like to document another function, let's name it test2
. This function takes exactly the same options
object, but needs another property parent
.
如何在不记录冗余选项的情况下记录这些内容?冗余意味着:
How to document this without documenting redundant options? Redundant means:
/**
* @typedef Test~options
* @type {object.<string>}
* @property {array} elements - An array containing elements
* @property {number} length - The array length
*/
/**
* @param {Test~options} opt - Option object
*/
test(opt){
}
/**
* @typedef Test~options2
* @type {object.<string>}
* @property {array} elements - An array containing elements
* @property {number} length - The array length
* @property {object} parent - The parent element
*/
/**
* @param {Test~options2} opt - Option object
*/
test2(opt){
}
推荐答案
试一试
/**
* @typedef {object.<string>} Test~options
* @property {array} elements - An array containing elements
* @property {number} length - The array length
*/
/**
* @param {Test~options} opt - Option object
*/
test(opt){
}
/**
* @typedef {Test~options} Test~options2
* @property {object} parent - The parent element
*/
/**
* @param {Test~options2} opt - Option object
*/
test2(opt){
}
这篇关于如何在JSDOC中扩展typedef参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文