simion314
simion314

Reputation: 1394

Intellij Idea/Webstorm jsdoc analysis issue ,Unresolved variable

I have a function where I declare the param asd

@param {HTMLElement} node

then later I use it like

node.parentElement

but it complains with Unresolved variable parentElement

I can't change the type to Node because I need it to be HTMLElement (I use .id later)

IS there a JSDoc change I can do to fix this or other solution (that si not ugly)

Upvotes: 0

Views: 665

Answers (1)

lena
lena

Reputation: 93868

Node.parentElement property is not defined in Idea core javascript libraries (WEB-21824). You can add its definition as follows:

  • Open plugins\JavaScriptLanguage\lib\JavaScriptLanguage.jar!\com\intellij\lang\javascript\index\predefined\DOMCore.js file in editor, copy its content to a new js file
  • add Node.prototype.parentElement = 0; to it. See what other properties definitions look like to get an idea

  • either add this file to your project, or set it up as a javascript library in Settings (Preferences) | Languages & Frameworks | JavaScript | Libraries to get it used for completion, etc.

Note that this property doesn't seem to be standard (though it's supported by most browsers) - can't see it in https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247.

Upvotes: 1

Related Questions