@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/tsserverlibrary.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.2";
|
|
38
|
-
version = `${versionMajorMinor}.0-insiders.
|
|
38
|
+
version = `${versionMajorMinor}.0-insiders.20230612`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -45394,9 +45394,9 @@ ${lanes.join("\n")}
|
|
|
45394
45394
|
candidatesOutArray,
|
|
45395
45395
|
/*argumentCount*/
|
|
45396
45396
|
void 0,
|
|
45397
|
-
|
|
45397
|
+
32 /* IsForStringLiteralArgumentCompletions */
|
|
45398
45398
|
)),
|
|
45399
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
45399
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
45400
45400
|
getExpandedParameters,
|
|
45401
45401
|
hasEffectiveRestParameter,
|
|
45402
45402
|
containsArgumentsReference,
|
|
@@ -53351,7 +53351,7 @@ ${lanes.join("\n")}
|
|
|
53351
53351
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53352
53352
|
}
|
|
53353
53353
|
function getTypeForBindingElement(declaration) {
|
|
53354
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53354
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
53355
53355
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53356
53356
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53357
53357
|
}
|
|
@@ -59875,6 +59875,114 @@ ${lanes.join("\n")}
|
|
|
59875
59875
|
}
|
|
59876
59876
|
return links.resolvedType;
|
|
59877
59877
|
}
|
|
59878
|
+
function getNarrowConditionalType(root, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59879
|
+
let result;
|
|
59880
|
+
let extraTypes;
|
|
59881
|
+
let tailCount = 0;
|
|
59882
|
+
while (true) {
|
|
59883
|
+
if (tailCount === 1e3) {
|
|
59884
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
59885
|
+
return errorType;
|
|
59886
|
+
}
|
|
59887
|
+
const checkType = instantiateNarrowType(getActualTypeVariable(root.checkType), narrowMapper, mapper);
|
|
59888
|
+
const extendsType = instantiateType(root.extendsType, mapper);
|
|
59889
|
+
if (checkType === errorType || extendsType === errorType) {
|
|
59890
|
+
return errorType;
|
|
59891
|
+
}
|
|
59892
|
+
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
59893
|
+
return wildcardType;
|
|
59894
|
+
}
|
|
59895
|
+
const checkTypeDeferred = false;
|
|
59896
|
+
let combinedMapper;
|
|
59897
|
+
if (root.inferTypeParameters) {
|
|
59898
|
+
const freshParams = sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
|
|
59899
|
+
const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : void 0;
|
|
59900
|
+
const context = createInferenceContext(
|
|
59901
|
+
freshParams,
|
|
59902
|
+
/*signature*/
|
|
59903
|
+
void 0,
|
|
59904
|
+
0 /* None */
|
|
59905
|
+
);
|
|
59906
|
+
if (freshMapper) {
|
|
59907
|
+
const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
59908
|
+
for (const p of freshParams) {
|
|
59909
|
+
if (root.inferTypeParameters.indexOf(p) === -1) {
|
|
59910
|
+
p.mapper = freshCombinedMapper;
|
|
59911
|
+
}
|
|
59912
|
+
}
|
|
59913
|
+
}
|
|
59914
|
+
if (!checkTypeDeferred) {
|
|
59915
|
+
inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
59916
|
+
}
|
|
59917
|
+
const innerMapper = combineTypeMappers(freshMapper, context.mapper);
|
|
59918
|
+
combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
|
|
59919
|
+
}
|
|
59920
|
+
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
59921
|
+
if (true) {
|
|
59922
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
59923
|
+
if (checkType.flags & 1 /* Any */) {
|
|
59924
|
+
(extraTypes || (extraTypes = [])).push(
|
|
59925
|
+
instantiateNarrowType(getTypeFromTypeNode(root.node.trueType), narrowMapper, combinedMapper || mapper)
|
|
59926
|
+
);
|
|
59927
|
+
}
|
|
59928
|
+
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
59929
|
+
if (falseType2.flags & 16777216 /* Conditional */) {
|
|
59930
|
+
const newRoot = falseType2.root;
|
|
59931
|
+
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
59932
|
+
root = newRoot;
|
|
59933
|
+
continue;
|
|
59934
|
+
}
|
|
59935
|
+
if (canTailRecurse(falseType2, mapper)) {
|
|
59936
|
+
continue;
|
|
59937
|
+
}
|
|
59938
|
+
}
|
|
59939
|
+
result = instantiateNarrowType(falseType2, narrowMapper, mapper);
|
|
59940
|
+
break;
|
|
59941
|
+
}
|
|
59942
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
59943
|
+
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
59944
|
+
const trueMapper = combinedMapper || mapper;
|
|
59945
|
+
if (canTailRecurse(trueType2, trueMapper)) {
|
|
59946
|
+
continue;
|
|
59947
|
+
}
|
|
59948
|
+
result = instantiateNarrowType(trueType2, narrowMapper, trueMapper);
|
|
59949
|
+
break;
|
|
59950
|
+
}
|
|
59951
|
+
}
|
|
59952
|
+
result = createType(16777216 /* Conditional */);
|
|
59953
|
+
result.root = root;
|
|
59954
|
+
result.checkType = instantiateType(root.checkType, mapper);
|
|
59955
|
+
result.extendsType = instantiateType(root.extendsType, mapper);
|
|
59956
|
+
result.mapper = mapper;
|
|
59957
|
+
result.combinedMapper = combinedMapper;
|
|
59958
|
+
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
59959
|
+
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper);
|
|
59960
|
+
break;
|
|
59961
|
+
}
|
|
59962
|
+
return extraTypes ? getIntersectionType(append(extraTypes, result)) : result;
|
|
59963
|
+
function canTailRecurse(newType, newMapper) {
|
|
59964
|
+
if (newType.flags & 16777216 /* Conditional */ && newMapper) {
|
|
59965
|
+
const newRoot = newType.root;
|
|
59966
|
+
if (newRoot.outerTypeParameters) {
|
|
59967
|
+
const typeParamMapper = combineTypeMappers(newType.mapper, newMapper);
|
|
59968
|
+
const typeArguments = map(newRoot.outerTypeParameters, (t) => getMappedType(t, typeParamMapper));
|
|
59969
|
+
const newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments);
|
|
59970
|
+
const newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : void 0;
|
|
59971
|
+
if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
59972
|
+
root = newRoot;
|
|
59973
|
+
mapper = newRootMapper;
|
|
59974
|
+
aliasSymbol = void 0;
|
|
59975
|
+
aliasTypeArguments = void 0;
|
|
59976
|
+
if (newRoot.aliasSymbol) {
|
|
59977
|
+
tailCount++;
|
|
59978
|
+
}
|
|
59979
|
+
return true;
|
|
59980
|
+
}
|
|
59981
|
+
}
|
|
59982
|
+
}
|
|
59983
|
+
return false;
|
|
59984
|
+
}
|
|
59985
|
+
}
|
|
59878
59986
|
function getTypeFromInferTypeNode(node) {
|
|
59879
59987
|
const links = getNodeLinks(node);
|
|
59880
59988
|
if (!links.resolvedType) {
|
|
@@ -60823,6 +60931,93 @@ ${lanes.join("\n")}
|
|
|
60823
60931
|
}
|
|
60824
60932
|
return type;
|
|
60825
60933
|
}
|
|
60934
|
+
function instantiateNarrowType(type, narrowMapper, mapper, noTopLevel = false) {
|
|
60935
|
+
return type ? instantiateNarrowTypeWithAlias(
|
|
60936
|
+
type,
|
|
60937
|
+
narrowMapper,
|
|
60938
|
+
mapper,
|
|
60939
|
+
/*aliasSymbol*/
|
|
60940
|
+
void 0,
|
|
60941
|
+
/*aliasTypeArguments*/
|
|
60942
|
+
void 0,
|
|
60943
|
+
noTopLevel
|
|
60944
|
+
) : type;
|
|
60945
|
+
}
|
|
60946
|
+
function instantiateNarrowTypeWithAlias(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
60947
|
+
var _a;
|
|
60948
|
+
if (!couldContainTypeVariables(type)) {
|
|
60949
|
+
return type;
|
|
60950
|
+
}
|
|
60951
|
+
if (instantiationDepth === 100 || instantiationCount >= 5e6) {
|
|
60952
|
+
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
|
|
60953
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
60954
|
+
return errorType;
|
|
60955
|
+
}
|
|
60956
|
+
totalInstantiationCount++;
|
|
60957
|
+
instantiationCount++;
|
|
60958
|
+
instantiationDepth++;
|
|
60959
|
+
const result = instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel);
|
|
60960
|
+
instantiationDepth--;
|
|
60961
|
+
return result;
|
|
60962
|
+
}
|
|
60963
|
+
function instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
60964
|
+
const flags = type.flags;
|
|
60965
|
+
if (flags & 262144 /* TypeParameter */) {
|
|
60966
|
+
if (noTopLevel) {
|
|
60967
|
+
return type;
|
|
60968
|
+
}
|
|
60969
|
+
return getMappedType(type, combineTypeMappers(mapper, narrowMapper));
|
|
60970
|
+
}
|
|
60971
|
+
if (flags & 8388608 /* IndexedAccess */) {
|
|
60972
|
+
const newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
60973
|
+
const newAliasTypeArguments = aliasSymbol || !mapper ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
60974
|
+
const objectType = instantiateType(type.objectType, mapper);
|
|
60975
|
+
let indexType = instantiateType(type.indexType, mapper);
|
|
60976
|
+
if (indexType.flags & 262144 /* TypeParameter */) {
|
|
60977
|
+
indexType = getMappedType(indexType, narrowMapper);
|
|
60978
|
+
}
|
|
60979
|
+
return getIndexedAccessType(
|
|
60980
|
+
objectType,
|
|
60981
|
+
indexType,
|
|
60982
|
+
type.accessFlags | 4 /* Writing */,
|
|
60983
|
+
// Get the writing type
|
|
60984
|
+
/*accessNode*/
|
|
60985
|
+
void 0,
|
|
60986
|
+
newAliasSymbol,
|
|
60987
|
+
newAliasTypeArguments
|
|
60988
|
+
);
|
|
60989
|
+
}
|
|
60990
|
+
if (flags & 16777216 /* Conditional */) {
|
|
60991
|
+
return getNarrowConditionalTypeInstantiation(
|
|
60992
|
+
type,
|
|
60993
|
+
narrowMapper,
|
|
60994
|
+
mapper ? combineTypeMappers(type.mapper, mapper) : type.mapper,
|
|
60995
|
+
aliasSymbol,
|
|
60996
|
+
aliasTypeArguments
|
|
60997
|
+
);
|
|
60998
|
+
}
|
|
60999
|
+
return type;
|
|
61000
|
+
}
|
|
61001
|
+
function getNarrowConditionalTypeInstantiation(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
61002
|
+
const root = type.root;
|
|
61003
|
+
if (root.outerTypeParameters) {
|
|
61004
|
+
const typeArguments = mapper ? map(root.outerTypeParameters, (t) => getMappedType(t, mapper)) : root.outerTypeParameters;
|
|
61005
|
+
let result;
|
|
61006
|
+
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
61007
|
+
const checkType = root.checkType;
|
|
61008
|
+
const distributionType = root.isDistributive ? getMappedType(checkType, combineTypeMappers(newMapper, narrowMapper)) : void 0;
|
|
61009
|
+
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
61010
|
+
result = mapTypeWithAlias(getReducedType(distributionType), (t) => getNarrowConditionalType(root, narrowMapper, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments);
|
|
61011
|
+
if (result.flags & 1048576 /* Union */) {
|
|
61012
|
+
result = getIntersectionType(result.types, aliasSymbol, aliasTypeArguments);
|
|
61013
|
+
}
|
|
61014
|
+
} else {
|
|
61015
|
+
result = getNarrowConditionalType(root, narrowMapper, newMapper, aliasSymbol, aliasTypeArguments);
|
|
61016
|
+
}
|
|
61017
|
+
return result;
|
|
61018
|
+
}
|
|
61019
|
+
return type;
|
|
61020
|
+
}
|
|
60826
61021
|
function instantiateReverseMappedType(type, mapper) {
|
|
60827
61022
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
60828
61023
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -68256,7 +68451,7 @@ ${lanes.join("\n")}
|
|
|
68256
68451
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68257
68452
|
}
|
|
68258
68453
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68259
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
68454
|
+
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(
|
|
68260
68455
|
node,
|
|
68261
68456
|
/*contextFlags*/
|
|
68262
68457
|
void 0
|
|
@@ -68264,7 +68459,7 @@ ${lanes.join("\n")}
|
|
|
68264
68459
|
return contextualType && !isGenericType(contextualType);
|
|
68265
68460
|
}
|
|
68266
68461
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
68267
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
68462
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (reference.flags & 8 /* Synthesized */ || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
68268
68463
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
68269
68464
|
}
|
|
68270
68465
|
function isExportOrExportExpression(location) {
|
|
@@ -69013,7 +69208,7 @@ ${lanes.join("\n")}
|
|
|
69013
69208
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
69014
69209
|
const parent2 = declaration.parent.parent;
|
|
69015
69210
|
const name = declaration.propertyName || declaration.name;
|
|
69016
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
69211
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
69017
69212
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
69018
69213
|
return void 0;
|
|
69019
69214
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -69056,9 +69251,16 @@ ${lanes.join("\n")}
|
|
|
69056
69251
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
69057
69252
|
const func = getContainingFunction(node);
|
|
69058
69253
|
if (func) {
|
|
69254
|
+
const functionFlags = getFunctionFlags(func);
|
|
69255
|
+
const links = getNodeLinks(node);
|
|
69256
|
+
if (links.contextualReturnType) {
|
|
69257
|
+
if (functionFlags & 2 /* Async */) {
|
|
69258
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
69259
|
+
}
|
|
69260
|
+
return links.contextualReturnType;
|
|
69261
|
+
}
|
|
69059
69262
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
69060
69263
|
if (contextualReturnType) {
|
|
69061
|
-
const functionFlags = getFunctionFlags(func);
|
|
69062
69264
|
if (functionFlags & 1 /* Generator */) {
|
|
69063
69265
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
69064
69266
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -69071,7 +69273,7 @@ ${lanes.join("\n")}
|
|
|
69071
69273
|
contextualReturnType = iterationReturnType;
|
|
69072
69274
|
}
|
|
69073
69275
|
if (functionFlags & 2 /* Async */) {
|
|
69074
|
-
const contextualAwaitedType =
|
|
69276
|
+
const contextualAwaitedType = getAwaitedTypeNoAlias(contextualReturnType);
|
|
69075
69277
|
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
|
|
69076
69278
|
}
|
|
69077
69279
|
return contextualReturnType;
|
|
@@ -70062,9 +70264,7 @@ ${lanes.join("\n")}
|
|
|
70062
70264
|
elementTypes.push(undefinedOrMissingType);
|
|
70063
70265
|
elementFlags.push(2 /* Optional */);
|
|
70064
70266
|
} else {
|
|
70065
|
-
const
|
|
70066
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70067
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70267
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
70068
70268
|
elementTypes.push(addOptionality(
|
|
70069
70269
|
type,
|
|
70070
70270
|
/*isProperty*/
|
|
@@ -70072,7 +70272,7 @@ ${lanes.join("\n")}
|
|
|
70072
70272
|
hasOmittedExpression
|
|
70073
70273
|
));
|
|
70074
70274
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70075
|
-
if (
|
|
70275
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
70076
70276
|
const inferenceContext = getInferenceContext(node);
|
|
70077
70277
|
Debug.assert(inferenceContext);
|
|
70078
70278
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70213,13 +70413,11 @@ ${lanes.join("\n")}
|
|
|
70213
70413
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70214
70414
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70215
70415
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70216
|
-
|
|
70217
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70218
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70416
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
70219
70417
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70220
70418
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70221
70419
|
// we don't want to say "could not find 'a'".
|
|
70222
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
70420
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
70223
70421
|
);
|
|
70224
70422
|
if (isInJavascript) {
|
|
70225
70423
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70263,7 +70461,7 @@ ${lanes.join("\n")}
|
|
|
70263
70461
|
prop.links.target = member;
|
|
70264
70462
|
member = prop;
|
|
70265
70463
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70266
|
-
if (
|
|
70464
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
70267
70465
|
const inferenceContext = getInferenceContext(node);
|
|
70268
70466
|
Debug.assert(inferenceContext);
|
|
70269
70467
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70436,9 +70634,7 @@ ${lanes.join("\n")}
|
|
|
70436
70634
|
for (const attributeDecl of attributes.properties) {
|
|
70437
70635
|
const member = attributeDecl.symbol;
|
|
70438
70636
|
if (isJsxAttribute(attributeDecl)) {
|
|
70439
|
-
const
|
|
70440
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70441
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70637
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
70442
70638
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70443
70639
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70444
70640
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70459,7 +70655,7 @@ ${lanes.join("\n")}
|
|
|
70459
70655
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70460
70656
|
}
|
|
70461
70657
|
}
|
|
70462
|
-
if (
|
|
70658
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
70463
70659
|
const inferenceContext = getInferenceContext(attributes);
|
|
70464
70660
|
Debug.assert(inferenceContext);
|
|
70465
70661
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72077,7 +72273,7 @@ ${lanes.join("\n")}
|
|
|
72077
72273
|
}
|
|
72078
72274
|
for (let i = 0; i < argCount; i++) {
|
|
72079
72275
|
const arg = args[i];
|
|
72080
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
72276
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
72081
72277
|
const paramType = getTypeAtPosition(signature, i);
|
|
72082
72278
|
if (couldContainTypeVariables(paramType)) {
|
|
72083
72279
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72690,12 +72886,12 @@ ${lanes.join("\n")}
|
|
|
72690
72886
|
const args = getEffectiveCallArguments(node);
|
|
72691
72887
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72692
72888
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72693
|
-
argCheckMode |= checkMode &
|
|
72889
|
+
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72694
72890
|
let candidatesForArgumentError;
|
|
72695
72891
|
let candidateForArgumentArityError;
|
|
72696
72892
|
let candidateForTypeArgumentError;
|
|
72697
72893
|
let result;
|
|
72698
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72894
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72699
72895
|
if (candidates.length > 1) {
|
|
72700
72896
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72701
72897
|
}
|
|
@@ -72914,7 +73110,7 @@ ${lanes.join("\n")}
|
|
|
72914
73110
|
continue;
|
|
72915
73111
|
}
|
|
72916
73112
|
if (argCheckMode) {
|
|
72917
|
-
argCheckMode = checkMode &
|
|
73113
|
+
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72918
73114
|
if (inferenceContext) {
|
|
72919
73115
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72920
73116
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75992,7 +76188,7 @@ ${lanes.join("\n")}
|
|
|
75992
76188
|
case 36 /* ExclamationEqualsToken */:
|
|
75993
76189
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75994
76190
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75995
|
-
if (!(checkMode && checkMode &
|
|
76191
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
75996
76192
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
75997
76193
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75998
76194
|
error2(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -76651,7 +76847,7 @@ ${lanes.join("\n")}
|
|
|
76651
76847
|
}
|
|
76652
76848
|
}
|
|
76653
76849
|
const startInvocationCount = flowInvocationCount;
|
|
76654
|
-
const type = checkExpression(node,
|
|
76850
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
76655
76851
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76656
76852
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76657
76853
|
cache[getNodeId(node)] = type;
|
|
@@ -79122,7 +79318,7 @@ ${lanes.join("\n")}
|
|
|
79122
79318
|
checkComputedPropertyName(node.propertyName);
|
|
79123
79319
|
}
|
|
79124
79320
|
const parent2 = node.parent.parent;
|
|
79125
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79321
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
79126
79322
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79127
79323
|
const name = node.propertyName || node.name;
|
|
79128
79324
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -80171,17 +80367,55 @@ ${lanes.join("\n")}
|
|
|
80171
80367
|
const returnType = getReturnTypeOfSignature(signature);
|
|
80172
80368
|
const functionFlags = getFunctionFlags(container);
|
|
80173
80369
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
80174
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
80175
80370
|
if (container.kind === 177 /* SetAccessor */) {
|
|
80176
80371
|
if (node.expression) {
|
|
80177
80372
|
error2(node, Diagnostics.Setters_cannot_return_a_value);
|
|
80178
80373
|
}
|
|
80179
80374
|
} else if (container.kind === 175 /* Constructor */) {
|
|
80375
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
80180
80376
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
80181
80377
|
error2(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
80182
80378
|
}
|
|
80183
80379
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
80184
80380
|
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
80381
|
+
let actualReturnType = unwrappedReturnType;
|
|
80382
|
+
const links = node.expression && getNodeLinks(node.expression);
|
|
80383
|
+
if (links && !links.contextualReturnType) {
|
|
80384
|
+
const outerTypeParameters = getOuterTypeParameters(
|
|
80385
|
+
container,
|
|
80386
|
+
/*includeThisTypes*/
|
|
80387
|
+
false
|
|
80388
|
+
);
|
|
80389
|
+
const typeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(container));
|
|
80390
|
+
const queryTypeParameters = typeParameters == null ? void 0 : typeParameters.filter(isQueryTypeParameter);
|
|
80391
|
+
if (queryTypeParameters) {
|
|
80392
|
+
const narrowMapper = createTypeMapper(queryTypeParameters, queryTypeParameters.map((tp) => {
|
|
80393
|
+
const originalName = tp.exprName;
|
|
80394
|
+
const fakeName = factory.cloneNode(originalName);
|
|
80395
|
+
setParent(fakeName, node.parent);
|
|
80396
|
+
setNodeFlags(fakeName, fakeName.flags | 8 /* Synthesized */);
|
|
80397
|
+
fakeName.flowNode = node.flowNode;
|
|
80398
|
+
const exprType2 = checkExpression(fakeName);
|
|
80399
|
+
if (getConstraintOfTypeParameter(tp)) {
|
|
80400
|
+
const narrowableConstraintType = mapType(tp.constraint, getBaseConstraintOrType);
|
|
80401
|
+
if (narrowableConstraintType === exprType2) {
|
|
80402
|
+
return tp;
|
|
80403
|
+
}
|
|
80404
|
+
}
|
|
80405
|
+
return exprType2;
|
|
80406
|
+
}));
|
|
80407
|
+
actualReturnType = instantiateNarrowType(
|
|
80408
|
+
unwrappedReturnType,
|
|
80409
|
+
narrowMapper,
|
|
80410
|
+
/*mapper*/
|
|
80411
|
+
void 0,
|
|
80412
|
+
/*noTopLevel*/
|
|
80413
|
+
true
|
|
80414
|
+
);
|
|
80415
|
+
}
|
|
80416
|
+
links.contextualReturnType = actualReturnType;
|
|
80417
|
+
}
|
|
80418
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
80185
80419
|
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
80186
80420
|
exprType,
|
|
80187
80421
|
/*withAlias*/
|
|
@@ -80189,14 +80423,57 @@ ${lanes.join("\n")}
|
|
|
80189
80423
|
node,
|
|
80190
80424
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
80191
80425
|
) : exprType;
|
|
80192
|
-
if (
|
|
80193
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType,
|
|
80426
|
+
if (actualReturnType) {
|
|
80427
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, actualReturnType, node, node.expression);
|
|
80194
80428
|
}
|
|
80195
80429
|
}
|
|
80196
80430
|
} else if (container.kind !== 175 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
80197
80431
|
error2(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
80198
80432
|
}
|
|
80199
80433
|
}
|
|
80434
|
+
function isQueryTypeParameter(typeParameter) {
|
|
80435
|
+
if (typeParameter.exprName) {
|
|
80436
|
+
return true;
|
|
80437
|
+
}
|
|
80438
|
+
if (isThisTypeParameter(typeParameter)) {
|
|
80439
|
+
return false;
|
|
80440
|
+
}
|
|
80441
|
+
if (!typeParameter.symbol) {
|
|
80442
|
+
return false;
|
|
80443
|
+
}
|
|
80444
|
+
const declaration = getDeclarationOfKind(typeParameter.symbol, 167 /* TypeParameter */);
|
|
80445
|
+
const owner = getTypeParameterOwner(declaration);
|
|
80446
|
+
if (!owner || !isFunctionLikeDeclaration(owner)) {
|
|
80447
|
+
return false;
|
|
80448
|
+
}
|
|
80449
|
+
const references = [];
|
|
80450
|
+
owner.parameters.forEach((parameter) => forEachChild(parameter, collectReferences));
|
|
80451
|
+
if (references.length === 1) {
|
|
80452
|
+
const reference = references[0];
|
|
80453
|
+
let exprName;
|
|
80454
|
+
if (isParameter(reference.parent) && reference.parent.parent === owner && (exprName = getNameOfDeclaration(reference.parent))) {
|
|
80455
|
+
typeParameter.exprName = exprName;
|
|
80456
|
+
return true;
|
|
80457
|
+
}
|
|
80458
|
+
}
|
|
80459
|
+
return false;
|
|
80460
|
+
function collectReferences(node) {
|
|
80461
|
+
if (isFunctionLikeDeclaration(node.parent) && node === node.parent.body) {
|
|
80462
|
+
return;
|
|
80463
|
+
}
|
|
80464
|
+
if (isNodeDescendantOf(node, owner.type)) {
|
|
80465
|
+
return;
|
|
80466
|
+
}
|
|
80467
|
+
if (isTypeReferenceNode(node)) {
|
|
80468
|
+
const type = getTypeFromTypeNode(node);
|
|
80469
|
+
if (type.flags & 262144 /* TypeParameter */ && isTypeIdenticalTo(type, typeParameter)) {
|
|
80470
|
+
references.push(node);
|
|
80471
|
+
}
|
|
80472
|
+
return;
|
|
80473
|
+
}
|
|
80474
|
+
forEachChild(node, collectReferences);
|
|
80475
|
+
}
|
|
80476
|
+
}
|
|
80200
80477
|
function checkWithStatement(node) {
|
|
80201
80478
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
80202
80479
|
if (node.flags & 32768 /* AwaitContext */) {
|
|
@@ -85858,11 +86135,10 @@ ${lanes.join("\n")}
|
|
|
85858
86135
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85859
86136
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85860
86137
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85861
|
-
CheckMode3[CheckMode3["
|
|
85862
|
-
CheckMode3[CheckMode3["
|
|
85863
|
-
CheckMode3[CheckMode3["
|
|
85864
|
-
CheckMode3[CheckMode3["
|
|
85865
|
-
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
86138
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
86139
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
86140
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
86141
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
85866
86142
|
return CheckMode3;
|
|
85867
86143
|
})(CheckMode || {});
|
|
85868
86144
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|