JSDoc an Array from Promise.All



我尝试记录一个承诺。所有结果一旦我破坏了数据。

这是一个例子,(我试图欺骗它将承诺放在封闭中)

      const promiseAll = () => {
        return Promise.all([
          this.b2bCompanies.getCompany(companyId, token),
          this.b2BFacade.getProfile(profileId, token),
        ]);
      };
      const [company, profile] = await promiseAll();

原始代码是:

      const [company, profile] = await Promise.all([
        this.b2bCompanies.getCompany(companyId, token),
        this.b2BFacade.getProfile(profileId, token),
      ]);

公司和配置文件成为*,但this.b2bCompanies.getCompany返回CompanySchema,配置文件调用ProfileSchema

任何想法我如何完成此操作并保持正确键入?

谢谢:)

闭合编译器的ES6外部定义了Promise.All thise;

/**
 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
 * @param {!Iterable<VALUE>} iterable
 * @return {!Promise<!Array<RESULT>>}
 * @template VALUE
 * @template RESULT := mapunion(VALUE, (V) =>
 *     cond(isUnknown(V),
 *         unknown(),
 *         cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
 *             templateTypeOf(V, 0),
 *             cond(sub(V, 'Thenable'), unknown(), V))))
 * =:
 */
Promise.all = function(iterable) {};

我认为以这种方式定义它会起作用,但我想知道您是否只能包括此外部?当然,只有在使用闭合编译器时才有意义。

最新更新