mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Update resolveEntityName to check for non entity name in property access expression
This commit is contained in:
@@ -1493,9 +1493,23 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (name.kind === SyntaxKind.QualifiedName || name.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const left = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).left : (<PropertyAccessEntityNameExpression>name).expression;
|
||||
const right = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).right : (<PropertyAccessExpression>name).name;
|
||||
let left: EntityNameOrEntityNameExpression;
|
||||
|
||||
if (name.kind === SyntaxKind.QualifiedName) {
|
||||
left = (<QualifiedName>name).left;
|
||||
}
|
||||
else if (name.kind === SyntaxKind.PropertyAccessExpression &&
|
||||
(name.expression.kind === SyntaxKind.ParenthesizedExpression || isEntityNameExpression(name.expression))) {
|
||||
left = name.expression;
|
||||
}
|
||||
else {
|
||||
// If the expression in property-access expression is not entity-name or parenthsizedExpression (e.g. it is a call expression), it won't be able to successfully resolve the name.
|
||||
// This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression
|
||||
// will attempt to checkPropertyAccessExpression to resolve symbol.
|
||||
// i.e class C extends foo()./*do language service operation here*/B {}
|
||||
return undefined;
|
||||
}
|
||||
const right = name.kind === SyntaxKind.QualifiedName ? name.right : name.name;
|
||||
const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors, /*dontResolveAlias*/ false, location);
|
||||
if (!namespace || nodeIsMissing(right)) {
|
||||
return undefined;
|
||||
@@ -1512,7 +1526,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (name.kind === SyntaxKind.ParenthesizedExpression) {
|
||||
return getSymbolOfNode(name.expression);
|
||||
// If the expression in parenthsizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.
|
||||
// This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression
|
||||
// will attempt to checkPropertyAccessExpression to resolve symbol.
|
||||
// i.e class C extends foo()./*do language service operation here*/B {}
|
||||
return isEntityNameExpression(name.expression) ?
|
||||
resolveEntityName(name.expression as EntityNameOrEntityNameExpression, meaning, ignoreErrors, dontResolveAlias, location) :
|
||||
undefined;
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unknown entity name kind.");
|
||||
@@ -21091,7 +21111,7 @@ namespace ts {
|
||||
return entityNameSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isPartOfExpression(entityName)) {
|
||||
if (nodeIsMissing(entityName)) {
|
||||
// Missing entity name.
|
||||
|
||||
Reference in New Issue
Block a user