Sometimes, we want to fix the "An async function or method in ES5/ES3 requires the ‘Promise’ constructor" with TypeScript.
In this article, we’ll look at how to fix the "An async function or method in ES5/ES3 requires the ‘Promise’ constructor" with TypeScript.
How to fix the "An async function or method in ES5/ES3 requires the ‘Promise’ constructor" with TypeScript?
To fix the "An async function or method in ES5/ES3 requires the ‘Promise’ constructor" with TypeScript, we can add the 'es2015' into the compilerOptions.lib array.
For instance, we write
{
//...
"compilerOptions": {
"lib": ["es2015"]
}
//...
}
to set compilerOptions.lib to ["es2015"] so that the TypeScript compiler can assume that the Promise constructor is available globally in our project.
Conclusion
To fix the "An async function or method in ES5/ES3 requires the ‘Promise’ constructor" with TypeScript, we can add the 'es2015' into the compilerOptions.lib array.