Skip to content

Commit 680d182

Browse files
committed
Add tests for destructuring from variable with inferrable type
1 parent af498eb commit 680d182

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/testRunner/unittests/services/convertToAsyncFunction.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,17 @@ function [#|innerPromise|](): Promise<string> {
655655
`
656656
);
657657

658+
_testConvertToAsyncFunction("convertToAsyncFunction_InnerPromiseRetBinding4", `
659+
function [#|innerPromise|](): Promise<string> {
660+
return fetch("https://typescriptlang.org").then(resp => {
661+
return resp.blob().then(({ blob }: { blob: { byteOffset: number } }) => [0, blob.byteOffset]).catch(({ message }: Error) => ['Error ', message]);
662+
}).then(([x, y]) => {
663+
return (x || y).toString();
664+
});
665+
}
666+
`
667+
);
668+
658669
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_VarReturn01", `
659670
function [#|f|]() {
660671
let blob = fetch("https://typescriptlang.org").then(resp => console.log(resp));
@@ -1221,6 +1232,12 @@ const { length } = [#|function|] () {
12211232
function [#|f|]() {
12221233
return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
12231234
}
1235+
`);
1236+
1237+
_testConvertToAsyncFunction("convertToAsyncFunction_catchBlockUniqueParamsBindingPattern", `
1238+
function [#|f|]() {
1239+
return Promise.resolve().then(() => ({ x: 3 })).catch(() => ({ x: "a" })).then(({ x }) => !!x);
1240+
}
12241241
`);
12251242

12261243
_testConvertToAsyncFunction("convertToAsyncFunction_bindingPattern", `

0 commit comments

Comments
 (0)