@@ -32880,13 +32880,12 @@ var ts;
3288032880 return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
3288132881 }
3288232882 function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
32883- return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, ignoreReturnTypes, /*reportErrors*/ false,
32884- /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */;
32883+ return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */;
3288532884 }
3288632885 /**
3288732886 * See signatureRelatedTo, compareSignaturesIdentical
3288832887 */
32889- function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
32888+ function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
3289032889 // TODO (drosen): De-duplicate code between related functions.
3289132890 if (source === target) {
3289232891 return -1 /* True */;
@@ -32921,23 +32920,9 @@ var ts;
3292132920 var sourceParams = source.parameters;
3292232921 var targetParams = target.parameters;
3292332922 for (var i = 0; i < checkCount; i++) {
32924- var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
32925- var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
32926- var sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
32927- var targetSig = getSingleCallSignature(getNonNullableType(targetType));
32928- // In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
32929- // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
32930- // they naturally relate only contra-variantly). However, if the source and target parameters both have
32931- // function types with a single call signature, we known we are relating two callback parameters. In
32932- // that case it is sufficient to only relate the parameters of the signatures co-variantly because,
32933- // similar to return values, callback parameters are output positions. This means that a Promise<T>,
32934- // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant)
32935- // with respect to T.
32936- var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
32937- (getFalsyFlags(sourceType) & 6144 /* Nullable */) === (getFalsyFlags(targetType) & 6144 /* Nullable */);
32938- var related = callbacks ?
32939- compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) :
32940- !checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
32923+ var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
32924+ var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
32925+ var related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors);
3294132926 if (!related) {
3294232927 if (reportErrors) {
3294332928 errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name);
@@ -32965,11 +32950,7 @@ var ts;
3296532950 }
3296632951 }
3296732952 else {
32968- // When relating callback signatures, we still need to relate return types bi-variantly as otherwise
32969- // the containing type wouldn't be co-variant. For example, interface Foo<T> { add(cb: () => T): void }
32970- // wouldn't be co-variant for T without this rule.
32971- result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) ||
32972- compareTypes(sourceReturnType, targetReturnType, reportErrors);
32953+ result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
3297332954 }
3297432955 }
3297532956 return result;
@@ -33888,7 +33869,7 @@ var ts;
3388833869 * See signatureAssignableTo, compareSignaturesIdentical
3388933870 */
3389033871 function signatureRelatedTo(source, target, reportErrors) {
33891- return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, /* ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
33872+ return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
3389233873 }
3389333874 function signaturesIdenticalTo(source, target, kind) {
3389433875 var sourceSignatures = getSignaturesOfType(source, kind);
0 commit comments