From 680d18207c71b74ac4e99af11c09f7ec74d22690 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 18 Apr 2019 12:01:11 -0700 Subject: [PATCH] Add tests for destructuring from variable with inferrable type --- .../services/convertToAsyncFunction.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/testRunner/unittests/services/convertToAsyncFunction.ts b/src/testRunner/unittests/services/convertToAsyncFunction.ts index dadde325a14..b5eb5cf37d0 100644 --- a/src/testRunner/unittests/services/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/services/convertToAsyncFunction.ts @@ -655,6 +655,17 @@ function [#|innerPromise|](): Promise { ` ); + _testConvertToAsyncFunction("convertToAsyncFunction_InnerPromiseRetBinding4", ` +function [#|innerPromise|](): Promise { + return fetch("https://typescriptlang.org").then(resp => { + return resp.blob().then(({ blob }: { blob: { byteOffset: number } }) => [0, blob.byteOffset]).catch(({ message }: Error) => ['Error ', message]); + }).then(([x, y]) => { + return (x || y).toString(); + }); +} +` + ); + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_VarReturn01", ` function [#|f|]() { let blob = fetch("https://typescriptlang.org").then(resp => console.log(resp)); @@ -1221,6 +1232,12 @@ const { length } = [#|function|] () { function [#|f|]() { return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x); } +`); + + _testConvertToAsyncFunction("convertToAsyncFunction_catchBlockUniqueParamsBindingPattern", ` +function [#|f|]() { + return Promise.resolve().then(() => ({ x: 3 })).catch(() => ({ x: "a" })).then(({ x }) => !!x); +} `); _testConvertToAsyncFunction("convertToAsyncFunction_bindingPattern", `