babel-core
Version:
Turn ES6 code into readable vanilla ES5 with source maps
57 lines (43 loc) • 1.01 kB
JavaScript
;
exports.ClassDeclaration = ClassDeclaration;
exports.ClassBody = ClassBody;
exports.MethodDefinition = MethodDefinition;
function ClassDeclaration(node, print) {
this.push("class");
if (node.id) {
this.space();
print(node.id);
}
print(node.typeParameters);
if (node.superClass) {
this.push(" extends ");
print(node.superClass);
print(node.superTypeParameters);
}
if (node["implements"]) {
this.push(" implements ");
print.join(node["implements"], { separator: ", " });
}
this.space();
print(node.body);
}
exports.ClassExpression = ClassDeclaration;
function ClassBody(node, print) {
if (node.body.length === 0) {
this.push("{}");
} else {
this.push("{");
this.newline();
this.indent();
print.sequence(node.body);
this.dedent();
this.rightBrace();
}
}
function MethodDefinition(node, print) {
if (node["static"]) {
this.push("static ");
}
this._method(node, print);
}
exports.__esModule = true;