TypeScript/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_thenFinallyThen.ts
Ron Buckton 6f7f3b1775
Minor fixes to "Convert To Async" refactor (#45536)
* Minor fixes to convertToAsync

* Back out on nested return in inner continuation

* Baseline update

* Verify type argument for call can be used, add a few more early exit shortcuts
2021-09-01 13:13:12 -07:00

19 lines
510 B
TypeScript

// ==ORIGINAL==
declare function foo(): Promise<number>;
function /*[#|*/f/*|]*/(): Promise<number> {
return foo().then(x => Promise.resolve(x + 1)).finally(() => console.log("done")).then(y => y + 2);
}
// ==ASYNC FUNCTION::Convert to async function==
declare function foo(): Promise<number>;
async function f(): Promise<number> {
let y: number;
try {
const x = await foo();
y = await Promise.resolve(x + 1);
} finally {
console.log("done");
}
return y + 2;
}