Fix emit for ES6 export default class with static initializers. Fixes #5136.

This commit is contained in:
Ron Buckton 2015-10-06 12:02:55 -07:00
parent e7c2003164
commit 64b6c9f52e
5 changed files with 28 additions and 2 deletions

View File

@ -4785,8 +4785,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// emit name if
// - node has a name
// - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel)
if ((node.name || (node.flags & NodeFlags.Default && languageVersion < ScriptTarget.ES6)) && !thisNodeIsDecorated) {
// - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel)
// - this is default export with static initializers
if ((node.name || (node.flags & NodeFlags.Default && (languageVersion < ScriptTarget.ES6
|| staticProperties.length > 0))) && !thisNodeIsDecorated) {
write(" ");
emitDeclarationName(node);
}

View File

@ -0,0 +1,9 @@
//// [exportDefaultClassWithStaticPropertyAssignmentsInES6.ts]
export default class {
static z: string = "Foo";
}
//// [exportDefaultClassWithStaticPropertyAssignmentsInES6.js]
export default class default_1 {
}
default_1.z = "Foo";

View File

@ -0,0 +1,5 @@
=== tests/cases/conformance/es6/classDeclaration/exportDefaultClassWithStaticPropertyAssignmentsInES6.ts ===
export default class {
static z: string = "Foo";
>z : Symbol(default.z, Decl(exportDefaultClassWithStaticPropertyAssignmentsInES6.ts, 0, 22))
}

View File

@ -0,0 +1,6 @@
=== tests/cases/conformance/es6/classDeclaration/exportDefaultClassWithStaticPropertyAssignmentsInES6.ts ===
export default class {
static z: string = "Foo";
>z : string
>"Foo" : string
}

View File

@ -0,0 +1,4 @@
// @target:es6
export default class {
static z: string = "Foo";
}