Java-like code autocompletion with JavaScript?

Viewed 1354

As a Java developer, I am used to being able to see all relevant information out of the code completion of the IDE already. Here is an example of code autocompletion from the Eclipse IDE. For instance, you can see that the return type of the function contentEquals is a boolean and it expect one parameter with type StringBuffer. Additionally, if the JavaDoc is there, you even get a nice explanation of how the function is supposed to be used.

enter image description here

Now I am looking for something similar when coding with JavaScript. I started using Webstorm as I wanted an IDE with the more advanced features but when you look at the code autocompletion, it either seems rather poor or I'm not using it right.

Can someone help me figure it out?

Here is a more specific example:

Let's say, you want to get the user's position by using the navigator.geolocation. Let's assume you know as much as that it can be done by calling the getCurrentPosition() method.

You go ahead and type in your IDE (Webstorm in my case):

navigator.geolocation.getCurrentPosition()

Here is what the Webstorm IDE makes out of it:

enter image description here

Ok, it tells me there is one mandatory and a couple of optional parameters to call this method. Let's say, you want to call this with only the mandatory parameter, which is supposed to be a function. So far so good, but what kind of function? Is this function supposed to take parameters? Does it return anything? There's no hint about it.

I found in various examples on the web, that this callback function actually does take one parameter, so I go ahead and write it:

function printPosition(position) {
    // do something
}

But here comes the next question: what type is this parameter position? What can you do with it?

So I try the code autocompletion on it: enter image description here

Whooot? It gives me all kinds of stuff, but not at all what I'm looking for. So I'm ending up with google again.

And here it is how it is supposed to look like:

console.log(position.coords.latitude + ' , ' + position.coords.longitude);

Honestly, I never would have guessed that this is how it's done only by looking at the autocompletion which is very annoying because I am used to being able to do that when coding in Java.

Can anyone relate to what I am experiencing? Am I missing something? Any help would be highly appreciated!

3 Answers

I also face similar issue while writing automation code in JS. I found that- using lightweight editors like- Visual Studio Code, I can get the limited number of Auto-complete suggestions.

enter image description here

Although its not as good as IntelliJ/Eclipse based auto-complete for Java or VSTS based IntelliSense for C#.Net for that matter. But still, it goes near as instead of myriad number of options, we get a limited number of suggestions.

Also, I have found that with TypeScript experience is much improved.

Related