Skip to content

Commit 47e5569

Browse files
committed
Update LKG
1 parent 9ada915 commit 47e5569

File tree

5 files changed

+35
-94
lines changed

5 files changed

+35
-94
lines changed

lib/tsc.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27271,9 +27271,9 @@ var ts;
2727127271
return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
2727227272
}
2727327273
function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
27274-
return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
27274+
return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
2727527275
}
27276-
function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
27276+
function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
2727727277
if (source === target) {
2727827278
return -1;
2727927279
}
@@ -27304,15 +27304,9 @@ var ts;
2730427304
var sourceParams = source.parameters;
2730527305
var targetParams = target.parameters;
2730627306
for (var i = 0; i < checkCount; i++) {
27307-
var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
27308-
var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
27309-
var sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
27310-
var targetSig = getSingleCallSignature(getNonNullableType(targetType));
27311-
var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
27312-
(getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144);
27313-
var related = callbacks ?
27314-
compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) :
27315-
!checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
27307+
var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
27308+
var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
27309+
var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors);
2731627310
if (!related) {
2731727311
if (reportErrors) {
2731827312
errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name);
@@ -27339,8 +27333,7 @@ var ts;
2733927333
}
2734027334
}
2734127335
else {
27342-
result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) ||
27343-
compareTypes(sourceReturnType, targetReturnType, reportErrors);
27336+
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
2734427337
}
2734527338
}
2734627339
return result;
@@ -28155,7 +28148,7 @@ var ts;
2815528148
return result;
2815628149
}
2815728150
function signatureRelatedTo(source, target, reportErrors) {
28158-
return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo);
28151+
return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo);
2815928152
}
2816028153
function signaturesIdenticalTo(source, target, kind) {
2816128154
var sourceSignatures = getSignaturesOfType(source, kind);

lib/tsserver.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28433,9 +28433,9 @@ var ts;
2843328433
return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
2843428434
}
2843528435
function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
28436-
return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
28436+
return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
2843728437
}
28438-
function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
28438+
function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
2843928439
if (source === target) {
2844028440
return -1;
2844128441
}
@@ -28466,15 +28466,9 @@ var ts;
2846628466
var sourceParams = source.parameters;
2846728467
var targetParams = target.parameters;
2846828468
for (var i = 0; i < checkCount; i++) {
28469-
var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
28470-
var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
28471-
var sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
28472-
var targetSig = getSingleCallSignature(getNonNullableType(targetType));
28473-
var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
28474-
(getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144);
28475-
var related = callbacks ?
28476-
compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) :
28477-
!checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
28469+
var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
28470+
var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
28471+
var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors);
2847828472
if (!related) {
2847928473
if (reportErrors) {
2848028474
errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name);
@@ -28501,8 +28495,7 @@ var ts;
2850128495
}
2850228496
}
2850328497
else {
28504-
result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) ||
28505-
compareTypes(sourceReturnType, targetReturnType, reportErrors);
28498+
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
2850628499
}
2850728500
}
2850828501
return result;
@@ -29317,7 +29310,7 @@ var ts;
2931729310
return result;
2931829311
}
2931929312
function signatureRelatedTo(source, target, reportErrors) {
29320-
return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo);
29313+
return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo);
2932129314
}
2932229315
function signaturesIdenticalTo(source, target, kind) {
2932329316
var sourceSignatures = getSignaturesOfType(source, kind);

lib/tsserverlibrary.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29779,9 +29779,9 @@ var ts;
2977929779
return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
2978029780
}
2978129781
function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
29782-
return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
29782+
return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0;
2978329783
}
29784-
function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
29784+
function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) {
2978529785
if (source === target) {
2978629786
return -1;
2978729787
}
@@ -29812,15 +29812,9 @@ var ts;
2981229812
var sourceParams = source.parameters;
2981329813
var targetParams = target.parameters;
2981429814
for (var i = 0; i < checkCount; i++) {
29815-
var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
29816-
var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
29817-
var sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
29818-
var targetSig = getSingleCallSignature(getNonNullableType(targetType));
29819-
var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
29820-
(getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144);
29821-
var related = callbacks ?
29822-
compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) :
29823-
!checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
29815+
var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
29816+
var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
29817+
var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors);
2982429818
if (!related) {
2982529819
if (reportErrors) {
2982629820
errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name);
@@ -29847,8 +29841,7 @@ var ts;
2984729841
}
2984829842
}
2984929843
else {
29850-
result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) ||
29851-
compareTypes(sourceReturnType, targetReturnType, reportErrors);
29844+
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
2985229845
}
2985329846
}
2985429847
return result;
@@ -30663,7 +30656,7 @@ var ts;
3066330656
return result;
3066430657
}
3066530658
function signatureRelatedTo(source, target, reportErrors) {
30666-
return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo);
30659+
return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo);
3066730660
}
3066830661
function signaturesIdenticalTo(source, target, kind) {
3066930662
var sourceSignatures = getSignaturesOfType(source, kind);

lib/typescript.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)