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?

Cheers.

0
Avatar
Permanently deleted user

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,

http://code.google.com/p/jsdoc-toolkit/

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

0

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

Regards,
Konstantin

0

请先登录再写评论。