Add handleing for classes

This commit is contained in:
Mohamed Hegazy
2016-06-08 16:43:56 -07:00
parent 18a875807c
commit 8360bc7961
17 changed files with 348 additions and 1 deletions

View File

@@ -5559,7 +5559,11 @@ const _super = (function (geti, seti) {
}
function emitClassLikeDeclarationBelowES6(node: ClassLikeDeclaration) {
const isES6ExportedClass = isES6ExportedDeclaration(node);
if (node.kind === SyntaxKind.ClassDeclaration) {
if (isES6ExportedClass && !(node.flags & NodeFlags.Default)) {
write("export ");
}
// source file level classes in system modules are hoisted so 'var's for them are already defined
if (!shouldHoistDeclarationInSystemJsModule(node)) {
write("var ");
@@ -5629,9 +5633,15 @@ const _super = (function (geti, seti) {
}
emitEnd(node);
if (node.kind === SyntaxKind.ClassDeclaration) {
if (node.kind === SyntaxKind.ClassDeclaration && !isES6ExportedClass) {
emitExportMemberAssignment(<ClassDeclaration>node);
}
else if (isES6ExportedClass && (node.flags & NodeFlags.Default)) {
writeLine();
write("export default ");
emitDeclarationName(node);
write(";");
}
}
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {