snippettypescriptCritical
TypeScript compiler says “An async function or method in ES5/ES3 requires the 'Promise' constructor”; how do I solve this?
Viewed 0 times
typescriptes5constructorhowfunctiones3themethodrequirespromise
Problem
Hello I'm using
[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
How can I solve that?
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?
Solution
As the error message says, add
UPDATE: if this doesn't work for you, try this:
JetBrains IDE such as WebStorm, use its own implementation by default. Make sure you configure it to use TypeScript language service instead.
For Visual Studio, the project files and
https://github.com/Microsoft/TypeScript/issues/3983#issuecomment-123861491
lib: es2015 to your tsconfig.json// tsconfig.json
{
"compilerOptions": {
"lib": [ "es2015" ]
}
}UPDATE: if this doesn't work for you, try this:
JetBrains IDE such as WebStorm, use its own implementation by default. Make sure you configure it to use TypeScript language service instead.
For Visual Studio, the project files and
tsconfig.json are mutually exclusive. You will need to configure your project directly.https://github.com/Microsoft/TypeScript/issues/3983#issuecomment-123861491
Code Snippets
// tsconfig.json
{
"compilerOptions": {
"lib": [ "es2015" ]
}
}Context
Stack Overflow Q#43555378, score: 236
Revisions (0)
No revisions yet.