Type parameters from class should not be in scope in base class expression

This commit is contained in:
Anders Hejlsberg
2017-08-18 11:00:46 +02:00
parent 80a7ed9a42
commit fa6773e685
2 changed files with 15 additions and 1 deletions
+11 -1
View File
@@ -1016,7 +1016,17 @@ namespace ts {
}
}
break;
case SyntaxKind.ExpressionWithTypeArguments:
if (lastLocation === (<ExpressionWithTypeArguments>location).expression && (<HeritageClause>location.parent).token === SyntaxKind.ExtendsKeyword) {
const container = location.parent.parent;
if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & SymbolFlags.Type))) {
if (nameNotFoundMessage) {
error(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
}
return undefined;
}
}
break;
// It is not legal to reference a class's own type parameters from a computed property name that
// belongs to the class. For example:
//
+4
View File
@@ -1912,6 +1912,10 @@
"category": "Error",
"code": 2560
},
"Base class expressions cannot reference class type parameters.": {
"category": "Error",
"code": 2561
},
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600