Check for type parameters on the original type when asking for the type argument constraint.

This commit is contained in:
Daniel Rosenwasser
2021-11-01 09:17:03 +00:00
committed by GitHub
parent e77514a53b
commit 3c0d51b3ed
+2 -1
View File
@@ -34729,7 +34729,8 @@ namespace ts {
function getTypeArgumentConstraint(node: TypeNode): Type | undefined {
const typeReferenceNode = tryCast(node.parent, isTypeReferenceType);
if (!typeReferenceNode) return undefined;
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode)!; // TODO: GH#18217
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
if (!typeParameters) return undefined;
const constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments!.indexOf(node)]);
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
}