From a6c0300362da60269ec72a53c33afdf1d15ac29a Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:35:49 +0100 Subject: [PATCH] feat(ses): update Hermes transform to error on 'this' expression --- packages/ses/scripts/hermesTransforms.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/ses/scripts/hermesTransforms.js b/packages/ses/scripts/hermesTransforms.js index 033dce50e6..80849b5fef 100644 --- a/packages/ses/scripts/hermesTransforms.js +++ b/packages/ses/scripts/hermesTransforms.js @@ -17,6 +17,18 @@ const asyncArrowEliminator = { if (path.node.async) { let body = path.node.body; + const startLine = path.node.loc.start.line; + const endLine = path.node.loc.end.line; + + path.traverse({ + ThisExpression(innerPath) { + // throw path.buildCodeFrameError("..."); // https://github.com/babel/babel/issues/8617 + throw Error( + `${startLine}:${endLine} Hermes makeBundle transform doesn't support 'this' keyword in async arrow functions`, + ); + }, + }); + // In case it's a ()=>expression style arrow function if (!t.isBlockStatement(body)) { body = t.blockStatement([t.returnStatement(body)]);