I get the error for formal parameter not matching when using goog.Timer.callOnce even when I think I have declared everything correctly.
goog.Timer.callOnce(/** @type {function} */ this.doSomething,0,this);
the method definition looks like
/**
* @param {!goog.events.Event} e
*/
model.someModel.prototype.doSomething = function(e){
}
The error looks like
ERROR - actual parameter 1 of goog.Timer.callOnce does not match formal parameter
==> default: [ERROR] found : function (this:model.someModel, goog.events.Event): undefined
==> default: [ERROR] required: (function (this:model.someModel): ?|null|{handleEvent: function (): ?})
==> default: [ERROR] goog.Timer.callOnce(/** @type {function} */doSomething,0,this);
I also tried typecasting /** @type {function()} */
but even this didnt work
The compiler is expecting a function that takes no arguments (because goog.Timer isn't going to pass any arguments) but you're passing a function that expects one argument. Either change the function so that it doesn't take an argument, or make the argument optional:
/**
* @param {!goog.events.Event=} opt_e
*/
model.someModel.prototype.doSomething = function(opt_e) {
if (opt_e) {
...
} else {
...
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.