我有一个像这样的对象:
const logTypes = {
debug: '35',
log : '37',
info : '34',
warn : '33',
error: '31'
}; // Don't pay attention to the values, it's for a specific system.
我想要一个函数,它采用 JSDoc 参数中的值之一。
我尝试了 @param {logTypes} logType
但它似乎不起作用。
我错过了什么?
最佳答案
const logTypes = {
debug: '35',
log: '37',
info: '34',
warn: '33',
error: '31',
};
/**
* @type {( type: keyof typeof logTypes ) => void}
*/
const log = () => {};
关于javascript - 如何在 JSDoc 中将对象的值设置为类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61958967/