diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb6fa4240a4..5a7c6fa29e5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7158,11 +7158,10 @@ namespace ts { inferFromTypes(source, t); } } - // Next, if target is a union type containing a single naked type parameter, make a - // secondary inference to that type parameter. We don't do this for intersection types - // because in a target type like Foo & T we don't know how which parts of the source type - // should be matched by Foo and which should be inferred to T. - if (target.flags & TypeFlags.Union && typeParameterCount === 1) { + // Next, if target containings a single naked type parameter, make a secondary inference to that type + // parameter. This gives meaningful results for union types in co-variant positions and intersection + // types in contra-variant positions (such as callback parameters). + if (typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--;