Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ExportDefaultDeclaration(path) {
if (this.file.get(versionKey) !== version) return;
const decl = path.get("declaration");
if (decl.isClassDeclaration() && hasDecorators(decl.node)) {
if (decl.node.id) {
// export default class Foo {}
// -->
// class Foo {} export { Foo as default }
splitExportDeclaration(path);
} else {
// Annyms class declarations can be
// transformed as if they were expressions
decl.node.type = "ClassExpression";
}
}
},
},
ExportDefaultDeclaration(path: NodePath) {
if (!path.get("declaration").isClassDeclaration()) return;
splitExportDeclaration(path);
},
maybeConvertFromExportDeclaration(parentDeclar) {
const maybeExportDeclar = parentDeclar.parentPath;
if (!maybeExportDeclar.isExportDeclaration()) {
return;
}
if (
maybeExportDeclar.isExportDefaultDeclaration() &&
!maybeExportDeclar.get("declaration").node.id
) {
return;
}
splitExportDeclaration(maybeExportDeclar);
}
ExportDefaultDeclaration(path) {
let decl = path.get("declaration");
if (!decl.isClassDeclaration() || !hasDecorators(decl)) return;
if (decl.node.id) decl = splitExportDeclaration(path);
decl.replaceWith(transformClass(decl, this.file));
},
ExportDefaultDeclaration(path) {
if (!path.get('declaration').isFunctionDeclaration()) return;
splitExportDeclaration(path);
},
programPath.get("body").forEach(child => {
if (!child.isExportDefaultDeclaration()) return;
splitExportDeclaration(child);
});
}