(source, target, kind, reportErrors)
| 66606 | return result; |
| 66607 | } |
| 66608 | function signaturesRelatedTo(source, target, kind, reportErrors) { |
| 66609 | var _a, _b; |
| 66610 | if (relation === identityRelation) { |
| 66611 | return signaturesIdenticalTo(source, target, kind); |
| 66612 | } |
| 66613 | if (target === anyFunctionType || source === anyFunctionType) { |
| 66614 | return -1 /* Ternary.True */; |
| 66615 | } |
| 66616 | var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); |
| 66617 | var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); |
| 66618 | var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? |
| 66619 | 0 /* SignatureKind.Call */ : kind); |
| 66620 | var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? |
| 66621 | 0 /* SignatureKind.Call */ : kind); |
| 66622 | if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { |
| 66623 | var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); |
| 66624 | var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); |
| 66625 | if (sourceIsAbstract && !targetIsAbstract) { |
| 66626 | // An abstract constructor type is not assignable to a non-abstract constructor type |
| 66627 | // as it would otherwise be possible to new an abstract class. Note that the assignability |
| 66628 | // check we perform for an extends clause excludes construct signatures from the target, |
| 66629 | // so this check never proceeds. |
| 66630 | if (reportErrors) { |
| 66631 | reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); |
| 66632 | } |
| 66633 | return 0 /* Ternary.False */; |
| 66634 | } |
| 66635 | if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { |
| 66636 | return 0 /* Ternary.False */; |
| 66637 | } |
| 66638 | } |
| 66639 | var result = -1 /* Ternary.True */; |
| 66640 | var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; |
| 66641 | var sourceObjectFlags = ts.getObjectFlags(source); |
| 66642 | var targetObjectFlags = ts.getObjectFlags(target); |
| 66643 | if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || |
| 66644 | sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { |
| 66645 | // We have instantiations of the same anonymous type (which typically will be the type of a |
| 66646 | // method). Simply do a pairwise comparison of the signatures in the two signature lists instead |
| 66647 | // of the much more expensive N * M comparison matrix we explore below. We erase type parameters |
| 66648 | // as they are known to always be the same. |
| 66649 | for (var i = 0; i < targetSignatures.length; i++) { |
| 66650 | var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); |
| 66651 | if (!related) { |
| 66652 | return 0 /* Ternary.False */; |
| 66653 | } |
| 66654 | result &= related; |
| 66655 | } |
| 66656 | } |
| 66657 | else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { |
| 66658 | // For simple functions (functions with a single signature) we only erase type parameters for |
| 66659 | // the comparable relation. Otherwise, if the source signature is generic, we instantiate it |
| 66660 | // in the context of the target signature before checking the relationship. Ideally we'd do |
| 66661 | // this regardless of the number of signatures, but the potential costs are prohibitive due |
| 66662 | // to the quadratic nature of the logic below. |
| 66663 | var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; |
| 66664 | var sourceSignature = ts.first(sourceSignatures); |
| 66665 | var targetSignature = ts.first(targetSignatures); |
no test coverage detected