Invalid number of parameters - Why is this being displayed?

JavaScript editing in WebStorm.

I've got a function that takes two parameters. I've got some code that calls this function and only passes the first parameter.

WebStorm is underlining my code and giving the message "Invalid number of parameters".

I like getting warnings from WebStorm, for instance, when I have a declared variable that is unused. However, on this occasion, I don't understand why WebStorm is providing the warning. My understanding is that all parameters to a JavaScript function call, from the interpreter's perspective, where optional.

Is there a way for me to explicitly mark my parameters as optional so that WebStorm will understand that missing parameters are ok?


Comment actions Permalink

Prior to my OP, I had not come across the concept of annotating JavaScript code. As I've looked into annotating, I've come across JSDoc,

The answer to the question in my OP is to document my JavaScript code as prescribed by JSDoc.

Comment actions Permalink

Also you could look at Closure Compiler tags and our blogpost about its support.



Please sign in to leave a comment.