Invalid number of arguments, expected 2

Hello,

 

Since today i'm getting a weak warning in my expressjs app. I'm chaining the middleware calls like this:

 

Yesterday everything went fine, no warnings or errors, when i started today Webstorm i got the warning "Invalid number of arguments, expected 2 less... (Ctrl+F1)
Checks JavaScript called function arguments , return values , assigned expressions to be of correct type. The validation works in JavaScript, html or jsp files."

When i don't use the chaining like above, or only have max 2 chains, then the warning disappears:

Interesting is that the warning comes from the signature mismatch inspection. Now i'm not sure what the actual problem is, is it a problem of expressjs itself or did i missed an update in Webstorm which added new inspection options?

 

Webstorm version 2017.1.4

 

0
2 comments

This happens because actually the IDE fails to properly resolve 'app' during static code analysis, and thus resolves use() method by name. When not using chained calls, it resolves it to the best matching

app.use = function use(fn) {}

 

in node_modules/express/lib/application.js; but then, when use() is called not on app, but on object returned by use(), it suggests other use() methods found in Express module, like

Authenticator.prototype.use = function(name, strategy) {}
2
Avatar
Permanently deleted user

Very interesting, first time i get this warning. Thanks for your reply!

0

Please sign in to leave a comment.