@typescript-deploys/pr-build 5.5.0-pr-57395-9 → 5.5.0-pr-57465-44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +123 -185
- package/lib/tsserver.js +123 -185
- package/lib/typescript.js +123 -185
- package/lib/typingsInstaller.js +2 -4
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240223`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -7810,9 +7810,7 @@ var Diagnostics = {
|
|
|
7810
7810
|
Compiler_option_0_cannot_be_given_an_empty_string: diag(18051, 1 /* Error */, "Compiler_option_0_cannot_be_given_an_empty_string_18051", "Compiler option '{0}' cannot be given an empty string."),
|
|
7811
7811
|
Non_abstract_class_0_does_not_implement_all_abstract_members_of_1: diag(18052, 1 /* Error */, "Non_abstract_class_0_does_not_implement_all_abstract_members_of_1_18052", "Non-abstract class '{0}' does not implement all abstract members of '{1}'"),
|
|
7812
7812
|
Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
|
|
7813
|
-
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
7814
|
-
There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1: diag(18055, 1 /* Error */, "There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signatu_18055", "There is no signature in type {0} such that its parameters are assignable to the parameters of signature {1}"),
|
|
7815
|
-
Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1: diag(18056, 1 /* Error */, "Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1_18056", "Parameters of signature {0} are not assignable to the parameters of any signature in type {1}")
|
|
7813
|
+
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
7816
7814
|
};
|
|
7817
7815
|
|
|
7818
7816
|
// src/compiler/scanner.ts
|
|
@@ -43671,8 +43669,6 @@ function createTypeChecker(host) {
|
|
|
43671
43669
|
var lastGetCombinedNodeFlagsResult = 0 /* None */;
|
|
43672
43670
|
var lastGetCombinedModifierFlagsNode;
|
|
43673
43671
|
var lastGetCombinedModifierFlagsResult = 0 /* None */;
|
|
43674
|
-
var checkTypeRelatedToDepth = 0;
|
|
43675
|
-
var checkTypeRelatedToCurrentlyVisitingMap;
|
|
43676
43672
|
const checker = {
|
|
43677
43673
|
getNodeCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.nodeCount, 0),
|
|
43678
43674
|
getIdentifierCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.identifierCount, 0),
|
|
@@ -45556,7 +45552,7 @@ function createTypeChecker(host) {
|
|
|
45556
45552
|
if (nameNotFoundMessage) {
|
|
45557
45553
|
addLazyDiagnostic(() => {
|
|
45558
45554
|
var _a2;
|
|
45559
|
-
if (
|
|
45555
|
+
if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || (meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */)) {
|
|
45560
45556
|
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
|
45561
45557
|
if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
|
|
45562
45558
|
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
|
@@ -56020,7 +56016,15 @@ function createTypeChecker(host) {
|
|
|
56020
56016
|
jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
|
|
56021
56017
|
}
|
|
56022
56018
|
}
|
|
56023
|
-
|
|
56019
|
+
if (type || jsdocPredicate) {
|
|
56020
|
+
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
56021
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType === booleanType)) {
|
|
56022
|
+
const { declaration } = signature;
|
|
56023
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
56024
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
56025
|
+
} else {
|
|
56026
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
56027
|
+
}
|
|
56024
56028
|
}
|
|
56025
56029
|
Debug.assert(!!signature.resolvedTypePredicate);
|
|
56026
56030
|
}
|
|
@@ -60605,7 +60609,7 @@ function createTypeChecker(host) {
|
|
|
60605
60609
|
}
|
|
60606
60610
|
return false;
|
|
60607
60611
|
}
|
|
60608
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers
|
|
60612
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
60609
60613
|
if (source === target) {
|
|
60610
60614
|
return -1 /* True */;
|
|
60611
60615
|
}
|
|
@@ -60670,21 +60674,12 @@ function createTypeChecker(host) {
|
|
|
60670
60674
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
60671
60675
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
60672
60676
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
60673
|
-
let related
|
|
60674
|
-
|
|
60675
|
-
|
|
60676
|
-
|
|
60677
|
-
|
|
60678
|
-
|
|
60679
|
-
sourceType,
|
|
60680
|
-
targetType,
|
|
60681
|
-
/*reportErrors*/
|
|
60682
|
-
false
|
|
60683
|
-
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
60684
|
-
} else {
|
|
60685
|
-
related = compareTypes(sourceType, targetType, reportErrors2);
|
|
60686
|
-
}
|
|
60687
|
-
}
|
|
60677
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
60678
|
+
sourceType,
|
|
60679
|
+
targetType,
|
|
60680
|
+
/*reportErrors*/
|
|
60681
|
+
false
|
|
60682
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
60688
60683
|
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
60689
60684
|
sourceType,
|
|
60690
60685
|
targetType,
|
|
@@ -61003,33 +60998,6 @@ function createTypeChecker(host) {
|
|
|
61003
60998
|
let incompatibleStack;
|
|
61004
60999
|
let relationCount = 16e6 - relation.size >> 3;
|
|
61005
61000
|
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
61006
|
-
const visitingKey = getRelationKey(
|
|
61007
|
-
source,
|
|
61008
|
-
target,
|
|
61009
|
-
/*intersectionState*/
|
|
61010
|
-
0 /* None */,
|
|
61011
|
-
relation,
|
|
61012
|
-
/*ignoreConstraints*/
|
|
61013
|
-
false
|
|
61014
|
-
);
|
|
61015
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
61016
|
-
checkTypeRelatedToCurrentlyVisitingMap = /* @__PURE__ */ new Map();
|
|
61017
|
-
}
|
|
61018
|
-
if (!errorNode && !headMessage) {
|
|
61019
|
-
let got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
61020
|
-
const maxSameKey = 1;
|
|
61021
|
-
if (got && got >= maxSameKey) {
|
|
61022
|
-
relation.set(visitingKey, 1 /* Succeeded */);
|
|
61023
|
-
return true;
|
|
61024
|
-
} else {
|
|
61025
|
-
if (!got)
|
|
61026
|
-
got = 1;
|
|
61027
|
-
else
|
|
61028
|
-
got = got + 1;
|
|
61029
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got);
|
|
61030
|
-
}
|
|
61031
|
-
}
|
|
61032
|
-
checkTypeRelatedToDepth++;
|
|
61033
61001
|
const result = isRelatedTo(
|
|
61034
61002
|
source,
|
|
61035
61003
|
target,
|
|
@@ -61097,18 +61065,6 @@ function createTypeChecker(host) {
|
|
|
61097
61065
|
if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) {
|
|
61098
61066
|
Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
|
|
61099
61067
|
}
|
|
61100
|
-
checkTypeRelatedToDepth--;
|
|
61101
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
61102
|
-
checkTypeRelatedToCurrentlyVisitingMap = void 0;
|
|
61103
|
-
} else {
|
|
61104
|
-
const got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
61105
|
-
if (got) {
|
|
61106
|
-
if (got === 1)
|
|
61107
|
-
checkTypeRelatedToCurrentlyVisitingMap.delete(visitingKey);
|
|
61108
|
-
else
|
|
61109
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got - 1);
|
|
61110
|
-
}
|
|
61111
|
-
}
|
|
61112
61068
|
return result !== 0 /* False */;
|
|
61113
61069
|
function resetErrorInfo(saved) {
|
|
61114
61070
|
errorInfo = saved.errorInfo;
|
|
@@ -61595,112 +61551,6 @@ function createTypeChecker(host) {
|
|
|
61595
61551
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
61596
61552
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
61597
61553
|
}
|
|
61598
|
-
function checkOverloadsRelatedToIntersection(source2, target2, _reportErrors) {
|
|
61599
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
61600
|
-
const constructSignatureToString = (signature, forceReturnType) => {
|
|
61601
|
-
const origReturnType = signature.resolvedReturnType;
|
|
61602
|
-
signature.resolvedReturnType = forceReturnType;
|
|
61603
|
-
const str = signatureToString(
|
|
61604
|
-
signature,
|
|
61605
|
-
/*enclosingDeclaration*/
|
|
61606
|
-
void 0,
|
|
61607
|
-
262144 /* WriteArrowStyleSignature */,
|
|
61608
|
-
0 /* Call */
|
|
61609
|
-
);
|
|
61610
|
-
signature.resolvedReturnType = origReturnType;
|
|
61611
|
-
return str;
|
|
61612
|
-
};
|
|
61613
|
-
const mapAssignedToBy = /* @__PURE__ */ new Map();
|
|
61614
|
-
const failed = sourceSignatures.some((ssig, _si) => {
|
|
61615
|
-
if (getReturnTypeOfSignature(ssig) === neverType)
|
|
61616
|
-
return false;
|
|
61617
|
-
const accum = {
|
|
61618
|
-
hadMatch: false,
|
|
61619
|
-
gReturn: neverType,
|
|
61620
|
-
gReturnAllVoid: true
|
|
61621
|
-
};
|
|
61622
|
-
const matchedTargetSigs = [];
|
|
61623
|
-
target2.types.forEach((targetMember, _tti) => {
|
|
61624
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
61625
|
-
targetSignatures.forEach((tsig, _ti) => {
|
|
61626
|
-
const targetReturnType = getReturnTypeOfSignature(tsig);
|
|
61627
|
-
if (compareSignaturesRelated(
|
|
61628
|
-
ssig,
|
|
61629
|
-
tsig,
|
|
61630
|
-
0 /* None */ | 4 /* IgnoreReturnTypes */,
|
|
61631
|
-
/*reportErrors*/
|
|
61632
|
-
false,
|
|
61633
|
-
/*errorReporter*/
|
|
61634
|
-
void 0,
|
|
61635
|
-
/*incompatibleErrorReporter*/
|
|
61636
|
-
void 0,
|
|
61637
|
-
compareTypesIdentical,
|
|
61638
|
-
// compareTypesAssignable,
|
|
61639
|
-
/*reportUnreliableMarkers*/
|
|
61640
|
-
void 0,
|
|
61641
|
-
/*compareTypesUnilaterally*/
|
|
61642
|
-
true
|
|
61643
|
-
) === -1 /* True */) {
|
|
61644
|
-
accum.hadMatch = true;
|
|
61645
|
-
if (targetReturnType !== voidType) {
|
|
61646
|
-
accum.gReturn = getUnionType([accum.gReturn, targetReturnType]);
|
|
61647
|
-
accum.gReturnAllVoid = false;
|
|
61648
|
-
}
|
|
61649
|
-
matchedTargetSigs.push(tsig);
|
|
61650
|
-
let mtti = mapAssignedToBy.get(_tti);
|
|
61651
|
-
if (!mtti) {
|
|
61652
|
-
mtti = /* @__PURE__ */ new Map();
|
|
61653
|
-
mapAssignedToBy.set(_tti, mtti);
|
|
61654
|
-
}
|
|
61655
|
-
const setsi = mtti.get(_ti);
|
|
61656
|
-
if (!setsi) {
|
|
61657
|
-
mtti.set(_ti, true);
|
|
61658
|
-
}
|
|
61659
|
-
}
|
|
61660
|
-
});
|
|
61661
|
-
});
|
|
61662
|
-
if (!accum.hadMatch) {
|
|
61663
|
-
if (_reportErrors) {
|
|
61664
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
61665
|
-
reportError(Diagnostics.Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1, constructSignatureToString(ssig), typeToString(target2));
|
|
61666
|
-
}
|
|
61667
|
-
return true;
|
|
61668
|
-
} else {
|
|
61669
|
-
const returnType = getReturnTypeOfSignature(ssig);
|
|
61670
|
-
if (!accum.gReturnAllVoid && !isTypeAssignableTo(returnType, accum.gReturn)) {
|
|
61671
|
-
if (_reportErrors) {
|
|
61672
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
61673
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(returnType), typeToString(accum.gReturn));
|
|
61674
|
-
const strset = /* @__PURE__ */ new Set();
|
|
61675
|
-
matchedTargetSigs.forEach((tsig) => strset.add(constructSignatureToString(tsig)));
|
|
61676
|
-
const strarr = [];
|
|
61677
|
-
strset.forEach((tstr) => strarr.push(tstr));
|
|
61678
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(ssig), strarr.join(" | "));
|
|
61679
|
-
}
|
|
61680
|
-
return true;
|
|
61681
|
-
}
|
|
61682
|
-
}
|
|
61683
|
-
});
|
|
61684
|
-
if (failed)
|
|
61685
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
61686
|
-
const failed2 = target2.types.some((targetMember, _tti) => {
|
|
61687
|
-
const mtti = mapAssignedToBy.get(_tti);
|
|
61688
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
61689
|
-
return targetSignatures.some((tsig, _ti) => {
|
|
61690
|
-
if (!mtti || !mtti.get(_ti)) {
|
|
61691
|
-
if (_reportErrors) {
|
|
61692
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
61693
|
-
reportError(Diagnostics.There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1, typeToString(source2), constructSignatureToString(tsig, anyType));
|
|
61694
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(source2), typeToString(targetMember));
|
|
61695
|
-
}
|
|
61696
|
-
return true;
|
|
61697
|
-
}
|
|
61698
|
-
});
|
|
61699
|
-
});
|
|
61700
|
-
if (failed2)
|
|
61701
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
61702
|
-
return { computed: true, ternary: -1 /* True */ };
|
|
61703
|
-
}
|
|
61704
61554
|
function unionOrIntersectionRelatedTo(source2, target2, reportErrors2, intersectionState) {
|
|
61705
61555
|
if (source2.flags & 1048576 /* Union */) {
|
|
61706
61556
|
if (target2.flags & 1048576 /* Union */) {
|
|
@@ -61719,22 +61569,7 @@ function createTypeChecker(host) {
|
|
|
61719
61569
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
|
|
61720
61570
|
}
|
|
61721
61571
|
if (target2.flags & 2097152 /* Intersection */) {
|
|
61722
|
-
|
|
61723
|
-
if (result1 === 0 /* False */) {
|
|
61724
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
61725
|
-
if (sourceSignatures.every((sourceSig) => {
|
|
61726
|
-
return !sourceSig.typeParameters;
|
|
61727
|
-
})) {
|
|
61728
|
-
if (source2.flags & 524288 /* Object */ && getSignaturesOfType(source2, 0 /* Call */).length > 1) {
|
|
61729
|
-
const { computed, ternary } = checkOverloadsRelatedToIntersection(source2, target2, reportErrors2);
|
|
61730
|
-
if (computed) {
|
|
61731
|
-
Debug.assert(ternary === -1 /* True */ || ternary === 0 /* False */);
|
|
61732
|
-
return ternary;
|
|
61733
|
-
}
|
|
61734
|
-
}
|
|
61735
|
-
}
|
|
61736
|
-
}
|
|
61737
|
-
return result1;
|
|
61572
|
+
return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
|
|
61738
61573
|
}
|
|
61739
61574
|
if (relation === comparableRelation && target2.flags & 402784252 /* Primitive */) {
|
|
61740
61575
|
const constraints = sameMap(source2.types, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(t) || unknownType : t);
|
|
@@ -74598,6 +74433,109 @@ function createTypeChecker(host) {
|
|
|
74598
74433
|
return false;
|
|
74599
74434
|
}
|
|
74600
74435
|
}
|
|
74436
|
+
function getTypePredicateFromBody(func) {
|
|
74437
|
+
switch (func.kind) {
|
|
74438
|
+
case 176 /* Constructor */:
|
|
74439
|
+
case 177 /* GetAccessor */:
|
|
74440
|
+
case 178 /* SetAccessor */:
|
|
74441
|
+
return void 0;
|
|
74442
|
+
}
|
|
74443
|
+
const functionFlags = getFunctionFlags(func);
|
|
74444
|
+
if (functionFlags !== 0 /* Normal */ || func.parameters.length === 0)
|
|
74445
|
+
return void 0;
|
|
74446
|
+
let singleReturn;
|
|
74447
|
+
if (func.body && func.body.kind !== 241 /* Block */) {
|
|
74448
|
+
singleReturn = func.body;
|
|
74449
|
+
} else {
|
|
74450
|
+
if (functionHasImplicitReturn(func))
|
|
74451
|
+
return void 0;
|
|
74452
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
74453
|
+
if (singleReturn || !returnStatement.expression)
|
|
74454
|
+
return true;
|
|
74455
|
+
singleReturn = returnStatement.expression;
|
|
74456
|
+
});
|
|
74457
|
+
if (bailedEarly || !singleReturn)
|
|
74458
|
+
return void 0;
|
|
74459
|
+
}
|
|
74460
|
+
if (isTriviallyNonBoolean(singleReturn))
|
|
74461
|
+
return void 0;
|
|
74462
|
+
const predicate = checkIfExpressionRefinesAnyParameter(singleReturn);
|
|
74463
|
+
if (predicate) {
|
|
74464
|
+
const [i, type] = predicate;
|
|
74465
|
+
const param = func.parameters[i];
|
|
74466
|
+
if (isIdentifier(param.name)) {
|
|
74467
|
+
return createTypePredicate(1 /* Identifier */, param.name.escapedText, i, type);
|
|
74468
|
+
}
|
|
74469
|
+
}
|
|
74470
|
+
return void 0;
|
|
74471
|
+
function checkIfExpressionRefinesAnyParameter(expr) {
|
|
74472
|
+
expr = skipParentheses(
|
|
74473
|
+
expr,
|
|
74474
|
+
/*excludeJSDocTypeAssertions*/
|
|
74475
|
+
true
|
|
74476
|
+
);
|
|
74477
|
+
const type = checkExpressionCached(expr, 64 /* TypeOnly */);
|
|
74478
|
+
if (type !== booleanType || !func.body)
|
|
74479
|
+
return void 0;
|
|
74480
|
+
return forEach(func.parameters, (param, i) => {
|
|
74481
|
+
const initType = getSymbolLinks(param.symbol).type;
|
|
74482
|
+
if (!initType || initType === booleanType || isSymbolAssigned(param.symbol)) {
|
|
74483
|
+
return;
|
|
74484
|
+
}
|
|
74485
|
+
const trueType2 = checkIfExpressionRefinesParameter(
|
|
74486
|
+
expr,
|
|
74487
|
+
param,
|
|
74488
|
+
initType,
|
|
74489
|
+
/*forceFullCheck*/
|
|
74490
|
+
false
|
|
74491
|
+
);
|
|
74492
|
+
if (trueType2) {
|
|
74493
|
+
const trueSubtype = checkIfExpressionRefinesParameter(
|
|
74494
|
+
expr,
|
|
74495
|
+
param,
|
|
74496
|
+
trueType2,
|
|
74497
|
+
/*forceFullCheck*/
|
|
74498
|
+
true
|
|
74499
|
+
);
|
|
74500
|
+
if (trueSubtype) {
|
|
74501
|
+
return [i, trueType2];
|
|
74502
|
+
}
|
|
74503
|
+
}
|
|
74504
|
+
});
|
|
74505
|
+
}
|
|
74506
|
+
function checkIfExpressionRefinesParameter(expr, param, initType, forceFullCheck) {
|
|
74507
|
+
const antecedent = expr.flowNode ?? { flags: 2 /* Start */ };
|
|
74508
|
+
const trueCondition = {
|
|
74509
|
+
flags: 32 /* TrueCondition */,
|
|
74510
|
+
node: expr,
|
|
74511
|
+
antecedent
|
|
74512
|
+
};
|
|
74513
|
+
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
74514
|
+
if (trueType2 === initType && !forceFullCheck)
|
|
74515
|
+
return void 0;
|
|
74516
|
+
const falseCondition = {
|
|
74517
|
+
...trueCondition,
|
|
74518
|
+
flags: 64 /* FalseCondition */
|
|
74519
|
+
};
|
|
74520
|
+
const falseType2 = getFlowTypeOfReference(param.name, initType, initType, func, falseCondition);
|
|
74521
|
+
const candidateFalse = filterType(initType, (t) => !isTypeSubtypeOf(t, trueType2));
|
|
74522
|
+
if (isTypeIdenticalTo(candidateFalse, falseType2)) {
|
|
74523
|
+
return trueType2;
|
|
74524
|
+
}
|
|
74525
|
+
}
|
|
74526
|
+
function isTriviallyNonBoolean(expr) {
|
|
74527
|
+
if (isLiteralExpression(expr) || isLiteralExpressionOfObject(expr)) {
|
|
74528
|
+
return true;
|
|
74529
|
+
}
|
|
74530
|
+
if (isIdentifier(expr)) {
|
|
74531
|
+
const sym = getResolvedSymbol(expr);
|
|
74532
|
+
if (sym.flags & (32 /* Class */ | 4096 /* ObjectLiteral */ | 16 /* Function */ | 384 /* Enum */ | 8 /* EnumMember */)) {
|
|
74533
|
+
return true;
|
|
74534
|
+
}
|
|
74535
|
+
}
|
|
74536
|
+
return false;
|
|
74537
|
+
}
|
|
74538
|
+
}
|
|
74601
74539
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
74602
74540
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
74603
74541
|
return;
|
package/lib/tsserver.js
CHANGED
|
@@ -2341,7 +2341,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2341
2341
|
|
|
2342
2342
|
// src/compiler/corePublic.ts
|
|
2343
2343
|
var versionMajorMinor = "5.5";
|
|
2344
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2344
|
+
var version = `${versionMajorMinor}.0-insiders.20240223`;
|
|
2345
2345
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2346
2346
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2347
2347
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -11378,9 +11378,7 @@ var Diagnostics = {
|
|
|
11378
11378
|
Compiler_option_0_cannot_be_given_an_empty_string: diag(18051, 1 /* Error */, "Compiler_option_0_cannot_be_given_an_empty_string_18051", "Compiler option '{0}' cannot be given an empty string."),
|
|
11379
11379
|
Non_abstract_class_0_does_not_implement_all_abstract_members_of_1: diag(18052, 1 /* Error */, "Non_abstract_class_0_does_not_implement_all_abstract_members_of_1_18052", "Non-abstract class '{0}' does not implement all abstract members of '{1}'"),
|
|
11380
11380
|
Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
|
|
11381
|
-
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
11382
|
-
There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1: diag(18055, 1 /* Error */, "There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signatu_18055", "There is no signature in type {0} such that its parameters are assignable to the parameters of signature {1}"),
|
|
11383
|
-
Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1: diag(18056, 1 /* Error */, "Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1_18056", "Parameters of signature {0} are not assignable to the parameters of any signature in type {1}")
|
|
11381
|
+
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
11384
11382
|
};
|
|
11385
11383
|
|
|
11386
11384
|
// src/compiler/scanner.ts
|
|
@@ -48416,8 +48414,6 @@ function createTypeChecker(host) {
|
|
|
48416
48414
|
var lastGetCombinedNodeFlagsResult = 0 /* None */;
|
|
48417
48415
|
var lastGetCombinedModifierFlagsNode;
|
|
48418
48416
|
var lastGetCombinedModifierFlagsResult = 0 /* None */;
|
|
48419
|
-
var checkTypeRelatedToDepth = 0;
|
|
48420
|
-
var checkTypeRelatedToCurrentlyVisitingMap;
|
|
48421
48417
|
const checker = {
|
|
48422
48418
|
getNodeCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.nodeCount, 0),
|
|
48423
48419
|
getIdentifierCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.identifierCount, 0),
|
|
@@ -50301,7 +50297,7 @@ function createTypeChecker(host) {
|
|
|
50301
50297
|
if (nameNotFoundMessage) {
|
|
50302
50298
|
addLazyDiagnostic(() => {
|
|
50303
50299
|
var _a2;
|
|
50304
|
-
if (
|
|
50300
|
+
if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || (meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */)) {
|
|
50305
50301
|
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
|
50306
50302
|
if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
|
|
50307
50303
|
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
|
@@ -60765,7 +60761,15 @@ function createTypeChecker(host) {
|
|
|
60765
60761
|
jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
|
|
60766
60762
|
}
|
|
60767
60763
|
}
|
|
60768
|
-
|
|
60764
|
+
if (type || jsdocPredicate) {
|
|
60765
|
+
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
60766
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType === booleanType)) {
|
|
60767
|
+
const { declaration } = signature;
|
|
60768
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
60769
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
60770
|
+
} else {
|
|
60771
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
60772
|
+
}
|
|
60769
60773
|
}
|
|
60770
60774
|
Debug.assert(!!signature.resolvedTypePredicate);
|
|
60771
60775
|
}
|
|
@@ -65350,7 +65354,7 @@ function createTypeChecker(host) {
|
|
|
65350
65354
|
}
|
|
65351
65355
|
return false;
|
|
65352
65356
|
}
|
|
65353
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers
|
|
65357
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
65354
65358
|
if (source === target) {
|
|
65355
65359
|
return -1 /* True */;
|
|
65356
65360
|
}
|
|
@@ -65415,21 +65419,12 @@ function createTypeChecker(host) {
|
|
|
65415
65419
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
65416
65420
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
65417
65421
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
65418
|
-
let related
|
|
65419
|
-
|
|
65420
|
-
|
|
65421
|
-
|
|
65422
|
-
|
|
65423
|
-
|
|
65424
|
-
sourceType,
|
|
65425
|
-
targetType,
|
|
65426
|
-
/*reportErrors*/
|
|
65427
|
-
false
|
|
65428
|
-
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
65429
|
-
} else {
|
|
65430
|
-
related = compareTypes(sourceType, targetType, reportErrors2);
|
|
65431
|
-
}
|
|
65432
|
-
}
|
|
65422
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
65423
|
+
sourceType,
|
|
65424
|
+
targetType,
|
|
65425
|
+
/*reportErrors*/
|
|
65426
|
+
false
|
|
65427
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
65433
65428
|
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
65434
65429
|
sourceType,
|
|
65435
65430
|
targetType,
|
|
@@ -65748,33 +65743,6 @@ function createTypeChecker(host) {
|
|
|
65748
65743
|
let incompatibleStack;
|
|
65749
65744
|
let relationCount = 16e6 - relation.size >> 3;
|
|
65750
65745
|
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
65751
|
-
const visitingKey = getRelationKey(
|
|
65752
|
-
source,
|
|
65753
|
-
target,
|
|
65754
|
-
/*intersectionState*/
|
|
65755
|
-
0 /* None */,
|
|
65756
|
-
relation,
|
|
65757
|
-
/*ignoreConstraints*/
|
|
65758
|
-
false
|
|
65759
|
-
);
|
|
65760
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
65761
|
-
checkTypeRelatedToCurrentlyVisitingMap = /* @__PURE__ */ new Map();
|
|
65762
|
-
}
|
|
65763
|
-
if (!errorNode && !headMessage) {
|
|
65764
|
-
let got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
65765
|
-
const maxSameKey = 1;
|
|
65766
|
-
if (got && got >= maxSameKey) {
|
|
65767
|
-
relation.set(visitingKey, 1 /* Succeeded */);
|
|
65768
|
-
return true;
|
|
65769
|
-
} else {
|
|
65770
|
-
if (!got)
|
|
65771
|
-
got = 1;
|
|
65772
|
-
else
|
|
65773
|
-
got = got + 1;
|
|
65774
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got);
|
|
65775
|
-
}
|
|
65776
|
-
}
|
|
65777
|
-
checkTypeRelatedToDepth++;
|
|
65778
65746
|
const result = isRelatedTo(
|
|
65779
65747
|
source,
|
|
65780
65748
|
target,
|
|
@@ -65842,18 +65810,6 @@ function createTypeChecker(host) {
|
|
|
65842
65810
|
if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) {
|
|
65843
65811
|
Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
|
|
65844
65812
|
}
|
|
65845
|
-
checkTypeRelatedToDepth--;
|
|
65846
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
65847
|
-
checkTypeRelatedToCurrentlyVisitingMap = void 0;
|
|
65848
|
-
} else {
|
|
65849
|
-
const got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
65850
|
-
if (got) {
|
|
65851
|
-
if (got === 1)
|
|
65852
|
-
checkTypeRelatedToCurrentlyVisitingMap.delete(visitingKey);
|
|
65853
|
-
else
|
|
65854
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got - 1);
|
|
65855
|
-
}
|
|
65856
|
-
}
|
|
65857
65813
|
return result !== 0 /* False */;
|
|
65858
65814
|
function resetErrorInfo(saved) {
|
|
65859
65815
|
errorInfo = saved.errorInfo;
|
|
@@ -66340,112 +66296,6 @@ function createTypeChecker(host) {
|
|
|
66340
66296
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
66341
66297
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
66342
66298
|
}
|
|
66343
|
-
function checkOverloadsRelatedToIntersection(source2, target2, _reportErrors) {
|
|
66344
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
66345
|
-
const constructSignatureToString = (signature, forceReturnType) => {
|
|
66346
|
-
const origReturnType = signature.resolvedReturnType;
|
|
66347
|
-
signature.resolvedReturnType = forceReturnType;
|
|
66348
|
-
const str = signatureToString(
|
|
66349
|
-
signature,
|
|
66350
|
-
/*enclosingDeclaration*/
|
|
66351
|
-
void 0,
|
|
66352
|
-
262144 /* WriteArrowStyleSignature */,
|
|
66353
|
-
0 /* Call */
|
|
66354
|
-
);
|
|
66355
|
-
signature.resolvedReturnType = origReturnType;
|
|
66356
|
-
return str;
|
|
66357
|
-
};
|
|
66358
|
-
const mapAssignedToBy = /* @__PURE__ */ new Map();
|
|
66359
|
-
const failed = sourceSignatures.some((ssig, _si) => {
|
|
66360
|
-
if (getReturnTypeOfSignature(ssig) === neverType)
|
|
66361
|
-
return false;
|
|
66362
|
-
const accum = {
|
|
66363
|
-
hadMatch: false,
|
|
66364
|
-
gReturn: neverType,
|
|
66365
|
-
gReturnAllVoid: true
|
|
66366
|
-
};
|
|
66367
|
-
const matchedTargetSigs = [];
|
|
66368
|
-
target2.types.forEach((targetMember, _tti) => {
|
|
66369
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
66370
|
-
targetSignatures.forEach((tsig, _ti) => {
|
|
66371
|
-
const targetReturnType = getReturnTypeOfSignature(tsig);
|
|
66372
|
-
if (compareSignaturesRelated(
|
|
66373
|
-
ssig,
|
|
66374
|
-
tsig,
|
|
66375
|
-
0 /* None */ | 4 /* IgnoreReturnTypes */,
|
|
66376
|
-
/*reportErrors*/
|
|
66377
|
-
false,
|
|
66378
|
-
/*errorReporter*/
|
|
66379
|
-
void 0,
|
|
66380
|
-
/*incompatibleErrorReporter*/
|
|
66381
|
-
void 0,
|
|
66382
|
-
compareTypesIdentical,
|
|
66383
|
-
// compareTypesAssignable,
|
|
66384
|
-
/*reportUnreliableMarkers*/
|
|
66385
|
-
void 0,
|
|
66386
|
-
/*compareTypesUnilaterally*/
|
|
66387
|
-
true
|
|
66388
|
-
) === -1 /* True */) {
|
|
66389
|
-
accum.hadMatch = true;
|
|
66390
|
-
if (targetReturnType !== voidType) {
|
|
66391
|
-
accum.gReturn = getUnionType([accum.gReturn, targetReturnType]);
|
|
66392
|
-
accum.gReturnAllVoid = false;
|
|
66393
|
-
}
|
|
66394
|
-
matchedTargetSigs.push(tsig);
|
|
66395
|
-
let mtti = mapAssignedToBy.get(_tti);
|
|
66396
|
-
if (!mtti) {
|
|
66397
|
-
mtti = /* @__PURE__ */ new Map();
|
|
66398
|
-
mapAssignedToBy.set(_tti, mtti);
|
|
66399
|
-
}
|
|
66400
|
-
const setsi = mtti.get(_ti);
|
|
66401
|
-
if (!setsi) {
|
|
66402
|
-
mtti.set(_ti, true);
|
|
66403
|
-
}
|
|
66404
|
-
}
|
|
66405
|
-
});
|
|
66406
|
-
});
|
|
66407
|
-
if (!accum.hadMatch) {
|
|
66408
|
-
if (_reportErrors) {
|
|
66409
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
66410
|
-
reportError(Diagnostics.Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1, constructSignatureToString(ssig), typeToString(target2));
|
|
66411
|
-
}
|
|
66412
|
-
return true;
|
|
66413
|
-
} else {
|
|
66414
|
-
const returnType = getReturnTypeOfSignature(ssig);
|
|
66415
|
-
if (!accum.gReturnAllVoid && !isTypeAssignableTo(returnType, accum.gReturn)) {
|
|
66416
|
-
if (_reportErrors) {
|
|
66417
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
66418
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(returnType), typeToString(accum.gReturn));
|
|
66419
|
-
const strset = /* @__PURE__ */ new Set();
|
|
66420
|
-
matchedTargetSigs.forEach((tsig) => strset.add(constructSignatureToString(tsig)));
|
|
66421
|
-
const strarr = [];
|
|
66422
|
-
strset.forEach((tstr) => strarr.push(tstr));
|
|
66423
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(ssig), strarr.join(" | "));
|
|
66424
|
-
}
|
|
66425
|
-
return true;
|
|
66426
|
-
}
|
|
66427
|
-
}
|
|
66428
|
-
});
|
|
66429
|
-
if (failed)
|
|
66430
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
66431
|
-
const failed2 = target2.types.some((targetMember, _tti) => {
|
|
66432
|
-
const mtti = mapAssignedToBy.get(_tti);
|
|
66433
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
66434
|
-
return targetSignatures.some((tsig, _ti) => {
|
|
66435
|
-
if (!mtti || !mtti.get(_ti)) {
|
|
66436
|
-
if (_reportErrors) {
|
|
66437
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
66438
|
-
reportError(Diagnostics.There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1, typeToString(source2), constructSignatureToString(tsig, anyType));
|
|
66439
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(source2), typeToString(targetMember));
|
|
66440
|
-
}
|
|
66441
|
-
return true;
|
|
66442
|
-
}
|
|
66443
|
-
});
|
|
66444
|
-
});
|
|
66445
|
-
if (failed2)
|
|
66446
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
66447
|
-
return { computed: true, ternary: -1 /* True */ };
|
|
66448
|
-
}
|
|
66449
66299
|
function unionOrIntersectionRelatedTo(source2, target2, reportErrors2, intersectionState) {
|
|
66450
66300
|
if (source2.flags & 1048576 /* Union */) {
|
|
66451
66301
|
if (target2.flags & 1048576 /* Union */) {
|
|
@@ -66464,22 +66314,7 @@ function createTypeChecker(host) {
|
|
|
66464
66314
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
|
|
66465
66315
|
}
|
|
66466
66316
|
if (target2.flags & 2097152 /* Intersection */) {
|
|
66467
|
-
|
|
66468
|
-
if (result1 === 0 /* False */) {
|
|
66469
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
66470
|
-
if (sourceSignatures.every((sourceSig) => {
|
|
66471
|
-
return !sourceSig.typeParameters;
|
|
66472
|
-
})) {
|
|
66473
|
-
if (source2.flags & 524288 /* Object */ && getSignaturesOfType(source2, 0 /* Call */).length > 1) {
|
|
66474
|
-
const { computed, ternary } = checkOverloadsRelatedToIntersection(source2, target2, reportErrors2);
|
|
66475
|
-
if (computed) {
|
|
66476
|
-
Debug.assert(ternary === -1 /* True */ || ternary === 0 /* False */);
|
|
66477
|
-
return ternary;
|
|
66478
|
-
}
|
|
66479
|
-
}
|
|
66480
|
-
}
|
|
66481
|
-
}
|
|
66482
|
-
return result1;
|
|
66317
|
+
return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
|
|
66483
66318
|
}
|
|
66484
66319
|
if (relation === comparableRelation && target2.flags & 402784252 /* Primitive */) {
|
|
66485
66320
|
const constraints = sameMap(source2.types, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(t) || unknownType : t);
|
|
@@ -79343,6 +79178,109 @@ function createTypeChecker(host) {
|
|
|
79343
79178
|
return false;
|
|
79344
79179
|
}
|
|
79345
79180
|
}
|
|
79181
|
+
function getTypePredicateFromBody(func) {
|
|
79182
|
+
switch (func.kind) {
|
|
79183
|
+
case 176 /* Constructor */:
|
|
79184
|
+
case 177 /* GetAccessor */:
|
|
79185
|
+
case 178 /* SetAccessor */:
|
|
79186
|
+
return void 0;
|
|
79187
|
+
}
|
|
79188
|
+
const functionFlags = getFunctionFlags(func);
|
|
79189
|
+
if (functionFlags !== 0 /* Normal */ || func.parameters.length === 0)
|
|
79190
|
+
return void 0;
|
|
79191
|
+
let singleReturn;
|
|
79192
|
+
if (func.body && func.body.kind !== 241 /* Block */) {
|
|
79193
|
+
singleReturn = func.body;
|
|
79194
|
+
} else {
|
|
79195
|
+
if (functionHasImplicitReturn(func))
|
|
79196
|
+
return void 0;
|
|
79197
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
79198
|
+
if (singleReturn || !returnStatement.expression)
|
|
79199
|
+
return true;
|
|
79200
|
+
singleReturn = returnStatement.expression;
|
|
79201
|
+
});
|
|
79202
|
+
if (bailedEarly || !singleReturn)
|
|
79203
|
+
return void 0;
|
|
79204
|
+
}
|
|
79205
|
+
if (isTriviallyNonBoolean(singleReturn))
|
|
79206
|
+
return void 0;
|
|
79207
|
+
const predicate = checkIfExpressionRefinesAnyParameter(singleReturn);
|
|
79208
|
+
if (predicate) {
|
|
79209
|
+
const [i, type] = predicate;
|
|
79210
|
+
const param = func.parameters[i];
|
|
79211
|
+
if (isIdentifier(param.name)) {
|
|
79212
|
+
return createTypePredicate(1 /* Identifier */, param.name.escapedText, i, type);
|
|
79213
|
+
}
|
|
79214
|
+
}
|
|
79215
|
+
return void 0;
|
|
79216
|
+
function checkIfExpressionRefinesAnyParameter(expr) {
|
|
79217
|
+
expr = skipParentheses(
|
|
79218
|
+
expr,
|
|
79219
|
+
/*excludeJSDocTypeAssertions*/
|
|
79220
|
+
true
|
|
79221
|
+
);
|
|
79222
|
+
const type = checkExpressionCached(expr, 64 /* TypeOnly */);
|
|
79223
|
+
if (type !== booleanType || !func.body)
|
|
79224
|
+
return void 0;
|
|
79225
|
+
return forEach(func.parameters, (param, i) => {
|
|
79226
|
+
const initType = getSymbolLinks(param.symbol).type;
|
|
79227
|
+
if (!initType || initType === booleanType || isSymbolAssigned(param.symbol)) {
|
|
79228
|
+
return;
|
|
79229
|
+
}
|
|
79230
|
+
const trueType2 = checkIfExpressionRefinesParameter(
|
|
79231
|
+
expr,
|
|
79232
|
+
param,
|
|
79233
|
+
initType,
|
|
79234
|
+
/*forceFullCheck*/
|
|
79235
|
+
false
|
|
79236
|
+
);
|
|
79237
|
+
if (trueType2) {
|
|
79238
|
+
const trueSubtype = checkIfExpressionRefinesParameter(
|
|
79239
|
+
expr,
|
|
79240
|
+
param,
|
|
79241
|
+
trueType2,
|
|
79242
|
+
/*forceFullCheck*/
|
|
79243
|
+
true
|
|
79244
|
+
);
|
|
79245
|
+
if (trueSubtype) {
|
|
79246
|
+
return [i, trueType2];
|
|
79247
|
+
}
|
|
79248
|
+
}
|
|
79249
|
+
});
|
|
79250
|
+
}
|
|
79251
|
+
function checkIfExpressionRefinesParameter(expr, param, initType, forceFullCheck) {
|
|
79252
|
+
const antecedent = expr.flowNode ?? { flags: 2 /* Start */ };
|
|
79253
|
+
const trueCondition = {
|
|
79254
|
+
flags: 32 /* TrueCondition */,
|
|
79255
|
+
node: expr,
|
|
79256
|
+
antecedent
|
|
79257
|
+
};
|
|
79258
|
+
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
79259
|
+
if (trueType2 === initType && !forceFullCheck)
|
|
79260
|
+
return void 0;
|
|
79261
|
+
const falseCondition = {
|
|
79262
|
+
...trueCondition,
|
|
79263
|
+
flags: 64 /* FalseCondition */
|
|
79264
|
+
};
|
|
79265
|
+
const falseType2 = getFlowTypeOfReference(param.name, initType, initType, func, falseCondition);
|
|
79266
|
+
const candidateFalse = filterType(initType, (t) => !isTypeSubtypeOf(t, trueType2));
|
|
79267
|
+
if (isTypeIdenticalTo(candidateFalse, falseType2)) {
|
|
79268
|
+
return trueType2;
|
|
79269
|
+
}
|
|
79270
|
+
}
|
|
79271
|
+
function isTriviallyNonBoolean(expr) {
|
|
79272
|
+
if (isLiteralExpression(expr) || isLiteralExpressionOfObject(expr)) {
|
|
79273
|
+
return true;
|
|
79274
|
+
}
|
|
79275
|
+
if (isIdentifier(expr)) {
|
|
79276
|
+
const sym = getResolvedSymbol(expr);
|
|
79277
|
+
if (sym.flags & (32 /* Class */ | 4096 /* ObjectLiteral */ | 16 /* Function */ | 384 /* Enum */ | 8 /* EnumMember */)) {
|
|
79278
|
+
return true;
|
|
79279
|
+
}
|
|
79280
|
+
}
|
|
79281
|
+
return false;
|
|
79282
|
+
}
|
|
79283
|
+
}
|
|
79346
79284
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
79347
79285
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
79348
79286
|
return;
|
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.5";
|
|
38
|
-
version = `${versionMajorMinor}.0-insiders.
|
|
38
|
+
version = `${versionMajorMinor}.0-insiders.20240223`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9147,9 +9147,7 @@ ${lanes.join("\n")}
|
|
|
9147
9147
|
Compiler_option_0_cannot_be_given_an_empty_string: diag(18051, 1 /* Error */, "Compiler_option_0_cannot_be_given_an_empty_string_18051", "Compiler option '{0}' cannot be given an empty string."),
|
|
9148
9148
|
Non_abstract_class_0_does_not_implement_all_abstract_members_of_1: diag(18052, 1 /* Error */, "Non_abstract_class_0_does_not_implement_all_abstract_members_of_1_18052", "Non-abstract class '{0}' does not implement all abstract members of '{1}'"),
|
|
9149
9149
|
Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
|
|
9150
|
-
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
9151
|
-
There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1: diag(18055, 1 /* Error */, "There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signatu_18055", "There is no signature in type {0} such that its parameters are assignable to the parameters of signature {1}"),
|
|
9152
|
-
Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1: diag(18056, 1 /* Error */, "Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1_18056", "Parameters of signature {0} are not assignable to the parameters of any signature in type {1}")
|
|
9150
|
+
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
9153
9151
|
};
|
|
9154
9152
|
}
|
|
9155
9153
|
});
|
|
@@ -46170,8 +46168,6 @@ ${lanes.join("\n")}
|
|
|
46170
46168
|
var lastGetCombinedNodeFlagsResult = 0 /* None */;
|
|
46171
46169
|
var lastGetCombinedModifierFlagsNode;
|
|
46172
46170
|
var lastGetCombinedModifierFlagsResult = 0 /* None */;
|
|
46173
|
-
var checkTypeRelatedToDepth = 0;
|
|
46174
|
-
var checkTypeRelatedToCurrentlyVisitingMap;
|
|
46175
46171
|
const checker = {
|
|
46176
46172
|
getNodeCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.nodeCount, 0),
|
|
46177
46173
|
getIdentifierCount: () => reduceLeft(host.getSourceFiles(), (n, s) => n + s.identifierCount, 0),
|
|
@@ -48055,7 +48051,7 @@ ${lanes.join("\n")}
|
|
|
48055
48051
|
if (nameNotFoundMessage) {
|
|
48056
48052
|
addLazyDiagnostic(() => {
|
|
48057
48053
|
var _a2;
|
|
48058
|
-
if (
|
|
48054
|
+
if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || (meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */)) {
|
|
48059
48055
|
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
|
48060
48056
|
if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
|
|
48061
48057
|
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
|
@@ -58519,7 +58515,15 @@ ${lanes.join("\n")}
|
|
|
58519
58515
|
jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
|
|
58520
58516
|
}
|
|
58521
58517
|
}
|
|
58522
|
-
|
|
58518
|
+
if (type || jsdocPredicate) {
|
|
58519
|
+
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
58520
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType === booleanType)) {
|
|
58521
|
+
const { declaration } = signature;
|
|
58522
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
58523
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
58524
|
+
} else {
|
|
58525
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
58526
|
+
}
|
|
58523
58527
|
}
|
|
58524
58528
|
Debug.assert(!!signature.resolvedTypePredicate);
|
|
58525
58529
|
}
|
|
@@ -63104,7 +63108,7 @@ ${lanes.join("\n")}
|
|
|
63104
63108
|
}
|
|
63105
63109
|
return false;
|
|
63106
63110
|
}
|
|
63107
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers
|
|
63111
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
63108
63112
|
if (source === target) {
|
|
63109
63113
|
return -1 /* True */;
|
|
63110
63114
|
}
|
|
@@ -63169,21 +63173,12 @@ ${lanes.join("\n")}
|
|
|
63169
63173
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
63170
63174
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
63171
63175
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
63172
|
-
let related
|
|
63173
|
-
|
|
63174
|
-
|
|
63175
|
-
|
|
63176
|
-
|
|
63177
|
-
|
|
63178
|
-
sourceType,
|
|
63179
|
-
targetType,
|
|
63180
|
-
/*reportErrors*/
|
|
63181
|
-
false
|
|
63182
|
-
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
63183
|
-
} else {
|
|
63184
|
-
related = compareTypes(sourceType, targetType, reportErrors2);
|
|
63185
|
-
}
|
|
63186
|
-
}
|
|
63176
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
63177
|
+
sourceType,
|
|
63178
|
+
targetType,
|
|
63179
|
+
/*reportErrors*/
|
|
63180
|
+
false
|
|
63181
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
63187
63182
|
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
63188
63183
|
sourceType,
|
|
63189
63184
|
targetType,
|
|
@@ -63502,33 +63497,6 @@ ${lanes.join("\n")}
|
|
|
63502
63497
|
let incompatibleStack;
|
|
63503
63498
|
let relationCount = 16e6 - relation.size >> 3;
|
|
63504
63499
|
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63505
|
-
const visitingKey = getRelationKey(
|
|
63506
|
-
source,
|
|
63507
|
-
target,
|
|
63508
|
-
/*intersectionState*/
|
|
63509
|
-
0 /* None */,
|
|
63510
|
-
relation,
|
|
63511
|
-
/*ignoreConstraints*/
|
|
63512
|
-
false
|
|
63513
|
-
);
|
|
63514
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
63515
|
-
checkTypeRelatedToCurrentlyVisitingMap = /* @__PURE__ */ new Map();
|
|
63516
|
-
}
|
|
63517
|
-
if (!errorNode && !headMessage) {
|
|
63518
|
-
let got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
63519
|
-
const maxSameKey = 1;
|
|
63520
|
-
if (got && got >= maxSameKey) {
|
|
63521
|
-
relation.set(visitingKey, 1 /* Succeeded */);
|
|
63522
|
-
return true;
|
|
63523
|
-
} else {
|
|
63524
|
-
if (!got)
|
|
63525
|
-
got = 1;
|
|
63526
|
-
else
|
|
63527
|
-
got = got + 1;
|
|
63528
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got);
|
|
63529
|
-
}
|
|
63530
|
-
}
|
|
63531
|
-
checkTypeRelatedToDepth++;
|
|
63532
63500
|
const result = isRelatedTo(
|
|
63533
63501
|
source,
|
|
63534
63502
|
target,
|
|
@@ -63596,18 +63564,6 @@ ${lanes.join("\n")}
|
|
|
63596
63564
|
if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) {
|
|
63597
63565
|
Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
|
|
63598
63566
|
}
|
|
63599
|
-
checkTypeRelatedToDepth--;
|
|
63600
|
-
if (checkTypeRelatedToDepth === 0) {
|
|
63601
|
-
checkTypeRelatedToCurrentlyVisitingMap = void 0;
|
|
63602
|
-
} else {
|
|
63603
|
-
const got = checkTypeRelatedToCurrentlyVisitingMap.get(visitingKey);
|
|
63604
|
-
if (got) {
|
|
63605
|
-
if (got === 1)
|
|
63606
|
-
checkTypeRelatedToCurrentlyVisitingMap.delete(visitingKey);
|
|
63607
|
-
else
|
|
63608
|
-
checkTypeRelatedToCurrentlyVisitingMap.set(visitingKey, got - 1);
|
|
63609
|
-
}
|
|
63610
|
-
}
|
|
63611
63567
|
return result !== 0 /* False */;
|
|
63612
63568
|
function resetErrorInfo(saved) {
|
|
63613
63569
|
errorInfo = saved.errorInfo;
|
|
@@ -64094,112 +64050,6 @@ ${lanes.join("\n")}
|
|
|
64094
64050
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
64095
64051
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
64096
64052
|
}
|
|
64097
|
-
function checkOverloadsRelatedToIntersection(source2, target2, _reportErrors) {
|
|
64098
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
64099
|
-
const constructSignatureToString = (signature, forceReturnType) => {
|
|
64100
|
-
const origReturnType = signature.resolvedReturnType;
|
|
64101
|
-
signature.resolvedReturnType = forceReturnType;
|
|
64102
|
-
const str = signatureToString(
|
|
64103
|
-
signature,
|
|
64104
|
-
/*enclosingDeclaration*/
|
|
64105
|
-
void 0,
|
|
64106
|
-
262144 /* WriteArrowStyleSignature */,
|
|
64107
|
-
0 /* Call */
|
|
64108
|
-
);
|
|
64109
|
-
signature.resolvedReturnType = origReturnType;
|
|
64110
|
-
return str;
|
|
64111
|
-
};
|
|
64112
|
-
const mapAssignedToBy = /* @__PURE__ */ new Map();
|
|
64113
|
-
const failed = sourceSignatures.some((ssig, _si) => {
|
|
64114
|
-
if (getReturnTypeOfSignature(ssig) === neverType)
|
|
64115
|
-
return false;
|
|
64116
|
-
const accum = {
|
|
64117
|
-
hadMatch: false,
|
|
64118
|
-
gReturn: neverType,
|
|
64119
|
-
gReturnAllVoid: true
|
|
64120
|
-
};
|
|
64121
|
-
const matchedTargetSigs = [];
|
|
64122
|
-
target2.types.forEach((targetMember, _tti) => {
|
|
64123
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
64124
|
-
targetSignatures.forEach((tsig, _ti) => {
|
|
64125
|
-
const targetReturnType = getReturnTypeOfSignature(tsig);
|
|
64126
|
-
if (compareSignaturesRelated(
|
|
64127
|
-
ssig,
|
|
64128
|
-
tsig,
|
|
64129
|
-
0 /* None */ | 4 /* IgnoreReturnTypes */,
|
|
64130
|
-
/*reportErrors*/
|
|
64131
|
-
false,
|
|
64132
|
-
/*errorReporter*/
|
|
64133
|
-
void 0,
|
|
64134
|
-
/*incompatibleErrorReporter*/
|
|
64135
|
-
void 0,
|
|
64136
|
-
compareTypesIdentical,
|
|
64137
|
-
// compareTypesAssignable,
|
|
64138
|
-
/*reportUnreliableMarkers*/
|
|
64139
|
-
void 0,
|
|
64140
|
-
/*compareTypesUnilaterally*/
|
|
64141
|
-
true
|
|
64142
|
-
) === -1 /* True */) {
|
|
64143
|
-
accum.hadMatch = true;
|
|
64144
|
-
if (targetReturnType !== voidType) {
|
|
64145
|
-
accum.gReturn = getUnionType([accum.gReturn, targetReturnType]);
|
|
64146
|
-
accum.gReturnAllVoid = false;
|
|
64147
|
-
}
|
|
64148
|
-
matchedTargetSigs.push(tsig);
|
|
64149
|
-
let mtti = mapAssignedToBy.get(_tti);
|
|
64150
|
-
if (!mtti) {
|
|
64151
|
-
mtti = /* @__PURE__ */ new Map();
|
|
64152
|
-
mapAssignedToBy.set(_tti, mtti);
|
|
64153
|
-
}
|
|
64154
|
-
const setsi = mtti.get(_ti);
|
|
64155
|
-
if (!setsi) {
|
|
64156
|
-
mtti.set(_ti, true);
|
|
64157
|
-
}
|
|
64158
|
-
}
|
|
64159
|
-
});
|
|
64160
|
-
});
|
|
64161
|
-
if (!accum.hadMatch) {
|
|
64162
|
-
if (_reportErrors) {
|
|
64163
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
64164
|
-
reportError(Diagnostics.Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1, constructSignatureToString(ssig), typeToString(target2));
|
|
64165
|
-
}
|
|
64166
|
-
return true;
|
|
64167
|
-
} else {
|
|
64168
|
-
const returnType = getReturnTypeOfSignature(ssig);
|
|
64169
|
-
if (!accum.gReturnAllVoid && !isTypeAssignableTo(returnType, accum.gReturn)) {
|
|
64170
|
-
if (_reportErrors) {
|
|
64171
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
64172
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(returnType), typeToString(accum.gReturn));
|
|
64173
|
-
const strset = /* @__PURE__ */ new Set();
|
|
64174
|
-
matchedTargetSigs.forEach((tsig) => strset.add(constructSignatureToString(tsig)));
|
|
64175
|
-
const strarr = [];
|
|
64176
|
-
strset.forEach((tstr) => strarr.push(tstr));
|
|
64177
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(ssig), strarr.join(" | "));
|
|
64178
|
-
}
|
|
64179
|
-
return true;
|
|
64180
|
-
}
|
|
64181
|
-
}
|
|
64182
|
-
});
|
|
64183
|
-
if (failed)
|
|
64184
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
64185
|
-
const failed2 = target2.types.some((targetMember, _tti) => {
|
|
64186
|
-
const mtti = mapAssignedToBy.get(_tti);
|
|
64187
|
-
const targetSignatures = getSignaturesOfType(targetMember, 0 /* Call */);
|
|
64188
|
-
return targetSignatures.some((tsig, _ti) => {
|
|
64189
|
-
if (!mtti || !mtti.get(_ti)) {
|
|
64190
|
-
if (_reportErrors) {
|
|
64191
|
-
resetErrorInfo({ skipParentCounter: 0 });
|
|
64192
|
-
reportError(Diagnostics.There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1, typeToString(source2), constructSignatureToString(tsig, anyType));
|
|
64193
|
-
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, typeToString(source2), typeToString(targetMember));
|
|
64194
|
-
}
|
|
64195
|
-
return true;
|
|
64196
|
-
}
|
|
64197
|
-
});
|
|
64198
|
-
});
|
|
64199
|
-
if (failed2)
|
|
64200
|
-
return { computed: true, ternary: 0 /* False */ };
|
|
64201
|
-
return { computed: true, ternary: -1 /* True */ };
|
|
64202
|
-
}
|
|
64203
64053
|
function unionOrIntersectionRelatedTo(source2, target2, reportErrors2, intersectionState) {
|
|
64204
64054
|
if (source2.flags & 1048576 /* Union */) {
|
|
64205
64055
|
if (target2.flags & 1048576 /* Union */) {
|
|
@@ -64218,22 +64068,7 @@ ${lanes.join("\n")}
|
|
|
64218
64068
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
|
|
64219
64069
|
}
|
|
64220
64070
|
if (target2.flags & 2097152 /* Intersection */) {
|
|
64221
|
-
|
|
64222
|
-
if (result1 === 0 /* False */) {
|
|
64223
|
-
const sourceSignatures = getSignaturesOfType(source2, 0 /* Call */);
|
|
64224
|
-
if (sourceSignatures.every((sourceSig) => {
|
|
64225
|
-
return !sourceSig.typeParameters;
|
|
64226
|
-
})) {
|
|
64227
|
-
if (source2.flags & 524288 /* Object */ && getSignaturesOfType(source2, 0 /* Call */).length > 1) {
|
|
64228
|
-
const { computed, ternary } = checkOverloadsRelatedToIntersection(source2, target2, reportErrors2);
|
|
64229
|
-
if (computed) {
|
|
64230
|
-
Debug.assert(ternary === -1 /* True */ || ternary === 0 /* False */);
|
|
64231
|
-
return ternary;
|
|
64232
|
-
}
|
|
64233
|
-
}
|
|
64234
|
-
}
|
|
64235
|
-
}
|
|
64236
|
-
return result1;
|
|
64071
|
+
return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
|
|
64237
64072
|
}
|
|
64238
64073
|
if (relation === comparableRelation && target2.flags & 402784252 /* Primitive */) {
|
|
64239
64074
|
const constraints = sameMap(source2.types, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(t) || unknownType : t);
|
|
@@ -77097,6 +76932,109 @@ ${lanes.join("\n")}
|
|
|
77097
76932
|
return false;
|
|
77098
76933
|
}
|
|
77099
76934
|
}
|
|
76935
|
+
function getTypePredicateFromBody(func) {
|
|
76936
|
+
switch (func.kind) {
|
|
76937
|
+
case 176 /* Constructor */:
|
|
76938
|
+
case 177 /* GetAccessor */:
|
|
76939
|
+
case 178 /* SetAccessor */:
|
|
76940
|
+
return void 0;
|
|
76941
|
+
}
|
|
76942
|
+
const functionFlags = getFunctionFlags(func);
|
|
76943
|
+
if (functionFlags !== 0 /* Normal */ || func.parameters.length === 0)
|
|
76944
|
+
return void 0;
|
|
76945
|
+
let singleReturn;
|
|
76946
|
+
if (func.body && func.body.kind !== 241 /* Block */) {
|
|
76947
|
+
singleReturn = func.body;
|
|
76948
|
+
} else {
|
|
76949
|
+
if (functionHasImplicitReturn(func))
|
|
76950
|
+
return void 0;
|
|
76951
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
76952
|
+
if (singleReturn || !returnStatement.expression)
|
|
76953
|
+
return true;
|
|
76954
|
+
singleReturn = returnStatement.expression;
|
|
76955
|
+
});
|
|
76956
|
+
if (bailedEarly || !singleReturn)
|
|
76957
|
+
return void 0;
|
|
76958
|
+
}
|
|
76959
|
+
if (isTriviallyNonBoolean(singleReturn))
|
|
76960
|
+
return void 0;
|
|
76961
|
+
const predicate = checkIfExpressionRefinesAnyParameter(singleReturn);
|
|
76962
|
+
if (predicate) {
|
|
76963
|
+
const [i, type] = predicate;
|
|
76964
|
+
const param = func.parameters[i];
|
|
76965
|
+
if (isIdentifier(param.name)) {
|
|
76966
|
+
return createTypePredicate(1 /* Identifier */, param.name.escapedText, i, type);
|
|
76967
|
+
}
|
|
76968
|
+
}
|
|
76969
|
+
return void 0;
|
|
76970
|
+
function checkIfExpressionRefinesAnyParameter(expr) {
|
|
76971
|
+
expr = skipParentheses(
|
|
76972
|
+
expr,
|
|
76973
|
+
/*excludeJSDocTypeAssertions*/
|
|
76974
|
+
true
|
|
76975
|
+
);
|
|
76976
|
+
const type = checkExpressionCached(expr, 64 /* TypeOnly */);
|
|
76977
|
+
if (type !== booleanType || !func.body)
|
|
76978
|
+
return void 0;
|
|
76979
|
+
return forEach(func.parameters, (param, i) => {
|
|
76980
|
+
const initType = getSymbolLinks(param.symbol).type;
|
|
76981
|
+
if (!initType || initType === booleanType || isSymbolAssigned(param.symbol)) {
|
|
76982
|
+
return;
|
|
76983
|
+
}
|
|
76984
|
+
const trueType2 = checkIfExpressionRefinesParameter(
|
|
76985
|
+
expr,
|
|
76986
|
+
param,
|
|
76987
|
+
initType,
|
|
76988
|
+
/*forceFullCheck*/
|
|
76989
|
+
false
|
|
76990
|
+
);
|
|
76991
|
+
if (trueType2) {
|
|
76992
|
+
const trueSubtype = checkIfExpressionRefinesParameter(
|
|
76993
|
+
expr,
|
|
76994
|
+
param,
|
|
76995
|
+
trueType2,
|
|
76996
|
+
/*forceFullCheck*/
|
|
76997
|
+
true
|
|
76998
|
+
);
|
|
76999
|
+
if (trueSubtype) {
|
|
77000
|
+
return [i, trueType2];
|
|
77001
|
+
}
|
|
77002
|
+
}
|
|
77003
|
+
});
|
|
77004
|
+
}
|
|
77005
|
+
function checkIfExpressionRefinesParameter(expr, param, initType, forceFullCheck) {
|
|
77006
|
+
const antecedent = expr.flowNode ?? { flags: 2 /* Start */ };
|
|
77007
|
+
const trueCondition = {
|
|
77008
|
+
flags: 32 /* TrueCondition */,
|
|
77009
|
+
node: expr,
|
|
77010
|
+
antecedent
|
|
77011
|
+
};
|
|
77012
|
+
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
77013
|
+
if (trueType2 === initType && !forceFullCheck)
|
|
77014
|
+
return void 0;
|
|
77015
|
+
const falseCondition = {
|
|
77016
|
+
...trueCondition,
|
|
77017
|
+
flags: 64 /* FalseCondition */
|
|
77018
|
+
};
|
|
77019
|
+
const falseType2 = getFlowTypeOfReference(param.name, initType, initType, func, falseCondition);
|
|
77020
|
+
const candidateFalse = filterType(initType, (t) => !isTypeSubtypeOf(t, trueType2));
|
|
77021
|
+
if (isTypeIdenticalTo(candidateFalse, falseType2)) {
|
|
77022
|
+
return trueType2;
|
|
77023
|
+
}
|
|
77024
|
+
}
|
|
77025
|
+
function isTriviallyNonBoolean(expr) {
|
|
77026
|
+
if (isLiteralExpression(expr) || isLiteralExpressionOfObject(expr)) {
|
|
77027
|
+
return true;
|
|
77028
|
+
}
|
|
77029
|
+
if (isIdentifier(expr)) {
|
|
77030
|
+
const sym = getResolvedSymbol(expr);
|
|
77031
|
+
if (sym.flags & (32 /* Class */ | 4096 /* ObjectLiteral */ | 16 /* Function */ | 384 /* Enum */ | 8 /* EnumMember */)) {
|
|
77032
|
+
return true;
|
|
77033
|
+
}
|
|
77034
|
+
}
|
|
77035
|
+
return false;
|
|
77036
|
+
}
|
|
77037
|
+
}
|
|
77100
77038
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
77101
77039
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
77102
77040
|
return;
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.5";
|
|
57
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
57
|
+
var version = `${versionMajorMinor}.0-insiders.20240223`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -7186,9 +7186,7 @@ var Diagnostics = {
|
|
|
7186
7186
|
Compiler_option_0_cannot_be_given_an_empty_string: diag(18051, 1 /* Error */, "Compiler_option_0_cannot_be_given_an_empty_string_18051", "Compiler option '{0}' cannot be given an empty string."),
|
|
7187
7187
|
Non_abstract_class_0_does_not_implement_all_abstract_members_of_1: diag(18052, 1 /* Error */, "Non_abstract_class_0_does_not_implement_all_abstract_members_of_1_18052", "Non-abstract class '{0}' does not implement all abstract members of '{1}'"),
|
|
7188
7188
|
Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
|
|
7189
|
-
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
7190
|
-
There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signature_1: diag(18055, 1 /* Error */, "There_is_no_signature_in_type_0_such_that_its_parameters_are_assignable_to_the_parameters_of_signatu_18055", "There is no signature in type {0} such that its parameters are assignable to the parameters of signature {1}"),
|
|
7191
|
-
Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1: diag(18056, 1 /* Error */, "Parameters_of_signature_0_are_not_assignable_to_the_parameters_of_any_signature_in_type_1_18056", "Parameters of signature {0} are not assignable to the parameters of any signature in type {1}")
|
|
7189
|
+
await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
|
|
7192
7190
|
};
|
|
7193
7191
|
|
|
7194
7192
|
// src/compiler/scanner.ts
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.5.0-pr-
|
|
5
|
+
"version": "5.5.0-pr-57465-44",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"node": "20.1.0",
|
|
115
115
|
"npm": "8.19.4"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "38a3acfa5adb621582815eb125e8f5d5ebb602cf"
|
|
118
118
|
}
|