0

我想将方法​​调用的参数注释为接受两个参数的函数,第一个是 Error 或 null,第二个是对象或对象数组。但是我似乎无法找出正确的注释 - 编译器总是给出错误类型的注释。

例子:

  /**
   * 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);
  };

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

所以我的问题是我该怎么做。

4

0 回答 0