microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

Convert to async/await doesn't support .finally() method #30469

Open DanielRosenwasser opened 5 years ago

DanielRosenwasser commented 5 years ago
declare function delay(n: number): Promise<void>;

async function foo() {
    delay().then(x => delay(400)).then(x => delay(400)).finally(x => console.log(x));
}
rjamesnw commented 5 years ago

finally does not exist in any library except es2028.promise (the lib.es2018.promise.d.ts file). My guess is you could just copy it from there for now, or change your lib to es2018.

https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es2018.promise.d.ts