Skip to content

Commit

Permalink
feat(ses): update Hermes transform to error on 'this' expression
Browse files Browse the repository at this point in the history
  • Loading branch information
leotm committed Aug 20, 2024
1 parent 1ed84e1 commit a6c0300
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ses/scripts/hermesTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
Expand Down

0 comments on commit a6c0300

Please sign in to comment.