【发布时间】:2021-10-05 21:36:11
【问题描述】:
我已经查看了一些不同的 Stack Overflow 答案,这些答案让我走到了这一步。到目前为止,我已经尝试了以下方法。
/**
* Prints true, false or empty string
* @param {boolean=} b
*/
test = (b = '') => { // Initialized type string not assignable to variable type boolean
console.log(`b = "${b}"`)
}
/**
* Prints true, false or empty string
* @param {boolean=} b
*/
test = (b) => {
// Initialized type string not assignable to variable type boolean
if (typeof b !== 'boolean') b = ''
console.log(`b = "${b}"`)
}
我感觉正确的答案是压制警告,但希望其他人有更好的答案。
【问题讨论】:
标签: javascript intellij-idea webstorm jsdoc