Emit class with export and export default

This commit is contained in:
Yui T
2015-03-11 16:45:55 -07:00
parent a0a506b11b
commit 7ee587c43f
4 changed files with 54 additions and 0 deletions
+7
View File
@@ -4664,6 +4664,13 @@ module ts {
}
function emitClassDeclarationAboveES6(node: ClassDeclaration) {
if (node.flags & NodeFlags.Export) {
write("export ");
if (node.flags & NodeFlags.Default) {
write("default ");
}
}
write("class ");
emitDeclarationName(node);
var baseTypeNode = getClassBaseTypeNode(node);
@@ -0,0 +1,16 @@
tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExport.ts(1,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExport.ts(5,22): error TS2309: An export assignment cannot be used in a module with other exported elements.
==== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExport.ts (2 errors) ====
export class C {
~
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
foo() { }
}
export default class D {
~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
bar() { }
}
@@ -0,0 +1,23 @@
//// [emitClassDeclarationWithExport.ts]
export class C {
foo() { }
}
export default class D {
bar() { }
}
//// [emitClassDeclarationWithExport.js]
export class C {
constructor() {
}
foo() {
}
}
export default class D {
constructor() {
}
bar() {
}
}
module.exports = D;
@@ -0,0 +1,8 @@
// @target: es6
export class C {
foo() { }
}
export default class D {
bar() { }
}