Merge pull request #17922 from Microsoft/baseExpressionTypeParameters

Class type parameters not in scope in base class expression
This commit is contained in:
Anders Hejlsberg
2017-08-22 07:14:54 +01:00
committed by GitHub
8 changed files with 106 additions and 9 deletions
+12 -1
View File
@@ -1016,7 +1016,18 @@ namespace ts {
}
}
break;
case SyntaxKind.ExpressionWithTypeArguments:
// The type parameters of a class are not in scope in the base class expression.
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