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

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

typescript 报错信息:

TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?
  ...
  > 22 |         resolve()
       |         ^^^^^^^^^
    23 |       }
    24 |       document.body.appendChild(script)
    25 |     })

解决方法

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

给 promise 实例指定 void 返回类型

本文地址:https://www.tides.cn/p_eslint-expected-1-arguments-but-got-0-did-you-forget-to-include-void-in-your-type-argument-to-promise

标签: TS2794