mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 17:27:54 -05:00
instantiate generic this param correctly
This commit is contained in:
@@ -21106,7 +21106,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isPartOfTypeNode(node)) {
|
||||
return getTypeFromTypeNode(<TypeNode>node);
|
||||
let typeFromTypeNode = getTypeFromTypeNode(<TypeNode>node);
|
||||
|
||||
if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) {
|
||||
const containingClass = getContainingClass(node);
|
||||
const classType = getTypeOfNode(containingClass) as InterfaceType;
|
||||
typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType);
|
||||
}
|
||||
|
||||
return typeFromTypeNode;
|
||||
}
|
||||
|
||||
if (isPartOfExpression(node)) {
|
||||
@@ -21116,7 +21124,10 @@ namespace ts {
|
||||
if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) {
|
||||
// A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
|
||||
// extends clause of a class. We handle that case here.
|
||||
return getBaseTypes(<InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0];
|
||||
const classNode = getContainingClass(node);
|
||||
const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; classType;
|
||||
const baseType = getBaseTypes(classType)[0]; baseType;
|
||||
return baseType && getTypeWithThisArgument(baseType, classType.thisType);
|
||||
}
|
||||
|
||||
if (isTypeDeclaration(node)) {
|
||||
|
||||
@@ -3126,6 +3126,14 @@ namespace ts {
|
||||
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionWithTypeArguments
|
||||
&& node.parent
|
||||
&& (<HeritageClause>node.parent).token === SyntaxKind.ImplementsKeyword
|
||||
&& node.parent.parent
|
||||
&& isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
export function isEntityNameExpression(node: Expression): node is EntityNameExpression {
|
||||
return node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((<PropertyAccessExpression>node).expression);
|
||||
|
||||
Reference in New Issue
Block a user