JSDoc 一个对象,无论名称如何,所有属性都具有相同的类型
JSDoc an Object, all properties regardless of name get same type
我想将 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
*/
我想将 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
*/