Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Javascript methods resolving when they should not

$
0
0

Hi, I have a question about the inspection "Unresolved JavaScript function".

Given the following code:

 

function MyClass() {}

MyClass.prototype.myFunction = function () {};


var myString = "a string";

myString.myFunction();

I would expect an error highlighted on the last line, but it resolves just fine. myFunction() does not appear on the autocomplete-list, but if I write it out, I don't get any errors (and CMD+mouseclick takes me to the definition above).

Am I missing something fundamentally, or is this the wrong behaviour? Does every function defined (in any namespace or class) resolve for any type of object? Is there a reason that it has to be this way?

Preben

Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>