File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -9415,7 +9415,16 @@ namespace ts {
94159415 // with a structural comparison. Otherwise, we know for certain the instantiations aren't
94169416 // related and we can return here.
94179417 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;
94199428 }
94209429 }
94219430 // 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