可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Hello I'm Using async/await in my TypeScript Project, But I Get this 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 --lib
option.
How Can I Solve That?
回答1:
As the error message says, add lib: es2015
to your tsconfig.json
// tsconfig.json { "compilerOptions": { "lib": [ "es2015" ] } }
回答2:
Try this package which contains type definitions for es6-promise
npm install --save @types/es6-promise
回答3:
If you are on VS, delete the tsconfig.json and right click open Properties->TypeScript Build in General change the followings