@typescript-deploys/pr-build 5.3.0-pr-55471-8 → 5.3.0-pr-55503-5
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 +66 -57
- package/lib/tsserver.js +90 -72
- package/lib/typescript.js +482 -464
- package/lib/typingsInstaller.js +4 -4
- 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-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20230824`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -5955,7 +5955,6 @@ var Diagnostics = {
|
|
|
5955
5955
|
Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, 1 /* Error */, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"),
|
|
5956
5956
|
Keywords_cannot_contain_escape_characters: diag(1260, 1 /* Error */, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
|
|
5957
5957
|
Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, 1 /* Error */, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."),
|
|
5958
|
-
Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module: diag(1262, 1 /* Error */, "Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module_1262", "Identifier expected. '{0}' is a reserved word at the top-level of a module."),
|
|
5959
5958
|
Declarations_with_initializers_cannot_also_have_definite_assignment_assertions: diag(1263, 1 /* Error */, "Declarations_with_initializers_cannot_also_have_definite_assignment_assertions_1263", "Declarations with initializers cannot also have definite assignment assertions."),
|
|
5960
5959
|
Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, 1 /* Error */, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."),
|
|
5961
5960
|
A_rest_element_cannot_follow_another_rest_element: diag(1265, 1 /* Error */, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."),
|
|
@@ -11771,8 +11770,8 @@ function getInternalEmitFlags(node) {
|
|
|
11771
11770
|
const emitNode = node.emitNode;
|
|
11772
11771
|
return emitNode && emitNode.internalFlags || 0;
|
|
11773
11772
|
}
|
|
11774
|
-
|
|
11775
|
-
|
|
11773
|
+
var getScriptTargetFeatures = /* @__PURE__ */ memoize(
|
|
11774
|
+
() => new Map(Object.entries({
|
|
11776
11775
|
Array: new Map(Object.entries({
|
|
11777
11776
|
es2015: [
|
|
11778
11777
|
"find",
|
|
@@ -11839,7 +11838,7 @@ function getScriptTargetFeatures() {
|
|
|
11839
11838
|
"defineProperty",
|
|
11840
11839
|
"deleteProperty",
|
|
11841
11840
|
"get",
|
|
11842
|
-
"
|
|
11841
|
+
"getOwnPropertyDescriptor",
|
|
11843
11842
|
"getPrototypeOf",
|
|
11844
11843
|
"has",
|
|
11845
11844
|
"isExtensible",
|
|
@@ -12165,8 +12164,8 @@ function getScriptTargetFeatures() {
|
|
|
12165
12164
|
"cause"
|
|
12166
12165
|
]
|
|
12167
12166
|
}))
|
|
12168
|
-
}))
|
|
12169
|
-
|
|
12167
|
+
}))
|
|
12168
|
+
);
|
|
12170
12169
|
function getLiteralText(node, sourceFile, flags) {
|
|
12171
12170
|
if (sourceFile && canUseOriginalText(node, flags)) {
|
|
12172
12171
|
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
|
@@ -29967,7 +29966,9 @@ var Parser;
|
|
|
29967
29966
|
let dotDotDotToken;
|
|
29968
29967
|
let expression;
|
|
29969
29968
|
if (token() !== 20 /* CloseBraceToken */) {
|
|
29970
|
-
|
|
29969
|
+
if (!inExpressionContext) {
|
|
29970
|
+
dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
29971
|
+
}
|
|
29971
29972
|
expression = parseExpression();
|
|
29972
29973
|
}
|
|
29973
29974
|
if (inExpressionContext) {
|
|
@@ -40898,12 +40899,8 @@ function createBinder() {
|
|
|
40898
40899
|
}
|
|
40899
40900
|
if (inStrictMode && originalKeywordKind >= 119 /* FirstFutureReservedWord */ && originalKeywordKind <= 127 /* LastFutureReservedWord */) {
|
|
40900
40901
|
file.bindDiagnostics.push(createDiagnosticForNode2(node, getStrictModeIdentifierMessage(node), declarationNameToString(node)));
|
|
40901
|
-
} else if (originalKeywordKind === 135 /* AwaitKeyword */) {
|
|
40902
|
-
|
|
40903
|
-
file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, declarationNameToString(node)));
|
|
40904
|
-
} else if (node.flags & 65536 /* AwaitContext */) {
|
|
40905
|
-
file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, declarationNameToString(node)));
|
|
40906
|
-
}
|
|
40902
|
+
} else if (originalKeywordKind === 135 /* AwaitKeyword */ && (node.flags & 65536 /* AwaitContext */ || isExternalModule(file))) {
|
|
40903
|
+
file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, declarationNameToString(node)));
|
|
40907
40904
|
} else if (originalKeywordKind === 127 /* YieldKeyword */ && node.flags & 16384 /* YieldContext */) {
|
|
40908
40905
|
file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, declarationNameToString(node)));
|
|
40909
40906
|
}
|
|
@@ -44418,6 +44415,9 @@ function createTypeChecker(host) {
|
|
|
44418
44415
|
const sourceFiles = host.getSourceFiles();
|
|
44419
44416
|
return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
|
|
44420
44417
|
}
|
|
44418
|
+
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
44419
|
+
return true;
|
|
44420
|
+
}
|
|
44421
44421
|
if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
|
|
44422
44422
|
if (declaration.kind === 208 /* BindingElement */) {
|
|
44423
44423
|
const errorBindingElement = getAncestor(usage, 208 /* BindingElement */);
|
|
@@ -44447,9 +44447,6 @@ function createTypeChecker(host) {
|
|
|
44447
44447
|
if (usage.kind === 277 /* ExportAssignment */ && usage.isExportEquals) {
|
|
44448
44448
|
return true;
|
|
44449
44449
|
}
|
|
44450
|
-
if (!!(usage.flags & 16777216 /* JSDoc */) || isInTypeQuery(usage) || isInAmbientOrTypeNode(usage)) {
|
|
44451
|
-
return true;
|
|
44452
|
-
}
|
|
44453
44450
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
44454
44451
|
if (emitStandardClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44455
44452
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
@@ -50659,8 +50656,8 @@ function createTypeChecker(host) {
|
|
|
50659
50656
|
});
|
|
50660
50657
|
}
|
|
50661
50658
|
});
|
|
50662
|
-
Debug.assert(setter
|
|
50663
|
-
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
|
|
50659
|
+
Debug.assert(!!setter);
|
|
50660
|
+
const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
|
|
50664
50661
|
result.push(setTextRange(
|
|
50665
50662
|
factory.createSetAccessorDeclaration(
|
|
50666
50663
|
factory.createModifiersFromModifierFlags(flag),
|
|
@@ -51436,7 +51433,7 @@ function createTypeChecker(host) {
|
|
|
51436
51433
|
const pattern = declaration.parent;
|
|
51437
51434
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
51438
51435
|
parentType = getNonNullableType(parentType);
|
|
51439
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
51436
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
51440
51437
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
51441
51438
|
}
|
|
51442
51439
|
let type;
|
|
@@ -51479,7 +51476,7 @@ function createTypeChecker(host) {
|
|
|
51479
51476
|
return type;
|
|
51480
51477
|
}
|
|
51481
51478
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
51482
|
-
return strictNullChecks && !(
|
|
51479
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
51483
51480
|
}
|
|
51484
51481
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
51485
51482
|
}
|
|
@@ -57081,7 +57078,7 @@ function createTypeChecker(host) {
|
|
|
57081
57078
|
}
|
|
57082
57079
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
57083
57080
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
57084
|
-
const propertyTypes = map(getPropertiesOfType(type), (prop) =>
|
|
57081
|
+
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
57085
57082
|
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
57086
57083
|
return getUnionType(
|
|
57087
57084
|
concatenate(propertyTypes, indexKeyTypes),
|
|
@@ -59587,7 +59584,7 @@ function createTypeChecker(host) {
|
|
|
59587
59584
|
if (sourceType && targetType) {
|
|
59588
59585
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
59589
59586
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
59590
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
|
59587
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
59591
59588
|
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
59589
|
sourceType,
|
|
59593
59590
|
targetType,
|
|
@@ -62744,7 +62741,7 @@ function createTypeChecker(host) {
|
|
|
62744
62741
|
return value.base10Value === "0";
|
|
62745
62742
|
}
|
|
62746
62743
|
function removeDefinitelyFalsyTypes(type) {
|
|
62747
|
-
return filterType(type, (t) =>
|
|
62744
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
62748
62745
|
}
|
|
62749
62746
|
function extractDefinitelyFalsyTypes(type) {
|
|
62750
62747
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -64020,12 +64017,14 @@ function createTypeChecker(host) {
|
|
|
64020
64017
|
}
|
|
64021
64018
|
function inferFromSignatures(source, target, kind) {
|
|
64022
64019
|
const sourceSignatures = getSignaturesOfType(source, kind);
|
|
64023
|
-
const targetSignatures = getSignaturesOfType(target, kind);
|
|
64024
64020
|
const sourceLen = sourceSignatures.length;
|
|
64025
|
-
|
|
64026
|
-
|
|
64027
|
-
|
|
64028
|
-
|
|
64021
|
+
if (sourceLen > 0) {
|
|
64022
|
+
const targetSignatures = getSignaturesOfType(target, kind);
|
|
64023
|
+
const targetLen = targetSignatures.length;
|
|
64024
|
+
for (let i = 0; i < targetLen; i++) {
|
|
64025
|
+
const sourceIndex = Math.max(sourceLen - targetLen + i, 0);
|
|
64026
|
+
inferFromSignature(getBaseSignature(sourceSignatures[sourceIndex]), getErasedSignature(targetSignatures[i]));
|
|
64027
|
+
}
|
|
64029
64028
|
}
|
|
64030
64029
|
}
|
|
64031
64030
|
function inferFromSignature(source, target) {
|
|
@@ -64487,7 +64486,13 @@ function createTypeChecker(host) {
|
|
|
64487
64486
|
const resolved = resolveStructuredTypeMembers(type);
|
|
64488
64487
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
64489
64488
|
}
|
|
64490
|
-
function getTypeFacts(type) {
|
|
64489
|
+
function getTypeFacts(type, mask) {
|
|
64490
|
+
return getTypeFactsWorker(type, mask) & mask;
|
|
64491
|
+
}
|
|
64492
|
+
function hasTypeFacts(type, mask) {
|
|
64493
|
+
return getTypeFacts(type, mask) !== 0;
|
|
64494
|
+
}
|
|
64495
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
64491
64496
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
64492
64497
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
64493
64498
|
}
|
|
@@ -64520,6 +64525,10 @@ function createTypeChecker(host) {
|
|
|
64520
64525
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
64521
64526
|
}
|
|
64522
64527
|
if (flags & 524288 /* Object */) {
|
|
64528
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
64529
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
64530
|
+
return 0;
|
|
64531
|
+
}
|
|
64523
64532
|
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
64533
|
}
|
|
64525
64534
|
if (flags & 16384 /* Void */) {
|
|
@@ -64541,20 +64550,20 @@ function createTypeChecker(host) {
|
|
|
64541
64550
|
return 0 /* None */;
|
|
64542
64551
|
}
|
|
64543
64552
|
if (flags & 1048576 /* Union */) {
|
|
64544
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
64553
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
64545
64554
|
}
|
|
64546
64555
|
if (flags & 2097152 /* Intersection */) {
|
|
64547
|
-
return getIntersectionTypeFacts(type);
|
|
64556
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
64548
64557
|
}
|
|
64549
64558
|
return 83886079 /* UnknownFacts */;
|
|
64550
64559
|
}
|
|
64551
|
-
function getIntersectionTypeFacts(type) {
|
|
64560
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
64552
64561
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
64553
64562
|
let oredFacts = 0 /* None */;
|
|
64554
64563
|
let andedFacts = 134217727 /* All */;
|
|
64555
64564
|
for (const t of type.types) {
|
|
64556
64565
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
64557
|
-
const f =
|
|
64566
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
64558
64567
|
oredFacts |= f;
|
|
64559
64568
|
andedFacts &= f;
|
|
64560
64569
|
}
|
|
@@ -64562,19 +64571,19 @@ function createTypeChecker(host) {
|
|
|
64562
64571
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
64563
64572
|
}
|
|
64564
64573
|
function getTypeWithFacts(type, include) {
|
|
64565
|
-
return filterType(type, (t) => (
|
|
64574
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
64566
64575
|
}
|
|
64567
64576
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
64568
64577
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
64569
64578
|
if (strictNullChecks) {
|
|
64570
64579
|
switch (facts) {
|
|
64571
64580
|
case 524288 /* NEUndefined */:
|
|
64572
|
-
return mapType(reduced, (t) =>
|
|
64581
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
64573
64582
|
case 1048576 /* NENull */:
|
|
64574
|
-
return mapType(reduced, (t) =>
|
|
64583
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
64575
64584
|
case 2097152 /* NEUndefinedOrNull */:
|
|
64576
64585
|
case 4194304 /* Truthy */:
|
|
64577
|
-
return mapType(reduced, (t) =>
|
|
64586
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
64578
64587
|
}
|
|
64579
64588
|
}
|
|
64580
64589
|
return reduced;
|
|
@@ -65561,7 +65570,7 @@ function createTypeChecker(host) {
|
|
|
65561
65570
|
return void 0;
|
|
65562
65571
|
}
|
|
65563
65572
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
65564
|
-
const type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
65573
|
+
const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
65565
65574
|
if (type.flags & 1048576 /* Union */) {
|
|
65566
65575
|
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
65567
65576
|
if (access) {
|
|
@@ -65911,14 +65920,14 @@ function createTypeChecker(host) {
|
|
|
65911
65920
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
65912
65921
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
65913
65922
|
// but are classified as "function" according to `typeof`.
|
|
65914
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
65923
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
65915
65924
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
65916
65925
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
65917
65926
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
65918
65927
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
65919
65928
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
65920
65929
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
65921
|
-
|
|
65930
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
65922
65931
|
)
|
|
65923
65932
|
)
|
|
65924
65933
|
));
|
|
@@ -65932,7 +65941,7 @@ function createTypeChecker(host) {
|
|
|
65932
65941
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
65933
65942
|
if (hasDefaultClause) {
|
|
65934
65943
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
65935
|
-
return filterType(type, (t) =>
|
|
65944
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
65936
65945
|
}
|
|
65937
65946
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
65938
65947
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -66070,7 +66079,7 @@ function createTypeChecker(host) {
|
|
|
66070
66079
|
false
|
|
66071
66080
|
);
|
|
66072
66081
|
}
|
|
66073
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
66082
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
66074
66083
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
66075
66084
|
}
|
|
66076
66085
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -66204,7 +66213,7 @@ function createTypeChecker(host) {
|
|
|
66204
66213
|
reportCircularityError(declaration.symbol);
|
|
66205
66214
|
return true;
|
|
66206
66215
|
}
|
|
66207
|
-
const containsUndefined = !!(
|
|
66216
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
66208
66217
|
if (!popTypeResolution()) {
|
|
66209
66218
|
reportCircularityError(declaration.symbol);
|
|
66210
66219
|
return true;
|
|
@@ -66214,7 +66223,7 @@ function createTypeChecker(host) {
|
|
|
66214
66223
|
return links.parameterInitializerContainsUndefined;
|
|
66215
66224
|
}
|
|
66216
66225
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
66217
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
66226
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
66218
66227
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
66219
66228
|
}
|
|
66220
66229
|
function isConstraintPosition(type, node) {
|
|
@@ -69044,7 +69053,7 @@ function createTypeChecker(host) {
|
|
|
69044
69053
|
return checkNonNullType(checkExpression(node), node);
|
|
69045
69054
|
}
|
|
69046
69055
|
function isNullableType(type) {
|
|
69047
|
-
return
|
|
69056
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69048
69057
|
}
|
|
69049
69058
|
function getNonNullableTypeIfNeeded(type) {
|
|
69050
69059
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -69090,7 +69099,7 @@ function createTypeChecker(host) {
|
|
|
69090
69099
|
error(node, Diagnostics.Object_is_of_type_unknown);
|
|
69091
69100
|
return errorType;
|
|
69092
69101
|
}
|
|
69093
|
-
const facts = getTypeFacts(type);
|
|
69102
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69094
69103
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
69095
69104
|
reportError(node, facts);
|
|
69096
69105
|
const t = getNonNullableType(type);
|
|
@@ -72870,7 +72879,7 @@ function createTypeChecker(host) {
|
|
|
72870
72879
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
72871
72880
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
72872
72881
|
}
|
|
72873
|
-
return !someType(operandConstraint, (t) =>
|
|
72882
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
72874
72883
|
}
|
|
72875
72884
|
const type = checkExpressionCached(node.expression);
|
|
72876
72885
|
if (!isLiteralType(type)) {
|
|
@@ -73188,14 +73197,15 @@ function createTypeChecker(host) {
|
|
|
73188
73197
|
if (symbol) {
|
|
73189
73198
|
if (isReadonlySymbol(symbol)) {
|
|
73190
73199
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
73200
|
+
} else {
|
|
73201
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73191
73202
|
}
|
|
73192
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
73193
73203
|
}
|
|
73194
73204
|
return booleanType;
|
|
73195
73205
|
}
|
|
73196
73206
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
73197
73207
|
const type = getTypeOfSymbol(symbol);
|
|
73198
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
73208
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
73199
73209
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
73200
73210
|
}
|
|
73201
73211
|
}
|
|
@@ -73330,7 +73340,7 @@ function createTypeChecker(host) {
|
|
|
73330
73340
|
return getUnaryResultType(operandType);
|
|
73331
73341
|
case 54 /* ExclamationToken */:
|
|
73332
73342
|
checkTruthinessOfType(operandType, node.operand);
|
|
73333
|
-
const facts = getTypeFacts(operandType
|
|
73343
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
73334
73344
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
73335
73345
|
case 46 /* PlusPlusToken */:
|
|
73336
73346
|
case 47 /* MinusMinusToken */:
|
|
@@ -73561,7 +73571,7 @@ function createTypeChecker(host) {
|
|
|
73561
73571
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
73562
73572
|
const prop = exprOrAssignment;
|
|
73563
73573
|
if (prop.objectAssignmentInitializer) {
|
|
73564
|
-
if (strictNullChecks && !(
|
|
73574
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
73565
73575
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
73566
73576
|
}
|
|
73567
73577
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -73973,7 +73983,7 @@ function createTypeChecker(host) {
|
|
|
73973
73983
|
return checkInExpression(left, right, leftType, rightType);
|
|
73974
73984
|
case 56 /* AmpersandAmpersandToken */:
|
|
73975
73985
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
73976
|
-
const resultType2 =
|
|
73986
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
73977
73987
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
73978
73988
|
checkAssignmentOperator(rightType);
|
|
73979
73989
|
}
|
|
@@ -73981,7 +73991,7 @@ function createTypeChecker(host) {
|
|
|
73981
73991
|
}
|
|
73982
73992
|
case 57 /* BarBarToken */:
|
|
73983
73993
|
case 76 /* BarBarEqualsToken */: {
|
|
73984
|
-
const resultType2 =
|
|
73994
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
73985
73995
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
73986
73996
|
checkAssignmentOperator(rightType);
|
|
73987
73997
|
}
|
|
@@ -73989,7 +73999,7 @@ function createTypeChecker(host) {
|
|
|
73989
73999
|
}
|
|
73990
74000
|
case 61 /* QuestionQuestionToken */:
|
|
73991
74001
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
73992
|
-
const resultType2 =
|
|
74002
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
73993
74003
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
73994
74004
|
checkAssignmentOperator(rightType);
|
|
73995
74005
|
}
|
|
@@ -77306,7 +77316,7 @@ function createTypeChecker(host) {
|
|
|
77306
77316
|
}
|
|
77307
77317
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
77308
77318
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
77309
|
-
if (!(
|
|
77319
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
77310
77320
|
return;
|
|
77311
77321
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
77312
77322
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
|
@@ -115277,7 +115287,6 @@ var plainJSErrors = /* @__PURE__ */ new Set([
|
|
|
115277
115287
|
Diagnostics.A_module_cannot_have_multiple_default_exports.code,
|
|
115278
115288
|
Diagnostics.Another_export_default_is_here.code,
|
|
115279
115289
|
Diagnostics.The_first_export_default_is_here.code,
|
|
115280
|
-
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
|
|
115281
115290
|
Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
|
|
115282
115291
|
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
|
|
115283
115292
|
Diagnostics.constructor_is_a_reserved_word.code,
|