diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1c3a88c85e..26b94358f36 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4961,6 +4961,10 @@ namespace ts { // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; links.resolvedType = type; + + if (noUnusedIdentifiers && symbol !== unknownSymbol && !isInAmbientContext(node)) { + symbol.hasReference = true; + } } return links.resolvedType; } @@ -8321,16 +8325,6 @@ namespace ts { return container === declarationContainer; } - function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void { - const extendedTypeNode = getClassExtendsHeritageClauseElement(node); - if (extendedTypeNode) { - const t = getTypeFromTypeNode(extendedTypeNode); - if (t !== unknownType && t.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { - t.symbol.hasReference = true; - } - } - } - function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { @@ -13620,9 +13614,6 @@ namespace ts { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); if (type !== unknownType) { - if (type.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { - type.symbol.hasReference = true; - } if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved forEach(node.typeArguments, checkSourceElement); @@ -16099,7 +16090,6 @@ namespace ts { if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); - updateReferencesForInterfaceHeritiageClauseTargets(node); checkUnusedTypeParameters(node); } }