Remove unnecessary getContainingClass
calls (#26753)
This commit is contained in:
parent
cea49dfb0d
commit
d37caf1c0d
|
@ -27344,12 +27344,10 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPartOfTypeNode(node)) {
|
if (isPartOfTypeNode(node)) {
|
||||||
let typeFromTypeNode = getTypeFromTypeNode(<TypeNode>node);
|
const typeFromTypeNode = getTypeFromTypeNode(<TypeNode>node);
|
||||||
|
|
||||||
if (isExpressionWithTypeArgumentsInClassImplementsClause(node)) {
|
if (isExpressionWithTypeArgumentsInClassImplementsClause(node)) {
|
||||||
const containingClass = getContainingClass(node)!;
|
return getTypeWithThisArgument(typeFromTypeNode, getTypeOfClassContainingHeritageClause(node).thisType);
|
||||||
const classType = getTypeOfNode(containingClass) as InterfaceType;
|
|
||||||
typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeFromTypeNode;
|
return typeFromTypeNode;
|
||||||
|
@ -27362,8 +27360,7 @@ namespace ts {
|
||||||
if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) {
|
if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) {
|
||||||
// A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
|
// A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
|
||||||
// extends clause of a class. We handle that case here.
|
// extends clause of a class. We handle that case here.
|
||||||
const classNode = getContainingClass(node)!;
|
const classType = getTypeOfClassContainingHeritageClause(node);
|
||||||
const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType;
|
|
||||||
const baseType = firstOrUndefined(getBaseTypes(classType));
|
const baseType = firstOrUndefined(getBaseTypes(classType));
|
||||||
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
||||||
}
|
}
|
||||||
|
@ -27405,6 +27402,10 @@ namespace ts {
|
||||||
return errorType;
|
return errorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTypeOfClassContainingHeritageClause(node: ExpressionWithTypeArguments): InterfaceType {
|
||||||
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node.parent.parent));
|
||||||
|
}
|
||||||
|
|
||||||
// Gets the type of object literal or array literal of destructuring assignment.
|
// Gets the type of object literal or array literal of destructuring assignment.
|
||||||
// { a } from
|
// { a } from
|
||||||
// for ( { a } of elems) {
|
// for ( { a } of elems) {
|
||||||
|
|
|
@ -3743,7 +3743,7 @@ namespace ts {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): node is ExpressionWithTypeArguments {
|
||||||
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue