Skip to content

Commit e86512e

Browse files
committed
Revert "Allow callbacks unioned with null and/or undefined"
This reverts commit ec35b80.
1 parent 22647bb commit e86512e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8233,8 +8233,8 @@ namespace ts {
82338233
for (let i = 0; i < checkCount; i++) {
82348234
const sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
82358235
const targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
8236-
const sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
8237-
const targetSig = getSingleCallSignature(getNonNullableType(targetType));
8236+
const sourceSig = getSingleCallSignature(sourceType);
8237+
const targetSig = getSingleCallSignature(targetType);
82388238
// In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
82398239
// how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
82408240
// they naturally relate only contra-variantly). However, if the source and target parameters both have
@@ -8243,9 +8243,7 @@ namespace ts {
82438243
// similar to return values, callback parameters are output positions. This means that a Promise<T>,
82448244
// where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant)
82458245
// with respect to T.
8246-
const callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
8247-
(getFalsyFlags(sourceType) & TypeFlags.Nullable) === (getFalsyFlags(targetType) & TypeFlags.Nullable);
8248-
const related = callbacks ?
8246+
const related = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate ?
82498247
compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) :
82508248
!checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
82518249
if (!related) {

0 commit comments

Comments
 (0)