TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?

栏目: eslint 发布时间:2023-03-23

先来看一个 eslint 报错信息:

ERROR in src/directives/export.directive.ts:17:17
TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?
    15 |               .export(binding.value.type, binding.value.query)
    16 |               .subscribe(() => {
  > 17 |                 resolve()
       |                 ^^^^^^^^^

解决方法:

给 Promise 设定 void 返回类型

return new Promise<void>((resolve, reject) => {
  ...
  resolve()
})

这样就不会再报错了

本文地址:https://www.tides.cn/p_eslint-TS2794-Expected-1-arguments-but-got-0-Did-you-forget-to-include-void-in-your-type-argument-to-Promise

标签: eslint