diff --git a/transforms/__testfixtures__/async-await-with-try-catch.input.js b/transforms/__testfixtures__/async-await-with-try-catch.input.js index 237c0c7..0580903 100644 --- a/transforms/__testfixtures__/async-await-with-try-catch.input.js +++ b/transforms/__testfixtures__/async-await-with-try-catch.input.js @@ -26,3 +26,17 @@ async function testData() { const a = async function(req, res) { const tasks = await repository.get(); }; + +async function testReturnAwaitData() { + return await getData(); +} +// ObjectExpression +const CompaniesController = { + verifySubDomain: async request => { + const company = await Company.findOne({ + where: { + id: request.params.id + } + }); + } +} diff --git a/transforms/__testfixtures__/async-await-with-try-catch.output.js b/transforms/__testfixtures__/async-await-with-try-catch.output.js index 0ff32fb..2761258 100644 --- a/transforms/__testfixtures__/async-await-with-try-catch.output.js +++ b/transforms/__testfixtures__/async-await-with-try-catch.output.js @@ -54,3 +54,25 @@ const a = async function(req, res) { console.log(e); } }; + +async function testReturnAwaitData() { + try { + return await getData(); + } catch (e) { + console.log(e); + } +} +// ObjectExpression +const CompaniesController = { + verifySubDomain: async request => { + try { + const company = await Company.findOne({ + where: { + id: request.params.id + } + }); + } catch (e) { + console.log(e); + } + } +} diff --git a/transforms/async-await-with-try-catch.js b/transforms/async-await-with-try-catch.js index 0251007..151b04f 100644 --- a/transforms/async-await-with-try-catch.js +++ b/transforms/async-await-with-try-catch.js @@ -4,7 +4,7 @@ export default function transformer(file, api) { const j = api.jscodeshift; const root = j(file.source); const ExpressionTypes = ['BinaryExpression', 'LogicalExpression', 'NewExpression', 'ObjectExpression']; - const DisAllowedFunctionExpressionTypes = ['ArrowFunctionExpression', 'FunctionExpression']; + const DisAllowedFunctionExpressionTypes = ['ArrowFunctionExpression', 'FunctionExpression', 'ObjectExpression']; function isAlreadyInsideTryBlock(path) { return j(path).closest(j.TryStatement).length; }