I try to compile an example code (app.ts) using an async function by using VScode but cannot get it without errors.
const request = async () => {
const response = await fetch('https://pokeapi.co/api/v2/pokemon/ditto');
const json = await response.json();
console.log(json);
}
Got this error message :
"Typescript: An async function or method in ES5/ES3 requires the 'Promise' constructor".
Now I added "lib": [ "ES2015", "DOM"]
to the tsconfig.json file and did a "tsc" in terminal and then tried it again "tsc app.ts". But I still get the same error.
I saw other people resolved this problem by adding these lines to the tsconfig.json, but it didn´t help for me. The compiler seems to take into account the tsconfig.json cause I tested by changing the outDir. "tsc" or "tsc -p tsconfig.json" are successful.
Target in compiler options is "es2016"