(source, target, reportErrors, intersectionState)
| 65378 | return target; |
| 65379 | } |
| 65380 | function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { |
| 65381 | var result = -1 /* Ternary.True */; |
| 65382 | var sourceTypes = source.types; |
| 65383 | // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath |
| 65384 | // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence |
| 65385 | var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); |
| 65386 | for (var i = 0; i < sourceTypes.length; i++) { |
| 65387 | var sourceType = sourceTypes[i]; |
| 65388 | if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { |
| 65389 | // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison |
| 65390 | // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large |
| 65391 | // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, |
| 65392 | // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` |
| 65393 | // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union |
| 65394 | var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); |
| 65395 | if (related_1) { |
| 65396 | result &= related_1; |
| 65397 | continue; |
| 65398 | } |
| 65399 | } |
| 65400 | var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); |
| 65401 | if (!related) { |
| 65402 | return 0 /* Ternary.False */; |
| 65403 | } |
| 65404 | result &= related; |
| 65405 | } |
| 65406 | return result; |
| 65407 | } |
| 65408 | function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) { |
| 65409 | if (sources === void 0) { sources = ts.emptyArray; } |
| 65410 | if (targets === void 0) { targets = ts.emptyArray; } |
no test coverage detected
searching dependent graphs…