Address CR feedback

This commit is contained in:
Anders Hejlsberg
2016-09-14 14:58:39 -07:00
parent 032cd32a81
commit 832295d8b0

View File

@@ -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 (<UnionOrIntersectionType>source).types) {
if (typeIdenticalToSomeType(t, (<UnionOrIntersectionType>target).types)) {
@@ -7616,8 +7618,7 @@ namespace ts {
else if (t.flags & (TypeFlags.NumberLiteral | TypeFlags.StringLiteral)) {
const b = getBaseTypeOfLiteralType(t);
if (typeIdenticalToSomeType(b, (<UnionOrIntersectionType>target).types)) {
(matchingTypes || (matchingTypes = [])).push(t);
matchingTypes.push(b);
(matchingTypes || (matchingTypes = [])).push(t, b);
}
}
}