I'm using typescript@next and I want to compile my code to es5, but each time I'm using async or await keywords the compiler errors with that message:
Cannot find name 'await'.
Heres my libs: dom, es2015, es2016, es2017.
Code example:
let asyncFn = () => {
return new Promise((resolve:Function)=>{resolve(2)})
}
// should log `2`
console.log(await asyncFn())
Such things are possible even with [email protected], I've tried it, but somehow I am unable to compile my code anyway.
async?Promiseasyncandawaitare a pair of keywords. You can't useawaitunless it's within anasyncscope.