typescript 5.3.0-dev.20230823 → 5.3.0-dev.20230825
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 +63 -48
- package/lib/tsserver.js +87 -63
- package/lib/typescript.js +479 -455
- package/lib/typingsInstaller.js +4 -2
- package/package.json +2 -5
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.3";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20230825`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -11771,8 +11771,8 @@ function getInternalEmitFlags(node) {
|
|
|
11771
11771
|
const emitNode = node.emitNode;
|
|
11772
11772
|
return emitNode && emitNode.internalFlags || 0;
|
|
11773
11773
|
}
|
|
11774
|
-
|
|
11775
|
-
|
|
11774
|
+
var getScriptTargetFeatures = /* @__PURE__ */ memoize(
|
|
11775
|
+
() => new Map(Object.entries({
|
|
11776
11776
|
Array: new Map(Object.entries({
|
|
11777
11777
|
es2015: [
|
|
11778
11778
|
"find",
|
|
@@ -11839,7 +11839,7 @@ function getScriptTargetFeatures() {
|
|
|
11839
11839
|
"defineProperty",
|
|
11840
11840
|
"deleteProperty",
|
|
11841
11841
|
"get",
|
|
11842
|
-
"
|
|
11842
|
+
"getOwnPropertyDescriptor",
|
|
11843
11843
|
"getPrototypeOf",
|
|
11844
11844
|
"has",
|
|
11845
11845
|
"isExtensible",
|
|
@@ -12165,8 +12165,8 @@ function getScriptTargetFeatures() {
|
|
|
12165
12165
|
"cause"
|
|
12166
12166
|
]
|
|
12167
12167
|
}))
|
|
12168
|
-
}))
|
|
12169
|
-
|
|
12168
|
+
}))
|
|
12169
|
+
);
|
|
12170
12170
|
function getLiteralText(node, sourceFile, flags) {
|
|
12171
12171
|
if (sourceFile && canUseOriginalText(node, flags)) {
|
|
12172
12172
|
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
|
@@ -29967,7 +29967,9 @@ var Parser;
|
|
|
29967
29967
|
let dotDotDotToken;
|
|
29968
29968
|
let expression;
|
|
29969
29969
|
if (token() !== 20 /* CloseBraceToken */) {
|
|
29970
|
-
|
|
29970
|
+
if (!inExpressionContext) {
|
|
29971
|
+
dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
29972
|
+
}
|
|
29971
29973
|
expression = parseExpression();
|
|
29972
29974
|
}
|
|
29973
29975
|
if (inExpressionContext) {
|
|
@@ -44418,6 +44420,9 @@ function createTypeChecker(host) {
|
|
|
44418
44420
|
const sourceFiles = host.getSourceFiles();
|
|
44419
44421
|
return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
|
|
44420
44422
|
}
|
|
44423
|
+
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
44424
|
+
return true;
|
|
44425
|
+
}
|
|
44421
44426
|
if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
|
|
44422
44427
|
if (declaration.kind === 208 /* BindingElement */) {
|
|
44423
44428
|
const errorBindingElement = getAncestor(usage, 208 /* BindingElement */);
|
|
@@ -44447,9 +44452,6 @@ function createTypeChecker(host) {
|
|
|
44447
44452
|
if (usage.kind === 277 /* ExportAssignment */ && usage.isExportEquals) {
|
|
44448
44453
|
return true;
|
|
44449
44454
|
}
|
|
44450
|
-
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
44451
|
-
return true;
|
|
44452
|
-
}
|
|
44453
44455
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
44454
44456
|
if (emitStandardClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44455
44457
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
@@ -50659,8 +50661,8 @@ function createTypeChecker(host) {
|
|
|
50659
50661
|
});
|
|
50660
50662
|
}
|
|
50661
50663
|
});
|
|
50662
|
-
Debug.assert(setter
|
|
50663
|
-
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
50664
|
+
Debug.assert(!!setter);
|
|
50665
|
+
const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
|
|
50664
50666
|
result.push(setTextRange(
|
|
50665
50667
|
factory.createSetAccessorDeclaration(
|
|
50666
50668
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -51436,7 +51438,7 @@ function createTypeChecker(host) {
|
|
|
51436
51438
|
const pattern = declaration.parent;
|
|
51437
51439
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
51438
51440
|
parentType = getNonNullableType(parentType);
|
|
51439
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
51441
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
51440
51442
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
51441
51443
|
}
|
|
51442
51444
|
let type;
|
|
@@ -51479,7 +51481,7 @@ function createTypeChecker(host) {
|
|
|
51479
51481
|
return type;
|
|
51480
51482
|
}
|
|
51481
51483
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
51482
|
-
return strictNullChecks && !(
|
|
51484
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
51483
51485
|
}
|
|
51484
51486
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
51485
51487
|
}
|
|
@@ -59587,7 +59589,7 @@ function createTypeChecker(host) {
|
|
|
59587
59589
|
if (sourceType && targetType) {
|
|
59588
59590
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
59589
59591
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
59590
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
59592
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
59591
59593
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
59592
59594
|
sourceType,
|
|
59593
59595
|
targetType,
|
|
@@ -62744,7 +62746,7 @@ function createTypeChecker(host) {
|
|
|
62744
62746
|
return value.base10Value === "0";
|
|
62745
62747
|
}
|
|
62746
62748
|
function removeDefinitelyFalsyTypes(type) {
|
|
62747
|
-
return filterType(type, (t) =>
|
|
62749
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
62748
62750
|
}
|
|
62749
62751
|
function extractDefinitelyFalsyTypes(type) {
|
|
62750
62752
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -64020,12 +64022,14 @@ function createTypeChecker(host) {
|
|
|
64020
64022
|
}
|
|
64021
64023
|
function inferFromSignatures(source, target, kind) {
|
|
64022
64024
|
const sourceSignatures = getSignaturesOfType(source, kind);
|
|
64023
|
-
const targetSignatures = getSignaturesOfType(target, kind);
|
|
64024
64025
|
const sourceLen = sourceSignatures.length;
|
|
64025
|
-
|
|
64026
|
-
|
|
64027
|
-
|
|
64028
|
-
|
|
64026
|
+
if (sourceLen > 0) {
|
|
64027
|
+
const targetSignatures = getSignaturesOfType(target, kind);
|
|
64028
|
+
const targetLen = targetSignatures.length;
|
|
64029
|
+
for (let i = 0; i < targetLen; i++) {
|
|
64030
|
+
const sourceIndex = Math.max(sourceLen - targetLen + i, 0);
|
|
64031
|
+
inferFromSignature(getBaseSignature(sourceSignatures[sourceIndex]), getErasedSignature(targetSignatures[i]));
|
|
64032
|
+
}
|
|
64029
64033
|
}
|
|
64030
64034
|
}
|
|
64031
64035
|
function inferFromSignature(source, target) {
|
|
@@ -64487,7 +64491,13 @@ function createTypeChecker(host) {
|
|
|
64487
64491
|
const resolved = resolveStructuredTypeMembers(type);
|
|
64488
64492
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
64489
64493
|
}
|
|
64490
|
-
function getTypeFacts(type) {
|
|
64494
|
+
function getTypeFacts(type, mask) {
|
|
64495
|
+
return getTypeFactsWorker(type, mask) & mask;
|
|
64496
|
+
}
|
|
64497
|
+
function hasTypeFacts(type, mask) {
|
|
64498
|
+
return getTypeFacts(type, mask) !== 0;
|
|
64499
|
+
}
|
|
64500
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
64491
64501
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
64492
64502
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
64493
64503
|
}
|
|
@@ -64520,6 +64530,10 @@ function createTypeChecker(host) {
|
|
|
64520
64530
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
64521
64531
|
}
|
|
64522
64532
|
if (flags & 524288 /* Object */) {
|
|
64533
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
64534
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
64535
|
+
return 0;
|
|
64536
|
+
}
|
|
64523
64537
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
64524
64538
|
}
|
|
64525
64539
|
if (flags & 16384 /* Void */) {
|
|
@@ -64541,20 +64555,20 @@ function createTypeChecker(host) {
|
|
|
64541
64555
|
return 0 /* None */;
|
|
64542
64556
|
}
|
|
64543
64557
|
if (flags & 1048576 /* Union */) {
|
|
64544
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
64558
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
64545
64559
|
}
|
|
64546
64560
|
if (flags & 2097152 /* Intersection */) {
|
|
64547
|
-
return getIntersectionTypeFacts(type);
|
|
64561
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
64548
64562
|
}
|
|
64549
64563
|
return 83886079 /* UnknownFacts */;
|
|
64550
64564
|
}
|
|
64551
|
-
function getIntersectionTypeFacts(type) {
|
|
64565
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
64552
64566
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
64553
64567
|
let oredFacts = 0 /* None */;
|
|
64554
64568
|
let andedFacts = 134217727 /* All */;
|
|
64555
64569
|
for (const t of type.types) {
|
|
64556
64570
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
64557
|
-
const f =
|
|
64571
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
64558
64572
|
oredFacts |= f;
|
|
64559
64573
|
andedFacts &= f;
|
|
64560
64574
|
}
|
|
@@ -64562,19 +64576,19 @@ function createTypeChecker(host) {
|
|
|
64562
64576
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
64563
64577
|
}
|
|
64564
64578
|
function getTypeWithFacts(type, include) {
|
|
64565
|
-
return filterType(type, (t) => (
|
|
64579
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
64566
64580
|
}
|
|
64567
64581
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
64568
64582
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
64569
64583
|
if (strictNullChecks) {
|
|
64570
64584
|
switch (facts) {
|
|
64571
64585
|
case 524288 /* NEUndefined */:
|
|
64572
|
-
return mapType(reduced, (t) =>
|
|
64586
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
64573
64587
|
case 1048576 /* NENull */:
|
|
64574
|
-
return mapType(reduced, (t) =>
|
|
64588
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
64575
64589
|
case 2097152 /* NEUndefinedOrNull */:
|
|
64576
64590
|
case 4194304 /* Truthy */:
|
|
64577
|
-
return mapType(reduced, (t) =>
|
|
64591
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
64578
64592
|
}
|
|
64579
64593
|
}
|
|
64580
64594
|
return reduced;
|
|
@@ -65561,7 +65575,7 @@ function createTypeChecker(host) {
|
|
|
65561
65575
|
return void 0;
|
|
65562
65576
|
}
|
|
65563
65577
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
65564
|
-
const type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
65578
|
+
const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
65565
65579
|
if (type.flags & 1048576 /* Union */) {
|
|
65566
65580
|
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
65567
65581
|
if (access) {
|
|
@@ -65911,14 +65925,14 @@ function createTypeChecker(host) {
|
|
|
65911
65925
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
65912
65926
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
65913
65927
|
// but are classified as "function" according to `typeof`.
|
|
65914
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
65928
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
65915
65929
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
65916
65930
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
65917
65931
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
65918
65932
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
65919
65933
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
65920
65934
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
65921
|
-
|
|
65935
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
65922
65936
|
)
|
|
65923
65937
|
)
|
|
65924
65938
|
));
|
|
@@ -65932,7 +65946,7 @@ function createTypeChecker(host) {
|
|
|
65932
65946
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
65933
65947
|
if (hasDefaultClause) {
|
|
65934
65948
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
65935
|
-
return filterType(type, (t) =>
|
|
65949
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
65936
65950
|
}
|
|
65937
65951
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
65938
65952
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -66070,7 +66084,7 @@ function createTypeChecker(host) {
|
|
|
66070
66084
|
false
|
|
66071
66085
|
);
|
|
66072
66086
|
}
|
|
66073
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
66087
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
66074
66088
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
66075
66089
|
}
|
|
66076
66090
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -66204,7 +66218,7 @@ function createTypeChecker(host) {
|
|
|
66204
66218
|
reportCircularityError(declaration.symbol);
|
|
66205
66219
|
return true;
|
|
66206
66220
|
}
|
|
66207
|
-
const containsUndefined = !!(
|
|
66221
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
66208
66222
|
if (!popTypeResolution()) {
|
|
66209
66223
|
reportCircularityError(declaration.symbol);
|
|
66210
66224
|
return true;
|
|
@@ -66214,7 +66228,7 @@ function createTypeChecker(host) {
|
|
|
66214
66228
|
return links.parameterInitializerContainsUndefined;
|
|
66215
66229
|
}
|
|
66216
66230
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
66217
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
66231
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
66218
66232
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
66219
66233
|
}
|
|
66220
66234
|
function isConstraintPosition(type, node) {
|
|
@@ -69044,7 +69058,7 @@ function createTypeChecker(host) {
|
|
|
69044
69058
|
return checkNonNullType(checkExpression(node), node);
|
|
69045
69059
|
}
|
|
69046
69060
|
function isNullableType(type) {
|
|
69047
|
-
return
|
|
69061
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69048
69062
|
}
|
|
69049
69063
|
function getNonNullableTypeIfNeeded(type) {
|
|
69050
69064
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -69090,7 +69104,7 @@ function createTypeChecker(host) {
|
|
|
69090
69104
|
error(node, Diagnostics.Object_is_of_type_unknown);
|
|
69091
69105
|
return errorType;
|
|
69092
69106
|
}
|
|
69093
|
-
const facts = getTypeFacts(type);
|
|
69107
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69094
69108
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
69095
69109
|
reportError(node, facts);
|
|
69096
69110
|
const t = getNonNullableType(type);
|
|
@@ -72870,7 +72884,7 @@ function createTypeChecker(host) {
|
|
|
72870
72884
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
72871
72885
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
72872
72886
|
}
|
|
72873
|
-
return !someType(operandConstraint, (t) =>
|
|
72887
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
72874
72888
|
}
|
|
72875
72889
|
const type = checkExpressionCached(node.expression);
|
|
72876
72890
|
if (!isLiteralType(type)) {
|
|
@@ -73188,14 +73202,15 @@ function createTypeChecker(host) {
|
|
|
73188
73202
|
if (symbol) {
|
|
73189
73203
|
if (isReadonlySymbol(symbol)) {
|
|
73190
73204
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
73205
|
+
} else {
|
|
73206
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73191
73207
|
}
|
|
73192
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73193
73208
|
}
|
|
73194
73209
|
return booleanType;
|
|
73195
73210
|
}
|
|
73196
73211
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
73197
73212
|
const type = getTypeOfSymbol(symbol);
|
|
73198
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
73213
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
73199
73214
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
73200
73215
|
}
|
|
73201
73216
|
}
|
|
@@ -73330,7 +73345,7 @@ function createTypeChecker(host) {
|
|
|
73330
73345
|
return getUnaryResultType(operandType);
|
|
73331
73346
|
case 54 /* ExclamationToken */:
|
|
73332
73347
|
checkTruthinessOfType(operandType, node.operand);
|
|
73333
|
-
const facts = getTypeFacts(operandType
|
|
73348
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
73334
73349
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
73335
73350
|
case 46 /* PlusPlusToken */:
|
|
73336
73351
|
case 47 /* MinusMinusToken */:
|
|
@@ -73561,7 +73576,7 @@ function createTypeChecker(host) {
|
|
|
73561
73576
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
73562
73577
|
const prop = exprOrAssignment;
|
|
73563
73578
|
if (prop.objectAssignmentInitializer) {
|
|
73564
|
-
if (strictNullChecks && !(
|
|
73579
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
73565
73580
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
73566
73581
|
}
|
|
73567
73582
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -73973,7 +73988,7 @@ function createTypeChecker(host) {
|
|
|
73973
73988
|
return checkInExpression(left, right, leftType, rightType);
|
|
73974
73989
|
case 56 /* AmpersandAmpersandToken */:
|
|
73975
73990
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
73976
|
-
const resultType2 =
|
|
73991
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
73977
73992
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
73978
73993
|
checkAssignmentOperator(rightType);
|
|
73979
73994
|
}
|
|
@@ -73981,7 +73996,7 @@ function createTypeChecker(host) {
|
|
|
73981
73996
|
}
|
|
73982
73997
|
case 57 /* BarBarToken */:
|
|
73983
73998
|
case 76 /* BarBarEqualsToken */: {
|
|
73984
|
-
const resultType2 =
|
|
73999
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
73985
74000
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
73986
74001
|
checkAssignmentOperator(rightType);
|
|
73987
74002
|
}
|
|
@@ -73989,7 +74004,7 @@ function createTypeChecker(host) {
|
|
|
73989
74004
|
}
|
|
73990
74005
|
case 61 /* QuestionQuestionToken */:
|
|
73991
74006
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
73992
|
-
const resultType2 =
|
|
74007
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
73993
74008
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
73994
74009
|
checkAssignmentOperator(rightType);
|
|
73995
74010
|
}
|
|
@@ -77306,7 +77321,7 @@ function createTypeChecker(host) {
|
|
|
77306
77321
|
}
|
|
77307
77322
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
77308
77323
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
77309
|
-
if (!(
|
|
77324
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
77310
77325
|
return;
|
|
77311
77326
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
77312
77327
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|