如何声明'Promise'构造函数?

问题描述 投票:0回答:1

我有一个针对ES5的旧TypeScript项目,由于诸多因素,不能选择升级到任何新版本,例如ES2015。在尝试利用异步/等待方式编译代码时,出现错误:

TS2705 (TS) An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your-lib option.

错误提示有两种解决方案,一个升级到ES2015并不是我的选择,因此我想知道如何准确地声明'Promise'构造函数。

我在论坛上进行了搜索,发现了许多类似的问题,但是我能够找到的所有建议最终都建议至少升级到ES2015,正如我在上文中指出的那样,在我看来,这不是一个选择。

javascript typescript promise async-await ecmascript-5
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.