File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -7608,11 +7608,18 @@ namespace ts {
7608
7608
// itself. When inferring from a type to itself we effectively find all type parameter
7609
7609
// occurrences within that type and infer themselves as their type arguments.
7610
7610
let matchingTypes: Type[];
7611
- for (const t of (<UnionOrIntersectionType>target ).types) {
7612
- if (typeIdenticalToSomeType(t, (<UnionOrIntersectionType>source ).types)) {
7611
+ for (const t of (<UnionOrIntersectionType>source ).types) {
7612
+ if (typeIdenticalToSomeType(t, (<UnionOrIntersectionType>target ).types)) {
7613
7613
(matchingTypes || (matchingTypes = [])).push(t);
7614
7614
inferFromTypes(t, t);
7615
7615
}
7616
+ else if (t.flags & (TypeFlags.NumberLiteral | TypeFlags.StringLiteral)) {
7617
+ const b = getBaseTypeOfLiteralType(t);
7618
+ if (typeIdenticalToSomeType(b, (<UnionOrIntersectionType>target).types)) {
7619
+ (matchingTypes || (matchingTypes = [])).push(t);
7620
+ matchingTypes.push(b);
7621
+ }
7622
+ }
7616
7623
}
7617
7624
// Next, to improve the quality of inferences, reduce the source and target types by
7618
7625
// removing the identically matched constituents. For example, when inferring from
You can’t perform that action at this time.
0 commit comments