I have a function that is similar to jQuery.noop
, angular.noop
, and goog.nullFunction
. It essentially does nothing and returns undefined, but it comes in handy when used like this: callback(successFn || noop);
.
This function is flexible and can be invoked with any number of arguments, regardless of their types.
Here is my current implementation:
/**
* @param varArgs {...*}
*/
var noop = function(varArgs) {};
Issue: However, Google Closure Compiler generates an error when this function is called without any arguments:
Function noop: called with 0 argument(s).
Function requires at least 1 argument(s) and no more than 1 argument(s).
Interestingly, even the annotation for goog.nullFunction by Closure Compiler is flawed. It throws errors when invoked with one or more arguments:
Function noop: called with 1 argument(s).
Function requires at least 0 argument(s) and no more than 0 argument(s).
Question: How can I accurately annotate my noop
function?