From 723a62bb16347ba2e020c3158bd4433b3fb0767d Mon Sep 17 00:00:00 2001 From: Vivek Nayyar Date: Fri, 1 Feb 2019 00:06:38 +0530 Subject: [PATCH] :beer: fixed the return statement issue --- transforms/async-await-with-try-catch.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transforms/async-await-with-try-catch.js b/transforms/async-await-with-try-catch.js index 91622bd..0251007 100644 --- a/transforms/async-await-with-try-catch.js +++ b/transforms/async-await-with-try-catch.js @@ -31,7 +31,11 @@ export default function transformer(file, api) { (ExpressionTypes.indexOf(path.parent.node.type) >= 0 || path.parent.node.type === 'VariableDeclarator') ) return; - replaceWithTryCatch(path, j.expressionStatement(path.node)); + if (path.parent.node.type === 'ReturnStatement') { + replaceWithTryCatch(path.parent, path.parent.node); + } else { + replaceWithTryCatch(path, j.expressionStatement(path.node)); + } }); root.find(j.VariableDeclaration).forEach(path => { const variableDeclarators = path.node.declarations;