6f7f3b1775
* 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
35 lines
617 B
TypeScript
35 lines
617 B
TypeScript
// ==ORIGINAL==
|
|
|
|
function /*[#|*/f/*|]*/(){
|
|
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
|
|
}
|
|
|
|
function res(result){
|
|
return 5;
|
|
}
|
|
|
|
function rej(reject){
|
|
return Promise.resolve(1);
|
|
}
|
|
|
|
// ==ASYNC FUNCTION::Convert to async function==
|
|
|
|
async function f(){
|
|
let result: number;
|
|
try {
|
|
const result_1 = await fetch("https://typescriptlang.org");
|
|
result = await res(result_1);
|
|
} catch (reject) {
|
|
result = await rej(reject);
|
|
}
|
|
return res(result);
|
|
}
|
|
|
|
function res(result){
|
|
return 5;
|
|
}
|
|
|
|
function rej(reject){
|
|
return Promise.resolve(1);
|
|
}
|