mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Merge pull request #4501 from Microsoft/checkClassExpressions
Properly check expressions in class extends clause
This commit is contained in:
@@ -12614,6 +12614,7 @@ namespace ts {
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
let baseType = baseTypes[0];
|
||||
let staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
|
||||
@@ -13683,6 +13684,8 @@ namespace ts {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.VariableDeclarationList:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.HeritageClause:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ====
|
||||
class George extends class { reset() { return this.y; } } {
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [missingPropertiesOfClassExpression.ts]
|
||||
class George extends class { reset() { return this.y; } } {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [missingPropertiesOfClassExpression.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var George = (function (_super) {
|
||||
__extends(George, _super);
|
||||
function George() {
|
||||
_super.call(this);
|
||||
}
|
||||
return George;
|
||||
})((function () {
|
||||
function class_1() {
|
||||
}
|
||||
class_1.prototype.reset = function () { return this.y; };
|
||||
return class_1;
|
||||
})());
|
||||
@@ -0,0 +1,5 @@
|
||||
class George extends class { reset() { return this.y; } } {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user