Home > Net >  JSdoc: Dynamic key name of return object
JSdoc: Dynamic key name of return object

Time:08-25


/**
 * 
 * @param {string} key 
 * @param {any} value
 * @returns {{[key]: typeof value}} 
 */
const set = (key, value) => {
    return {[key]: value}
}

const myObj = set("country", "USA")

myObj. // should suggest .country key

I can not understand how correct define key name of return object

enter image description here

CodePudding user response:

The following would do the trick. Just use Screenshot

  • Related