mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Emit class with export and export default
This commit is contained in:
@@ -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() { }
|
||||
}
|
||||
Reference in New Issue
Block a user