如何解决JSDoc是一个对象,所有属性无论名称如何都具有相同的类型
我想将JSDocs添加到我的函数中。我无法弄清楚如何定义键不重要的对象(每个键都指向相同类型的对象)。有什么办法实现?
/**
* @typedef EmojiGroupContent
* @type {Object}
* @prop {string[]} emojis All Emojis belonging to the group
* @prop {function} onAdd Runs when the group is unlocked
* (no other emoji in the group is active),* and the user reacts with an emoji from this group.
* @prop {function} onDel Runs when the user removes a reaction belonging to this group.
*/
/**
* @param {object} pool INSTANCE OF POOL
* @param {Object} groups
* @param {EmojiGroupContent} groups.anyNameHere <= Can I force all the properties to be of
* the type EmojiGroupContent,would it also
* be possible to have the keys to have a JsDoc
* comment.
*/
const registerEmojiInteraction = (pool,groups) => {
...
};
registerEmojiInteraction(POOL,{
race: {
emojies : ["",...],onAdd : ()=>{},onDel : ()=>{},},vsrace: {
...
},});
解决方法
看起来像你想要的
/**
* @param {Object.<string,EmojiGroupContent>} groups
*/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。