diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index 943c7cb1903..b58c698effd 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -1138,6 +1138,12 @@ const [#|foo|] = function () { const foo = function [#|f|]() { return fetch('https://typescriptlang.org').then(result => { console.log(result) }); } +`); + + _testConvertToAsyncFunction("convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern", ` +const { length } = [#|function|] () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} `); _testConvertToAsyncFunction("convertToAsyncFunction_catchBlockUniqueParams", ` diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js new file mode 100644 index 00000000000..b34c369046f --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const { length } = /*[#|*/function/*|]*/ () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const { length } = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts new file mode 100644 index 00000000000..b34c369046f --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const { length } = /*[#|*/function/*|]*/ () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const { length } = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +}