From 3c0d51b3edc393c79071e1adff6767981e7f9424 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 1 Nov 2021 09:17:03 +0000 Subject: [PATCH] Check for type parameters on the original type when asking for the type argument constraint. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7dddeaac50788..9a8e9eb1ee868 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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))); }