@@ -664,7 +664,7 @@ namespace ts {
664
664
// Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
665
665
// the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
666
666
// the given name can be found.
667
- function resolveName(location: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol {
667
+ function resolveName(location: Node | undefined , name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol {
668
668
let result: Symbol;
669
669
let lastLocation: Node;
670
670
let propertyWithInvalidInitializer: Node;
@@ -881,7 +881,8 @@ namespace ts {
881
881
882
882
if (!result) {
883
883
if (nameNotFoundMessage) {
884
- if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
884
+ if (!errorLocation ||
885
+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
885
886
!checkAndReportErrorForExtendingInterface(errorLocation)) {
886
887
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
887
888
}
@@ -930,7 +931,7 @@ namespace ts {
930
931
}
931
932
932
933
function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean {
933
- if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(<Identifier>errorLocation)) || isInTypeQuery(errorLocation))) {
934
+ if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(<Identifier>errorLocation)) || isInTypeQuery(errorLocation))) {
934
935
return false;
935
936
}
936
937
@@ -980,23 +981,15 @@ namespace ts {
980
981
* but returns undefined if that expression is not an EntityNameExpression.
981
982
*/
982
983
function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined {
983
- for (; ; ) {
984
- switch (node.kind) {
985
- case SyntaxKind.Identifier:
986
- case SyntaxKind.PropertyAccessExpression:
987
- if (node.parent) {
988
- node = node.parent;
989
- }
990
- else {
991
- return undefined;
992
- }
993
- break;
994
- case SyntaxKind.ExpressionWithTypeArguments:
995
- Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
996
- return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
997
- default:
998
- return undefined;
999
- }
984
+ switch (node.kind) {
985
+ case SyntaxKind.Identifier:
986
+ case SyntaxKind.PropertyAccessExpression:
987
+ return node.parent ? climbToEntityNameOfExpressionWithTypeArguments(node.parent) : undefined;
988
+ case SyntaxKind.ExpressionWithTypeArguments:
989
+ Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
990
+ return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression
991
+ default:
992
+ return undefined;
1000
993
}
1001
994
}
1002
995
0 commit comments