typescript 5.3.0-dev.20230824 → 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 +50 -37
- package/lib/tsserver.js +50 -37
- package/lib/typescript.js +50 -37
- package/lib/typingsInstaller.js +4 -2
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.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 = [];
|
|
@@ -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);
|
|
@@ -64489,7 +64491,13 @@ function createTypeChecker(host) {
|
|
|
64489
64491
|
const resolved = resolveStructuredTypeMembers(type);
|
|
64490
64492
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
64491
64493
|
}
|
|
64492
|
-
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) {
|
|
64493
64501
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
64494
64502
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
64495
64503
|
}
|
|
@@ -64522,6 +64530,10 @@ function createTypeChecker(host) {
|
|
|
64522
64530
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
64523
64531
|
}
|
|
64524
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
|
+
}
|
|
64525
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 */;
|
|
64526
64538
|
}
|
|
64527
64539
|
if (flags & 16384 /* Void */) {
|
|
@@ -64543,20 +64555,20 @@ function createTypeChecker(host) {
|
|
|
64543
64555
|
return 0 /* None */;
|
|
64544
64556
|
}
|
|
64545
64557
|
if (flags & 1048576 /* Union */) {
|
|
64546
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
64558
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
64547
64559
|
}
|
|
64548
64560
|
if (flags & 2097152 /* Intersection */) {
|
|
64549
|
-
return getIntersectionTypeFacts(type);
|
|
64561
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
64550
64562
|
}
|
|
64551
64563
|
return 83886079 /* UnknownFacts */;
|
|
64552
64564
|
}
|
|
64553
|
-
function getIntersectionTypeFacts(type) {
|
|
64565
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
64554
64566
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
64555
64567
|
let oredFacts = 0 /* None */;
|
|
64556
64568
|
let andedFacts = 134217727 /* All */;
|
|
64557
64569
|
for (const t of type.types) {
|
|
64558
64570
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
64559
|
-
const f =
|
|
64571
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
64560
64572
|
oredFacts |= f;
|
|
64561
64573
|
andedFacts &= f;
|
|
64562
64574
|
}
|
|
@@ -64564,19 +64576,19 @@ function createTypeChecker(host) {
|
|
|
64564
64576
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
64565
64577
|
}
|
|
64566
64578
|
function getTypeWithFacts(type, include) {
|
|
64567
|
-
return filterType(type, (t) => (
|
|
64579
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
64568
64580
|
}
|
|
64569
64581
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
64570
64582
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
64571
64583
|
if (strictNullChecks) {
|
|
64572
64584
|
switch (facts) {
|
|
64573
64585
|
case 524288 /* NEUndefined */:
|
|
64574
|
-
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);
|
|
64575
64587
|
case 1048576 /* NENull */:
|
|
64576
|
-
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);
|
|
64577
64589
|
case 2097152 /* NEUndefinedOrNull */:
|
|
64578
64590
|
case 4194304 /* Truthy */:
|
|
64579
|
-
return mapType(reduced, (t) =>
|
|
64591
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
64580
64592
|
}
|
|
64581
64593
|
}
|
|
64582
64594
|
return reduced;
|
|
@@ -65913,14 +65925,14 @@ function createTypeChecker(host) {
|
|
|
65913
65925
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
65914
65926
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
65915
65927
|
// but are classified as "function" according to `typeof`.
|
|
65916
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
65928
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
65917
65929
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
65918
65930
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
65919
65931
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
65920
65932
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
65921
65933
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
65922
65934
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
65923
|
-
|
|
65935
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
65924
65936
|
)
|
|
65925
65937
|
)
|
|
65926
65938
|
));
|
|
@@ -65934,7 +65946,7 @@ function createTypeChecker(host) {
|
|
|
65934
65946
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
65935
65947
|
if (hasDefaultClause) {
|
|
65936
65948
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
65937
|
-
return filterType(type, (t) =>
|
|
65949
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
65938
65950
|
}
|
|
65939
65951
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
65940
65952
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -66072,7 +66084,7 @@ function createTypeChecker(host) {
|
|
|
66072
66084
|
false
|
|
66073
66085
|
);
|
|
66074
66086
|
}
|
|
66075
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
66087
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
66076
66088
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
66077
66089
|
}
|
|
66078
66090
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -66206,7 +66218,7 @@ function createTypeChecker(host) {
|
|
|
66206
66218
|
reportCircularityError(declaration.symbol);
|
|
66207
66219
|
return true;
|
|
66208
66220
|
}
|
|
66209
|
-
const containsUndefined = !!(
|
|
66221
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
66210
66222
|
if (!popTypeResolution()) {
|
|
66211
66223
|
reportCircularityError(declaration.symbol);
|
|
66212
66224
|
return true;
|
|
@@ -66216,7 +66228,7 @@ function createTypeChecker(host) {
|
|
|
66216
66228
|
return links.parameterInitializerContainsUndefined;
|
|
66217
66229
|
}
|
|
66218
66230
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
66219
|
-
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);
|
|
66220
66232
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
66221
66233
|
}
|
|
66222
66234
|
function isConstraintPosition(type, node) {
|
|
@@ -69046,7 +69058,7 @@ function createTypeChecker(host) {
|
|
|
69046
69058
|
return checkNonNullType(checkExpression(node), node);
|
|
69047
69059
|
}
|
|
69048
69060
|
function isNullableType(type) {
|
|
69049
|
-
return
|
|
69061
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69050
69062
|
}
|
|
69051
69063
|
function getNonNullableTypeIfNeeded(type) {
|
|
69052
69064
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -69092,7 +69104,7 @@ function createTypeChecker(host) {
|
|
|
69092
69104
|
error(node, Diagnostics.Object_is_of_type_unknown);
|
|
69093
69105
|
return errorType;
|
|
69094
69106
|
}
|
|
69095
|
-
const facts = getTypeFacts(type);
|
|
69107
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69096
69108
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
69097
69109
|
reportError(node, facts);
|
|
69098
69110
|
const t = getNonNullableType(type);
|
|
@@ -72872,7 +72884,7 @@ function createTypeChecker(host) {
|
|
|
72872
72884
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
72873
72885
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
72874
72886
|
}
|
|
72875
|
-
return !someType(operandConstraint, (t) =>
|
|
72887
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
72876
72888
|
}
|
|
72877
72889
|
const type = checkExpressionCached(node.expression);
|
|
72878
72890
|
if (!isLiteralType(type)) {
|
|
@@ -73190,14 +73202,15 @@ function createTypeChecker(host) {
|
|
|
73190
73202
|
if (symbol) {
|
|
73191
73203
|
if (isReadonlySymbol(symbol)) {
|
|
73192
73204
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
73205
|
+
} else {
|
|
73206
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73193
73207
|
}
|
|
73194
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73195
73208
|
}
|
|
73196
73209
|
return booleanType;
|
|
73197
73210
|
}
|
|
73198
73211
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
73199
73212
|
const type = getTypeOfSymbol(symbol);
|
|
73200
|
-
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 */))) {
|
|
73201
73214
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
73202
73215
|
}
|
|
73203
73216
|
}
|
|
@@ -73332,7 +73345,7 @@ function createTypeChecker(host) {
|
|
|
73332
73345
|
return getUnaryResultType(operandType);
|
|
73333
73346
|
case 54 /* ExclamationToken */:
|
|
73334
73347
|
checkTruthinessOfType(operandType, node.operand);
|
|
73335
|
-
const facts = getTypeFacts(operandType
|
|
73348
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
73336
73349
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
73337
73350
|
case 46 /* PlusPlusToken */:
|
|
73338
73351
|
case 47 /* MinusMinusToken */:
|
|
@@ -73563,7 +73576,7 @@ function createTypeChecker(host) {
|
|
|
73563
73576
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
73564
73577
|
const prop = exprOrAssignment;
|
|
73565
73578
|
if (prop.objectAssignmentInitializer) {
|
|
73566
|
-
if (strictNullChecks && !(
|
|
73579
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
73567
73580
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
73568
73581
|
}
|
|
73569
73582
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -73975,7 +73988,7 @@ function createTypeChecker(host) {
|
|
|
73975
73988
|
return checkInExpression(left, right, leftType, rightType);
|
|
73976
73989
|
case 56 /* AmpersandAmpersandToken */:
|
|
73977
73990
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
73978
|
-
const resultType2 =
|
|
73991
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
73979
73992
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
73980
73993
|
checkAssignmentOperator(rightType);
|
|
73981
73994
|
}
|
|
@@ -73983,7 +73996,7 @@ function createTypeChecker(host) {
|
|
|
73983
73996
|
}
|
|
73984
73997
|
case 57 /* BarBarToken */:
|
|
73985
73998
|
case 76 /* BarBarEqualsToken */: {
|
|
73986
|
-
const resultType2 =
|
|
73999
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
73987
74000
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
73988
74001
|
checkAssignmentOperator(rightType);
|
|
73989
74002
|
}
|
|
@@ -73991,7 +74004,7 @@ function createTypeChecker(host) {
|
|
|
73991
74004
|
}
|
|
73992
74005
|
case 61 /* QuestionQuestionToken */:
|
|
73993
74006
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
73994
|
-
const resultType2 =
|
|
74007
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
73995
74008
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
73996
74009
|
checkAssignmentOperator(rightType);
|
|
73997
74010
|
}
|
|
@@ -77308,7 +77321,7 @@ function createTypeChecker(host) {
|
|
|
77308
77321
|
}
|
|
77309
77322
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
77310
77323
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
77311
|
-
if (!(
|
|
77324
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
77312
77325
|
return;
|
|
77313
77326
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
77314
77327
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
package/lib/tsserver.js
CHANGED
|
@@ -2333,7 +2333,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2333
2333
|
|
|
2334
2334
|
// src/compiler/corePublic.ts
|
|
2335
2335
|
var versionMajorMinor = "5.3";
|
|
2336
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2336
|
+
var version = `${versionMajorMinor}.0-dev.20230825`;
|
|
2337
2337
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2338
2338
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2339
2339
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -34369,7 +34369,9 @@ var Parser;
|
|
|
34369
34369
|
let dotDotDotToken;
|
|
34370
34370
|
let expression;
|
|
34371
34371
|
if (token() !== 20 /* CloseBraceToken */) {
|
|
34372
|
-
|
|
34372
|
+
if (!inExpressionContext) {
|
|
34373
|
+
dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
34374
|
+
}
|
|
34373
34375
|
expression = parseExpression();
|
|
34374
34376
|
}
|
|
34375
34377
|
if (inExpressionContext) {
|
|
@@ -49126,6 +49128,9 @@ function createTypeChecker(host) {
|
|
|
49126
49128
|
const sourceFiles = host.getSourceFiles();
|
|
49127
49129
|
return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
|
|
49128
49130
|
}
|
|
49131
|
+
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
49132
|
+
return true;
|
|
49133
|
+
}
|
|
49129
49134
|
if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
|
|
49130
49135
|
if (declaration.kind === 208 /* BindingElement */) {
|
|
49131
49136
|
const errorBindingElement = getAncestor(usage, 208 /* BindingElement */);
|
|
@@ -49155,9 +49160,6 @@ function createTypeChecker(host) {
|
|
|
49155
49160
|
if (usage.kind === 277 /* ExportAssignment */ && usage.isExportEquals) {
|
|
49156
49161
|
return true;
|
|
49157
49162
|
}
|
|
49158
|
-
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
49159
|
-
return true;
|
|
49160
|
-
}
|
|
49161
49163
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
49162
49164
|
if (emitStandardClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
49163
49165
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
@@ -55367,8 +55369,8 @@ function createTypeChecker(host) {
|
|
|
55367
55369
|
});
|
|
55368
55370
|
}
|
|
55369
55371
|
});
|
|
55370
|
-
Debug.assert(setter
|
|
55371
|
-
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
55372
|
+
Debug.assert(!!setter);
|
|
55373
|
+
const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
|
|
55372
55374
|
result.push(setTextRange(
|
|
55373
55375
|
factory.createSetAccessorDeclaration(
|
|
55374
55376
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -56144,7 +56146,7 @@ function createTypeChecker(host) {
|
|
|
56144
56146
|
const pattern = declaration.parent;
|
|
56145
56147
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
56146
56148
|
parentType = getNonNullableType(parentType);
|
|
56147
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
56149
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
56148
56150
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
56149
56151
|
}
|
|
56150
56152
|
let type;
|
|
@@ -56187,7 +56189,7 @@ function createTypeChecker(host) {
|
|
|
56187
56189
|
return type;
|
|
56188
56190
|
}
|
|
56189
56191
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
56190
|
-
return strictNullChecks && !(
|
|
56192
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
56191
56193
|
}
|
|
56192
56194
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
56193
56195
|
}
|
|
@@ -64295,7 +64297,7 @@ function createTypeChecker(host) {
|
|
|
64295
64297
|
if (sourceType && targetType) {
|
|
64296
64298
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
64297
64299
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
64298
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
64300
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
64299
64301
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
64300
64302
|
sourceType,
|
|
64301
64303
|
targetType,
|
|
@@ -67452,7 +67454,7 @@ function createTypeChecker(host) {
|
|
|
67452
67454
|
return value.base10Value === "0";
|
|
67453
67455
|
}
|
|
67454
67456
|
function removeDefinitelyFalsyTypes(type) {
|
|
67455
|
-
return filterType(type, (t) =>
|
|
67457
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
67456
67458
|
}
|
|
67457
67459
|
function extractDefinitelyFalsyTypes(type) {
|
|
67458
67460
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -69197,7 +69199,13 @@ function createTypeChecker(host) {
|
|
|
69197
69199
|
const resolved = resolveStructuredTypeMembers(type);
|
|
69198
69200
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
69199
69201
|
}
|
|
69200
|
-
function getTypeFacts(type) {
|
|
69202
|
+
function getTypeFacts(type, mask2) {
|
|
69203
|
+
return getTypeFactsWorker(type, mask2) & mask2;
|
|
69204
|
+
}
|
|
69205
|
+
function hasTypeFacts(type, mask2) {
|
|
69206
|
+
return getTypeFacts(type, mask2) !== 0;
|
|
69207
|
+
}
|
|
69208
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
69201
69209
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
69202
69210
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
69203
69211
|
}
|
|
@@ -69230,6 +69238,10 @@ function createTypeChecker(host) {
|
|
|
69230
69238
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
69231
69239
|
}
|
|
69232
69240
|
if (flags & 524288 /* Object */) {
|
|
69241
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
69242
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
69243
|
+
return 0;
|
|
69244
|
+
}
|
|
69233
69245
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
69234
69246
|
}
|
|
69235
69247
|
if (flags & 16384 /* Void */) {
|
|
@@ -69251,20 +69263,20 @@ function createTypeChecker(host) {
|
|
|
69251
69263
|
return 0 /* None */;
|
|
69252
69264
|
}
|
|
69253
69265
|
if (flags & 1048576 /* Union */) {
|
|
69254
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
69266
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
69255
69267
|
}
|
|
69256
69268
|
if (flags & 2097152 /* Intersection */) {
|
|
69257
|
-
return getIntersectionTypeFacts(type);
|
|
69269
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
69258
69270
|
}
|
|
69259
69271
|
return 83886079 /* UnknownFacts */;
|
|
69260
69272
|
}
|
|
69261
|
-
function getIntersectionTypeFacts(type) {
|
|
69273
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
69262
69274
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
69263
69275
|
let oredFacts = 0 /* None */;
|
|
69264
69276
|
let andedFacts = 134217727 /* All */;
|
|
69265
69277
|
for (const t of type.types) {
|
|
69266
69278
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
69267
|
-
const f =
|
|
69279
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
69268
69280
|
oredFacts |= f;
|
|
69269
69281
|
andedFacts &= f;
|
|
69270
69282
|
}
|
|
@@ -69272,19 +69284,19 @@ function createTypeChecker(host) {
|
|
|
69272
69284
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
69273
69285
|
}
|
|
69274
69286
|
function getTypeWithFacts(type, include) {
|
|
69275
|
-
return filterType(type, (t) => (
|
|
69287
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
69276
69288
|
}
|
|
69277
69289
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
69278
69290
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69279
69291
|
if (strictNullChecks) {
|
|
69280
69292
|
switch (facts) {
|
|
69281
69293
|
case 524288 /* NEUndefined */:
|
|
69282
|
-
return mapType(reduced, (t) =>
|
|
69294
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
69283
69295
|
case 1048576 /* NENull */:
|
|
69284
|
-
return mapType(reduced, (t) =>
|
|
69296
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
69285
69297
|
case 2097152 /* NEUndefinedOrNull */:
|
|
69286
69298
|
case 4194304 /* Truthy */:
|
|
69287
|
-
return mapType(reduced, (t) =>
|
|
69299
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
69288
69300
|
}
|
|
69289
69301
|
}
|
|
69290
69302
|
return reduced;
|
|
@@ -70621,14 +70633,14 @@ function createTypeChecker(host) {
|
|
|
70621
70633
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
70622
70634
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
70623
70635
|
// but are classified as "function" according to `typeof`.
|
|
70624
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
70636
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
70625
70637
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
70626
70638
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
70627
70639
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
70628
70640
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
70629
70641
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
70630
70642
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
70631
|
-
|
|
70643
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
70632
70644
|
)
|
|
70633
70645
|
)
|
|
70634
70646
|
));
|
|
@@ -70642,7 +70654,7 @@ function createTypeChecker(host) {
|
|
|
70642
70654
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
70643
70655
|
if (hasDefaultClause) {
|
|
70644
70656
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
70645
|
-
return filterType(type, (t) =>
|
|
70657
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
70646
70658
|
}
|
|
70647
70659
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
70648
70660
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -70780,7 +70792,7 @@ function createTypeChecker(host) {
|
|
|
70780
70792
|
false
|
|
70781
70793
|
);
|
|
70782
70794
|
}
|
|
70783
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
70795
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
70784
70796
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
70785
70797
|
}
|
|
70786
70798
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -70914,7 +70926,7 @@ function createTypeChecker(host) {
|
|
|
70914
70926
|
reportCircularityError(declaration.symbol);
|
|
70915
70927
|
return true;
|
|
70916
70928
|
}
|
|
70917
|
-
const containsUndefined = !!(
|
|
70929
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
70918
70930
|
if (!popTypeResolution()) {
|
|
70919
70931
|
reportCircularityError(declaration.symbol);
|
|
70920
70932
|
return true;
|
|
@@ -70924,7 +70936,7 @@ function createTypeChecker(host) {
|
|
|
70924
70936
|
return links.parameterInitializerContainsUndefined;
|
|
70925
70937
|
}
|
|
70926
70938
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
70927
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
70939
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
70928
70940
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
70929
70941
|
}
|
|
70930
70942
|
function isConstraintPosition(type, node) {
|
|
@@ -73754,7 +73766,7 @@ function createTypeChecker(host) {
|
|
|
73754
73766
|
return checkNonNullType(checkExpression(node), node);
|
|
73755
73767
|
}
|
|
73756
73768
|
function isNullableType(type) {
|
|
73757
|
-
return
|
|
73769
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73758
73770
|
}
|
|
73759
73771
|
function getNonNullableTypeIfNeeded(type) {
|
|
73760
73772
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -73800,7 +73812,7 @@ function createTypeChecker(host) {
|
|
|
73800
73812
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
73801
73813
|
return errorType;
|
|
73802
73814
|
}
|
|
73803
|
-
const facts = getTypeFacts(type);
|
|
73815
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73804
73816
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73805
73817
|
reportError(node, facts);
|
|
73806
73818
|
const t = getNonNullableType(type);
|
|
@@ -77580,7 +77592,7 @@ function createTypeChecker(host) {
|
|
|
77580
77592
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
77581
77593
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
77582
77594
|
}
|
|
77583
|
-
return !someType(operandConstraint, (t) =>
|
|
77595
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
77584
77596
|
}
|
|
77585
77597
|
const type = checkExpressionCached(node.expression);
|
|
77586
77598
|
if (!isLiteralType(type)) {
|
|
@@ -77898,14 +77910,15 @@ function createTypeChecker(host) {
|
|
|
77898
77910
|
if (symbol) {
|
|
77899
77911
|
if (isReadonlySymbol(symbol)) {
|
|
77900
77912
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
77913
|
+
} else {
|
|
77914
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
77901
77915
|
}
|
|
77902
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
77903
77916
|
}
|
|
77904
77917
|
return booleanType;
|
|
77905
77918
|
}
|
|
77906
77919
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
77907
77920
|
const type = getTypeOfSymbol(symbol);
|
|
77908
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
77921
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
77909
77922
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
77910
77923
|
}
|
|
77911
77924
|
}
|
|
@@ -78040,7 +78053,7 @@ function createTypeChecker(host) {
|
|
|
78040
78053
|
return getUnaryResultType(operandType);
|
|
78041
78054
|
case 54 /* ExclamationToken */:
|
|
78042
78055
|
checkTruthinessOfType(operandType, node.operand);
|
|
78043
|
-
const facts = getTypeFacts(operandType
|
|
78056
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
78044
78057
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
78045
78058
|
case 46 /* PlusPlusToken */:
|
|
78046
78059
|
case 47 /* MinusMinusToken */:
|
|
@@ -78271,7 +78284,7 @@ function createTypeChecker(host) {
|
|
|
78271
78284
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
78272
78285
|
const prop = exprOrAssignment;
|
|
78273
78286
|
if (prop.objectAssignmentInitializer) {
|
|
78274
|
-
if (strictNullChecks && !(
|
|
78287
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
78275
78288
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
78276
78289
|
}
|
|
78277
78290
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -78683,7 +78696,7 @@ function createTypeChecker(host) {
|
|
|
78683
78696
|
return checkInExpression(left, right, leftType, rightType);
|
|
78684
78697
|
case 56 /* AmpersandAmpersandToken */:
|
|
78685
78698
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
78686
|
-
const resultType2 =
|
|
78699
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
78687
78700
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
78688
78701
|
checkAssignmentOperator(rightType);
|
|
78689
78702
|
}
|
|
@@ -78691,7 +78704,7 @@ function createTypeChecker(host) {
|
|
|
78691
78704
|
}
|
|
78692
78705
|
case 57 /* BarBarToken */:
|
|
78693
78706
|
case 76 /* BarBarEqualsToken */: {
|
|
78694
|
-
const resultType2 =
|
|
78707
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
78695
78708
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
78696
78709
|
checkAssignmentOperator(rightType);
|
|
78697
78710
|
}
|
|
@@ -78699,7 +78712,7 @@ function createTypeChecker(host) {
|
|
|
78699
78712
|
}
|
|
78700
78713
|
case 61 /* QuestionQuestionToken */:
|
|
78701
78714
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
78702
|
-
const resultType2 =
|
|
78715
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
78703
78716
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
78704
78717
|
checkAssignmentOperator(rightType);
|
|
78705
78718
|
}
|
|
@@ -82016,7 +82029,7 @@ function createTypeChecker(host) {
|
|
|
82016
82029
|
}
|
|
82017
82030
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
82018
82031
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82019
|
-
if (!(
|
|
82032
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
82020
82033
|
return;
|
|
82021
82034
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
82022
82035
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.3";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230825`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -32436,7 +32436,9 @@ ${lanes.join("\n")}
|
|
|
32436
32436
|
let dotDotDotToken;
|
|
32437
32437
|
let expression;
|
|
32438
32438
|
if (token() !== 20 /* CloseBraceToken */) {
|
|
32439
|
-
|
|
32439
|
+
if (!inExpressionContext) {
|
|
32440
|
+
dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
32441
|
+
}
|
|
32440
32442
|
expression = parseExpression();
|
|
32441
32443
|
}
|
|
32442
32444
|
if (inExpressionContext) {
|
|
@@ -46887,6 +46889,9 @@ ${lanes.join("\n")}
|
|
|
46887
46889
|
const sourceFiles = host.getSourceFiles();
|
|
46888
46890
|
return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
|
|
46889
46891
|
}
|
|
46892
|
+
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
46893
|
+
return true;
|
|
46894
|
+
}
|
|
46890
46895
|
if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
|
|
46891
46896
|
if (declaration.kind === 208 /* BindingElement */) {
|
|
46892
46897
|
const errorBindingElement = getAncestor(usage, 208 /* BindingElement */);
|
|
@@ -46916,9 +46921,6 @@ ${lanes.join("\n")}
|
|
|
46916
46921
|
if (usage.kind === 277 /* ExportAssignment */ && usage.isExportEquals) {
|
|
46917
46922
|
return true;
|
|
46918
46923
|
}
|
|
46919
|
-
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
46920
|
-
return true;
|
|
46921
|
-
}
|
|
46922
46924
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
46923
46925
|
if (emitStandardClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
46924
46926
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
@@ -53128,8 +53130,8 @@ ${lanes.join("\n")}
|
|
|
53128
53130
|
});
|
|
53129
53131
|
}
|
|
53130
53132
|
});
|
|
53131
|
-
Debug.assert(setter
|
|
53132
|
-
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
53133
|
+
Debug.assert(!!setter);
|
|
53134
|
+
const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
|
|
53133
53135
|
result.push(setTextRange(
|
|
53134
53136
|
factory.createSetAccessorDeclaration(
|
|
53135
53137
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -53905,7 +53907,7 @@ ${lanes.join("\n")}
|
|
|
53905
53907
|
const pattern = declaration.parent;
|
|
53906
53908
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
53907
53909
|
parentType = getNonNullableType(parentType);
|
|
53908
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
53910
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
53909
53911
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
53910
53912
|
}
|
|
53911
53913
|
let type;
|
|
@@ -53948,7 +53950,7 @@ ${lanes.join("\n")}
|
|
|
53948
53950
|
return type;
|
|
53949
53951
|
}
|
|
53950
53952
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
53951
|
-
return strictNullChecks && !(
|
|
53953
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
53952
53954
|
}
|
|
53953
53955
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
53954
53956
|
}
|
|
@@ -62056,7 +62058,7 @@ ${lanes.join("\n")}
|
|
|
62056
62058
|
if (sourceType && targetType) {
|
|
62057
62059
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
62058
62060
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
62059
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
62061
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
62060
62062
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
62061
62063
|
sourceType,
|
|
62062
62064
|
targetType,
|
|
@@ -65213,7 +65215,7 @@ ${lanes.join("\n")}
|
|
|
65213
65215
|
return value.base10Value === "0";
|
|
65214
65216
|
}
|
|
65215
65217
|
function removeDefinitelyFalsyTypes(type) {
|
|
65216
|
-
return filterType(type, (t) =>
|
|
65218
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
65217
65219
|
}
|
|
65218
65220
|
function extractDefinitelyFalsyTypes(type) {
|
|
65219
65221
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -66958,7 +66960,13 @@ ${lanes.join("\n")}
|
|
|
66958
66960
|
const resolved = resolveStructuredTypeMembers(type);
|
|
66959
66961
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
66960
66962
|
}
|
|
66961
|
-
function getTypeFacts(type) {
|
|
66963
|
+
function getTypeFacts(type, mask2) {
|
|
66964
|
+
return getTypeFactsWorker(type, mask2) & mask2;
|
|
66965
|
+
}
|
|
66966
|
+
function hasTypeFacts(type, mask2) {
|
|
66967
|
+
return getTypeFacts(type, mask2) !== 0;
|
|
66968
|
+
}
|
|
66969
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
66962
66970
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
66963
66971
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
66964
66972
|
}
|
|
@@ -66991,6 +66999,10 @@ ${lanes.join("\n")}
|
|
|
66991
66999
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
66992
67000
|
}
|
|
66993
67001
|
if (flags & 524288 /* Object */) {
|
|
67002
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
67003
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
67004
|
+
return 0;
|
|
67005
|
+
}
|
|
66994
67006
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
66995
67007
|
}
|
|
66996
67008
|
if (flags & 16384 /* Void */) {
|
|
@@ -67012,20 +67024,20 @@ ${lanes.join("\n")}
|
|
|
67012
67024
|
return 0 /* None */;
|
|
67013
67025
|
}
|
|
67014
67026
|
if (flags & 1048576 /* Union */) {
|
|
67015
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
67027
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
67016
67028
|
}
|
|
67017
67029
|
if (flags & 2097152 /* Intersection */) {
|
|
67018
|
-
return getIntersectionTypeFacts(type);
|
|
67030
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
67019
67031
|
}
|
|
67020
67032
|
return 83886079 /* UnknownFacts */;
|
|
67021
67033
|
}
|
|
67022
|
-
function getIntersectionTypeFacts(type) {
|
|
67034
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
67023
67035
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
67024
67036
|
let oredFacts = 0 /* None */;
|
|
67025
67037
|
let andedFacts = 134217727 /* All */;
|
|
67026
67038
|
for (const t of type.types) {
|
|
67027
67039
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
67028
|
-
const f =
|
|
67040
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
67029
67041
|
oredFacts |= f;
|
|
67030
67042
|
andedFacts &= f;
|
|
67031
67043
|
}
|
|
@@ -67033,19 +67045,19 @@ ${lanes.join("\n")}
|
|
|
67033
67045
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
67034
67046
|
}
|
|
67035
67047
|
function getTypeWithFacts(type, include) {
|
|
67036
|
-
return filterType(type, (t) => (
|
|
67048
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
67037
67049
|
}
|
|
67038
67050
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
67039
67051
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
67040
67052
|
if (strictNullChecks) {
|
|
67041
67053
|
switch (facts) {
|
|
67042
67054
|
case 524288 /* NEUndefined */:
|
|
67043
|
-
return mapType(reduced, (t) =>
|
|
67055
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
67044
67056
|
case 1048576 /* NENull */:
|
|
67045
|
-
return mapType(reduced, (t) =>
|
|
67057
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
67046
67058
|
case 2097152 /* NEUndefinedOrNull */:
|
|
67047
67059
|
case 4194304 /* Truthy */:
|
|
67048
|
-
return mapType(reduced, (t) =>
|
|
67060
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
67049
67061
|
}
|
|
67050
67062
|
}
|
|
67051
67063
|
return reduced;
|
|
@@ -68382,14 +68394,14 @@ ${lanes.join("\n")}
|
|
|
68382
68394
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
68383
68395
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
68384
68396
|
// but are classified as "function" according to `typeof`.
|
|
68385
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
68397
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
68386
68398
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
68387
68399
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
68388
68400
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
68389
68401
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
68390
68402
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
68391
68403
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
68392
|
-
|
|
68404
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
68393
68405
|
)
|
|
68394
68406
|
)
|
|
68395
68407
|
));
|
|
@@ -68403,7 +68415,7 @@ ${lanes.join("\n")}
|
|
|
68403
68415
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
68404
68416
|
if (hasDefaultClause) {
|
|
68405
68417
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
68406
|
-
return filterType(type, (t) =>
|
|
68418
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
68407
68419
|
}
|
|
68408
68420
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
68409
68421
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -68541,7 +68553,7 @@ ${lanes.join("\n")}
|
|
|
68541
68553
|
false
|
|
68542
68554
|
);
|
|
68543
68555
|
}
|
|
68544
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
68556
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
68545
68557
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
68546
68558
|
}
|
|
68547
68559
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -68675,7 +68687,7 @@ ${lanes.join("\n")}
|
|
|
68675
68687
|
reportCircularityError(declaration.symbol);
|
|
68676
68688
|
return true;
|
|
68677
68689
|
}
|
|
68678
|
-
const containsUndefined = !!(
|
|
68690
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
68679
68691
|
if (!popTypeResolution()) {
|
|
68680
68692
|
reportCircularityError(declaration.symbol);
|
|
68681
68693
|
return true;
|
|
@@ -68685,7 +68697,7 @@ ${lanes.join("\n")}
|
|
|
68685
68697
|
return links.parameterInitializerContainsUndefined;
|
|
68686
68698
|
}
|
|
68687
68699
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
68688
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
68700
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
68689
68701
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
68690
68702
|
}
|
|
68691
68703
|
function isConstraintPosition(type, node) {
|
|
@@ -71515,7 +71527,7 @@ ${lanes.join("\n")}
|
|
|
71515
71527
|
return checkNonNullType(checkExpression(node), node);
|
|
71516
71528
|
}
|
|
71517
71529
|
function isNullableType(type) {
|
|
71518
|
-
return
|
|
71530
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
71519
71531
|
}
|
|
71520
71532
|
function getNonNullableTypeIfNeeded(type) {
|
|
71521
71533
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -71561,7 +71573,7 @@ ${lanes.join("\n")}
|
|
|
71561
71573
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
71562
71574
|
return errorType;
|
|
71563
71575
|
}
|
|
71564
|
-
const facts = getTypeFacts(type);
|
|
71576
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
71565
71577
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
71566
71578
|
reportError(node, facts);
|
|
71567
71579
|
const t = getNonNullableType(type);
|
|
@@ -75341,7 +75353,7 @@ ${lanes.join("\n")}
|
|
|
75341
75353
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
75342
75354
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
75343
75355
|
}
|
|
75344
|
-
return !someType(operandConstraint, (t) =>
|
|
75356
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
75345
75357
|
}
|
|
75346
75358
|
const type = checkExpressionCached(node.expression);
|
|
75347
75359
|
if (!isLiteralType(type)) {
|
|
@@ -75659,14 +75671,15 @@ ${lanes.join("\n")}
|
|
|
75659
75671
|
if (symbol) {
|
|
75660
75672
|
if (isReadonlySymbol(symbol)) {
|
|
75661
75673
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
75674
|
+
} else {
|
|
75675
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
75662
75676
|
}
|
|
75663
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
75664
75677
|
}
|
|
75665
75678
|
return booleanType;
|
|
75666
75679
|
}
|
|
75667
75680
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
75668
75681
|
const type = getTypeOfSymbol(symbol);
|
|
75669
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
75682
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
75670
75683
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
75671
75684
|
}
|
|
75672
75685
|
}
|
|
@@ -75801,7 +75814,7 @@ ${lanes.join("\n")}
|
|
|
75801
75814
|
return getUnaryResultType(operandType);
|
|
75802
75815
|
case 54 /* ExclamationToken */:
|
|
75803
75816
|
checkTruthinessOfType(operandType, node.operand);
|
|
75804
|
-
const facts = getTypeFacts(operandType
|
|
75817
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
75805
75818
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
75806
75819
|
case 46 /* PlusPlusToken */:
|
|
75807
75820
|
case 47 /* MinusMinusToken */:
|
|
@@ -76032,7 +76045,7 @@ ${lanes.join("\n")}
|
|
|
76032
76045
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
76033
76046
|
const prop = exprOrAssignment;
|
|
76034
76047
|
if (prop.objectAssignmentInitializer) {
|
|
76035
|
-
if (strictNullChecks && !(
|
|
76048
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
76036
76049
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
76037
76050
|
}
|
|
76038
76051
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -76444,7 +76457,7 @@ ${lanes.join("\n")}
|
|
|
76444
76457
|
return checkInExpression(left, right, leftType, rightType);
|
|
76445
76458
|
case 56 /* AmpersandAmpersandToken */:
|
|
76446
76459
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
76447
|
-
const resultType2 =
|
|
76460
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
76448
76461
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
76449
76462
|
checkAssignmentOperator(rightType);
|
|
76450
76463
|
}
|
|
@@ -76452,7 +76465,7 @@ ${lanes.join("\n")}
|
|
|
76452
76465
|
}
|
|
76453
76466
|
case 57 /* BarBarToken */:
|
|
76454
76467
|
case 76 /* BarBarEqualsToken */: {
|
|
76455
|
-
const resultType2 =
|
|
76468
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
76456
76469
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
76457
76470
|
checkAssignmentOperator(rightType);
|
|
76458
76471
|
}
|
|
@@ -76460,7 +76473,7 @@ ${lanes.join("\n")}
|
|
|
76460
76473
|
}
|
|
76461
76474
|
case 61 /* QuestionQuestionToken */:
|
|
76462
76475
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
76463
|
-
const resultType2 =
|
|
76476
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
76464
76477
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
76465
76478
|
checkAssignmentOperator(rightType);
|
|
76466
76479
|
}
|
|
@@ -79777,7 +79790,7 @@ ${lanes.join("\n")}
|
|
|
79777
79790
|
}
|
|
79778
79791
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
79779
79792
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
79780
|
-
if (!(
|
|
79793
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
79781
79794
|
return;
|
|
79782
79795
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
79783
79796
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.3";
|
|
57
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20230825`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -21824,7 +21824,9 @@ var Parser;
|
|
|
21824
21824
|
let dotDotDotToken;
|
|
21825
21825
|
let expression;
|
|
21826
21826
|
if (token() !== 20 /* CloseBraceToken */) {
|
|
21827
|
-
|
|
21827
|
+
if (!inExpressionContext) {
|
|
21828
|
+
dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
21829
|
+
}
|
|
21828
21830
|
expression = parseExpression();
|
|
21829
21831
|
}
|
|
21830
21832
|
if (inExpressionContext) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.3.0-dev.
|
|
5
|
+
"version": "5.3.0-dev.20230825",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"node": "20.1.0",
|
|
113
113
|
"npm": "8.19.4"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "c3c5abb3a7d960de6e2fb75bc2a74fb90d9109b6"
|
|
116
116
|
}
|