Skip to content

Commit 38962ee

Browse files
use resolveEntityName to find interface
1 parent c721b5f commit 38962ee

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

src/compiler/checker.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -939,29 +939,26 @@ namespace ts {
939939

940940

941941
function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean {
942-
const container = getContainingClass(errorLocation);
943-
const heritageClause = <HeritageClause>getAncestor(errorLocation, SyntaxKind.HeritageClause);
944-
if (!container || !heritageClause || heritageClause.token !== SyntaxKind.ExtendsKeyword) {
945-
return false;
946-
}
947-
if (errorLocation.kind === SyntaxKind.Identifier) {
948-
const name = (<Identifier>errorLocation).text;
949-
const interfaceOrModule = resolveName(
950-
errorLocation, name,
951-
SymbolFlags.Interface | SymbolFlags.HasExports,
952-
/*errorMessage*/ undefined, /*nameArg*/ undefined)
953-
if (!interfaceOrModule) {
954-
return false;
942+
let parentClassExpression = errorLocation;
943+
while (parentClassExpression) {
944+
const kind = parentClassExpression.kind;
945+
if (kind === SyntaxKind.Identifier || kind === SyntaxKind.PropertyAccessExpression) {
946+
parentClassExpression = parentClassExpression.parent;
947+
continue;
955948
}
956-
if (interfaceOrModule.flags & SymbolFlags.Interface) {
957-
error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, name);
958-
return true;
949+
if (kind === SyntaxKind.ExpressionWithTypeArguments) {
950+
break;
959951
}
952+
return false;
960953
}
961-
else if (errorLocation.kind === SyntaxKind.PropertyAccessExpression) {
962-
// todo
954+
if (!parentClassExpression) {
955+
return false;
956+
}
957+
const expression = (<ExpressionWithTypeArguments>parentClassExpression).expression;
958+
if (resolveEntityName(expression, SymbolFlags.Interface, true)) {
959+
error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression));
960+
return true;
963961
}
964-
965962
return false;
966963
}
967964

0 commit comments

Comments
 (0)