Add tests for destructuring from variable with inferrable type

This commit is contained in:
Andrew Branch 2019-04-18 12:01:11 -07:00
parent af498eb6ca
commit 680d18207c
No known key found for this signature in database
GPG key ID: 22CCA4B120C427D2

View file

@ -655,6 +655,17 @@ function [#|innerPromise|](): Promise<string> {
`
);
_testConvertToAsyncFunction("convertToAsyncFunction_InnerPromiseRetBinding4", `
function [#|innerPromise|](): Promise<string> {
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", `