Consolidate type reference marking in getTypeFromTypeReference

This commit is contained in:
Mohamed Hegazy
2016-06-29 14:07:42 -07:00
parent 62f47fe995
commit d4513c8aff

View File

@@ -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);
}
}