注释参数作为函数接受几种类型作为闭包编译器的参数

时间:2013-03-05 13:08:31

标签: google-closure-compiler

我想将方法​​调用的参数注释为接受两个参数的函数,首先是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);
  };

我不确定这是否真的可行,但我发现它比使用未知类型更好。

所以我的问题是如何做到这一点。

0 个答案:

没有答案