@@ -5408,11 +5408,11 @@ namespace ts {
5408
5408
inferFromTypes(sourceTypes[i], targetTypes[i]);
5409
5409
}
5410
5410
}
5411
- else if (target.flags & TypeFlags.Union ) {
5412
- let targetTypes = (<UnionType >target).types;
5411
+ else if (target.flags & TypeFlags.UnionOrIntersection ) {
5412
+ let targetTypes = (<UnionOrIntersectionType >target).types;
5413
5413
let typeParameterCount = 0;
5414
5414
let typeParameter: TypeParameter;
5415
- // First infer to each type in union that isn't a type parameter
5415
+ // First infer to each type in union or intersection that isn't a type parameter
5416
5416
for (let t of targetTypes) {
5417
5417
if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) {
5418
5418
typeParameter = <TypeParameter>t;
@@ -5422,8 +5422,9 @@ namespace ts {
5422
5422
inferFromTypes(source, t);
5423
5423
}
5424
5424
}
5425
- // If union contains a single naked type parameter, make a secondary inference to that type parameter
5426
- if (typeParameterCount === 1) {
5425
+ // Next, if target is a union type containing a single naked type parameter, make a
5426
+ // secondary inference to that type parameter
5427
+ if (target.flags & TypeFlags.Union && typeParameterCount === 1) {
5427
5428
inferiority++;
5428
5429
inferFromTypes(source, typeParameter);
5429
5430
inferiority--;
0 commit comments