@typescript-deploys/pr-build 5.2.0-pr-54581-2 → 5.2.0-pr-54282-26
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/lib.es2015.collection.d.ts +1 -1
- package/lib/tsc.js +322 -37
- package/lib/tsserver.js +313 -37
- package/lib/tsserverlibrary.js +313 -37
- package/lib/typescript.js +313 -37
- package/lib/typingsInstaller.js +5 -6
- package/package.json +3 -3
package/lib/tsserver.js
CHANGED
|
@@ -2305,7 +2305,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2305
2305
|
|
|
2306
2306
|
// src/compiler/corePublic.ts
|
|
2307
2307
|
var versionMajorMinor = "5.2";
|
|
2308
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2308
|
+
var version = `${versionMajorMinor}.0-insiders.20230612`;
|
|
2309
2309
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2310
2310
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2311
2311
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -47322,11 +47322,10 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
47322
47322
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
47323
47323
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47324
47324
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47325
|
-
CheckMode3[CheckMode3["
|
|
47326
|
-
CheckMode3[CheckMode3["
|
|
47327
|
-
CheckMode3[CheckMode3["
|
|
47328
|
-
CheckMode3[CheckMode3["
|
|
47329
|
-
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
47325
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47326
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47327
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47328
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
47330
47329
|
return CheckMode3;
|
|
47331
47330
|
})(CheckMode || {});
|
|
47332
47331
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -47606,9 +47605,9 @@ function createTypeChecker(host) {
|
|
|
47606
47605
|
candidatesOutArray,
|
|
47607
47606
|
/*argumentCount*/
|
|
47608
47607
|
void 0,
|
|
47609
|
-
|
|
47608
|
+
32 /* IsForStringLiteralArgumentCompletions */
|
|
47610
47609
|
)),
|
|
47611
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
47610
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
47612
47611
|
getExpandedParameters,
|
|
47613
47612
|
hasEffectiveRestParameter,
|
|
47614
47613
|
containsArgumentsReference,
|
|
@@ -55563,7 +55562,7 @@ function createTypeChecker(host) {
|
|
|
55563
55562
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
55564
55563
|
}
|
|
55565
55564
|
function getTypeForBindingElement(declaration) {
|
|
55566
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
55565
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55567
55566
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55568
55567
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55569
55568
|
}
|
|
@@ -62087,6 +62086,114 @@ function createTypeChecker(host) {
|
|
|
62087
62086
|
}
|
|
62088
62087
|
return links.resolvedType;
|
|
62089
62088
|
}
|
|
62089
|
+
function getNarrowConditionalType(root, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
62090
|
+
let result;
|
|
62091
|
+
let extraTypes;
|
|
62092
|
+
let tailCount = 0;
|
|
62093
|
+
while (true) {
|
|
62094
|
+
if (tailCount === 1e3) {
|
|
62095
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
62096
|
+
return errorType;
|
|
62097
|
+
}
|
|
62098
|
+
const checkType = instantiateNarrowType(getActualTypeVariable(root.checkType), narrowMapper, mapper);
|
|
62099
|
+
const extendsType = instantiateType(root.extendsType, mapper);
|
|
62100
|
+
if (checkType === errorType || extendsType === errorType) {
|
|
62101
|
+
return errorType;
|
|
62102
|
+
}
|
|
62103
|
+
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
62104
|
+
return wildcardType;
|
|
62105
|
+
}
|
|
62106
|
+
const checkTypeDeferred = false;
|
|
62107
|
+
let combinedMapper;
|
|
62108
|
+
if (root.inferTypeParameters) {
|
|
62109
|
+
const freshParams = sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
|
|
62110
|
+
const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : void 0;
|
|
62111
|
+
const context = createInferenceContext(
|
|
62112
|
+
freshParams,
|
|
62113
|
+
/*signature*/
|
|
62114
|
+
void 0,
|
|
62115
|
+
0 /* None */
|
|
62116
|
+
);
|
|
62117
|
+
if (freshMapper) {
|
|
62118
|
+
const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
62119
|
+
for (const p of freshParams) {
|
|
62120
|
+
if (root.inferTypeParameters.indexOf(p) === -1) {
|
|
62121
|
+
p.mapper = freshCombinedMapper;
|
|
62122
|
+
}
|
|
62123
|
+
}
|
|
62124
|
+
}
|
|
62125
|
+
if (!checkTypeDeferred) {
|
|
62126
|
+
inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
62127
|
+
}
|
|
62128
|
+
const innerMapper = combineTypeMappers(freshMapper, context.mapper);
|
|
62129
|
+
combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
|
|
62130
|
+
}
|
|
62131
|
+
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
62132
|
+
if (true) {
|
|
62133
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
62134
|
+
if (checkType.flags & 1 /* Any */) {
|
|
62135
|
+
(extraTypes || (extraTypes = [])).push(
|
|
62136
|
+
instantiateNarrowType(getTypeFromTypeNode(root.node.trueType), narrowMapper, combinedMapper || mapper)
|
|
62137
|
+
);
|
|
62138
|
+
}
|
|
62139
|
+
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
62140
|
+
if (falseType2.flags & 16777216 /* Conditional */) {
|
|
62141
|
+
const newRoot = falseType2.root;
|
|
62142
|
+
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
62143
|
+
root = newRoot;
|
|
62144
|
+
continue;
|
|
62145
|
+
}
|
|
62146
|
+
if (canTailRecurse(falseType2, mapper)) {
|
|
62147
|
+
continue;
|
|
62148
|
+
}
|
|
62149
|
+
}
|
|
62150
|
+
result = instantiateNarrowType(falseType2, narrowMapper, mapper);
|
|
62151
|
+
break;
|
|
62152
|
+
}
|
|
62153
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
62154
|
+
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
62155
|
+
const trueMapper = combinedMapper || mapper;
|
|
62156
|
+
if (canTailRecurse(trueType2, trueMapper)) {
|
|
62157
|
+
continue;
|
|
62158
|
+
}
|
|
62159
|
+
result = instantiateNarrowType(trueType2, narrowMapper, trueMapper);
|
|
62160
|
+
break;
|
|
62161
|
+
}
|
|
62162
|
+
}
|
|
62163
|
+
result = createType(16777216 /* Conditional */);
|
|
62164
|
+
result.root = root;
|
|
62165
|
+
result.checkType = instantiateType(root.checkType, mapper);
|
|
62166
|
+
result.extendsType = instantiateType(root.extendsType, mapper);
|
|
62167
|
+
result.mapper = mapper;
|
|
62168
|
+
result.combinedMapper = combinedMapper;
|
|
62169
|
+
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
62170
|
+
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper);
|
|
62171
|
+
break;
|
|
62172
|
+
}
|
|
62173
|
+
return extraTypes ? getIntersectionType(append(extraTypes, result)) : result;
|
|
62174
|
+
function canTailRecurse(newType, newMapper) {
|
|
62175
|
+
if (newType.flags & 16777216 /* Conditional */ && newMapper) {
|
|
62176
|
+
const newRoot = newType.root;
|
|
62177
|
+
if (newRoot.outerTypeParameters) {
|
|
62178
|
+
const typeParamMapper = combineTypeMappers(newType.mapper, newMapper);
|
|
62179
|
+
const typeArguments = map(newRoot.outerTypeParameters, (t) => getMappedType(t, typeParamMapper));
|
|
62180
|
+
const newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments);
|
|
62181
|
+
const newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : void 0;
|
|
62182
|
+
if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
62183
|
+
root = newRoot;
|
|
62184
|
+
mapper = newRootMapper;
|
|
62185
|
+
aliasSymbol = void 0;
|
|
62186
|
+
aliasTypeArguments = void 0;
|
|
62187
|
+
if (newRoot.aliasSymbol) {
|
|
62188
|
+
tailCount++;
|
|
62189
|
+
}
|
|
62190
|
+
return true;
|
|
62191
|
+
}
|
|
62192
|
+
}
|
|
62193
|
+
}
|
|
62194
|
+
return false;
|
|
62195
|
+
}
|
|
62196
|
+
}
|
|
62090
62197
|
function getTypeFromInferTypeNode(node) {
|
|
62091
62198
|
const links = getNodeLinks(node);
|
|
62092
62199
|
if (!links.resolvedType) {
|
|
@@ -63035,6 +63142,93 @@ function createTypeChecker(host) {
|
|
|
63035
63142
|
}
|
|
63036
63143
|
return type;
|
|
63037
63144
|
}
|
|
63145
|
+
function instantiateNarrowType(type, narrowMapper, mapper, noTopLevel = false) {
|
|
63146
|
+
return type ? instantiateNarrowTypeWithAlias(
|
|
63147
|
+
type,
|
|
63148
|
+
narrowMapper,
|
|
63149
|
+
mapper,
|
|
63150
|
+
/*aliasSymbol*/
|
|
63151
|
+
void 0,
|
|
63152
|
+
/*aliasTypeArguments*/
|
|
63153
|
+
void 0,
|
|
63154
|
+
noTopLevel
|
|
63155
|
+
) : type;
|
|
63156
|
+
}
|
|
63157
|
+
function instantiateNarrowTypeWithAlias(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
63158
|
+
var _a;
|
|
63159
|
+
if (!couldContainTypeVariables(type)) {
|
|
63160
|
+
return type;
|
|
63161
|
+
}
|
|
63162
|
+
if (instantiationDepth === 100 || instantiationCount >= 5e6) {
|
|
63163
|
+
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
|
|
63164
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63165
|
+
return errorType;
|
|
63166
|
+
}
|
|
63167
|
+
totalInstantiationCount++;
|
|
63168
|
+
instantiationCount++;
|
|
63169
|
+
instantiationDepth++;
|
|
63170
|
+
const result = instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel);
|
|
63171
|
+
instantiationDepth--;
|
|
63172
|
+
return result;
|
|
63173
|
+
}
|
|
63174
|
+
function instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
63175
|
+
const flags = type.flags;
|
|
63176
|
+
if (flags & 262144 /* TypeParameter */) {
|
|
63177
|
+
if (noTopLevel) {
|
|
63178
|
+
return type;
|
|
63179
|
+
}
|
|
63180
|
+
return getMappedType(type, combineTypeMappers(mapper, narrowMapper));
|
|
63181
|
+
}
|
|
63182
|
+
if (flags & 8388608 /* IndexedAccess */) {
|
|
63183
|
+
const newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
63184
|
+
const newAliasTypeArguments = aliasSymbol || !mapper ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
63185
|
+
const objectType = instantiateType(type.objectType, mapper);
|
|
63186
|
+
let indexType = instantiateType(type.indexType, mapper);
|
|
63187
|
+
if (indexType.flags & 262144 /* TypeParameter */) {
|
|
63188
|
+
indexType = getMappedType(indexType, narrowMapper);
|
|
63189
|
+
}
|
|
63190
|
+
return getIndexedAccessType(
|
|
63191
|
+
objectType,
|
|
63192
|
+
indexType,
|
|
63193
|
+
type.accessFlags | 4 /* Writing */,
|
|
63194
|
+
// Get the writing type
|
|
63195
|
+
/*accessNode*/
|
|
63196
|
+
void 0,
|
|
63197
|
+
newAliasSymbol,
|
|
63198
|
+
newAliasTypeArguments
|
|
63199
|
+
);
|
|
63200
|
+
}
|
|
63201
|
+
if (flags & 16777216 /* Conditional */) {
|
|
63202
|
+
return getNarrowConditionalTypeInstantiation(
|
|
63203
|
+
type,
|
|
63204
|
+
narrowMapper,
|
|
63205
|
+
mapper ? combineTypeMappers(type.mapper, mapper) : type.mapper,
|
|
63206
|
+
aliasSymbol,
|
|
63207
|
+
aliasTypeArguments
|
|
63208
|
+
);
|
|
63209
|
+
}
|
|
63210
|
+
return type;
|
|
63211
|
+
}
|
|
63212
|
+
function getNarrowConditionalTypeInstantiation(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
63213
|
+
const root = type.root;
|
|
63214
|
+
if (root.outerTypeParameters) {
|
|
63215
|
+
const typeArguments = mapper ? map(root.outerTypeParameters, (t) => getMappedType(t, mapper)) : root.outerTypeParameters;
|
|
63216
|
+
let result;
|
|
63217
|
+
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
63218
|
+
const checkType = root.checkType;
|
|
63219
|
+
const distributionType = root.isDistributive ? getMappedType(checkType, combineTypeMappers(newMapper, narrowMapper)) : void 0;
|
|
63220
|
+
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
63221
|
+
result = mapTypeWithAlias(getReducedType(distributionType), (t) => getNarrowConditionalType(root, narrowMapper, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments);
|
|
63222
|
+
if (result.flags & 1048576 /* Union */) {
|
|
63223
|
+
result = getIntersectionType(result.types, aliasSymbol, aliasTypeArguments);
|
|
63224
|
+
}
|
|
63225
|
+
} else {
|
|
63226
|
+
result = getNarrowConditionalType(root, narrowMapper, newMapper, aliasSymbol, aliasTypeArguments);
|
|
63227
|
+
}
|
|
63228
|
+
return result;
|
|
63229
|
+
}
|
|
63230
|
+
return type;
|
|
63231
|
+
}
|
|
63038
63232
|
function instantiateReverseMappedType(type, mapper) {
|
|
63039
63233
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
63040
63234
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -70468,7 +70662,7 @@ function createTypeChecker(host) {
|
|
|
70468
70662
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70469
70663
|
}
|
|
70470
70664
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70471
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
70665
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
70472
70666
|
node,
|
|
70473
70667
|
/*contextFlags*/
|
|
70474
70668
|
void 0
|
|
@@ -70476,7 +70670,7 @@ function createTypeChecker(host) {
|
|
|
70476
70670
|
return contextualType && !isGenericType(contextualType);
|
|
70477
70671
|
}
|
|
70478
70672
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
70479
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70673
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (reference.flags & 8 /* Synthesized */ || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70480
70674
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
70481
70675
|
}
|
|
70482
70676
|
function isExportOrExportExpression(location) {
|
|
@@ -71225,7 +71419,7 @@ function createTypeChecker(host) {
|
|
|
71225
71419
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
71226
71420
|
const parent2 = declaration.parent.parent;
|
|
71227
71421
|
const name = declaration.propertyName || declaration.name;
|
|
71228
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
71422
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71229
71423
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
71230
71424
|
return void 0;
|
|
71231
71425
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -71268,9 +71462,16 @@ function createTypeChecker(host) {
|
|
|
71268
71462
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
71269
71463
|
const func = getContainingFunction(node);
|
|
71270
71464
|
if (func) {
|
|
71465
|
+
const functionFlags = getFunctionFlags(func);
|
|
71466
|
+
const links = getNodeLinks(node);
|
|
71467
|
+
if (links.contextualReturnType) {
|
|
71468
|
+
if (functionFlags & 2 /* Async */) {
|
|
71469
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
71470
|
+
}
|
|
71471
|
+
return links.contextualReturnType;
|
|
71472
|
+
}
|
|
71271
71473
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
71272
71474
|
if (contextualReturnType) {
|
|
71273
|
-
const functionFlags = getFunctionFlags(func);
|
|
71274
71475
|
if (functionFlags & 1 /* Generator */) {
|
|
71275
71476
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
71276
71477
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -71283,7 +71484,7 @@ function createTypeChecker(host) {
|
|
|
71283
71484
|
contextualReturnType = iterationReturnType;
|
|
71284
71485
|
}
|
|
71285
71486
|
if (functionFlags & 2 /* Async */) {
|
|
71286
|
-
const contextualAwaitedType =
|
|
71487
|
+
const contextualAwaitedType = getAwaitedTypeNoAlias(contextualReturnType);
|
|
71287
71488
|
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
|
|
71288
71489
|
}
|
|
71289
71490
|
return contextualReturnType;
|
|
@@ -72274,9 +72475,7 @@ function createTypeChecker(host) {
|
|
|
72274
72475
|
elementTypes.push(undefinedOrMissingType);
|
|
72275
72476
|
elementFlags.push(2 /* Optional */);
|
|
72276
72477
|
} else {
|
|
72277
|
-
const
|
|
72278
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72279
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
72478
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
72280
72479
|
elementTypes.push(addOptionality(
|
|
72281
72480
|
type,
|
|
72282
72481
|
/*isProperty*/
|
|
@@ -72284,7 +72483,7 @@ function createTypeChecker(host) {
|
|
|
72284
72483
|
hasOmittedExpression
|
|
72285
72484
|
));
|
|
72286
72485
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72287
|
-
if (
|
|
72486
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
72288
72487
|
const inferenceContext = getInferenceContext(node);
|
|
72289
72488
|
Debug.assert(inferenceContext);
|
|
72290
72489
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -72425,13 +72624,11 @@ function createTypeChecker(host) {
|
|
|
72425
72624
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
72426
72625
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
72427
72626
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
72428
|
-
|
|
72429
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72430
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
72627
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
72431
72628
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
72432
72629
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
72433
72630
|
// we don't want to say "could not find 'a'".
|
|
72434
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
72631
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
72435
72632
|
);
|
|
72436
72633
|
if (isInJavascript) {
|
|
72437
72634
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -72475,7 +72672,7 @@ function createTypeChecker(host) {
|
|
|
72475
72672
|
prop.links.target = member;
|
|
72476
72673
|
member = prop;
|
|
72477
72674
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
72478
|
-
if (
|
|
72675
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
72479
72676
|
const inferenceContext = getInferenceContext(node);
|
|
72480
72677
|
Debug.assert(inferenceContext);
|
|
72481
72678
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -72648,9 +72845,7 @@ function createTypeChecker(host) {
|
|
|
72648
72845
|
for (const attributeDecl of attributes.properties) {
|
|
72649
72846
|
const member = attributeDecl.symbol;
|
|
72650
72847
|
if (isJsxAttribute(attributeDecl)) {
|
|
72651
|
-
const
|
|
72652
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72653
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
72848
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
72654
72849
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
72655
72850
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
72656
72851
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -72671,7 +72866,7 @@ function createTypeChecker(host) {
|
|
|
72671
72866
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
72672
72867
|
}
|
|
72673
72868
|
}
|
|
72674
|
-
if (
|
|
72869
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
72675
72870
|
const inferenceContext = getInferenceContext(attributes);
|
|
72676
72871
|
Debug.assert(inferenceContext);
|
|
72677
72872
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -74289,7 +74484,7 @@ function createTypeChecker(host) {
|
|
|
74289
74484
|
}
|
|
74290
74485
|
for (let i = 0; i < argCount; i++) {
|
|
74291
74486
|
const arg = args[i];
|
|
74292
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
74487
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74293
74488
|
const paramType = getTypeAtPosition(signature, i);
|
|
74294
74489
|
if (couldContainTypeVariables(paramType)) {
|
|
74295
74490
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -74902,12 +75097,12 @@ function createTypeChecker(host) {
|
|
|
74902
75097
|
const args = getEffectiveCallArguments(node);
|
|
74903
75098
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
74904
75099
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
74905
|
-
argCheckMode |= checkMode &
|
|
75100
|
+
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
74906
75101
|
let candidatesForArgumentError;
|
|
74907
75102
|
let candidateForArgumentArityError;
|
|
74908
75103
|
let candidateForTypeArgumentError;
|
|
74909
75104
|
let result;
|
|
74910
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
75105
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
74911
75106
|
if (candidates.length > 1) {
|
|
74912
75107
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
74913
75108
|
}
|
|
@@ -75126,7 +75321,7 @@ function createTypeChecker(host) {
|
|
|
75126
75321
|
continue;
|
|
75127
75322
|
}
|
|
75128
75323
|
if (argCheckMode) {
|
|
75129
|
-
argCheckMode = checkMode &
|
|
75324
|
+
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
75130
75325
|
if (inferenceContext) {
|
|
75131
75326
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
75132
75327
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -78204,7 +78399,7 @@ function createTypeChecker(host) {
|
|
|
78204
78399
|
case 36 /* ExclamationEqualsToken */:
|
|
78205
78400
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
78206
78401
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
78207
|
-
if (!(checkMode && checkMode &
|
|
78402
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
78208
78403
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
78209
78404
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
78210
78405
|
error2(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -78863,7 +79058,7 @@ function createTypeChecker(host) {
|
|
|
78863
79058
|
}
|
|
78864
79059
|
}
|
|
78865
79060
|
const startInvocationCount = flowInvocationCount;
|
|
78866
|
-
const type = checkExpression(node,
|
|
79061
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
78867
79062
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78868
79063
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
78869
79064
|
cache[getNodeId(node)] = type;
|
|
@@ -81334,7 +81529,7 @@ function createTypeChecker(host) {
|
|
|
81334
81529
|
checkComputedPropertyName(node.propertyName);
|
|
81335
81530
|
}
|
|
81336
81531
|
const parent2 = node.parent.parent;
|
|
81337
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
81532
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81338
81533
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
81339
81534
|
const name = node.propertyName || node.name;
|
|
81340
81535
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -82383,17 +82578,55 @@ function createTypeChecker(host) {
|
|
|
82383
82578
|
const returnType = getReturnTypeOfSignature(signature);
|
|
82384
82579
|
const functionFlags = getFunctionFlags(container);
|
|
82385
82580
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
82386
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
82387
82581
|
if (container.kind === 177 /* SetAccessor */) {
|
|
82388
82582
|
if (node.expression) {
|
|
82389
82583
|
error2(node, Diagnostics.Setters_cannot_return_a_value);
|
|
82390
82584
|
}
|
|
82391
82585
|
} else if (container.kind === 175 /* Constructor */) {
|
|
82586
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
82392
82587
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
82393
82588
|
error2(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
82394
82589
|
}
|
|
82395
82590
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
82396
82591
|
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
82592
|
+
let actualReturnType = unwrappedReturnType;
|
|
82593
|
+
const links = node.expression && getNodeLinks(node.expression);
|
|
82594
|
+
if (links && !links.contextualReturnType) {
|
|
82595
|
+
const outerTypeParameters = getOuterTypeParameters(
|
|
82596
|
+
container,
|
|
82597
|
+
/*includeThisTypes*/
|
|
82598
|
+
false
|
|
82599
|
+
);
|
|
82600
|
+
const typeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(container));
|
|
82601
|
+
const queryTypeParameters = typeParameters == null ? void 0 : typeParameters.filter(isQueryTypeParameter);
|
|
82602
|
+
if (queryTypeParameters) {
|
|
82603
|
+
const narrowMapper = createTypeMapper(queryTypeParameters, queryTypeParameters.map((tp) => {
|
|
82604
|
+
const originalName = tp.exprName;
|
|
82605
|
+
const fakeName = factory.cloneNode(originalName);
|
|
82606
|
+
setParent(fakeName, node.parent);
|
|
82607
|
+
setNodeFlags(fakeName, fakeName.flags | 8 /* Synthesized */);
|
|
82608
|
+
fakeName.flowNode = node.flowNode;
|
|
82609
|
+
const exprType2 = checkExpression(fakeName);
|
|
82610
|
+
if (getConstraintOfTypeParameter(tp)) {
|
|
82611
|
+
const narrowableConstraintType = mapType(tp.constraint, getBaseConstraintOrType);
|
|
82612
|
+
if (narrowableConstraintType === exprType2) {
|
|
82613
|
+
return tp;
|
|
82614
|
+
}
|
|
82615
|
+
}
|
|
82616
|
+
return exprType2;
|
|
82617
|
+
}));
|
|
82618
|
+
actualReturnType = instantiateNarrowType(
|
|
82619
|
+
unwrappedReturnType,
|
|
82620
|
+
narrowMapper,
|
|
82621
|
+
/*mapper*/
|
|
82622
|
+
void 0,
|
|
82623
|
+
/*noTopLevel*/
|
|
82624
|
+
true
|
|
82625
|
+
);
|
|
82626
|
+
}
|
|
82627
|
+
links.contextualReturnType = actualReturnType;
|
|
82628
|
+
}
|
|
82629
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
82397
82630
|
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
82398
82631
|
exprType,
|
|
82399
82632
|
/*withAlias*/
|
|
@@ -82401,14 +82634,57 @@ function createTypeChecker(host) {
|
|
|
82401
82634
|
node,
|
|
82402
82635
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
82403
82636
|
) : exprType;
|
|
82404
|
-
if (
|
|
82405
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType,
|
|
82637
|
+
if (actualReturnType) {
|
|
82638
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, actualReturnType, node, node.expression);
|
|
82406
82639
|
}
|
|
82407
82640
|
}
|
|
82408
82641
|
} else if (container.kind !== 175 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
82409
82642
|
error2(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
82410
82643
|
}
|
|
82411
82644
|
}
|
|
82645
|
+
function isQueryTypeParameter(typeParameter) {
|
|
82646
|
+
if (typeParameter.exprName) {
|
|
82647
|
+
return true;
|
|
82648
|
+
}
|
|
82649
|
+
if (isThisTypeParameter(typeParameter)) {
|
|
82650
|
+
return false;
|
|
82651
|
+
}
|
|
82652
|
+
if (!typeParameter.symbol) {
|
|
82653
|
+
return false;
|
|
82654
|
+
}
|
|
82655
|
+
const declaration = getDeclarationOfKind(typeParameter.symbol, 167 /* TypeParameter */);
|
|
82656
|
+
const owner = getTypeParameterOwner(declaration);
|
|
82657
|
+
if (!owner || !isFunctionLikeDeclaration(owner)) {
|
|
82658
|
+
return false;
|
|
82659
|
+
}
|
|
82660
|
+
const references = [];
|
|
82661
|
+
owner.parameters.forEach((parameter) => forEachChild(parameter, collectReferences));
|
|
82662
|
+
if (references.length === 1) {
|
|
82663
|
+
const reference = references[0];
|
|
82664
|
+
let exprName;
|
|
82665
|
+
if (isParameter(reference.parent) && reference.parent.parent === owner && (exprName = getNameOfDeclaration(reference.parent))) {
|
|
82666
|
+
typeParameter.exprName = exprName;
|
|
82667
|
+
return true;
|
|
82668
|
+
}
|
|
82669
|
+
}
|
|
82670
|
+
return false;
|
|
82671
|
+
function collectReferences(node) {
|
|
82672
|
+
if (isFunctionLikeDeclaration(node.parent) && node === node.parent.body) {
|
|
82673
|
+
return;
|
|
82674
|
+
}
|
|
82675
|
+
if (isNodeDescendantOf(node, owner.type)) {
|
|
82676
|
+
return;
|
|
82677
|
+
}
|
|
82678
|
+
if (isTypeReferenceNode(node)) {
|
|
82679
|
+
const type = getTypeFromTypeNode(node);
|
|
82680
|
+
if (type.flags & 262144 /* TypeParameter */ && isTypeIdenticalTo(type, typeParameter)) {
|
|
82681
|
+
references.push(node);
|
|
82682
|
+
}
|
|
82683
|
+
return;
|
|
82684
|
+
}
|
|
82685
|
+
forEachChild(node, collectReferences);
|
|
82686
|
+
}
|
|
82687
|
+
}
|
|
82412
82688
|
function checkWithStatement(node) {
|
|
82413
82689
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
82414
82690
|
if (node.flags & 32768 /* AwaitContext */) {
|