@typescript-deploys/pr-build 5.3.0-pr-55459-3 → 5.3.0-pr-55471-8
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 +60 -46
- package/lib/tsserver.js +60 -46
- package/lib/typescript.js +60 -46
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -48630,11 +48630,17 @@ function createTypeChecker(host) {
|
|
|
48630
48630
|
const constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
48631
48631
|
return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
|
|
48632
48632
|
}
|
|
48633
|
-
function
|
|
48634
|
-
|
|
48635
|
-
if (
|
|
48636
|
-
parameterDeclaration
|
|
48633
|
+
function getEffectiveParameterDeclaration(parameterSymbol) {
|
|
48634
|
+
const parameterDeclaration = getDeclarationOfKind(parameterSymbol, 169 /* Parameter */);
|
|
48635
|
+
if (parameterDeclaration) {
|
|
48636
|
+
return parameterDeclaration;
|
|
48637
|
+
}
|
|
48638
|
+
if (!isTransientSymbol(parameterSymbol)) {
|
|
48639
|
+
return getDeclarationOfKind(parameterSymbol, 348 /* JSDocParameterTag */);
|
|
48637
48640
|
}
|
|
48641
|
+
}
|
|
48642
|
+
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
|
|
48643
|
+
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
48638
48644
|
let parameterType = getTypeOfSymbol(parameterSymbol);
|
|
48639
48645
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
48640
48646
|
parameterType = getOptionalType(parameterType);
|
|
@@ -48643,7 +48649,7 @@ function createTypeChecker(host) {
|
|
|
48643
48649
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
48644
48650
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
48645
48651
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
48646
|
-
const name =
|
|
48652
|
+
const name = parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context);
|
|
48647
48653
|
const isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */;
|
|
48648
48654
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
48649
48655
|
const parameterNode = factory.createParameterDeclaration(
|
|
@@ -48657,6 +48663,9 @@ function createTypeChecker(host) {
|
|
|
48657
48663
|
);
|
|
48658
48664
|
context.approximateLength += symbolName(parameterSymbol).length + 3;
|
|
48659
48665
|
return parameterNode;
|
|
48666
|
+
}
|
|
48667
|
+
function parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context) {
|
|
48668
|
+
return parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 80 /* Identifier */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : parameterDeclaration.name.kind === 166 /* QualifiedName */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol);
|
|
48660
48669
|
function cloneBindingName(node) {
|
|
48661
48670
|
return elideInitializerAndSetEmitFlags(node);
|
|
48662
48671
|
function elideInitializerAndSetEmitFlags(node2) {
|
|
@@ -50637,6 +50646,21 @@ function createTypeChecker(host) {
|
|
|
50637
50646
|
if (p.flags & 98304 /* Accessor */ && useAccessors) {
|
|
50638
50647
|
const result = [];
|
|
50639
50648
|
if (p.flags & 65536 /* SetAccessor */) {
|
|
50649
|
+
const setter = p.declarations && forEach(p.declarations, (d) => {
|
|
50650
|
+
if (d.kind === 178 /* SetAccessor */) {
|
|
50651
|
+
return d;
|
|
50652
|
+
}
|
|
50653
|
+
if (isCallExpression(d) && isBindableObjectDefinePropertyCall(d)) {
|
|
50654
|
+
return forEach(d.arguments[2].properties, (propDecl) => {
|
|
50655
|
+
const id = getNameOfDeclaration(propDecl);
|
|
50656
|
+
if (!!id && isIdentifier(id) && idText(id) === "set") {
|
|
50657
|
+
return propDecl;
|
|
50658
|
+
}
|
|
50659
|
+
});
|
|
50660
|
+
}
|
|
50661
|
+
});
|
|
50662
|
+
Debug.assert(setter && isFunctionLikeDeclaration(setter));
|
|
50663
|
+
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
50640
50664
|
result.push(setTextRange(
|
|
50641
50665
|
factory.createSetAccessorDeclaration(
|
|
50642
50666
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -50646,7 +50670,7 @@ function createTypeChecker(host) {
|
|
|
50646
50670
|
void 0,
|
|
50647
50671
|
/*dotDotDotToken*/
|
|
50648
50672
|
void 0,
|
|
50649
|
-
"
|
|
50673
|
+
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
|
|
50650
50674
|
/*questionToken*/
|
|
50651
50675
|
void 0,
|
|
50652
50676
|
isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled)
|
|
@@ -51412,7 +51436,7 @@ function createTypeChecker(host) {
|
|
|
51412
51436
|
const pattern = declaration.parent;
|
|
51413
51437
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
51414
51438
|
parentType = getNonNullableType(parentType);
|
|
51415
|
-
} else if (strictNullChecks && pattern.parent.initializer && !
|
|
51439
|
+
} else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) {
|
|
51416
51440
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
51417
51441
|
}
|
|
51418
51442
|
let type;
|
|
@@ -51455,7 +51479,7 @@ function createTypeChecker(host) {
|
|
|
51455
51479
|
return type;
|
|
51456
51480
|
}
|
|
51457
51481
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
51458
|
-
return strictNullChecks && !
|
|
51482
|
+
return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
51459
51483
|
}
|
|
51460
51484
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
51461
51485
|
}
|
|
@@ -57057,7 +57081,7 @@ function createTypeChecker(host) {
|
|
|
57057
57081
|
}
|
|
57058
57082
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
57059
57083
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
57060
|
-
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
57084
|
+
const propertyTypes = map(getPropertiesOfType(type), (prop) => prop.flags & 4194304 /* Prototype */ ? neverType : getLiteralTypeFromProperty(prop, include));
|
|
57061
57085
|
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
57062
57086
|
return getUnionType(
|
|
57063
57087
|
concatenate(propertyTypes, indexKeyTypes),
|
|
@@ -59563,7 +59587,7 @@ function createTypeChecker(host) {
|
|
|
59563
59587
|
if (sourceType && targetType) {
|
|
59564
59588
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
59565
59589
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
59566
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
59590
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
|
|
59567
59591
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
59568
59592
|
sourceType,
|
|
59569
59593
|
targetType,
|
|
@@ -62720,7 +62744,7 @@ function createTypeChecker(host) {
|
|
|
62720
62744
|
return value.base10Value === "0";
|
|
62721
62745
|
}
|
|
62722
62746
|
function removeDefinitelyFalsyTypes(type) {
|
|
62723
|
-
return filterType(type, (t) =>
|
|
62747
|
+
return filterType(type, (t) => !!(getTypeFacts(t) & 4194304 /* Truthy */));
|
|
62724
62748
|
}
|
|
62725
62749
|
function extractDefinitelyFalsyTypes(type) {
|
|
62726
62750
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -64463,13 +64487,7 @@ function createTypeChecker(host) {
|
|
|
64463
64487
|
const resolved = resolveStructuredTypeMembers(type);
|
|
64464
64488
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
64465
64489
|
}
|
|
64466
|
-
function
|
|
64467
|
-
return getTypeFactsWorker(type, mask) & mask;
|
|
64468
|
-
}
|
|
64469
|
-
function hasTypeFacts(type, mask) {
|
|
64470
|
-
return getOnlyTypeFacts(type, mask) !== 0;
|
|
64471
|
-
}
|
|
64472
|
-
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
64490
|
+
function getTypeFacts(type) {
|
|
64473
64491
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
64474
64492
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
64475
64493
|
}
|
|
@@ -64502,10 +64520,6 @@ function createTypeChecker(host) {
|
|
|
64502
64520
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
64503
64521
|
}
|
|
64504
64522
|
if (flags & 524288 /* Object */) {
|
|
64505
|
-
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
64506
|
-
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
64507
|
-
return 0;
|
|
64508
|
-
}
|
|
64509
64523
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
64510
64524
|
}
|
|
64511
64525
|
if (flags & 16384 /* Void */) {
|
|
@@ -64527,20 +64541,20 @@ function createTypeChecker(host) {
|
|
|
64527
64541
|
return 0 /* None */;
|
|
64528
64542
|
}
|
|
64529
64543
|
if (flags & 1048576 /* Union */) {
|
|
64530
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
64544
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFacts(t), 0 /* None */);
|
|
64531
64545
|
}
|
|
64532
64546
|
if (flags & 2097152 /* Intersection */) {
|
|
64533
|
-
return getIntersectionTypeFacts(type
|
|
64547
|
+
return getIntersectionTypeFacts(type);
|
|
64534
64548
|
}
|
|
64535
64549
|
return 83886079 /* UnknownFacts */;
|
|
64536
64550
|
}
|
|
64537
|
-
function getIntersectionTypeFacts(type
|
|
64551
|
+
function getIntersectionTypeFacts(type) {
|
|
64538
64552
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
64539
64553
|
let oredFacts = 0 /* None */;
|
|
64540
64554
|
let andedFacts = 134217727 /* All */;
|
|
64541
64555
|
for (const t of type.types) {
|
|
64542
64556
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
64543
|
-
const f =
|
|
64557
|
+
const f = getTypeFacts(t);
|
|
64544
64558
|
oredFacts |= f;
|
|
64545
64559
|
andedFacts &= f;
|
|
64546
64560
|
}
|
|
@@ -64548,19 +64562,19 @@ function createTypeChecker(host) {
|
|
|
64548
64562
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
64549
64563
|
}
|
|
64550
64564
|
function getTypeWithFacts(type, include) {
|
|
64551
|
-
return filterType(type, (t) =>
|
|
64565
|
+
return filterType(type, (t) => (getTypeFacts(t) & include) !== 0);
|
|
64552
64566
|
}
|
|
64553
64567
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
64554
64568
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
64555
64569
|
if (strictNullChecks) {
|
|
64556
64570
|
switch (facts) {
|
|
64557
64571
|
case 524288 /* NEUndefined */:
|
|
64558
|
-
return mapType(reduced, (t) =>
|
|
64572
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
64559
64573
|
case 1048576 /* NENull */:
|
|
64560
|
-
return mapType(reduced, (t) =>
|
|
64574
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
64561
64575
|
case 2097152 /* NEUndefinedOrNull */:
|
|
64562
64576
|
case 4194304 /* Truthy */:
|
|
64563
|
-
return mapType(reduced, (t) =>
|
|
64577
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
64564
64578
|
}
|
|
64565
64579
|
}
|
|
64566
64580
|
return reduced;
|
|
@@ -65897,14 +65911,14 @@ function createTypeChecker(host) {
|
|
|
65897
65911
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
65898
65912
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
65899
65913
|
// but are classified as "function" according to `typeof`.
|
|
65900
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
65914
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
|
|
65901
65915
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
65902
65916
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
65903
65917
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
65904
65918
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
65905
65919
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
65906
65920
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
65907
|
-
|
|
65921
|
+
getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
|
|
65908
65922
|
)
|
|
65909
65923
|
)
|
|
65910
65924
|
));
|
|
@@ -65918,7 +65932,7 @@ function createTypeChecker(host) {
|
|
|
65918
65932
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
65919
65933
|
if (hasDefaultClause) {
|
|
65920
65934
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
65921
|
-
return filterType(type, (t) =>
|
|
65935
|
+
return filterType(type, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
65922
65936
|
}
|
|
65923
65937
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
65924
65938
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -66056,7 +66070,7 @@ function createTypeChecker(host) {
|
|
|
66056
66070
|
false
|
|
66057
66071
|
);
|
|
66058
66072
|
}
|
|
66059
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !
|
|
66073
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
66060
66074
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
66061
66075
|
}
|
|
66062
66076
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -66190,7 +66204,7 @@ function createTypeChecker(host) {
|
|
|
66190
66204
|
reportCircularityError(declaration.symbol);
|
|
66191
66205
|
return true;
|
|
66192
66206
|
}
|
|
66193
|
-
const containsUndefined = !!
|
|
66207
|
+
const containsUndefined = !!(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */);
|
|
66194
66208
|
if (!popTypeResolution()) {
|
|
66195
66209
|
reportCircularityError(declaration.symbol);
|
|
66196
66210
|
return true;
|
|
@@ -66200,7 +66214,7 @@ function createTypeChecker(host) {
|
|
|
66200
66214
|
return links.parameterInitializerContainsUndefined;
|
|
66201
66215
|
}
|
|
66202
66216
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
66203
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
66217
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && !parameterInitializerContainsUndefined(declaration);
|
|
66204
66218
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
66205
66219
|
}
|
|
66206
66220
|
function isConstraintPosition(type, node) {
|
|
@@ -69030,7 +69044,7 @@ function createTypeChecker(host) {
|
|
|
69030
69044
|
return checkNonNullType(checkExpression(node), node);
|
|
69031
69045
|
}
|
|
69032
69046
|
function isNullableType(type) {
|
|
69033
|
-
return
|
|
69047
|
+
return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
|
|
69034
69048
|
}
|
|
69035
69049
|
function getNonNullableTypeIfNeeded(type) {
|
|
69036
69050
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -69076,7 +69090,7 @@ function createTypeChecker(host) {
|
|
|
69076
69090
|
error(node, Diagnostics.Object_is_of_type_unknown);
|
|
69077
69091
|
return errorType;
|
|
69078
69092
|
}
|
|
69079
|
-
const facts =
|
|
69093
|
+
const facts = getTypeFacts(type);
|
|
69080
69094
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
69081
69095
|
reportError(node, facts);
|
|
69082
69096
|
const t = getNonNullableType(type);
|
|
@@ -72856,7 +72870,7 @@ function createTypeChecker(host) {
|
|
|
72856
72870
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
72857
72871
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
72858
72872
|
}
|
|
72859
|
-
return !someType(operandConstraint, (t) =>
|
|
72873
|
+
return !someType(operandConstraint, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
72860
72874
|
}
|
|
72861
72875
|
const type = checkExpressionCached(node.expression);
|
|
72862
72876
|
if (!isLiteralType(type)) {
|
|
@@ -73181,7 +73195,7 @@ function createTypeChecker(host) {
|
|
|
73181
73195
|
}
|
|
73182
73196
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
73183
73197
|
const type = getTypeOfSymbol(symbol);
|
|
73184
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
73198
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
|
|
73185
73199
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
73186
73200
|
}
|
|
73187
73201
|
}
|
|
@@ -73316,7 +73330,7 @@ function createTypeChecker(host) {
|
|
|
73316
73330
|
return getUnaryResultType(operandType);
|
|
73317
73331
|
case 54 /* ExclamationToken */:
|
|
73318
73332
|
checkTruthinessOfType(operandType, node.operand);
|
|
73319
|
-
const facts =
|
|
73333
|
+
const facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
73320
73334
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
73321
73335
|
case 46 /* PlusPlusToken */:
|
|
73322
73336
|
case 47 /* MinusMinusToken */:
|
|
@@ -73547,7 +73561,7 @@ function createTypeChecker(host) {
|
|
|
73547
73561
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
73548
73562
|
const prop = exprOrAssignment;
|
|
73549
73563
|
if (prop.objectAssignmentInitializer) {
|
|
73550
|
-
if (strictNullChecks && !
|
|
73564
|
+
if (strictNullChecks && !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
|
|
73551
73565
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
73552
73566
|
}
|
|
73553
73567
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -73959,7 +73973,7 @@ function createTypeChecker(host) {
|
|
|
73959
73973
|
return checkInExpression(left, right, leftType, rightType);
|
|
73960
73974
|
case 56 /* AmpersandAmpersandToken */:
|
|
73961
73975
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
73962
|
-
const resultType2 =
|
|
73976
|
+
const resultType2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
73963
73977
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
73964
73978
|
checkAssignmentOperator(rightType);
|
|
73965
73979
|
}
|
|
@@ -73967,7 +73981,7 @@ function createTypeChecker(host) {
|
|
|
73967
73981
|
}
|
|
73968
73982
|
case 57 /* BarBarToken */:
|
|
73969
73983
|
case 76 /* BarBarEqualsToken */: {
|
|
73970
|
-
const resultType2 =
|
|
73984
|
+
const resultType2 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
73971
73985
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
73972
73986
|
checkAssignmentOperator(rightType);
|
|
73973
73987
|
}
|
|
@@ -73975,7 +73989,7 @@ function createTypeChecker(host) {
|
|
|
73975
73989
|
}
|
|
73976
73990
|
case 61 /* QuestionQuestionToken */:
|
|
73977
73991
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
73978
|
-
const resultType2 =
|
|
73992
|
+
const resultType2 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
73979
73993
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
73980
73994
|
checkAssignmentOperator(rightType);
|
|
73981
73995
|
}
|
|
@@ -77292,7 +77306,7 @@ function createTypeChecker(host) {
|
|
|
77292
77306
|
}
|
|
77293
77307
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
77294
77308
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
77295
|
-
if (!
|
|
77309
|
+
if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
77296
77310
|
return;
|
|
77297
77311
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
77298
77312
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
package/lib/tsserver.js
CHANGED
|
@@ -53338,11 +53338,17 @@ function createTypeChecker(host) {
|
|
|
53338
53338
|
const constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
53339
53339
|
return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
|
|
53340
53340
|
}
|
|
53341
|
-
function
|
|
53342
|
-
|
|
53343
|
-
if (
|
|
53344
|
-
parameterDeclaration
|
|
53341
|
+
function getEffectiveParameterDeclaration(parameterSymbol) {
|
|
53342
|
+
const parameterDeclaration = getDeclarationOfKind(parameterSymbol, 169 /* Parameter */);
|
|
53343
|
+
if (parameterDeclaration) {
|
|
53344
|
+
return parameterDeclaration;
|
|
53345
|
+
}
|
|
53346
|
+
if (!isTransientSymbol(parameterSymbol)) {
|
|
53347
|
+
return getDeclarationOfKind(parameterSymbol, 348 /* JSDocParameterTag */);
|
|
53345
53348
|
}
|
|
53349
|
+
}
|
|
53350
|
+
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
|
|
53351
|
+
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
53346
53352
|
let parameterType = getTypeOfSymbol(parameterSymbol);
|
|
53347
53353
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
53348
53354
|
parameterType = getOptionalType(parameterType);
|
|
@@ -53351,7 +53357,7 @@ function createTypeChecker(host) {
|
|
|
53351
53357
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
53352
53358
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
53353
53359
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
53354
|
-
const name =
|
|
53360
|
+
const name = parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context);
|
|
53355
53361
|
const isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */;
|
|
53356
53362
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
53357
53363
|
const parameterNode = factory.createParameterDeclaration(
|
|
@@ -53365,6 +53371,9 @@ function createTypeChecker(host) {
|
|
|
53365
53371
|
);
|
|
53366
53372
|
context.approximateLength += symbolName(parameterSymbol).length + 3;
|
|
53367
53373
|
return parameterNode;
|
|
53374
|
+
}
|
|
53375
|
+
function parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context) {
|
|
53376
|
+
return parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 80 /* Identifier */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : parameterDeclaration.name.kind === 166 /* QualifiedName */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol);
|
|
53368
53377
|
function cloneBindingName(node) {
|
|
53369
53378
|
return elideInitializerAndSetEmitFlags(node);
|
|
53370
53379
|
function elideInitializerAndSetEmitFlags(node2) {
|
|
@@ -55345,6 +55354,21 @@ function createTypeChecker(host) {
|
|
|
55345
55354
|
if (p.flags & 98304 /* Accessor */ && useAccessors) {
|
|
55346
55355
|
const result = [];
|
|
55347
55356
|
if (p.flags & 65536 /* SetAccessor */) {
|
|
55357
|
+
const setter = p.declarations && forEach(p.declarations, (d) => {
|
|
55358
|
+
if (d.kind === 178 /* SetAccessor */) {
|
|
55359
|
+
return d;
|
|
55360
|
+
}
|
|
55361
|
+
if (isCallExpression(d) && isBindableObjectDefinePropertyCall(d)) {
|
|
55362
|
+
return forEach(d.arguments[2].properties, (propDecl) => {
|
|
55363
|
+
const id = getNameOfDeclaration(propDecl);
|
|
55364
|
+
if (!!id && isIdentifier(id) && idText(id) === "set") {
|
|
55365
|
+
return propDecl;
|
|
55366
|
+
}
|
|
55367
|
+
});
|
|
55368
|
+
}
|
|
55369
|
+
});
|
|
55370
|
+
Debug.assert(setter && isFunctionLikeDeclaration(setter));
|
|
55371
|
+
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
55348
55372
|
result.push(setTextRange(
|
|
55349
55373
|
factory.createSetAccessorDeclaration(
|
|
55350
55374
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -55354,7 +55378,7 @@ function createTypeChecker(host) {
|
|
|
55354
55378
|
void 0,
|
|
55355
55379
|
/*dotDotDotToken*/
|
|
55356
55380
|
void 0,
|
|
55357
|
-
"
|
|
55381
|
+
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
|
|
55358
55382
|
/*questionToken*/
|
|
55359
55383
|
void 0,
|
|
55360
55384
|
isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled)
|
|
@@ -56120,7 +56144,7 @@ function createTypeChecker(host) {
|
|
|
56120
56144
|
const pattern = declaration.parent;
|
|
56121
56145
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
56122
56146
|
parentType = getNonNullableType(parentType);
|
|
56123
|
-
} else if (strictNullChecks && pattern.parent.initializer && !
|
|
56147
|
+
} else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) {
|
|
56124
56148
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
56125
56149
|
}
|
|
56126
56150
|
let type;
|
|
@@ -56163,7 +56187,7 @@ function createTypeChecker(host) {
|
|
|
56163
56187
|
return type;
|
|
56164
56188
|
}
|
|
56165
56189
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
56166
|
-
return strictNullChecks && !
|
|
56190
|
+
return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
56167
56191
|
}
|
|
56168
56192
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
56169
56193
|
}
|
|
@@ -61765,7 +61789,7 @@ function createTypeChecker(host) {
|
|
|
61765
61789
|
}
|
|
61766
61790
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
61767
61791
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
61768
|
-
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
61792
|
+
const propertyTypes = map(getPropertiesOfType(type), (prop) => prop.flags & 4194304 /* Prototype */ ? neverType : getLiteralTypeFromProperty(prop, include));
|
|
61769
61793
|
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
61770
61794
|
return getUnionType(
|
|
61771
61795
|
concatenate(propertyTypes, indexKeyTypes),
|
|
@@ -64271,7 +64295,7 @@ function createTypeChecker(host) {
|
|
|
64271
64295
|
if (sourceType && targetType) {
|
|
64272
64296
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
64273
64297
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
64274
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
64298
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
|
|
64275
64299
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
64276
64300
|
sourceType,
|
|
64277
64301
|
targetType,
|
|
@@ -67428,7 +67452,7 @@ function createTypeChecker(host) {
|
|
|
67428
67452
|
return value.base10Value === "0";
|
|
67429
67453
|
}
|
|
67430
67454
|
function removeDefinitelyFalsyTypes(type) {
|
|
67431
|
-
return filterType(type, (t) =>
|
|
67455
|
+
return filterType(type, (t) => !!(getTypeFacts(t) & 4194304 /* Truthy */));
|
|
67432
67456
|
}
|
|
67433
67457
|
function extractDefinitelyFalsyTypes(type) {
|
|
67434
67458
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -69171,13 +69195,7 @@ function createTypeChecker(host) {
|
|
|
69171
69195
|
const resolved = resolveStructuredTypeMembers(type);
|
|
69172
69196
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
69173
69197
|
}
|
|
69174
|
-
function
|
|
69175
|
-
return getTypeFactsWorker(type, mask2) & mask2;
|
|
69176
|
-
}
|
|
69177
|
-
function hasTypeFacts(type, mask2) {
|
|
69178
|
-
return getOnlyTypeFacts(type, mask2) !== 0;
|
|
69179
|
-
}
|
|
69180
|
-
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
69198
|
+
function getTypeFacts(type) {
|
|
69181
69199
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
69182
69200
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
69183
69201
|
}
|
|
@@ -69210,10 +69228,6 @@ function createTypeChecker(host) {
|
|
|
69210
69228
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
69211
69229
|
}
|
|
69212
69230
|
if (flags & 524288 /* Object */) {
|
|
69213
|
-
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
69214
|
-
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
69215
|
-
return 0;
|
|
69216
|
-
}
|
|
69217
69231
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
69218
69232
|
}
|
|
69219
69233
|
if (flags & 16384 /* Void */) {
|
|
@@ -69235,20 +69249,20 @@ function createTypeChecker(host) {
|
|
|
69235
69249
|
return 0 /* None */;
|
|
69236
69250
|
}
|
|
69237
69251
|
if (flags & 1048576 /* Union */) {
|
|
69238
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
69252
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFacts(t), 0 /* None */);
|
|
69239
69253
|
}
|
|
69240
69254
|
if (flags & 2097152 /* Intersection */) {
|
|
69241
|
-
return getIntersectionTypeFacts(type
|
|
69255
|
+
return getIntersectionTypeFacts(type);
|
|
69242
69256
|
}
|
|
69243
69257
|
return 83886079 /* UnknownFacts */;
|
|
69244
69258
|
}
|
|
69245
|
-
function getIntersectionTypeFacts(type
|
|
69259
|
+
function getIntersectionTypeFacts(type) {
|
|
69246
69260
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
69247
69261
|
let oredFacts = 0 /* None */;
|
|
69248
69262
|
let andedFacts = 134217727 /* All */;
|
|
69249
69263
|
for (const t of type.types) {
|
|
69250
69264
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
69251
|
-
const f =
|
|
69265
|
+
const f = getTypeFacts(t);
|
|
69252
69266
|
oredFacts |= f;
|
|
69253
69267
|
andedFacts &= f;
|
|
69254
69268
|
}
|
|
@@ -69256,19 +69270,19 @@ function createTypeChecker(host) {
|
|
|
69256
69270
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
69257
69271
|
}
|
|
69258
69272
|
function getTypeWithFacts(type, include) {
|
|
69259
|
-
return filterType(type, (t) =>
|
|
69273
|
+
return filterType(type, (t) => (getTypeFacts(t) & include) !== 0);
|
|
69260
69274
|
}
|
|
69261
69275
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
69262
69276
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69263
69277
|
if (strictNullChecks) {
|
|
69264
69278
|
switch (facts) {
|
|
69265
69279
|
case 524288 /* NEUndefined */:
|
|
69266
|
-
return mapType(reduced, (t) =>
|
|
69280
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
69267
69281
|
case 1048576 /* NENull */:
|
|
69268
|
-
return mapType(reduced, (t) =>
|
|
69282
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
69269
69283
|
case 2097152 /* NEUndefinedOrNull */:
|
|
69270
69284
|
case 4194304 /* Truthy */:
|
|
69271
|
-
return mapType(reduced, (t) =>
|
|
69285
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
69272
69286
|
}
|
|
69273
69287
|
}
|
|
69274
69288
|
return reduced;
|
|
@@ -70605,14 +70619,14 @@ function createTypeChecker(host) {
|
|
|
70605
70619
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
70606
70620
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
70607
70621
|
// but are classified as "function" according to `typeof`.
|
|
70608
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
70622
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
|
|
70609
70623
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
70610
70624
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
70611
70625
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
70612
70626
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
70613
70627
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
70614
70628
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
70615
|
-
|
|
70629
|
+
getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
|
|
70616
70630
|
)
|
|
70617
70631
|
)
|
|
70618
70632
|
));
|
|
@@ -70626,7 +70640,7 @@ function createTypeChecker(host) {
|
|
|
70626
70640
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
70627
70641
|
if (hasDefaultClause) {
|
|
70628
70642
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
70629
|
-
return filterType(type, (t) =>
|
|
70643
|
+
return filterType(type, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
70630
70644
|
}
|
|
70631
70645
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
70632
70646
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -70764,7 +70778,7 @@ function createTypeChecker(host) {
|
|
|
70764
70778
|
false
|
|
70765
70779
|
);
|
|
70766
70780
|
}
|
|
70767
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !
|
|
70781
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
70768
70782
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
70769
70783
|
}
|
|
70770
70784
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -70898,7 +70912,7 @@ function createTypeChecker(host) {
|
|
|
70898
70912
|
reportCircularityError(declaration.symbol);
|
|
70899
70913
|
return true;
|
|
70900
70914
|
}
|
|
70901
|
-
const containsUndefined = !!
|
|
70915
|
+
const containsUndefined = !!(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */);
|
|
70902
70916
|
if (!popTypeResolution()) {
|
|
70903
70917
|
reportCircularityError(declaration.symbol);
|
|
70904
70918
|
return true;
|
|
@@ -70908,7 +70922,7 @@ function createTypeChecker(host) {
|
|
|
70908
70922
|
return links.parameterInitializerContainsUndefined;
|
|
70909
70923
|
}
|
|
70910
70924
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
70911
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
70925
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && !parameterInitializerContainsUndefined(declaration);
|
|
70912
70926
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
70913
70927
|
}
|
|
70914
70928
|
function isConstraintPosition(type, node) {
|
|
@@ -73738,7 +73752,7 @@ function createTypeChecker(host) {
|
|
|
73738
73752
|
return checkNonNullType(checkExpression(node), node);
|
|
73739
73753
|
}
|
|
73740
73754
|
function isNullableType(type) {
|
|
73741
|
-
return
|
|
73755
|
+
return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
|
|
73742
73756
|
}
|
|
73743
73757
|
function getNonNullableTypeIfNeeded(type) {
|
|
73744
73758
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -73784,7 +73798,7 @@ function createTypeChecker(host) {
|
|
|
73784
73798
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
73785
73799
|
return errorType;
|
|
73786
73800
|
}
|
|
73787
|
-
const facts =
|
|
73801
|
+
const facts = getTypeFacts(type);
|
|
73788
73802
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73789
73803
|
reportError(node, facts);
|
|
73790
73804
|
const t = getNonNullableType(type);
|
|
@@ -77564,7 +77578,7 @@ function createTypeChecker(host) {
|
|
|
77564
77578
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
77565
77579
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
77566
77580
|
}
|
|
77567
|
-
return !someType(operandConstraint, (t) =>
|
|
77581
|
+
return !someType(operandConstraint, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
77568
77582
|
}
|
|
77569
77583
|
const type = checkExpressionCached(node.expression);
|
|
77570
77584
|
if (!isLiteralType(type)) {
|
|
@@ -77889,7 +77903,7 @@ function createTypeChecker(host) {
|
|
|
77889
77903
|
}
|
|
77890
77904
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
77891
77905
|
const type = getTypeOfSymbol(symbol);
|
|
77892
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
77906
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
|
|
77893
77907
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
77894
77908
|
}
|
|
77895
77909
|
}
|
|
@@ -78024,7 +78038,7 @@ function createTypeChecker(host) {
|
|
|
78024
78038
|
return getUnaryResultType(operandType);
|
|
78025
78039
|
case 54 /* ExclamationToken */:
|
|
78026
78040
|
checkTruthinessOfType(operandType, node.operand);
|
|
78027
|
-
const facts =
|
|
78041
|
+
const facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
78028
78042
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
78029
78043
|
case 46 /* PlusPlusToken */:
|
|
78030
78044
|
case 47 /* MinusMinusToken */:
|
|
@@ -78255,7 +78269,7 @@ function createTypeChecker(host) {
|
|
|
78255
78269
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
78256
78270
|
const prop = exprOrAssignment;
|
|
78257
78271
|
if (prop.objectAssignmentInitializer) {
|
|
78258
|
-
if (strictNullChecks && !
|
|
78272
|
+
if (strictNullChecks && !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
|
|
78259
78273
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
78260
78274
|
}
|
|
78261
78275
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -78667,7 +78681,7 @@ function createTypeChecker(host) {
|
|
|
78667
78681
|
return checkInExpression(left, right, leftType, rightType);
|
|
78668
78682
|
case 56 /* AmpersandAmpersandToken */:
|
|
78669
78683
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
78670
|
-
const resultType2 =
|
|
78684
|
+
const resultType2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
78671
78685
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
78672
78686
|
checkAssignmentOperator(rightType);
|
|
78673
78687
|
}
|
|
@@ -78675,7 +78689,7 @@ function createTypeChecker(host) {
|
|
|
78675
78689
|
}
|
|
78676
78690
|
case 57 /* BarBarToken */:
|
|
78677
78691
|
case 76 /* BarBarEqualsToken */: {
|
|
78678
|
-
const resultType2 =
|
|
78692
|
+
const resultType2 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
78679
78693
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
78680
78694
|
checkAssignmentOperator(rightType);
|
|
78681
78695
|
}
|
|
@@ -78683,7 +78697,7 @@ function createTypeChecker(host) {
|
|
|
78683
78697
|
}
|
|
78684
78698
|
case 61 /* QuestionQuestionToken */:
|
|
78685
78699
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
78686
|
-
const resultType2 =
|
|
78700
|
+
const resultType2 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
78687
78701
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
78688
78702
|
checkAssignmentOperator(rightType);
|
|
78689
78703
|
}
|
|
@@ -82000,7 +82014,7 @@ function createTypeChecker(host) {
|
|
|
82000
82014
|
}
|
|
82001
82015
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
82002
82016
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82003
|
-
if (!
|
|
82017
|
+
if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
82004
82018
|
return;
|
|
82005
82019
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
82006
82020
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
package/lib/typescript.js
CHANGED
|
@@ -51099,11 +51099,17 @@ ${lanes.join("\n")}
|
|
|
51099
51099
|
const constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
51100
51100
|
return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
|
|
51101
51101
|
}
|
|
51102
|
-
function
|
|
51103
|
-
|
|
51104
|
-
if (
|
|
51105
|
-
parameterDeclaration
|
|
51102
|
+
function getEffectiveParameterDeclaration(parameterSymbol) {
|
|
51103
|
+
const parameterDeclaration = getDeclarationOfKind(parameterSymbol, 169 /* Parameter */);
|
|
51104
|
+
if (parameterDeclaration) {
|
|
51105
|
+
return parameterDeclaration;
|
|
51106
|
+
}
|
|
51107
|
+
if (!isTransientSymbol(parameterSymbol)) {
|
|
51108
|
+
return getDeclarationOfKind(parameterSymbol, 348 /* JSDocParameterTag */);
|
|
51106
51109
|
}
|
|
51110
|
+
}
|
|
51111
|
+
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
|
|
51112
|
+
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
51107
51113
|
let parameterType = getTypeOfSymbol(parameterSymbol);
|
|
51108
51114
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
51109
51115
|
parameterType = getOptionalType(parameterType);
|
|
@@ -51112,7 +51118,7 @@ ${lanes.join("\n")}
|
|
|
51112
51118
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
51113
51119
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
51114
51120
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
51115
|
-
const name =
|
|
51121
|
+
const name = parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context);
|
|
51116
51122
|
const isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */;
|
|
51117
51123
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
51118
51124
|
const parameterNode = factory.createParameterDeclaration(
|
|
@@ -51126,6 +51132,9 @@ ${lanes.join("\n")}
|
|
|
51126
51132
|
);
|
|
51127
51133
|
context.approximateLength += symbolName(parameterSymbol).length + 3;
|
|
51128
51134
|
return parameterNode;
|
|
51135
|
+
}
|
|
51136
|
+
function parameterToParameterDeclarationName(parameterSymbol, parameterDeclaration, context) {
|
|
51137
|
+
return parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 80 /* Identifier */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : parameterDeclaration.name.kind === 166 /* QualifiedName */ ? setEmitFlags(factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol);
|
|
51129
51138
|
function cloneBindingName(node) {
|
|
51130
51139
|
return elideInitializerAndSetEmitFlags(node);
|
|
51131
51140
|
function elideInitializerAndSetEmitFlags(node2) {
|
|
@@ -53106,6 +53115,21 @@ ${lanes.join("\n")}
|
|
|
53106
53115
|
if (p.flags & 98304 /* Accessor */ && useAccessors) {
|
|
53107
53116
|
const result = [];
|
|
53108
53117
|
if (p.flags & 65536 /* SetAccessor */) {
|
|
53118
|
+
const setter = p.declarations && forEach(p.declarations, (d) => {
|
|
53119
|
+
if (d.kind === 178 /* SetAccessor */) {
|
|
53120
|
+
return d;
|
|
53121
|
+
}
|
|
53122
|
+
if (isCallExpression(d) && isBindableObjectDefinePropertyCall(d)) {
|
|
53123
|
+
return forEach(d.arguments[2].properties, (propDecl) => {
|
|
53124
|
+
const id = getNameOfDeclaration(propDecl);
|
|
53125
|
+
if (!!id && isIdentifier(id) && idText(id) === "set") {
|
|
53126
|
+
return propDecl;
|
|
53127
|
+
}
|
|
53128
|
+
});
|
|
53129
|
+
}
|
|
53130
|
+
});
|
|
53131
|
+
Debug.assert(setter && isFunctionLikeDeclaration(setter));
|
|
53132
|
+
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
53109
53133
|
result.push(setTextRange(
|
|
53110
53134
|
factory.createSetAccessorDeclaration(
|
|
53111
53135
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -53115,7 +53139,7 @@ ${lanes.join("\n")}
|
|
|
53115
53139
|
void 0,
|
|
53116
53140
|
/*dotDotDotToken*/
|
|
53117
53141
|
void 0,
|
|
53118
|
-
"
|
|
53142
|
+
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
|
|
53119
53143
|
/*questionToken*/
|
|
53120
53144
|
void 0,
|
|
53121
53145
|
isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled)
|
|
@@ -53881,7 +53905,7 @@ ${lanes.join("\n")}
|
|
|
53881
53905
|
const pattern = declaration.parent;
|
|
53882
53906
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
53883
53907
|
parentType = getNonNullableType(parentType);
|
|
53884
|
-
} else if (strictNullChecks && pattern.parent.initializer && !
|
|
53908
|
+
} else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) {
|
|
53885
53909
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
53886
53910
|
}
|
|
53887
53911
|
let type;
|
|
@@ -53924,7 +53948,7 @@ ${lanes.join("\n")}
|
|
|
53924
53948
|
return type;
|
|
53925
53949
|
}
|
|
53926
53950
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
53927
|
-
return strictNullChecks && !
|
|
53951
|
+
return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
53928
53952
|
}
|
|
53929
53953
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
53930
53954
|
}
|
|
@@ -59526,7 +59550,7 @@ ${lanes.join("\n")}
|
|
|
59526
59550
|
}
|
|
59527
59551
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
59528
59552
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
59529
|
-
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
59553
|
+
const propertyTypes = map(getPropertiesOfType(type), (prop) => prop.flags & 4194304 /* Prototype */ ? neverType : getLiteralTypeFromProperty(prop, include));
|
|
59530
59554
|
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
59531
59555
|
return getUnionType(
|
|
59532
59556
|
concatenate(propertyTypes, indexKeyTypes),
|
|
@@ -62032,7 +62056,7 @@ ${lanes.join("\n")}
|
|
|
62032
62056
|
if (sourceType && targetType) {
|
|
62033
62057
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
62034
62058
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
62035
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
62059
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
|
|
62036
62060
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
62037
62061
|
sourceType,
|
|
62038
62062
|
targetType,
|
|
@@ -65189,7 +65213,7 @@ ${lanes.join("\n")}
|
|
|
65189
65213
|
return value.base10Value === "0";
|
|
65190
65214
|
}
|
|
65191
65215
|
function removeDefinitelyFalsyTypes(type) {
|
|
65192
|
-
return filterType(type, (t) =>
|
|
65216
|
+
return filterType(type, (t) => !!(getTypeFacts(t) & 4194304 /* Truthy */));
|
|
65193
65217
|
}
|
|
65194
65218
|
function extractDefinitelyFalsyTypes(type) {
|
|
65195
65219
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -66932,13 +66956,7 @@ ${lanes.join("\n")}
|
|
|
66932
66956
|
const resolved = resolveStructuredTypeMembers(type);
|
|
66933
66957
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
66934
66958
|
}
|
|
66935
|
-
function
|
|
66936
|
-
return getTypeFactsWorker(type, mask2) & mask2;
|
|
66937
|
-
}
|
|
66938
|
-
function hasTypeFacts(type, mask2) {
|
|
66939
|
-
return getOnlyTypeFacts(type, mask2) !== 0;
|
|
66940
|
-
}
|
|
66941
|
-
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
66959
|
+
function getTypeFacts(type) {
|
|
66942
66960
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
66943
66961
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
66944
66962
|
}
|
|
@@ -66971,10 +66989,6 @@ ${lanes.join("\n")}
|
|
|
66971
66989
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
66972
66990
|
}
|
|
66973
66991
|
if (flags & 524288 /* Object */) {
|
|
66974
|
-
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
66975
|
-
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
66976
|
-
return 0;
|
|
66977
|
-
}
|
|
66978
66992
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
66979
66993
|
}
|
|
66980
66994
|
if (flags & 16384 /* Void */) {
|
|
@@ -66996,20 +67010,20 @@ ${lanes.join("\n")}
|
|
|
66996
67010
|
return 0 /* None */;
|
|
66997
67011
|
}
|
|
66998
67012
|
if (flags & 1048576 /* Union */) {
|
|
66999
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
67013
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFacts(t), 0 /* None */);
|
|
67000
67014
|
}
|
|
67001
67015
|
if (flags & 2097152 /* Intersection */) {
|
|
67002
|
-
return getIntersectionTypeFacts(type
|
|
67016
|
+
return getIntersectionTypeFacts(type);
|
|
67003
67017
|
}
|
|
67004
67018
|
return 83886079 /* UnknownFacts */;
|
|
67005
67019
|
}
|
|
67006
|
-
function getIntersectionTypeFacts(type
|
|
67020
|
+
function getIntersectionTypeFacts(type) {
|
|
67007
67021
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
67008
67022
|
let oredFacts = 0 /* None */;
|
|
67009
67023
|
let andedFacts = 134217727 /* All */;
|
|
67010
67024
|
for (const t of type.types) {
|
|
67011
67025
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
67012
|
-
const f =
|
|
67026
|
+
const f = getTypeFacts(t);
|
|
67013
67027
|
oredFacts |= f;
|
|
67014
67028
|
andedFacts &= f;
|
|
67015
67029
|
}
|
|
@@ -67017,19 +67031,19 @@ ${lanes.join("\n")}
|
|
|
67017
67031
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
67018
67032
|
}
|
|
67019
67033
|
function getTypeWithFacts(type, include) {
|
|
67020
|
-
return filterType(type, (t) =>
|
|
67034
|
+
return filterType(type, (t) => (getTypeFacts(t) & include) !== 0);
|
|
67021
67035
|
}
|
|
67022
67036
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
67023
67037
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
67024
67038
|
if (strictNullChecks) {
|
|
67025
67039
|
switch (facts) {
|
|
67026
67040
|
case 524288 /* NEUndefined */:
|
|
67027
|
-
return mapType(reduced, (t) =>
|
|
67041
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
67028
67042
|
case 1048576 /* NENull */:
|
|
67029
|
-
return mapType(reduced, (t) =>
|
|
67043
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
67030
67044
|
case 2097152 /* NEUndefinedOrNull */:
|
|
67031
67045
|
case 4194304 /* Truthy */:
|
|
67032
|
-
return mapType(reduced, (t) =>
|
|
67046
|
+
return mapType(reduced, (t) => getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
67033
67047
|
}
|
|
67034
67048
|
}
|
|
67035
67049
|
return reduced;
|
|
@@ -68366,14 +68380,14 @@ ${lanes.join("\n")}
|
|
|
68366
68380
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
68367
68381
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
68368
68382
|
// but are classified as "function" according to `typeof`.
|
|
68369
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
68383
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
|
|
68370
68384
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
68371
68385
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
68372
68386
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
68373
68387
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
68374
68388
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
68375
68389
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
68376
|
-
|
|
68390
|
+
getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
|
|
68377
68391
|
)
|
|
68378
68392
|
)
|
|
68379
68393
|
));
|
|
@@ -68387,7 +68401,7 @@ ${lanes.join("\n")}
|
|
|
68387
68401
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
68388
68402
|
if (hasDefaultClause) {
|
|
68389
68403
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
68390
|
-
return filterType(type, (t) =>
|
|
68404
|
+
return filterType(type, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
68391
68405
|
}
|
|
68392
68406
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
68393
68407
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -68525,7 +68539,7 @@ ${lanes.join("\n")}
|
|
|
68525
68539
|
false
|
|
68526
68540
|
);
|
|
68527
68541
|
}
|
|
68528
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !
|
|
68542
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
68529
68543
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
68530
68544
|
}
|
|
68531
68545
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -68659,7 +68673,7 @@ ${lanes.join("\n")}
|
|
|
68659
68673
|
reportCircularityError(declaration.symbol);
|
|
68660
68674
|
return true;
|
|
68661
68675
|
}
|
|
68662
|
-
const containsUndefined = !!
|
|
68676
|
+
const containsUndefined = !!(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */);
|
|
68663
68677
|
if (!popTypeResolution()) {
|
|
68664
68678
|
reportCircularityError(declaration.symbol);
|
|
68665
68679
|
return true;
|
|
@@ -68669,7 +68683,7 @@ ${lanes.join("\n")}
|
|
|
68669
68683
|
return links.parameterInitializerContainsUndefined;
|
|
68670
68684
|
}
|
|
68671
68685
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
68672
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
68686
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && !parameterInitializerContainsUndefined(declaration);
|
|
68673
68687
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
68674
68688
|
}
|
|
68675
68689
|
function isConstraintPosition(type, node) {
|
|
@@ -71499,7 +71513,7 @@ ${lanes.join("\n")}
|
|
|
71499
71513
|
return checkNonNullType(checkExpression(node), node);
|
|
71500
71514
|
}
|
|
71501
71515
|
function isNullableType(type) {
|
|
71502
|
-
return
|
|
71516
|
+
return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
|
|
71503
71517
|
}
|
|
71504
71518
|
function getNonNullableTypeIfNeeded(type) {
|
|
71505
71519
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -71545,7 +71559,7 @@ ${lanes.join("\n")}
|
|
|
71545
71559
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
71546
71560
|
return errorType;
|
|
71547
71561
|
}
|
|
71548
|
-
const facts =
|
|
71562
|
+
const facts = getTypeFacts(type);
|
|
71549
71563
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
71550
71564
|
reportError(node, facts);
|
|
71551
71565
|
const t = getNonNullableType(type);
|
|
@@ -75325,7 +75339,7 @@ ${lanes.join("\n")}
|
|
|
75325
75339
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
75326
75340
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
75327
75341
|
}
|
|
75328
|
-
return !someType(operandConstraint, (t) =>
|
|
75342
|
+
return !someType(operandConstraint, (t) => (getTypeFacts(t) & notEqualFacts) === notEqualFacts);
|
|
75329
75343
|
}
|
|
75330
75344
|
const type = checkExpressionCached(node.expression);
|
|
75331
75345
|
if (!isLiteralType(type)) {
|
|
@@ -75650,7 +75664,7 @@ ${lanes.join("\n")}
|
|
|
75650
75664
|
}
|
|
75651
75665
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
75652
75666
|
const type = getTypeOfSymbol(symbol);
|
|
75653
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
75667
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
|
|
75654
75668
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
75655
75669
|
}
|
|
75656
75670
|
}
|
|
@@ -75785,7 +75799,7 @@ ${lanes.join("\n")}
|
|
|
75785
75799
|
return getUnaryResultType(operandType);
|
|
75786
75800
|
case 54 /* ExclamationToken */:
|
|
75787
75801
|
checkTruthinessOfType(operandType, node.operand);
|
|
75788
|
-
const facts =
|
|
75802
|
+
const facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
75789
75803
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
75790
75804
|
case 46 /* PlusPlusToken */:
|
|
75791
75805
|
case 47 /* MinusMinusToken */:
|
|
@@ -76016,7 +76030,7 @@ ${lanes.join("\n")}
|
|
|
76016
76030
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
76017
76031
|
const prop = exprOrAssignment;
|
|
76018
76032
|
if (prop.objectAssignmentInitializer) {
|
|
76019
|
-
if (strictNullChecks && !
|
|
76033
|
+
if (strictNullChecks && !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
|
|
76020
76034
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
76021
76035
|
}
|
|
76022
76036
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -76428,7 +76442,7 @@ ${lanes.join("\n")}
|
|
|
76428
76442
|
return checkInExpression(left, right, leftType, rightType);
|
|
76429
76443
|
case 56 /* AmpersandAmpersandToken */:
|
|
76430
76444
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
76431
|
-
const resultType2 =
|
|
76445
|
+
const resultType2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
76432
76446
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
76433
76447
|
checkAssignmentOperator(rightType);
|
|
76434
76448
|
}
|
|
@@ -76436,7 +76450,7 @@ ${lanes.join("\n")}
|
|
|
76436
76450
|
}
|
|
76437
76451
|
case 57 /* BarBarToken */:
|
|
76438
76452
|
case 76 /* BarBarEqualsToken */: {
|
|
76439
|
-
const resultType2 =
|
|
76453
|
+
const resultType2 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
76440
76454
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
76441
76455
|
checkAssignmentOperator(rightType);
|
|
76442
76456
|
}
|
|
@@ -76444,7 +76458,7 @@ ${lanes.join("\n")}
|
|
|
76444
76458
|
}
|
|
76445
76459
|
case 61 /* QuestionQuestionToken */:
|
|
76446
76460
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
76447
|
-
const resultType2 =
|
|
76461
|
+
const resultType2 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
76448
76462
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
76449
76463
|
checkAssignmentOperator(rightType);
|
|
76450
76464
|
}
|
|
@@ -79761,7 +79775,7 @@ ${lanes.join("\n")}
|
|
|
79761
79775
|
}
|
|
79762
79776
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
79763
79777
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
79764
|
-
if (!
|
|
79778
|
+
if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
79765
79779
|
return;
|
|
79766
79780
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
79767
79781
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
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.3.0-pr-
|
|
5
|
+
"version": "5.3.0-pr-55471-8",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"node": "20.1.0",
|
|
117
117
|
"npm": "8.19.4"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "04f2ae5aa5ea29320b7888eb3af57e7162105c05"
|
|
120
120
|
}
|