Merge pull request #21744 from Microsoft/fixGetConstrainedTypeParameter

Fix getConstrainedTypeParameter function
This commit is contained in:
Anders Hejlsberg
2018-02-07 16:37:10 -08:00
committed by GitHub
7 changed files with 58 additions and 2 deletions
+1 -1
View File
@@ -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 === (<ConditionalTypeNode>parent).trueType) {
if (getTypeFromTypeNode((<ConditionalTypeNode>parent).checkType) === typeParameter) {
+2
View File
@@ -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