mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Fix emit for ES6 export default class with static initializers. Fixes #5136.
This commit is contained in:
parent
e7c2003164
commit
64b6c9f52e
@ -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);
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
//// [exportDefaultClassWithStaticPropertyAssignmentsInES6.ts]
|
||||
export default class {
|
||||
static z: string = "Foo";
|
||||
}
|
||||
|
||||
//// [exportDefaultClassWithStaticPropertyAssignmentsInES6.js]
|
||||
export default class default_1 {
|
||||
}
|
||||
default_1.z = "Foo";
|
||||
@ -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))
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/classDeclaration/exportDefaultClassWithStaticPropertyAssignmentsInES6.ts ===
|
||||
export default class {
|
||||
static z: string = "Foo";
|
||||
>z : string
|
||||
>"Foo" : string
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
// @target:es6
|
||||
export default class {
|
||||
static z: string = "Foo";
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user