Skip to content

Commit fa6773e

Browse files
committed
Type parameters from class should not be in scope in base class expression
1 parent 80a7ed9 commit fa6773e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,17 @@ namespace ts {
10161016
}
10171017
}
10181018
break;
1019-
1019+
case SyntaxKind.ExpressionWithTypeArguments:
1020+
if (lastLocation === (<ExpressionWithTypeArguments>location).expression && (<HeritageClause>location.parent).token === SyntaxKind.ExtendsKeyword) {
1021+
const container = location.parent.parent;
1022+
if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & SymbolFlags.Type))) {
1023+
if (nameNotFoundMessage) {
1024+
error(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
1025+
}
1026+
return undefined;
1027+
}
1028+
}
1029+
break;
10201030
// It is not legal to reference a class's own type parameters from a computed property name that
10211031
// belongs to the class. For example:
10221032
//

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,10 @@
19121912
"category": "Error",
19131913
"code": 2560
19141914
},
1915+
"Base class expressions cannot reference class type parameters.": {
1916+
"category": "Error",
1917+
"code": 2561
1918+
},
19151919
"JSX element attributes type '{0}' may not be a union type.": {
19161920
"category": "Error",
19171921
"code": 2600

0 commit comments

Comments
 (0)