webstormjetbrains-idejavascript-intellisense

Why doesn't WebStorm provide method documentation on the second level?


I recently started to use WebStorm and I've noticed that the IDE sometimes doesn't provide property or method documentation on the second level. So, when I call an object and try to explore the available methods and properties on the second level, no documentation or hints are displayed. It only displays "unresolved method".

tagName and getAttribute() without documentation

I've already tried checking the settings and making sure that I'm using the latest version of WebStorm, but that hasn't fixed the problem.

Is there a way to change this behavior in WebStorm or am I missing something?

I have tried to enable "show full method signatures" and that worked for a minute. After that it suddenly stopped and went back to no documentation. Also i have tried to reset the JavaScript language version to ES 5.1 and then back to ES 6+.

Changing of the language version

Enable "show full method signatures"


Solution

  • The reason is that the exact type of event parameter is unknown, so the type is inferred as generic Event; EventTarget interface doesn't have tagName and getAttribute properties. You need to explicitly tell the IDE the type of the HTMLElement which is your target using type annotations. See https://freshman.tech/snippets/typescript/fix-value-not-exist-eventtarget/

    For pure JavaScript, this can be done using JSDoc annotations