Merge pull request #2841 from hzoo/i-2694
transform-es2015-classes: check if node.id is null
This commit is contained in:
@@ -8,13 +8,15 @@ export default function ({ types: t }) {
|
||||
ClassDeclaration(path) {
|
||||
let { node } = path;
|
||||
|
||||
let ref = node.id || path.scope.generateUidIdentifier("class");
|
||||
|
||||
if (path.parentPath.isExportDefaultDeclaration()) {
|
||||
path = path.parentPath;
|
||||
path.insertAfter(t.exportDefaultDeclaration(node.id));
|
||||
path.insertAfter(t.exportDefaultDeclaration(ref));
|
||||
}
|
||||
|
||||
path.replaceWith(t.variableDeclaration("let", [
|
||||
t.variableDeclarator(node.id, t.toExpression(node))
|
||||
t.variableDeclarator(ref, t.toExpression(node))
|
||||
]));
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user