@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/tsserver.js
CHANGED
|
@@ -1587,7 +1587,6 @@ __export(server_exports, {
|
|
|
1587
1587
|
isNamedImports: () => isNamedImports,
|
|
1588
1588
|
isNamedImportsOrExports: () => isNamedImportsOrExports,
|
|
1589
1589
|
isNamedTupleMember: () => isNamedTupleMember,
|
|
1590
|
-
isNamedTupleMemberName: () => isNamedTupleMemberName,
|
|
1591
1590
|
isNamespaceBody: () => isNamespaceBody,
|
|
1592
1591
|
isNamespaceExport: () => isNamespaceExport,
|
|
1593
1592
|
isNamespaceExportDeclaration: () => isNamespaceExportDeclaration,
|
|
@@ -2334,7 +2333,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2334
2333
|
|
|
2335
2334
|
// src/compiler/corePublic.ts
|
|
2336
2335
|
var versionMajorMinor = "5.3";
|
|
2337
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2336
|
+
var version = `${versionMajorMinor}.0-insiders.20230822`;
|
|
2338
2337
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2339
2338
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2340
2339
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21686,9 +21685,6 @@ function getPropertyNameFromType(type) {
|
|
|
21686
21685
|
}
|
|
21687
21686
|
return Debug.fail();
|
|
21688
21687
|
}
|
|
21689
|
-
function isNamedTupleMemberName(node) {
|
|
21690
|
-
return node.kind === 80 /* Identifier */ || node.kind === 203 /* TemplateLiteralType */ || node.kind === 15 /* NoSubstitutionTemplateLiteral */;
|
|
21691
|
-
}
|
|
21692
21688
|
|
|
21693
21689
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21694
21690
|
function createBaseNodeFactory() {
|
|
@@ -33063,29 +33059,21 @@ var Parser;
|
|
|
33063
33059
|
}
|
|
33064
33060
|
return type;
|
|
33065
33061
|
}
|
|
33066
|
-
function
|
|
33067
|
-
return
|
|
33062
|
+
function isNextTokenColonOrQuestionColon() {
|
|
33063
|
+
return nextToken() === 59 /* ColonToken */ || token() === 58 /* QuestionToken */ && nextToken() === 59 /* ColonToken */;
|
|
33068
33064
|
}
|
|
33069
33065
|
function isTupleElementName() {
|
|
33070
33066
|
if (token() === 26 /* DotDotDotToken */) {
|
|
33071
|
-
nextToken();
|
|
33072
|
-
}
|
|
33073
|
-
if (token() === 16 /* TemplateHead */) {
|
|
33074
|
-
parseTemplateType();
|
|
33075
|
-
return isTokenColonOrQuestionColon();
|
|
33076
|
-
}
|
|
33077
|
-
if (tokenIsIdentifierOrKeyword(token()) || token() === 15 /* NoSubstitutionTemplateLiteral */) {
|
|
33078
|
-
nextToken();
|
|
33079
|
-
return isTokenColonOrQuestionColon();
|
|
33067
|
+
return tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
|
|
33080
33068
|
}
|
|
33081
|
-
return
|
|
33069
|
+
return tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
|
|
33082
33070
|
}
|
|
33083
33071
|
function parseTupleElementNameOrTupleElementType() {
|
|
33084
33072
|
if (lookAhead(isTupleElementName)) {
|
|
33085
33073
|
const pos = getNodePos();
|
|
33086
33074
|
const hasJSDoc = hasPrecedingJSDocComment();
|
|
33087
33075
|
const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
|
|
33088
|
-
const name =
|
|
33076
|
+
const name = parseIdentifierName();
|
|
33089
33077
|
const questionToken = parseOptionalToken(58 /* QuestionToken */);
|
|
33090
33078
|
parseExpected(59 /* ColonToken */);
|
|
33091
33079
|
const type = parseTupleElementType();
|
|
@@ -52801,11 +52789,10 @@ function createTypeChecker(host) {
|
|
|
52801
52789
|
for (let i = 0; i < tupleConstituentNodes.length; i++) {
|
|
52802
52790
|
const flags = type2.target.elementFlags[i];
|
|
52803
52791
|
const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
|
|
52804
|
-
|
|
52805
|
-
if (label) {
|
|
52792
|
+
if (labeledElementDeclaration) {
|
|
52806
52793
|
tupleConstituentNodes[i] = factory.createNamedTupleMember(
|
|
52807
52794
|
flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
|
|
52808
|
-
factory.createIdentifier(unescapeLeadingUnderscores(
|
|
52795
|
+
factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
|
|
52809
52796
|
flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
|
|
52810
52797
|
flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
|
|
52811
52798
|
);
|
|
@@ -56133,7 +56120,7 @@ function createTypeChecker(host) {
|
|
|
56133
56120
|
const pattern = declaration.parent;
|
|
56134
56121
|
if (strictNullChecks && declaration.flags & 33554432 /* Ambient */ && isParameterDeclaration(declaration)) {
|
|
56135
56122
|
parentType = getNonNullableType(parentType);
|
|
56136
|
-
} else if (strictNullChecks && pattern.parent.initializer && !(
|
|
56123
|
+
} else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
|
|
56137
56124
|
parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
|
|
56138
56125
|
}
|
|
56139
56126
|
let type;
|
|
@@ -56176,7 +56163,7 @@ function createTypeChecker(host) {
|
|
|
56176
56163
|
return type;
|
|
56177
56164
|
}
|
|
56178
56165
|
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
|
56179
|
-
return strictNullChecks && !(
|
|
56166
|
+
return strictNullChecks && !hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
|
|
56180
56167
|
}
|
|
56181
56168
|
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
56182
56169
|
}
|
|
@@ -58005,7 +57992,7 @@ function createTypeChecker(host) {
|
|
|
58005
57992
|
function getUniqAssociatedNamesFromTupleType(type, restName) {
|
|
58006
57993
|
const associatedNamesMap = /* @__PURE__ */ new Map();
|
|
58007
57994
|
return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
|
|
58008
|
-
const name = getTupleElementLabel(
|
|
57995
|
+
const name = getTupleElementLabel(labeledElement, i, restName);
|
|
58009
57996
|
const prevCounter = associatedNamesMap.get(name);
|
|
58010
57997
|
if (prevCounter === void 0) {
|
|
58011
57998
|
associatedNamesMap.set(name, 1);
|
|
@@ -59461,7 +59448,7 @@ function createTypeChecker(host) {
|
|
|
59461
59448
|
}
|
|
59462
59449
|
const iife = getImmediatelyInvokedFunctionExpression(node.parent);
|
|
59463
59450
|
if (iife) {
|
|
59464
|
-
return !node.type && !node.dotDotDotToken && node.parent.parameters.indexOf(node) >= iife.
|
|
59451
|
+
return !node.type && !node.dotDotDotToken && node.parent.parameters.indexOf(node) >= getEffectiveCallArguments(iife).length;
|
|
59465
59452
|
}
|
|
59466
59453
|
return false;
|
|
59467
59454
|
}
|
|
@@ -64284,7 +64271,7 @@ function createTypeChecker(host) {
|
|
|
64284
64271
|
if (sourceType && targetType) {
|
|
64285
64272
|
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
64286
64273
|
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
64287
|
-
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (
|
|
64274
|
+
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getOnlyTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getOnlyTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
64288
64275
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
64289
64276
|
sourceType,
|
|
64290
64277
|
targetType,
|
|
@@ -67441,7 +67428,7 @@ function createTypeChecker(host) {
|
|
|
67441
67428
|
return value.base10Value === "0";
|
|
67442
67429
|
}
|
|
67443
67430
|
function removeDefinitelyFalsyTypes(type) {
|
|
67444
|
-
return filterType(type, (t) =>
|
|
67431
|
+
return filterType(type, (t) => hasTypeFacts(t, 4194304 /* Truthy */));
|
|
67445
67432
|
}
|
|
67446
67433
|
function extractDefinitelyFalsyTypes(type) {
|
|
67447
67434
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
@@ -69184,7 +69171,13 @@ function createTypeChecker(host) {
|
|
|
69184
69171
|
const resolved = resolveStructuredTypeMembers(type);
|
|
69185
69172
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
69186
69173
|
}
|
|
69187
|
-
function
|
|
69174
|
+
function getOnlyTypeFacts(type, mask2) {
|
|
69175
|
+
return getTypeFactsWorker(type, mask2) & mask2;
|
|
69176
|
+
}
|
|
69177
|
+
function hasTypeFacts(type, mask2) {
|
|
69178
|
+
return getOnlyTypeFacts(type, mask2) !== 0;
|
|
69179
|
+
}
|
|
69180
|
+
function getTypeFactsWorker(type, callerOnlyNeeds) {
|
|
69188
69181
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
69189
69182
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
69190
69183
|
}
|
|
@@ -69217,6 +69210,10 @@ function createTypeChecker(host) {
|
|
|
69217
69210
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
69218
69211
|
}
|
|
69219
69212
|
if (flags & 524288 /* Object */) {
|
|
69213
|
+
const possibleFacts = strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ | 7880640 /* FunctionStrictFacts */ | 7888800 /* ObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ | 16728e3 /* FunctionFacts */ | 16736160 /* ObjectFacts */;
|
|
69214
|
+
if ((callerOnlyNeeds & possibleFacts) === 0) {
|
|
69215
|
+
return 0;
|
|
69216
|
+
}
|
|
69220
69217
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
69221
69218
|
}
|
|
69222
69219
|
if (flags & 16384 /* Void */) {
|
|
@@ -69238,20 +69235,20 @@ function createTypeChecker(host) {
|
|
|
69238
69235
|
return 0 /* None */;
|
|
69239
69236
|
}
|
|
69240
69237
|
if (flags & 1048576 /* Union */) {
|
|
69241
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
69238
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
69242
69239
|
}
|
|
69243
69240
|
if (flags & 2097152 /* Intersection */) {
|
|
69244
|
-
return getIntersectionTypeFacts(type);
|
|
69241
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
69245
69242
|
}
|
|
69246
69243
|
return 83886079 /* UnknownFacts */;
|
|
69247
69244
|
}
|
|
69248
|
-
function getIntersectionTypeFacts(type) {
|
|
69245
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
69249
69246
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
69250
69247
|
let oredFacts = 0 /* None */;
|
|
69251
69248
|
let andedFacts = 134217727 /* All */;
|
|
69252
69249
|
for (const t of type.types) {
|
|
69253
69250
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
69254
|
-
const f =
|
|
69251
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
69255
69252
|
oredFacts |= f;
|
|
69256
69253
|
andedFacts &= f;
|
|
69257
69254
|
}
|
|
@@ -69259,19 +69256,19 @@ function createTypeChecker(host) {
|
|
|
69259
69256
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
69260
69257
|
}
|
|
69261
69258
|
function getTypeWithFacts(type, include) {
|
|
69262
|
-
return filterType(type, (t) => (
|
|
69259
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
69263
69260
|
}
|
|
69264
69261
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
69265
69262
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69266
69263
|
if (strictNullChecks) {
|
|
69267
69264
|
switch (facts) {
|
|
69268
69265
|
case 524288 /* NEUndefined */:
|
|
69269
|
-
return mapType(reduced, (t) =>
|
|
69266
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
|
|
69270
69267
|
case 1048576 /* NENull */:
|
|
69271
|
-
return mapType(reduced, (t) =>
|
|
69268
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
|
|
69272
69269
|
case 2097152 /* NEUndefinedOrNull */:
|
|
69273
69270
|
case 4194304 /* Truthy */:
|
|
69274
|
-
return mapType(reduced, (t) =>
|
|
69271
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
69275
69272
|
}
|
|
69276
69273
|
}
|
|
69277
69274
|
return reduced;
|
|
@@ -70608,14 +70605,14 @@ function createTypeChecker(host) {
|
|
|
70608
70605
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
70609
70606
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
70610
70607
|
// but are classified as "function" according to `typeof`.
|
|
70611
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
70608
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
70612
70609
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
70613
70610
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
70614
70611
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
70615
70612
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
70616
70613
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
70617
70614
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
70618
|
-
|
|
70615
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
70619
70616
|
)
|
|
70620
70617
|
)
|
|
70621
70618
|
));
|
|
@@ -70629,7 +70626,7 @@ function createTypeChecker(host) {
|
|
|
70629
70626
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
70630
70627
|
if (hasDefaultClause) {
|
|
70631
70628
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
70632
|
-
return filterType(type, (t) => (
|
|
70629
|
+
return filterType(type, (t) => getOnlyTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
70633
70630
|
}
|
|
70634
70631
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
70635
70632
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -70767,7 +70764,7 @@ function createTypeChecker(host) {
|
|
|
70767
70764
|
false
|
|
70768
70765
|
);
|
|
70769
70766
|
}
|
|
70770
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
70767
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
70771
70768
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
70772
70769
|
}
|
|
70773
70770
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -70901,7 +70898,7 @@ function createTypeChecker(host) {
|
|
|
70901
70898
|
reportCircularityError(declaration.symbol);
|
|
70902
70899
|
return true;
|
|
70903
70900
|
}
|
|
70904
|
-
const containsUndefined = !!(
|
|
70901
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
70905
70902
|
if (!popTypeResolution()) {
|
|
70906
70903
|
reportCircularityError(declaration.symbol);
|
|
70907
70904
|
return true;
|
|
@@ -70911,7 +70908,7 @@ function createTypeChecker(host) {
|
|
|
70911
70908
|
return links.parameterInitializerContainsUndefined;
|
|
70912
70909
|
}
|
|
70913
70910
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
70914
|
-
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer &&
|
|
70911
|
+
const removeUndefined = strictNullChecks && declaration.kind === 169 /* Parameter */ && declaration.initializer && hasTypeFacts(declaredType, 16777216 /* IsUndefined */) && !parameterInitializerContainsUndefined(declaration);
|
|
70915
70912
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
70916
70913
|
}
|
|
70917
70914
|
function isConstraintPosition(type, node) {
|
|
@@ -73741,7 +73738,7 @@ function createTypeChecker(host) {
|
|
|
73741
73738
|
return checkNonNullType(checkExpression(node), node);
|
|
73742
73739
|
}
|
|
73743
73740
|
function isNullableType(type) {
|
|
73744
|
-
return
|
|
73741
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73745
73742
|
}
|
|
73746
73743
|
function getNonNullableTypeIfNeeded(type) {
|
|
73747
73744
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -73787,7 +73784,7 @@ function createTypeChecker(host) {
|
|
|
73787
73784
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
73788
73785
|
return errorType;
|
|
73789
73786
|
}
|
|
73790
|
-
const facts =
|
|
73787
|
+
const facts = getOnlyTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73791
73788
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73792
73789
|
reportError(node, facts);
|
|
73793
73790
|
const t = getNonNullableType(type);
|
|
@@ -76761,27 +76758,20 @@ function createTypeChecker(host) {
|
|
|
76761
76758
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
76762
76759
|
}
|
|
76763
76760
|
function getTypeOfParameter(symbol) {
|
|
76764
|
-
const
|
|
76765
|
-
|
|
76766
|
-
|
|
76767
|
-
|
|
76768
|
-
|
|
76769
|
-
|
|
76770
|
-
|
|
76771
|
-
|
|
76761
|
+
const declaration = symbol.valueDeclaration;
|
|
76762
|
+
return addOptionality(
|
|
76763
|
+
getTypeOfSymbol(symbol),
|
|
76764
|
+
/*isProperty*/
|
|
76765
|
+
false,
|
|
76766
|
+
/*isOptional*/
|
|
76767
|
+
!!declaration && (hasInitializer(declaration) || isOptionalDeclaration(declaration))
|
|
76768
|
+
);
|
|
76772
76769
|
}
|
|
76773
|
-
function getTupleElementLabel(
|
|
76770
|
+
function getTupleElementLabel(d, index, restParameterName = "arg") {
|
|
76774
76771
|
if (!d) {
|
|
76775
76772
|
return `${restParameterName}_${index}`;
|
|
76776
76773
|
}
|
|
76777
|
-
Debug.assert(
|
|
76778
|
-
if (d.name.kind === 203 /* TemplateLiteralType */) {
|
|
76779
|
-
const label = instantiateType(getTypeFromTypeNode(d.name), tupleType.mapper);
|
|
76780
|
-
return label.flags & 128 /* StringLiteral */ ? escapeLeadingUnderscores(label.value) : typeof index === "number" ? `${restParameterName}_${index}` : void 0;
|
|
76781
|
-
}
|
|
76782
|
-
if (d.name.kind === 15 /* NoSubstitutionTemplateLiteral */) {
|
|
76783
|
-
return escapeLeadingUnderscores(d.name.text);
|
|
76784
|
-
}
|
|
76774
|
+
Debug.assert(isIdentifier(d.name));
|
|
76785
76775
|
return d.name.escapedText;
|
|
76786
76776
|
}
|
|
76787
76777
|
function getParameterNameAtPosition(signature, pos, overrideRestType) {
|
|
@@ -76794,7 +76784,7 @@ function createTypeChecker(host) {
|
|
|
76794
76784
|
if (isTupleType(restType)) {
|
|
76795
76785
|
const associatedNames = restType.target.labeledElementDeclarations;
|
|
76796
76786
|
const index = pos - paramCount;
|
|
76797
|
-
return getTupleElementLabel(
|
|
76787
|
+
return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
|
|
76798
76788
|
}
|
|
76799
76789
|
return restParameter.escapedName;
|
|
76800
76790
|
}
|
|
@@ -76824,7 +76814,8 @@ function createTypeChecker(host) {
|
|
|
76824
76814
|
const index = pos - paramCount;
|
|
76825
76815
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
76826
76816
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
76827
|
-
if (associatedName
|
|
76817
|
+
if (associatedName) {
|
|
76818
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
76828
76819
|
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
76829
76820
|
}
|
|
76830
76821
|
return void 0;
|
|
@@ -77041,23 +77032,29 @@ function createTypeChecker(host) {
|
|
|
77041
77032
|
assignParameterType(parameter);
|
|
77042
77033
|
}
|
|
77043
77034
|
}
|
|
77044
|
-
function assignParameterType(parameter,
|
|
77035
|
+
function assignParameterType(parameter, contextualType) {
|
|
77045
77036
|
const links = getSymbolLinks(parameter);
|
|
77046
77037
|
if (!links.type) {
|
|
77047
77038
|
const declaration = parameter.valueDeclaration;
|
|
77048
|
-
links.type =
|
|
77049
|
-
declaration
|
|
77050
|
-
|
|
77051
|
-
|
|
77052
|
-
|
|
77039
|
+
links.type = addOptionality(
|
|
77040
|
+
contextualType || (declaration ? getWidenedTypeForVariableLikeDeclaration(
|
|
77041
|
+
declaration,
|
|
77042
|
+
/*reportErrors*/
|
|
77043
|
+
true
|
|
77044
|
+
) : getTypeOfSymbol(parameter)),
|
|
77045
|
+
/*isProperty*/
|
|
77046
|
+
false,
|
|
77047
|
+
/*isOptional*/
|
|
77048
|
+
!!declaration && !declaration.initializer && isOptionalDeclaration(declaration)
|
|
77049
|
+
);
|
|
77053
77050
|
if (declaration && declaration.name.kind !== 80 /* Identifier */) {
|
|
77054
77051
|
if (links.type === unknownType) {
|
|
77055
77052
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
77056
77053
|
}
|
|
77057
77054
|
assignBindingElementTypes(declaration.name, links.type);
|
|
77058
77055
|
}
|
|
77059
|
-
} else if (
|
|
77060
|
-
Debug.assertEqual(links.type,
|
|
77056
|
+
} else if (contextualType) {
|
|
77057
|
+
Debug.assertEqual(links.type, contextualType, "Parameter symbol already has a cached type which differs from newly assigned type");
|
|
77061
77058
|
}
|
|
77062
77059
|
}
|
|
77063
77060
|
function assignBindingElementTypes(pattern, parentType) {
|
|
@@ -77567,7 +77564,7 @@ function createTypeChecker(host) {
|
|
|
77567
77564
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
77568
77565
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
77569
77566
|
}
|
|
77570
|
-
return !someType(operandConstraint, (t) => (
|
|
77567
|
+
return !someType(operandConstraint, (t) => getOnlyTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
77571
77568
|
}
|
|
77572
77569
|
const type = checkExpressionCached(node.expression);
|
|
77573
77570
|
if (!isLiteralType(type)) {
|
|
@@ -77892,7 +77889,7 @@ function createTypeChecker(host) {
|
|
|
77892
77889
|
}
|
|
77893
77890
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
77894
77891
|
const type = getTypeOfSymbol(symbol);
|
|
77895
|
-
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ :
|
|
77892
|
+
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : hasTypeFacts(type, 16777216 /* IsUndefined */))) {
|
|
77896
77893
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
77897
77894
|
}
|
|
77898
77895
|
}
|
|
@@ -78027,7 +78024,7 @@ function createTypeChecker(host) {
|
|
|
78027
78024
|
return getUnaryResultType(operandType);
|
|
78028
78025
|
case 54 /* ExclamationToken */:
|
|
78029
78026
|
checkTruthinessOfType(operandType, node.operand);
|
|
78030
|
-
const facts =
|
|
78027
|
+
const facts = getOnlyTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
78031
78028
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
78032
78029
|
case 46 /* PlusPlusToken */:
|
|
78033
78030
|
case 47 /* MinusMinusToken */:
|
|
@@ -78258,7 +78255,7 @@ function createTypeChecker(host) {
|
|
|
78258
78255
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
78259
78256
|
const prop = exprOrAssignment;
|
|
78260
78257
|
if (prop.objectAssignmentInitializer) {
|
|
78261
|
-
if (strictNullChecks && !(
|
|
78258
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
78262
78259
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
78263
78260
|
}
|
|
78264
78261
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -78670,7 +78667,7 @@ function createTypeChecker(host) {
|
|
|
78670
78667
|
return checkInExpression(left, right, leftType, rightType);
|
|
78671
78668
|
case 56 /* AmpersandAmpersandToken */:
|
|
78672
78669
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
78673
|
-
const resultType2 =
|
|
78670
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
78674
78671
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
78675
78672
|
checkAssignmentOperator(rightType);
|
|
78676
78673
|
}
|
|
@@ -78678,7 +78675,7 @@ function createTypeChecker(host) {
|
|
|
78678
78675
|
}
|
|
78679
78676
|
case 57 /* BarBarToken */:
|
|
78680
78677
|
case 76 /* BarBarEqualsToken */: {
|
|
78681
|
-
const resultType2 =
|
|
78678
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
78682
78679
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
78683
78680
|
checkAssignmentOperator(rightType);
|
|
78684
78681
|
}
|
|
@@ -78686,7 +78683,7 @@ function createTypeChecker(host) {
|
|
|
78686
78683
|
}
|
|
78687
78684
|
case 61 /* QuestionQuestionToken */:
|
|
78688
78685
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
78689
|
-
const resultType2 =
|
|
78686
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
78690
78687
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
78691
78688
|
checkAssignmentOperator(rightType);
|
|
78692
78689
|
}
|
|
@@ -80322,9 +80319,6 @@ function createTypeChecker(host) {
|
|
|
80322
80319
|
if (node.type.kind === 191 /* RestType */) {
|
|
80323
80320
|
grammarErrorOnNode(node.type, Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
|
|
80324
80321
|
}
|
|
80325
|
-
if (node.name.kind === 203 /* TemplateLiteralType */) {
|
|
80326
|
-
checkSourceElement(node.name);
|
|
80327
|
-
}
|
|
80328
80322
|
checkSourceElement(node.type);
|
|
80329
80323
|
getTypeFromTypeNode(node);
|
|
80330
80324
|
}
|
|
@@ -82006,7 +82000,7 @@ function createTypeChecker(host) {
|
|
|
82006
82000
|
}
|
|
82007
82001
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
82008
82002
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82009
|
-
if (!(
|
|
82003
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
82010
82004
|
return;
|
|
82011
82005
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
82012
82006
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
|
@@ -89136,7 +89130,7 @@ var visitEachChildTable = {
|
|
|
89136
89130
|
return context.factory.updateNamedTupleMember(
|
|
89137
89131
|
node,
|
|
89138
89132
|
tokenVisitor ? nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken) : node.dotDotDotToken,
|
|
89139
|
-
Debug.checkDefined(nodeVisitor(node.name, visitor,
|
|
89133
|
+
Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)),
|
|
89140
89134
|
tokenVisitor ? nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken) : node.questionToken,
|
|
89141
89135
|
Debug.checkDefined(nodeVisitor(node.type, visitor, isTypeNode))
|
|
89142
89136
|
);
|
|
@@ -173480,7 +173474,6 @@ __export(ts_exports2, {
|
|
|
173480
173474
|
isNamedImports: () => isNamedImports,
|
|
173481
173475
|
isNamedImportsOrExports: () => isNamedImportsOrExports,
|
|
173482
173476
|
isNamedTupleMember: () => isNamedTupleMember,
|
|
173483
|
-
isNamedTupleMemberName: () => isNamedTupleMemberName,
|
|
173484
173477
|
isNamespaceBody: () => isNamespaceBody,
|
|
173485
173478
|
isNamespaceExport: () => isNamespaceExport,
|
|
173486
173479
|
isNamespaceExportDeclaration: () => isNamespaceExportDeclaration,
|
|
@@ -188036,7 +188029,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188036
188029
|
isNamedImports,
|
|
188037
188030
|
isNamedImportsOrExports,
|
|
188038
188031
|
isNamedTupleMember,
|
|
188039
|
-
isNamedTupleMemberName,
|
|
188040
188032
|
isNamespaceBody,
|
|
188041
188033
|
isNamespaceExport,
|
|
188042
188034
|
isNamespaceExportDeclaration,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -5196,11 +5196,10 @@ declare namespace ts {
|
|
|
5196
5196
|
readonly kind: SyntaxKind.TupleType;
|
|
5197
5197
|
readonly elements: NodeArray<TypeNode | NamedTupleMember>;
|
|
5198
5198
|
}
|
|
5199
|
-
type NamedTupleMemberName = Identifier | NoSubstitutionTemplateLiteral | TemplateLiteralTypeNode;
|
|
5200
5199
|
interface NamedTupleMember extends TypeNode, Declaration, JSDocContainer {
|
|
5201
5200
|
readonly kind: SyntaxKind.NamedTupleMember;
|
|
5202
5201
|
readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
|
|
5203
|
-
readonly name:
|
|
5202
|
+
readonly name: Identifier;
|
|
5204
5203
|
readonly questionToken?: Token<SyntaxKind.QuestionToken>;
|
|
5205
5204
|
readonly type: TypeNode;
|
|
5206
5205
|
}
|
|
@@ -7933,8 +7932,8 @@ declare namespace ts {
|
|
|
7933
7932
|
updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
|
7934
7933
|
createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
|
|
7935
7934
|
updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
|
|
7936
|
-
createNamedTupleMember(dotDotDotToken: DotDotDotToken | undefined, name:
|
|
7937
|
-
updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: DotDotDotToken | undefined, name:
|
|
7935
|
+
createNamedTupleMember(dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember;
|
|
7936
|
+
updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember;
|
|
7938
7937
|
createOptionalTypeNode(type: TypeNode): OptionalTypeNode;
|
|
7939
7938
|
updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode;
|
|
7940
7939
|
createRestTypeNode(type: TypeNode): RestTypeNode;
|