Add and update tests

This commit is contained in:
Benjamin Lichtman 2018-09-12 14:47:13 -07:00
parent 906fbae37b
commit 95e5f7d55a
3 changed files with 28 additions and 0 deletions

View File

@ -1198,6 +1198,15 @@ const [#|foo|] = function () {
function [#|f|]() {
return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
}
`);
_testConvertToAsyncFunction("convertToAsyncFunction_bindingPattern", `
function [#|f|]():Promise<void> {
return fetch('https://typescriptlang.org').then(res);
}
function res({ status, trailer }){
console.log(status);
}
`);
});

View File

@ -13,5 +13,6 @@ function /*[#|*/f/*|]*/(): Promise<string> {
async function f(): Promise<string> {
const resp = await fetch("https://typescriptlang.org");
var blob = resp.blob().then(blob_1 => blob_1.byteOffset).catch(err => 'Error');
const blob_2 = undefined;
return blob_2.toString();
}

View File

@ -0,0 +1,18 @@
// ==ORIGINAL==
function /*[#|*/f/*|]*/():Promise<void> {
return fetch('https://typescriptlang.org').then(res);
}
function res({ status, trailer }){
console.log(status);
}
// ==ASYNC FUNCTION::Convert to async function==
async function f():Promise<void> {
const __0 = await fetch('https://typescriptlang.org');
return res(__0);
}
function res({ status, trailer }){
console.log(status);
}