Skip to content

Commit

Permalink
Avoid duplicate function names when rewriting export default
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetrich committed Aug 3, 2019
1 parent 8a354a7 commit b9aadf2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion async-to-promises.ts
Expand Up @@ -3408,7 +3408,7 @@ export default function({ types, template, traverse, transformFromAst, version }
if (path.parentPath.isExportDefaultDeclaration() && id !== null) {
// export default function... is a function expression in babel 6
const targetPath = path.parentPath;
targetPath.replaceWith(types.variableDeclaration("const", [types.variableDeclarator(path.node.id, types.functionExpression(path.node.id, path.node.params, path.node.body, path.node.generator, path.node.async))]));
targetPath.replaceWith(types.variableDeclaration("const", [types.variableDeclarator(path.node.id || id, types.functionExpression(undefined, path.node.params, path.node.body, path.node.generator, path.node.async))]));
targetPath.insertAfter(types.exportDefaultDeclaration(id));
reorderPathBeforeSiblingStatements(targetPath);
return;
Expand Down

0 comments on commit b9aadf2

Please sign in to comment.