@@ -664,7 +664,7 @@ namespace ts {
664664 // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
665665 // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
666666 // 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 {
668668 let result: Symbol;
669669 let lastLocation: Node;
670670 let propertyWithInvalidInitializer: Node;
@@ -881,7 +881,8 @@ namespace ts {
881881
882882 if (!result) {
883883 if (nameNotFoundMessage) {
884- if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
884+ if (!errorLocation ||
885+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
885886 !checkAndReportErrorForExtendingInterface(errorLocation)) {
886887 error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
887888 }
@@ -930,7 +931,7 @@ namespace ts {
930931 }
931932
932933 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))) {
934935 return false;
935936 }
936937
@@ -980,23 +981,15 @@ namespace ts {
980981 * but returns undefined if that expression is not an EntityNameExpression.
981982 */
982983 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;
1000993 }
1001994 }
1002995
0 commit comments