check heritage clause for the presence of entry with Extends keyword (#11711)

This commit is contained in:
Vladimir Matveev
2016-10-18 11:35:22 -07:00
committed by Mohamed Hegazy
parent 85248bb58d
commit ff17eeda8f
5 changed files with 69 additions and 1 deletions

View File

@@ -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(

View File

@@ -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;
}());

View File

@@ -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))
}
};

View File

@@ -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
}
};

View File

@@ -0,0 +1,8 @@
interface A {}
let x = class B implements A {
prop: number;
onStart(): void {
}
func = () => {
}
};