我想将方法调用的参数注释为接受两个参数的函数,首先是Error或null,第二个是Object或Object对象。但是我似乎无法弄清楚正确的注释 - 编译器总是给出Bad类型的注释。
示例:
/**
* Allows to predefine the callback for a named 'run' method. This is
* useful mostly for application code that has only one consumer for any
* particular named request.
*
* @param {!string} run_name The name of the run to register default callback
* for.
* @param {function(Error, (Array.<Object>|Object)): undefined} callback The callback
* function to execute for the named request if no other callback is provided
* with the request.
*/
_.registerRunCallback = function(run_name, callback) {
this.internalImplementation(run_name, callback);
};
我不确定这是否真的可行,但我发现它比使用未知类型更好。
所以我的问题是如何做到这一点。