Skip to content

Commit ff17eed

Browse files
vladimamhegazy
authored andcommitted
check heritage clause for the presence of entry with Extends keyword (microsoft#11711)
1 parent 85248bb commit ff17eed

5 files changed

Lines changed: 69 additions & 1 deletion

File tree

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ namespace ts {
795795
function visitClassExpression(node: ClassExpression): Expression {
796796
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
797797
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
798-
const members = transformClassMembers(node, heritageClauses !== undefined);
798+
const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword));
799799

800800
const classExpression = setOriginalNode(
801801
createClassExpression(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//// [classExpressions.ts]
2+
interface A {}
3+
let x = class B implements A {
4+
prop: number;
5+
onStart(): void {
6+
}
7+
func = () => {
8+
}
9+
};
10+
11+
//// [classExpressions.js]
12+
var x = (function () {
13+
function B() {
14+
this.func = function () {
15+
};
16+
}
17+
B.prototype.onStart = function () {
18+
};
19+
return B;
20+
}());
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/classExpressions.ts ===
2+
interface A {}
3+
>A : Symbol(A, Decl(classExpressions.ts, 0, 0))
4+
5+
let x = class B implements A {
6+
>x : Symbol(x, Decl(classExpressions.ts, 1, 3))
7+
>B : Symbol(B, Decl(classExpressions.ts, 1, 7))
8+
>A : Symbol(A, Decl(classExpressions.ts, 0, 0))
9+
10+
prop: number;
11+
>prop : Symbol(B.prop, Decl(classExpressions.ts, 1, 30))
12+
13+
onStart(): void {
14+
>onStart : Symbol(B.onStart, Decl(classExpressions.ts, 2, 17))
15+
}
16+
func = () => {
17+
>func : Symbol(B.func, Decl(classExpressions.ts, 4, 5))
18+
}
19+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/classExpressions.ts ===
2+
interface A {}
3+
>A : A
4+
5+
let x = class B implements A {
6+
>x : typeof B
7+
>class B implements A { prop: number; onStart(): void { } func = () => { }} : typeof B
8+
>B : typeof B
9+
>A : A
10+
11+
prop: number;
12+
>prop : number
13+
14+
onStart(): void {
15+
>onStart : () => void
16+
}
17+
func = () => {
18+
>func : () => void
19+
>() => { } : () => void
20+
}
21+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
interface A {}
2+
let x = class B implements A {
3+
prop: number;
4+
onStart(): void {
5+
}
6+
func = () => {
7+
}
8+
};

0 commit comments

Comments
 (0)