VS Code中JSDoc含null的联合类型hover未显示null问题
VS Code中JSDoc联合类型标注不生效问题
在VS Code中使用JSDoc配合jsconfig.json做类型检查时,定义了LinkedListNode类,其中this.next用JSDoc标注为LinkedListNode | null的联合类型,但hover该属性时,VS Code仅显示LinkedListNode,完全忽略了联合类型中的null。
我已经尝试过以下几种标注写法,均未解决问题:
/** @type {LinkedListNode | null} *//** @type {?LinkedListNode} *//** @type {(LinkedListNode|null)} */
期望hover时能正确显示完整的联合类型:LinkedListNode | null
相关代码
class LinkedListNode { /** * @param {number | undefined} value * @param {LinkedListNode | undefined} next */ constructor(value, next) { /** @type {number} */ this.value = value ?? 0; /** @type {LinkedListNode | null} */ this.next = next ?? null; } }
当前hover提示
(property) LinkedListNode.next: LinkedListNode
期望的hover提示
(property) LinkedListNode.next: LinkedListNode | null
内容的提问来源于stack exchange,提问作者user20668178
相关产品推荐
相关产品推荐

