No warning on a callback function argument with different parameters
Hello,
I'm evaluating Webstorm and I like the code inspection feature in combination with JSDoc very much. This can be very helpful during development.
However I ran into a situation where I would expect a warning by the code inspection, but I didn't get any.
I have defined a class with a callback function parameter in the constructor. This callback function is defined as a function with 2 (String type) parameters.
I would expect a warning when I call the constructor of this class with a faulty callback function argument which is a function with different parameters as the defined callback function type.
Do I have to add extra JSDoc defintions to get this warning or how can I avoid these type of mistakes...
Example code:
/**
* Callback function definition
*
* @callback Callback
* @param {string} param1
* @param {string} param2
*/
/**
* My class defintion which will use the Callback function
*
* @constructor
* @param {Callback} cbFunc
*/
function MyClass (cbFunc) {
}
/**
* Faulty callback function
*
* @function
* @param {boolean} differentParam
*/
function faultyCallback (differentParam) {
}
var myClassInst = new MyClass(faultyCallback); // Would expect a warning here!!
Please sign in to leave a comment.
Logged as https://youtrack.jetbrains.com/issue/WEB-20729, please vote for it to be notified on any progress