问题描述
我想将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
*/