【发布时间】:2021-02-05 15:27:10
【问题描述】:
Web API 具有扩展Node 接口的Element 接口。 如何告诉 JetBrains IDE 这个特定的 Node 是 Element?
希望下面的代码能解释一切。
/**
* @param {Node} node
* @return {string}
*/
function extractor(node) {
let text;
if (node.nodeType === Node.ELEMENT_NODE) {
// On the next line IDE shows a warning,
// that innerHTML property is not defined for Node.
// How to tell IDE that node variable became and Element here?
text = node.innerHTML;
} else {
text = node.textContent;
}
return text;
}
我正在使用 PyCharm Professional,但我认为这并不重要。
【问题讨论】:
标签: javascript intellij-idea jsdoc