typescript 5.3.0-dev.20230823 → 5.3.0-dev.20230825
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +63 -48
- package/lib/tsserver.js +87 -63
- package/lib/typescript.js +479 -455
- package/lib/typingsInstaller.js +4 -2
- package/package.json +2 -5
package/lib/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";
|
|
@@ -15541,8 +15541,8 @@ function getInternalEmitFlags(node) {
|
|
|
15541
15541
|
const emitNode = node.emitNode;
|
|
15542
15542
|
return emitNode && emitNode.internalFlags || 0;
|
|
15543
15543
|
}
|
|
15544
|
-
|
|
15545
|
-
|
|
15544
|
+
var getScriptTargetFeatures = /* @__PURE__ */ memoize(
|
|
15545
|
+
() => new Map(Object.entries({
|
|
15546
15546
|
Array: new Map(Object.entries({
|
|
15547
15547
|
es2015: [
|
|
15548
15548
|
"find",
|
|
@@ -15609,7 +15609,7 @@ function getScriptTargetFeatures() {
|
|
|
15609
15609
|
"defineProperty",
|
|
15610
15610
|
"deleteProperty",
|
|
15611
15611
|
"get",
|
|
15612
|
-
"
|
|
15612
|
+
"getOwnPropertyDescriptor",
|
|
15613
15613
|
"getPrototypeOf",
|
|
15614
15614
|
"has",
|
|
15615
15615
|
"isExtensible",
|
|
@@ -15935,8 +15935,8 @@ function getScriptTargetFeatures() {
|
|
|
15935
15935
|
"cause"
|
|
15936
15936
|
]
|
|
15937
15937
|
}))
|
|
15938
|
-
}))
|
|
15939
|
-
|
|
15938
|
+
}))
|
|
15939
|
+
);
|
|
15940
15940
|
var GetLiteralTextFlags = /* @__PURE__ */ ((GetLiteralTextFlags2) => {
|
|
15941
15941
|
GetLiteralTextFlags2[GetLiteralTextFlags2["None"] = 0] = "None";
|
|
15942
15942
|
GetLiteralTextFlags2[GetLiteralTextFlags2["NeverAsciiEscape"] = 1] = "NeverAsciiEscape";
|
|
@@ -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);
|
|
@@ -68728,12 +68730,14 @@ function createTypeChecker(host) {
|
|
|
68728
68730
|
}
|
|
68729
68731
|
function inferFromSignatures(source, target, kind) {
|
|
68730
68732
|
const sourceSignatures = getSignaturesOfType(source, kind);
|
|
68731
|
-
const targetSignatures = getSignaturesOfType(target, kind);
|
|
68732
68733
|
const sourceLen = sourceSignatures.length;
|
|
68733
|
-
|
|
68734
|
-
|
|
68735
|
-
|
|
68736
|
-
|
|
68734
|
+
if (sourceLen > 0) {
|
|
68735
|
+
const targetSignatures = getSignaturesOfType(target, kind);
|
|
68736
|
+
const targetLen = targetSignatures.length;
|
|
68737
|
+
for (let i = 0; i < targetLen; i++) {
|
|
68738
|
+
const sourceIndex = Math.max(sourceLen - targetLen + i, 0);
|
|
68739
|
+
inferFromSignature(getBaseSignature(sourceSignatures[sourceIndex]), getErasedSignature(targetSignatures[i]));
|
|
68740
|
+
}
|
|
68737
68741
|
}
|
|
68738
68742
|
}
|
|
68739
68743
|
function inferFromSignature(source, target) {
|
|
@@ -69195,7 +69199,13 @@ function createTypeChecker(host) {
|
|
|
69195
69199
|
const resolved = resolveStructuredTypeMembers(type);
|
|
69196
69200
|
return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
|
|
69197
69201
|
}
|
|
69198
|
-
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) {
|
|
69199
69209
|
if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
|
|
69200
69210
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
69201
69211
|
}
|
|
@@ -69228,6 +69238,10 @@ function createTypeChecker(host) {
|
|
|
69228
69238
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
69229
69239
|
}
|
|
69230
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
|
+
}
|
|
69231
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 */;
|
|
69232
69246
|
}
|
|
69233
69247
|
if (flags & 16384 /* Void */) {
|
|
@@ -69249,20 +69263,20 @@ function createTypeChecker(host) {
|
|
|
69249
69263
|
return 0 /* None */;
|
|
69250
69264
|
}
|
|
69251
69265
|
if (flags & 1048576 /* Union */) {
|
|
69252
|
-
return reduceLeft(type.types, (facts, t) => facts |
|
|
69266
|
+
return reduceLeft(type.types, (facts, t) => facts | getTypeFactsWorker(t, callerOnlyNeeds), 0 /* None */);
|
|
69253
69267
|
}
|
|
69254
69268
|
if (flags & 2097152 /* Intersection */) {
|
|
69255
|
-
return getIntersectionTypeFacts(type);
|
|
69269
|
+
return getIntersectionTypeFacts(type, callerOnlyNeeds);
|
|
69256
69270
|
}
|
|
69257
69271
|
return 83886079 /* UnknownFacts */;
|
|
69258
69272
|
}
|
|
69259
|
-
function getIntersectionTypeFacts(type) {
|
|
69273
|
+
function getIntersectionTypeFacts(type, callerOnlyNeeds) {
|
|
69260
69274
|
const ignoreObjects = maybeTypeOfKind(type, 402784252 /* Primitive */);
|
|
69261
69275
|
let oredFacts = 0 /* None */;
|
|
69262
69276
|
let andedFacts = 134217727 /* All */;
|
|
69263
69277
|
for (const t of type.types) {
|
|
69264
69278
|
if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
|
|
69265
|
-
const f =
|
|
69279
|
+
const f = getTypeFactsWorker(t, callerOnlyNeeds);
|
|
69266
69280
|
oredFacts |= f;
|
|
69267
69281
|
andedFacts &= f;
|
|
69268
69282
|
}
|
|
@@ -69270,19 +69284,19 @@ function createTypeChecker(host) {
|
|
|
69270
69284
|
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
|
|
69271
69285
|
}
|
|
69272
69286
|
function getTypeWithFacts(type, include) {
|
|
69273
|
-
return filterType(type, (t) => (
|
|
69287
|
+
return filterType(type, (t) => hasTypeFacts(t, include));
|
|
69274
69288
|
}
|
|
69275
69289
|
function getAdjustedTypeWithFacts(type, facts) {
|
|
69276
69290
|
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69277
69291
|
if (strictNullChecks) {
|
|
69278
69292
|
switch (facts) {
|
|
69279
69293
|
case 524288 /* NEUndefined */:
|
|
69280
|
-
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);
|
|
69281
69295
|
case 1048576 /* NENull */:
|
|
69282
|
-
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);
|
|
69283
69297
|
case 2097152 /* NEUndefinedOrNull */:
|
|
69284
69298
|
case 4194304 /* Truthy */:
|
|
69285
|
-
return mapType(reduced, (t) =>
|
|
69299
|
+
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
69286
69300
|
}
|
|
69287
69301
|
}
|
|
69288
69302
|
return reduced;
|
|
@@ -70269,7 +70283,7 @@ function createTypeChecker(host) {
|
|
|
70269
70283
|
return void 0;
|
|
70270
70284
|
}
|
|
70271
70285
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
70272
|
-
const type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
70286
|
+
const type = !(computedType.flags & 1048576 /* Union */) && declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
|
|
70273
70287
|
if (type.flags & 1048576 /* Union */) {
|
|
70274
70288
|
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
70275
70289
|
if (access) {
|
|
@@ -70619,14 +70633,14 @@ function createTypeChecker(host) {
|
|
|
70619
70633
|
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
70620
70634
|
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
70621
70635
|
// but are classified as "function" according to `typeof`.
|
|
70622
|
-
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ?
|
|
70636
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? hasTypeFacts(t, facts) ? t : neverType : (
|
|
70623
70637
|
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
70624
70638
|
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
70625
70639
|
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
70626
70640
|
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
70627
70641
|
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
70628
70642
|
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
70629
|
-
|
|
70643
|
+
hasTypeFacts(t, facts) ? getIntersectionType([t, impliedType]) : neverType
|
|
70630
70644
|
)
|
|
70631
70645
|
)
|
|
70632
70646
|
));
|
|
@@ -70640,7 +70654,7 @@ function createTypeChecker(host) {
|
|
|
70640
70654
|
const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
|
|
70641
70655
|
if (hasDefaultClause) {
|
|
70642
70656
|
const notEqualFacts = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
|
|
70643
|
-
return filterType(type, (t) =>
|
|
70657
|
+
return filterType(type, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
70644
70658
|
}
|
|
70645
70659
|
const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
|
|
70646
70660
|
return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
|
|
@@ -70778,7 +70792,7 @@ function createTypeChecker(host) {
|
|
|
70778
70792
|
false
|
|
70779
70793
|
);
|
|
70780
70794
|
}
|
|
70781
|
-
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(
|
|
70795
|
+
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !hasTypeFacts(predicate.type, 65536 /* EQUndefined */)) {
|
|
70782
70796
|
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
70783
70797
|
}
|
|
70784
70798
|
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
@@ -70912,7 +70926,7 @@ function createTypeChecker(host) {
|
|
|
70912
70926
|
reportCircularityError(declaration.symbol);
|
|
70913
70927
|
return true;
|
|
70914
70928
|
}
|
|
70915
|
-
const containsUndefined = !!(
|
|
70929
|
+
const containsUndefined = !!hasTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */), 16777216 /* IsUndefined */);
|
|
70916
70930
|
if (!popTypeResolution()) {
|
|
70917
70931
|
reportCircularityError(declaration.symbol);
|
|
70918
70932
|
return true;
|
|
@@ -70922,7 +70936,7 @@ function createTypeChecker(host) {
|
|
|
70922
70936
|
return links.parameterInitializerContainsUndefined;
|
|
70923
70937
|
}
|
|
70924
70938
|
function removeOptionalityFromDeclaredType(declaredType, declaration) {
|
|
70925
|
-
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);
|
|
70926
70940
|
return removeUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
|
|
70927
70941
|
}
|
|
70928
70942
|
function isConstraintPosition(type, node) {
|
|
@@ -73752,7 +73766,7 @@ function createTypeChecker(host) {
|
|
|
73752
73766
|
return checkNonNullType(checkExpression(node), node);
|
|
73753
73767
|
}
|
|
73754
73768
|
function isNullableType(type) {
|
|
73755
|
-
return
|
|
73769
|
+
return hasTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73756
73770
|
}
|
|
73757
73771
|
function getNonNullableTypeIfNeeded(type) {
|
|
73758
73772
|
return isNullableType(type) ? getNonNullableType(type) : type;
|
|
@@ -73798,7 +73812,7 @@ function createTypeChecker(host) {
|
|
|
73798
73812
|
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
73799
73813
|
return errorType;
|
|
73800
73814
|
}
|
|
73801
|
-
const facts = getTypeFacts(type);
|
|
73815
|
+
const facts = getTypeFacts(type, 50331648 /* IsUndefinedOrNull */);
|
|
73802
73816
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73803
73817
|
reportError(node, facts);
|
|
73804
73818
|
const t = getNonNullableType(type);
|
|
@@ -77578,7 +77592,7 @@ function createTypeChecker(host) {
|
|
|
77578
77592
|
if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
|
|
77579
77593
|
return (556800 /* AllTypeofNE */ & notEqualFacts) === 556800 /* AllTypeofNE */;
|
|
77580
77594
|
}
|
|
77581
|
-
return !someType(operandConstraint, (t) =>
|
|
77595
|
+
return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
|
|
77582
77596
|
}
|
|
77583
77597
|
const type = checkExpressionCached(node.expression);
|
|
77584
77598
|
if (!isLiteralType(type)) {
|
|
@@ -77896,14 +77910,15 @@ function createTypeChecker(host) {
|
|
|
77896
77910
|
if (symbol) {
|
|
77897
77911
|
if (isReadonlySymbol(symbol)) {
|
|
77898
77912
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
77913
|
+
} else {
|
|
77914
|
+
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
77899
77915
|
}
|
|
77900
|
-
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
77901
77916
|
}
|
|
77902
77917
|
return booleanType;
|
|
77903
77918
|
}
|
|
77904
77919
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
77905
77920
|
const type = getTypeOfSymbol(symbol);
|
|
77906
|
-
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 */))) {
|
|
77907
77922
|
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
77908
77923
|
}
|
|
77909
77924
|
}
|
|
@@ -78038,7 +78053,7 @@ function createTypeChecker(host) {
|
|
|
78038
78053
|
return getUnaryResultType(operandType);
|
|
78039
78054
|
case 54 /* ExclamationToken */:
|
|
78040
78055
|
checkTruthinessOfType(operandType, node.operand);
|
|
78041
|
-
const facts = getTypeFacts(operandType
|
|
78056
|
+
const facts = getTypeFacts(operandType, 4194304 /* Truthy */ | 8388608 /* Falsy */);
|
|
78042
78057
|
return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType;
|
|
78043
78058
|
case 46 /* PlusPlusToken */:
|
|
78044
78059
|
case 47 /* MinusMinusToken */:
|
|
@@ -78269,7 +78284,7 @@ function createTypeChecker(host) {
|
|
|
78269
78284
|
if (exprOrAssignment.kind === 304 /* ShorthandPropertyAssignment */) {
|
|
78270
78285
|
const prop = exprOrAssignment;
|
|
78271
78286
|
if (prop.objectAssignmentInitializer) {
|
|
78272
|
-
if (strictNullChecks && !(
|
|
78287
|
+
if (strictNullChecks && !hasTypeFacts(checkExpression(prop.objectAssignmentInitializer), 16777216 /* IsUndefined */)) {
|
|
78273
78288
|
sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
|
|
78274
78289
|
}
|
|
78275
78290
|
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
|
|
@@ -78681,7 +78696,7 @@ function createTypeChecker(host) {
|
|
|
78681
78696
|
return checkInExpression(left, right, leftType, rightType);
|
|
78682
78697
|
case 56 /* AmpersandAmpersandToken */:
|
|
78683
78698
|
case 77 /* AmpersandAmpersandEqualsToken */: {
|
|
78684
|
-
const resultType2 =
|
|
78699
|
+
const resultType2 = hasTypeFacts(leftType, 4194304 /* Truthy */) ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType;
|
|
78685
78700
|
if (operator === 77 /* AmpersandAmpersandEqualsToken */) {
|
|
78686
78701
|
checkAssignmentOperator(rightType);
|
|
78687
78702
|
}
|
|
@@ -78689,7 +78704,7 @@ function createTypeChecker(host) {
|
|
|
78689
78704
|
}
|
|
78690
78705
|
case 57 /* BarBarToken */:
|
|
78691
78706
|
case 76 /* BarBarEqualsToken */: {
|
|
78692
|
-
const resultType2 =
|
|
78707
|
+
const resultType2 = hasTypeFacts(leftType, 8388608 /* Falsy */) ? getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : leftType;
|
|
78693
78708
|
if (operator === 76 /* BarBarEqualsToken */) {
|
|
78694
78709
|
checkAssignmentOperator(rightType);
|
|
78695
78710
|
}
|
|
@@ -78697,7 +78712,7 @@ function createTypeChecker(host) {
|
|
|
78697
78712
|
}
|
|
78698
78713
|
case 61 /* QuestionQuestionToken */:
|
|
78699
78714
|
case 78 /* QuestionQuestionEqualsToken */: {
|
|
78700
|
-
const resultType2 =
|
|
78715
|
+
const resultType2 = hasTypeFacts(leftType, 262144 /* EQUndefinedOrNull */) ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType;
|
|
78701
78716
|
if (operator === 78 /* QuestionQuestionEqualsToken */) {
|
|
78702
78717
|
checkAssignmentOperator(rightType);
|
|
78703
78718
|
}
|
|
@@ -82014,7 +82029,7 @@ function createTypeChecker(host) {
|
|
|
82014
82029
|
}
|
|
82015
82030
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
82016
82031
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82017
|
-
if (!(
|
|
82032
|
+
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
82018
82033
|
return;
|
|
82019
82034
|
const callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
82020
82035
|
const isPromise = !!getAwaitedTypeOfPromise(type);
|
|
@@ -164666,11 +164681,11 @@ function provideInlayHints(context) {
|
|
|
164666
164681
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
164667
164682
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
164668
164683
|
}
|
|
164669
|
-
function addParameterHints(text, parameter, position, isFirstVariadicArgument
|
|
164684
|
+
function addParameterHints(text, parameter, position, isFirstVariadicArgument) {
|
|
164670
164685
|
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
|
164671
164686
|
let displayParts;
|
|
164672
164687
|
if (shouldUseInteractiveInlayHints(preferences)) {
|
|
164673
|
-
displayParts = [getNodeDisplayPart(hintText, parameter
|
|
164688
|
+
displayParts = [getNodeDisplayPart(hintText, parameter), { text: ":" }];
|
|
164674
164689
|
hintText = "";
|
|
164675
164690
|
} else {
|
|
164676
164691
|
hintText += ":";
|
|
@@ -164742,7 +164757,6 @@ function provideInlayHints(context) {
|
|
|
164742
164757
|
if (!signature || !candidates.length) {
|
|
164743
164758
|
return;
|
|
164744
164759
|
}
|
|
164745
|
-
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
164746
164760
|
let signatureParamPos = 0;
|
|
164747
164761
|
for (const originalArg of args) {
|
|
164748
164762
|
const arg = skipParentheses(originalArg);
|
|
@@ -164777,7 +164791,7 @@ function provideInlayHints(context) {
|
|
|
164777
164791
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164778
164792
|
continue;
|
|
164779
164793
|
}
|
|
164780
|
-
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument
|
|
164794
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument);
|
|
164781
164795
|
}
|
|
164782
164796
|
}
|
|
164783
164797
|
}
|
|
@@ -164913,7 +164927,8 @@ function provideInlayHints(context) {
|
|
|
164913
164927
|
}
|
|
164914
164928
|
return true;
|
|
164915
164929
|
}
|
|
164916
|
-
function getNodeDisplayPart(text, node
|
|
164930
|
+
function getNodeDisplayPart(text, node) {
|
|
164931
|
+
const sourceFile = node.getSourceFile();
|
|
164917
164932
|
return {
|
|
164918
164933
|
text,
|
|
164919
164934
|
span: createTextSpanFromNode(node, sourceFile),
|
|
@@ -167712,11 +167727,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
167712
167727
|
if (documentation.length === 0 && isIdentifier(location) && symbol.valueDeclaration && isBindingElement(symbol.valueDeclaration)) {
|
|
167713
167728
|
const declaration = symbol.valueDeclaration;
|
|
167714
167729
|
const parent2 = declaration.parent;
|
|
167715
|
-
|
|
167716
|
-
|
|
167730
|
+
const name = declaration.propertyName || declaration.name;
|
|
167731
|
+
if (isIdentifier(name) && isObjectBindingPattern(parent2)) {
|
|
167732
|
+
const propertyName = getTextOfIdentifierOrLiteral(name);
|
|
167717
167733
|
const objectType = typeChecker.getTypeAtLocation(parent2);
|
|
167718
167734
|
documentation = firstDefined(objectType.isUnion() ? objectType.types : [objectType], (t) => {
|
|
167719
|
-
const prop = t.getProperty(
|
|
167735
|
+
const prop = t.getProperty(propertyName);
|
|
167720
167736
|
return prop ? prop.getDocumentationComment(typeChecker) : void 0;
|
|
167721
167737
|
}) || emptyArray;
|
|
167722
167738
|
}
|
|
@@ -183599,14 +183615,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
183599
183615
|
return {
|
|
183600
183616
|
...hint,
|
|
183601
183617
|
position: scriptInfo.positionToLineOffset(position),
|
|
183602
|
-
displayParts: displayParts == null ? void 0 : displayParts.map(({ text, span, file: file2 }) =>
|
|
183603
|
-
|
|
183604
|
-
|
|
183605
|
-
|
|
183606
|
-
|
|
183607
|
-
|
|
183618
|
+
displayParts: displayParts == null ? void 0 : displayParts.map(({ text, span, file: file2 }) => {
|
|
183619
|
+
if (span) {
|
|
183620
|
+
Debug.assertIsDefined(file2, "Target file should be defined together with its span.");
|
|
183621
|
+
const scriptInfo2 = this.projectService.getScriptInfo(file2);
|
|
183622
|
+
return {
|
|
183623
|
+
text,
|
|
183624
|
+
span: {
|
|
183625
|
+
start: scriptInfo2.positionToLineOffset(span.start),
|
|
183626
|
+
end: scriptInfo2.positionToLineOffset(span.start + span.length),
|
|
183627
|
+
file: file2
|
|
183628
|
+
}
|
|
183629
|
+
};
|
|
183630
|
+
} else {
|
|
183631
|
+
return { text };
|
|
183608
183632
|
}
|
|
183609
|
-
})
|
|
183633
|
+
})
|
|
183610
183634
|
};
|
|
183611
183635
|
});
|
|
183612
183636
|
}
|