diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 1d930c3c21e..a1190efee10 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -795,7 +795,7 @@ namespace ts { function visitClassExpression(node: ClassExpression): Expression { const staticProperties = getInitializedProperties(node, /*isStatic*/ true); const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); - const members = transformClassMembers(node, heritageClauses !== undefined); + const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword)); const classExpression = setOriginalNode( createClassExpression( diff --git a/tests/baselines/reference/classExpressions.js b/tests/baselines/reference/classExpressions.js new file mode 100644 index 00000000000..3932fa5045b --- /dev/null +++ b/tests/baselines/reference/classExpressions.js @@ -0,0 +1,20 @@ +//// [classExpressions.ts] +interface A {} +let x = class B implements A { + prop: number; + onStart(): void { + } + func = () => { + } +}; + +//// [classExpressions.js] +var x = (function () { + function B() { + this.func = function () { + }; + } + B.prototype.onStart = function () { + }; + return B; +}()); diff --git a/tests/baselines/reference/classExpressions.symbols b/tests/baselines/reference/classExpressions.symbols new file mode 100644 index 00000000000..038b1b81116 --- /dev/null +++ b/tests/baselines/reference/classExpressions.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/classExpressions.ts === +interface A {} +>A : Symbol(A, Decl(classExpressions.ts, 0, 0)) + +let x = class B implements A { +>x : Symbol(x, Decl(classExpressions.ts, 1, 3)) +>B : Symbol(B, Decl(classExpressions.ts, 1, 7)) +>A : Symbol(A, Decl(classExpressions.ts, 0, 0)) + + prop: number; +>prop : Symbol(B.prop, Decl(classExpressions.ts, 1, 30)) + + onStart(): void { +>onStart : Symbol(B.onStart, Decl(classExpressions.ts, 2, 17)) + } + func = () => { +>func : Symbol(B.func, Decl(classExpressions.ts, 4, 5)) + } +}; diff --git a/tests/baselines/reference/classExpressions.types b/tests/baselines/reference/classExpressions.types new file mode 100644 index 00000000000..3fcff32c4a4 --- /dev/null +++ b/tests/baselines/reference/classExpressions.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/classExpressions.ts === +interface A {} +>A : A + +let x = class B implements A { +>x : typeof B +>class B implements A { prop: number; onStart(): void { } func = () => { }} : typeof B +>B : typeof B +>A : A + + prop: number; +>prop : number + + onStart(): void { +>onStart : () => void + } + func = () => { +>func : () => void +>() => { } : () => void + } +}; diff --git a/tests/cases/compiler/classExpressions.ts b/tests/cases/compiler/classExpressions.ts new file mode 100644 index 00000000000..fc7ce376469 --- /dev/null +++ b/tests/cases/compiler/classExpressions.ts @@ -0,0 +1,8 @@ +interface A {} +let x = class B implements A { + prop: number; + onStart(): void { + } + func = () => { + } +}; \ No newline at end of file