@typescript-deploys/pr-build 5.3.0-pr-55452-4 → 5.3.0-pr-55459-3
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 +77 -82
- package/lib/tsserver.js +77 -85
- package/lib/typescript.d.ts +3 -4
- package/lib/typescript.js +77 -84
- package/lib/typingsInstaller.js +7 -18
- 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-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20230822`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -17484,9 +17484,6 @@ function getPropertyNameFromType(type) {
|
|
|
17484
17484
|
}
|
|
17485
17485
|
return Debug.fail();
|
|
17486
17486
|
}
|
|
17487
|
-
function isNamedTupleMemberName(node) {
|
|
17488
|
-
return node.kind === 80 /* Identifier */ || node.kind === 203 /* TemplateLiteralType */ || node.kind === 15 /* NoSubstitutionTemplateLiteral */;
|
|
17489
|
-
}
|
|
17490
17487
|
|
|
17491
17488
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17492
17489
|
function createBaseNodeFactory() {
|
|
@@ -28660,29 +28657,21 @@ var Parser;
|
|
|
28660
28657
|
}
|
|
28661
28658
|
return type;
|
|
28662
28659
|
}
|
|
28663
|
-
function
|
|
28664
|
-
return
|
|
28660
|
+
function isNextTokenColonOrQuestionColon() {
|
|
28661
|
+
return nextToken() === 59 /* ColonToken */ || token() === 58 /* QuestionToken */ && nextToken() === 59 /* ColonToken */;
|
|
28665
28662
|
}
|
|
28666
28663
|
function isTupleElementName() {
|
|
28667
28664
|
if (token() === 26 /* DotDotDotToken */) {
|
|
28668
|
-
nextToken();
|
|
28669
|
-
}
|
|
28670
|
-
if (token() === 16 /* TemplateHead */) {
|
|
28671
|
-
parseTemplateType();
|
|
28672
|
-
return isTokenColonOrQuestionColon();
|
|
28673
|
-
}
|
|
28674
|
-
if (tokenIsIdentifierOrKeyword(token()) || token() === 15 /* NoSubstitutionTemplateLiteral */) {
|
|
28675
|
-
nextToken();
|
|
28676
|
-
return isTokenColonOrQuestionColon();
|
|
28665
|
+
return tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
|
|
28677
28666
|
}
|
|
28678
|
-
return
|
|
28667
|
+
return tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
|
|
28679
28668
|
}
|
|
28680
28669
|
function parseTupleElementNameOrTupleElementType() {
|
|
28681
28670
|
if (lookAhead(isTupleElementName)) {
|
|
28682
28671
|
const pos = getNodePos();
|
|
28683
28672
|
const hasJSDoc = hasPrecedingJSDocComment();
|
|
28684
28673
|
const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
28685
|
-
const name =
|
|
28674
|
+
const name = parseIdentifierName();
|
|
28686
28675
|
const questionToken = parseOptionalToken(58 /* QuestionToken */);
|
|
28687
28676
|
parseExpected(59 /* ColonToken */);
|
|
28688
28677
|
const type = parseTupleElementType();
|
|
@@ -48092,11 +48081,10 @@ function createTypeChecker(host) {
|
|
|
48092
48081
|
for (let i = 0; i < tupleConstituentNodes.length; i++) {
|
|
48093
48082
|
const flags = type2.target.elementFlags[i];
|
|
48094
48083
|
const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
|
|
48095
|
-
|
|
48096
|
-
if (label) {
|
|
48084
|
+
if (labeledElementDeclaration) {
|
|
48097
48085
|
tupleConstituentNodes[i] = factory.createNamedTupleMember(
|
|
48098
48086
|
flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
|
|
48099
|
-
factory.createIdentifier(unescapeLeadingUnderscores(
|
|
48087
|
+
factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
|
|
48100
48088
|
flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
|
|
48101
48089
|
flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
|
|
48102
48090
|
);
|
|
@@ -51424,7 +51412,7 @@ function createTypeChecker(host) {
|
|
|
51424
51412
|
const pattern = declaration.parent;
|
|
51425
51413
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
51426
51414
|
parentType = getNonNullableType(parentType);
|
|
51427
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
51415
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
51428
51416
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
51429
51417
|
}
|
|
51430
51418
|
let type;
|
|
@@ -51467,7 +51455,7 @@ function createTypeChecker(host) {
|
|
|
51467
51455
|
return type;
|
|
51468
51456
|
}
|
|
51469
51457
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
51470
|
-
return strictNullChecks && !(
|
|
51458
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
51471
51459
|
}
|
|
51472
51460
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
51473
51461
|
}
|
|
@@ -53296,7 +53284,7 @@ function createTypeChecker(host) {
|
|
|
53296
53284
|
function getUniqAssociatedNamesFromTupleType(type, restName) {
|
|
53297
53285
|
const associatedNamesMap = /* @__PURE__ */ new Map();
|
|
53298
53286
|
return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
|
|
53299
|
-
const name = getTupleElementLabel(
|
|
53287
|
+
const name = getTupleElementLabel(labeledElement, i, restName);
|
|
53300
53288
|
const prevCounter = associatedNamesMap.get(name);
|
|
53301
53289
|
if (prevCounter === void 0) {
|
|
53302
53290
|
associatedNamesMap.set(name, 1);
|
|
@@ -54752,7 +54740,7 @@ function createTypeChecker(host) {
|
|
|
54752
54740
|
}
|
|
54753
54741
|
const iife = getImmediatelyInvokedFunctionExpression(node.parent);
|
|
54754
54742
|
if (iife) {
|
|
54755
|
-
return !node.type && !node.dotDotDotToken && node.parent.parameters.indexOf(node) >= iife.
|
|
54743
|
+
return !node.type && !node.dotDotDotToken && node.parent.parameters.indexOf(node) >= getEffectiveCallArguments(iife).length;
|
|
54756
54744
|
}
|
|
54757
54745
|
return false;
|
|
54758
54746
|
}
|
|
@@ -59575,7 +59563,7 @@ function createTypeChecker(host) {
|
|
|
59575
59563
|
if (sourceType && targetType) {
|
|
59576
59564
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
59577
59565
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
59578
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (
|
|
59566
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getOnlyTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getOnlyTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
59579
59567
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
59580
59568
|
sourceType,
|
|
59581
59569
|
targetType,
|
|
@@ -62732,7 +62720,7 @@ function createTypeChecker(host) {
|
|
|
62732
62720
|
return value.base10Value === "0";
|
|
62733
62721
|
}
|
|
62734
62722
|
function removeDefinitelyFalsyTypes(type) {
|
|
62735
|
-
return filterType(type, (t) =>
|
|
62723
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
62736
62724
|
}
|
|
62737
62725
|
function extractDefinitelyFalsyTypes(type) {
|
|
62738
62726
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -64475,7 +64463,13 @@ function createTypeChecker(host) {
|
|
|
64475
64463
|
const resolved = resolveStructuredTypeMembers(type);
|
|
64476
64464
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
64477
64465
|
}
|
|
64478
|
-
function
|
|
64466
|
+
function getOnlyTypeFacts(type, mask) {
|
|
64467
|
+
return getTypeFactsWorker(type, mask) & mask;
|
|
64468
|
+
}
|
|
64469
|
+
function hasTypeFacts(type, mask) {
|
|
64470
|
+
return getOnlyTypeFacts(type, mask) !== 0;
|
|
64471
|
+
}
|
|
64472
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
64479
64473
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
64480
64474
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
64481
64475
|
}
|
|
@@ -64508,6 +64502,10 @@ function createTypeChecker(host) {
|
|
|
64508
64502
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
64509
64503
|
}
|
|
64510
64504
|
if (flags & 524288 /* Object */) {
|
|
64505
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
64506
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
64507
|
+
return 0;
|
|
64508
|
+
}
|
|
64511
64509
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
64512
64510
|
}
|
|
64513
64511
|
if (flags & 16384 /* Void */) {
|
|
@@ -64529,20 +64527,20 @@ function createTypeChecker(host) {
|
|
|
64529
64527
|
return 0 /* None */;
|
|
64530
64528
|
}
|
|
64531
64529
|
if (flags & 1048576 /* Union */) {
|
|
64532
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
64530
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
64533
64531
|
}
|
|
64534
64532
|
if (flags & 2097152 /* Intersection */) {
|
|
64535
|
-
return getIntersectionTypeFacts(type);
|
|
64533
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
64536
64534
|
}
|
|
64537
64535
|
return 83886079 /* UnknownFacts */;
|
|
64538
64536
|
}
|
|
64539
|
-
function getIntersectionTypeFacts(type) {
|
|
64537
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
64540
64538
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
64541
64539
|
let oredFacts = 0 /* None */;
|
|
64542
64540
|
let andedFacts = 134217727 /* All */;
|
|
64543
64541
|
for (const t of type.types) {
|
|
64544
64542
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
64545
|
-
const f =
|
|
64543
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
64546
64544
|
oredFacts |= f;
|
|
64547
64545
|
andedFacts &= f;
|
|
64548
64546
|
}
|
|
@@ -64550,19 +64548,19 @@ function createTypeChecker(host) {
|
|
|
64550
64548
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
64551
64549
|
}
|
|
64552
64550
|
function getTypeWithFacts(type, include) {
|
|
64553
|
-
return filterType(type, (t) => (
|
|
64551
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
64554
64552
|
}
|
|
64555
64553
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
64556
64554
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
64557
64555
|
if (strictNullChecks) {
|
|
64558
64556
|
switch (facts) {
|
|
64559
64557
|
case 524288 /* NEUndefined */:
|
|
64560
|
-
return mapType(reduced, (t) =>
|
|
64558
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
64561
64559
|
case 1048576 /* NENull */:
|
|
64562
|
-
return mapType(reduced, (t) =>
|
|
64560
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
64563
64561
|
case 2097152 /* NEUndefinedOrNull */:
|
|
64564
64562
|
case 4194304 /* Truthy */:
|
|
64565
|
-
return mapType(reduced, (t) =>
|
|
64563
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
64566
64564
|
}
|
|
64567
64565
|
}
|
|
64568
64566
|
return reduced;
|
|
@@ -65899,14 +65897,14 @@ function createTypeChecker(host) {
|
|
|
65899
65897
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
65900
65898
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
65901
65899
|
// but are classified as "function" according to `typeof`.
|
|
65902
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
65900
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
65903
65901
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
65904
65902
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
65905
65903
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
65906
65904
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
65907
65905
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
65908
65906
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
65909
|
-
|
|
65907
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
65910
65908
|
)
|
|
65911
65909
|
)
|
|
65912
65910
|
));
|
|
@@ -65920,7 +65918,7 @@ function createTypeChecker(host) {
|
|
|
65920
65918
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
65921
65919
|
if (hasDefaultClause) {
|
|
65922
65920
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
65923
|
-
return filterType(type, (t) => (
|
|
65921
|
+
return filterType(type, (t) => getOnlyTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
65924
65922
|
}
|
|
65925
65923
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
65926
65924
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -66058,7 +66056,7 @@ function createTypeChecker(host) {
|
|
|
66058
66056
|
false
|
|
66059
66057
|
);
|
|
66060
66058
|
}
|
|
66061
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
66059
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
66062
66060
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
66063
66061
|
}
|
|
66064
66062
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -66192,7 +66190,7 @@ function createTypeChecker(host) {
|
|
|
66192
66190
|
reportCircularityError(declaration.symbol);
|
|
66193
66191
|
return true;
|
|
66194
66192
|
}
|
|
66195
|
-
const containsUndefined = !!(
|
|
66193
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
66196
66194
|
if (!popTypeResolution()) {
|
|
66197
66195
|
reportCircularityError(declaration.symbol);
|
|
66198
66196
|
return true;
|
|
@@ -66202,7 +66200,7 @@ function createTypeChecker(host) {
|
|
|
66202
66200
|
return links.parameterInitializerContainsUndefined;
|
|
66203
66201
|
}
|
|
66204
66202
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
66205
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
66203
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
66206
66204
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
66207
66205
|
}
|
|
66208
66206
|
function isConstraintPosition(type, node) {
|
|
@@ -69032,7 +69030,7 @@ function createTypeChecker(host) {
|
|
|
69032
69030
|
return checkNonNullType(checkExpression(node), node);
|
|
69033
69031
|
}
|
|
69034
69032
|
function isNullableType(type) {
|
|
69035
|
-
return
|
|
69033
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69036
69034
|
}
|
|
69037
69035
|
function getNonNullableTypeIfNeeded(type) {
|
|
69038
69036
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -69078,7 +69076,7 @@ function createTypeChecker(host) {
|
|
|
69078
69076
|
error(node, Diagnostics.Object_is_of_type_unknown);
|
|
69079
69077
|
return errorType;
|
|
69080
69078
|
}
|
|
69081
|
-
const facts =
|
|
69079
|
+
const facts = getOnlyTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
69082
69080
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
69083
69081
|
reportError(node, facts);
|
|
69084
69082
|
const t = getNonNullableType(type);
|
|
@@ -72052,27 +72050,20 @@ function createTypeChecker(host) {
|
|
|
72052
72050
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
72053
72051
|
}
|
|
72054
72052
|
function getTypeOfParameter(symbol) {
|
|
72055
|
-
const
|
|
72056
|
-
|
|
72057
|
-
|
|
72058
|
-
|
|
72059
|
-
|
|
72060
|
-
|
|
72061
|
-
|
|
72062
|
-
|
|
72053
|
+
const declaration = symbol.valueDeclaration;
|
|
72054
|
+
return addOptionality(
|
|
72055
|
+
getTypeOfSymbol(symbol),
|
|
72056
|
+
/*isProperty*/
|
|
72057
|
+
false,
|
|
72058
|
+
/*isOptional*/
|
|
72059
|
+
!!declaration && (hasInitializer(declaration) || isOptionalDeclaration(declaration))
|
|
72060
|
+
);
|
|
72063
72061
|
}
|
|
72064
|
-
function getTupleElementLabel(
|
|
72062
|
+
function getTupleElementLabel(d, index, restParameterName = "arg") {
|
|
72065
72063
|
if (!d) {
|
|
72066
72064
|
return `${restParameterName}_${index}`;
|
|
72067
72065
|
}
|
|
72068
|
-
Debug.assert(
|
|
72069
|
-
if (d.name.kind === 203 /* TemplateLiteralType */) {
|
|
72070
|
-
const label = instantiateType(getTypeFromTypeNode(d.name), tupleType.mapper);
|
|
72071
|
-
return label.flags & 128 /* StringLiteral */ ? escapeLeadingUnderscores(label.value) : typeof index === "number" ? `${restParameterName}_${index}` : void 0;
|
|
72072
|
-
}
|
|
72073
|
-
if (d.name.kind === 15 /* NoSubstitutionTemplateLiteral */) {
|
|
72074
|
-
return escapeLeadingUnderscores(d.name.text);
|
|
72075
|
-
}
|
|
72066
|
+
Debug.assert(isIdentifier(d.name));
|
|
72076
72067
|
return d.name.escapedText;
|
|
72077
72068
|
}
|
|
72078
72069
|
function getParameterNameAtPosition(signature, pos, overrideRestType) {
|
|
@@ -72085,7 +72076,7 @@ function createTypeChecker(host) {
|
|
|
72085
72076
|
if (isTupleType(restType)) {
|
|
72086
72077
|
const associatedNames = restType.target.labeledElementDeclarations;
|
|
72087
72078
|
const index = pos - paramCount;
|
|
72088
|
-
return getTupleElementLabel(
|
|
72079
|
+
return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
|
|
72089
72080
|
}
|
|
72090
72081
|
return restParameter.escapedName;
|
|
72091
72082
|
}
|
|
@@ -72115,7 +72106,8 @@ function createTypeChecker(host) {
|
|
|
72115
72106
|
const index = pos - paramCount;
|
|
72116
72107
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
72117
72108
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
72118
|
-
if (associatedName
|
|
72109
|
+
if (associatedName) {
|
|
72110
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
72119
72111
|
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
72120
72112
|
}
|
|
72121
72113
|
return void 0;
|
|
@@ -72332,23 +72324,29 @@ function createTypeChecker(host) {
|
|
|
72332
72324
|
assignParameterType(parameter);
|
|
72333
72325
|
}
|
|
72334
72326
|
}
|
|
72335
|
-
function assignParameterType(parameter,
|
|
72327
|
+
function assignParameterType(parameter, contextualType) {
|
|
72336
72328
|
const links = getSymbolLinks(parameter);
|
|
72337
72329
|
if (!links.type) {
|
|
72338
72330
|
const declaration = parameter.valueDeclaration;
|
|
72339
|
-
links.type =
|
|
72340
|
-
declaration
|
|
72341
|
-
|
|
72342
|
-
|
|
72343
|
-
|
|
72331
|
+
links.type = addOptionality(
|
|
72332
|
+
contextualType || (declaration ? getWidenedTypeForVariableLikeDeclaration(
|
|
72333
|
+
declaration,
|
|
72334
|
+
/*reportErrors*/
|
|
72335
|
+
true
|
|
72336
|
+
) : getTypeOfSymbol(parameter)),
|
|
72337
|
+
/*isProperty*/
|
|
72338
|
+
false,
|
|
72339
|
+
/*isOptional*/
|
|
72340
|
+
!!declaration && !declaration.initializer && isOptionalDeclaration(declaration)
|
|
72341
|
+
);
|
|
72344
72342
|
if (declaration && declaration.name.kind !== 80 /* Identifier */) {
|
|
72345
72343
|
if (links.type === unknownType) {
|
|
72346
72344
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
72347
72345
|
}
|
|
72348
72346
|
assignBindingElementTypes(declaration.name, links.type);
|
|
72349
72347
|
}
|
|
72350
|
-
} else if (
|
|
72351
|
-
Debug.assertEqual(links.type,
|
|
72348
|
+
} else if (contextualType) {
|
|
72349
|
+
Debug.assertEqual(links.type, contextualType, "Parameter symbol already has a cached type which differs from newly assigned type");
|
|
72352
72350
|
}
|
|
72353
72351
|
}
|
|
72354
72352
|
function assignBindingElementTypes(pattern, parentType) {
|
|
@@ -72858,7 +72856,7 @@ function createTypeChecker(host) {
|
|
|
72858
72856
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
72859
72857
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
72860
72858
|
}
|
|
72861
|
-
return !someType(operandConstraint, (t) => (
|
|
72859
|
+
return !someType(operandConstraint, (t) => getOnlyTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
72862
72860
|
}
|
|
72863
72861
|
const type = checkExpressionCached(node.expression);
|
|
72864
72862
|
if (!isLiteralType(type)) {
|
|
@@ -73183,7 +73181,7 @@ function createTypeChecker(host) {
|
|
|
73183
73181
|
}
|
|
73184
73182
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
73185
73183
|
const type = getTypeOfSymbol(symbol);
|
|
73186
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
73184
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
73187
73185
|
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
73188
73186
|
}
|
|
73189
73187
|
}
|
|
@@ -73318,7 +73316,7 @@ function createTypeChecker(host) {
|
|
|
73318
73316
|
return getUnaryResultType(operandType);
|
|
73319
73317
|
case 54 /* ExclamationToken */:
|
|
73320
73318
|
checkTruthinessOfType(operandType, node.operand);
|
|
73321
|
-
const facts =
|
|
73319
|
+
const facts = getOnlyTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
73322
73320
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
73323
73321
|
case 46 /* PlusPlusToken */:
|
|
73324
73322
|
case 47 /* MinusMinusToken */:
|
|
@@ -73549,7 +73547,7 @@ function createTypeChecker(host) {
|
|
|
73549
73547
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
73550
73548
|
const prop = exprOrAssignment;
|
|
73551
73549
|
if (prop.objectAssignmentInitializer) {
|
|
73552
|
-
if (strictNullChecks && !(
|
|
73550
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
73553
73551
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
73554
73552
|
}
|
|
73555
73553
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -73961,7 +73959,7 @@ function createTypeChecker(host) {
|
|
|
73961
73959
|
return checkInExpression(left, right, leftType, rightType);
|
|
73962
73960
|
case 56 /* AmpersandAmpersandToken */:
|
|
73963
73961
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
73964
|
-
const resultType2 =
|
|
73962
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
73965
73963
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
73966
73964
|
checkAssignmentOperator(rightType);
|
|
73967
73965
|
}
|
|
@@ -73969,7 +73967,7 @@ function createTypeChecker(host) {
|
|
|
73969
73967
|
}
|
|
73970
73968
|
case 57 /* BarBarToken */:
|
|
73971
73969
|
case 76 /* BarBarEqualsToken */: {
|
|
73972
|
-
const resultType2 =
|
|
73970
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
73973
73971
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
73974
73972
|
checkAssignmentOperator(rightType);
|
|
73975
73973
|
}
|
|
@@ -73977,7 +73975,7 @@ function createTypeChecker(host) {
|
|
|
73977
73975
|
}
|
|
73978
73976
|
case 61 /* QuestionQuestionToken */:
|
|
73979
73977
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
73980
|
-
const resultType2 =
|
|
73978
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
73981
73979
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
73982
73980
|
checkAssignmentOperator(rightType);
|
|
73983
73981
|
}
|
|
@@ -75613,9 +75611,6 @@ function createTypeChecker(host) {
|
|
|
75613
75611
|
if (node.type.kind === 191 /* RestType */) {
|
|
75614
75612
|
grammarErrorOnNode(node.type, Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
|
|
75615
75613
|
}
|
|
75616
|
-
if (node.name.kind === 203 /* TemplateLiteralType */) {
|
|
75617
|
-
checkSourceElement(node.name);
|
|
75618
|
-
}
|
|
75619
75614
|
checkSourceElement(node.type);
|
|
75620
75615
|
getTypeFromTypeNode(node);
|
|
75621
75616
|
}
|
|
@@ -77297,7 +77292,7 @@ function createTypeChecker(host) {
|
|
|
77297
77292
|
}
|
|
77298
77293
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
77299
77294
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
77300
|
-
if (!(
|
|
77295
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
77301
77296
|
return;
|
|
77302
77297
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
77303
77298
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
|
@@ -84427,7 +84422,7 @@ var visitEachChildTable = {
|
|
|
84427
84422
|
return context.factory.updateNamedTupleMember(
|
|
84428
84423
|
node,
|
|
84429
84424
|
tokenVisitor ? nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken) : node.dotDotDotToken,
|
|
84430
|
-
Debug.checkDefined(nodeVisitor(node.name, visitor,
|
|
84425
|
+
Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)),
|
|
84431
84426
|
tokenVisitor ? nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken) : node.questionToken,
|
|
84432
84427
|
Debug.checkDefined(nodeVisitor(node.type, visitor, isTypeNode))
|
|
84433
84428
|
);
|