您好,我在我的TypeScript项目中使用async/await,但我得到以下日志(log):
[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 100 option.
我该怎么解决呢?
您好,我在我的TypeScript项目中使用async/await,但我得到以下日志(log):
[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 100 option.
我该怎么解决呢?
如错误消息所示,将lib: es2015
添加到tsconfig.json
// tsconfig.json
{
"compilerOptions": {
"lib": [ "es2015" ]
}
}
更新:如果这对你不起作用,试试这个:
JetBrains IDE(如WebStorm)默认使用自己的实现.请确保将其配置为使用TypeScript语言服务.
对于Visual Studio,项目文件和tsconfig.json
是互斥的.你需要直接配置你的项目.
https://github.com/Microsoft/TypeScript/issues/3983#issuecomment-123861491