From 22cbfe3b1b70d44b1647a7cecaeb5e84ca247b47 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 7 Feb 2018 14:48:13 -0800 Subject: [PATCH] Fix getConstrainedTypeParameter function --- src/compiler/checker.ts | 2 +- src/compiler/utilities.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7cfa484118e..a10bfe1d18c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7245,7 +7245,7 @@ namespace ts { function getConstrainedTypeParameter(typeParameter: TypeParameter, node: Node) { let constraints: Type[]; - while (isTypeNode(node)) { + while (isPartOfTypeNode(node)) { const parent = node.parent; if (parent.kind === SyntaxKind.ConditionalType && node === (parent).trueType) { if (getTypeFromTypeNode((parent).checkType) === typeParameter) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 388ce814cc3..3c76bcf3119 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -771,6 +771,8 @@ namespace ts { return node.parent.kind !== SyntaxKind.VoidExpression; case SyntaxKind.ExpressionWithTypeArguments: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case SyntaxKind.TypeParameter: + return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container