Skip to content

Commit

Permalink
Update transform_files.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Oct 31, 2022
1 parent f6d9031 commit b3c73d1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scripts/transform_files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,21 @@ function transformClass(type, raw, options = {}) {
node.callee.property.name === 'callSuper'
) {
const [methodNameArg, ...args] = node.arguments;
const lastArg = args[args.length - 1];
const removeParen =
lastArg.type === 'Identifier' || lastArg.type === 'Literal';
const out = `${
methodNameArg.value === 'initialize'
? 'super'
: `super.${methodNameArg.value}`
}(${printASTNode(value, args)})`;
superTransforms.push({
node,
methodName: methodNameArg.value,
value: `super.${methodNameArg.value}(${printASTNode(
value,
args
).replace(/\(|\)/gm, '')});`,
value:
removeParen && out[out.length - 1] === ')'
? out.slice(0, -1)
: out,
});
}
},
Expand Down

0 comments on commit b3c73d1

Please sign in to comment.