From 832295d8b03f63b3879eb7329195f4dd09d22906 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 14 Sep 2016 14:58:39 -0700 Subject: [PATCH] Address CR feedback --- src/compiler/checker.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 001e300bbc7..080637363ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7603,10 +7603,12 @@ namespace ts { } return; } - // Find each target constituent type that has an identically matching source - // constituent type, and for each such target constituent type infer from the type to - // itself. When inferring from a type to itself we effectively find all type parameter - // occurrences within that type and infer themselves as their type arguments. + // Find each source constituent type that has an identically matching target constituent + // type, and for each such type infer from the type to itself. When inferring from a + // type to itself we effectively find all type parameter occurrences within that type + // and infer themselves as their type arguments. We have special handling for numeric + // and string literals because the number and string types are not represented as unions + // of all their possible values. let matchingTypes: Type[]; for (const t of (source).types) { if (typeIdenticalToSomeType(t, (target).types)) { @@ -7616,8 +7618,7 @@ namespace ts { else if (t.flags & (TypeFlags.NumberLiteral | TypeFlags.StringLiteral)) { const b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, (target).types)) { - (matchingTypes || (matchingTypes = [])).push(t); - matchingTypes.push(b); + (matchingTypes || (matchingTypes = [])).push(t, b); } } }