File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -9415,7 +9415,16 @@ namespace ts {
9415
9415
// with a structural comparison. Otherwise, we know for certain the instantiations aren't
9416
9416
// related and we can return here.
9417
9417
if (variances !== emptyArray && !hasCovariantVoidArgument(<TypeReference>target, variances)) {
9418
- return Ternary.False;
9418
+ // In some cases generic types that are covariant in regular type checking mode become
9419
+ // invariant in --strictFunctionTypes mode because one or more type parameters are used in
9420
+ // both co- and contravariant positions. In order to make it easier to diagnose *why* such
9421
+ // types are invariant, if any of the type parameters are invariant we reset the reported
9422
+ // errors and instead force a structural comparison (which will include elaborations that
9423
+ // reveal the reason).
9424
+ if (!(reportErrors && some(variances, v => v === Variance.Invariant))) {
9425
+ return Ternary.False;
9426
+ }
9427
+ errorInfo = saveErrorInfo;
9419
9428
}
9420
9429
}
9421
9430
// Even if relationship doesn't hold for unions, intersections, or generic type references,
You can’t perform that action at this time.
0 commit comments