@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.
@@ -82,7 +82,7 @@ interface WeakMap<K extends WeakKey, V> {
82
82
  }
83
83
 
84
84
  interface WeakMapConstructor {
85
- new <K extends WeakKey = WeakKey, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
85
+ new <K extends WeakKey = WeakKey, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>;
86
86
  readonly prototype: WeakMap<WeakKey, any>;
87
87
  }
88
88
  declare var WeakMap: WeakMapConstructor;
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.2";
21
- var version = `${versionMajorMinor}.0-insiders.20230609`;
21
+ var version = `${versionMajorMinor}.0-insiders.20230612`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -10049,6 +10049,15 @@ function createTextChangeRange(span, newLength) {
10049
10049
  return { span, newLength };
10050
10050
  }
10051
10051
  var unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
10052
+ function getTypeParameterOwner(d) {
10053
+ if (d && d.kind === 167 /* TypeParameter */) {
10054
+ for (let current = d; current; current = current.parent) {
10055
+ if (isFunctionLike(current) || isClassLike(current) || current.kind === 263 /* InterfaceDeclaration */) {
10056
+ return current;
10057
+ }
10058
+ }
10059
+ }
10060
+ }
10052
10061
  function isParameterPropertyDeclaration(node, parent) {
10053
10062
  return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 175 /* Constructor */;
10054
10063
  }
@@ -42681,11 +42690,10 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
42681
42690
  CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
42682
42691
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
42683
42692
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
42684
- CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
42685
- CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
42686
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
42687
- CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
42688
- CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
42693
+ CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
42694
+ CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
42695
+ CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
42696
+ CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
42689
42697
  return CheckMode3;
42690
42698
  })(CheckMode || {});
42691
42699
  var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -42965,9 +42973,9 @@ function createTypeChecker(host) {
42965
42973
  candidatesOutArray,
42966
42974
  /*argumentCount*/
42967
42975
  void 0,
42968
- 64 /* IsForStringLiteralArgumentCompletions */
42976
+ 32 /* IsForStringLiteralArgumentCompletions */
42969
42977
  )),
42970
- getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
42978
+ getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
42971
42979
  getExpandedParameters,
42972
42980
  hasEffectiveRestParameter,
42973
42981
  containsArgumentsReference,
@@ -50922,7 +50930,7 @@ function createTypeChecker(host) {
50922
50930
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
50923
50931
  }
50924
50932
  function getTypeForBindingElement(declaration) {
50925
- const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
50933
+ const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
50926
50934
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
50927
50935
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
50928
50936
  }
@@ -57446,6 +57454,114 @@ function createTypeChecker(host) {
57446
57454
  }
57447
57455
  return links.resolvedType;
57448
57456
  }
57457
+ function getNarrowConditionalType(root, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
57458
+ let result;
57459
+ let extraTypes;
57460
+ let tailCount = 0;
57461
+ while (true) {
57462
+ if (tailCount === 1e3) {
57463
+ error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
57464
+ return errorType;
57465
+ }
57466
+ const checkType = instantiateNarrowType(getActualTypeVariable(root.checkType), narrowMapper, mapper);
57467
+ const extendsType = instantiateType(root.extendsType, mapper);
57468
+ if (checkType === errorType || extendsType === errorType) {
57469
+ return errorType;
57470
+ }
57471
+ if (checkType === wildcardType || extendsType === wildcardType) {
57472
+ return wildcardType;
57473
+ }
57474
+ const checkTypeDeferred = false;
57475
+ let combinedMapper;
57476
+ if (root.inferTypeParameters) {
57477
+ const freshParams = sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
57478
+ const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : void 0;
57479
+ const context = createInferenceContext(
57480
+ freshParams,
57481
+ /*signature*/
57482
+ void 0,
57483
+ 0 /* None */
57484
+ );
57485
+ if (freshMapper) {
57486
+ const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
57487
+ for (const p of freshParams) {
57488
+ if (root.inferTypeParameters.indexOf(p) === -1) {
57489
+ p.mapper = freshCombinedMapper;
57490
+ }
57491
+ }
57492
+ }
57493
+ if (!checkTypeDeferred) {
57494
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
57495
+ }
57496
+ const innerMapper = combineTypeMappers(freshMapper, context.mapper);
57497
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
57498
+ }
57499
+ const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
57500
+ if (true) {
57501
+ if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
57502
+ if (checkType.flags & 1 /* Any */) {
57503
+ (extraTypes || (extraTypes = [])).push(
57504
+ instantiateNarrowType(getTypeFromTypeNode(root.node.trueType), narrowMapper, combinedMapper || mapper)
57505
+ );
57506
+ }
57507
+ const falseType2 = getTypeFromTypeNode(root.node.falseType);
57508
+ if (falseType2.flags & 16777216 /* Conditional */) {
57509
+ const newRoot = falseType2.root;
57510
+ if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
57511
+ root = newRoot;
57512
+ continue;
57513
+ }
57514
+ if (canTailRecurse(falseType2, mapper)) {
57515
+ continue;
57516
+ }
57517
+ }
57518
+ result = instantiateNarrowType(falseType2, narrowMapper, mapper);
57519
+ break;
57520
+ }
57521
+ if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
57522
+ const trueType2 = getTypeFromTypeNode(root.node.trueType);
57523
+ const trueMapper = combinedMapper || mapper;
57524
+ if (canTailRecurse(trueType2, trueMapper)) {
57525
+ continue;
57526
+ }
57527
+ result = instantiateNarrowType(trueType2, narrowMapper, trueMapper);
57528
+ break;
57529
+ }
57530
+ }
57531
+ result = createType(16777216 /* Conditional */);
57532
+ result.root = root;
57533
+ result.checkType = instantiateType(root.checkType, mapper);
57534
+ result.extendsType = instantiateType(root.extendsType, mapper);
57535
+ result.mapper = mapper;
57536
+ result.combinedMapper = combinedMapper;
57537
+ result.aliasSymbol = aliasSymbol || root.aliasSymbol;
57538
+ result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper);
57539
+ break;
57540
+ }
57541
+ return extraTypes ? getIntersectionType(append(extraTypes, result)) : result;
57542
+ function canTailRecurse(newType, newMapper) {
57543
+ if (newType.flags & 16777216 /* Conditional */ && newMapper) {
57544
+ const newRoot = newType.root;
57545
+ if (newRoot.outerTypeParameters) {
57546
+ const typeParamMapper = combineTypeMappers(newType.mapper, newMapper);
57547
+ const typeArguments = map(newRoot.outerTypeParameters, (t) => getMappedType(t, typeParamMapper));
57548
+ const newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments);
57549
+ const newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : void 0;
57550
+ if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) {
57551
+ root = newRoot;
57552
+ mapper = newRootMapper;
57553
+ aliasSymbol = void 0;
57554
+ aliasTypeArguments = void 0;
57555
+ if (newRoot.aliasSymbol) {
57556
+ tailCount++;
57557
+ }
57558
+ return true;
57559
+ }
57560
+ }
57561
+ }
57562
+ return false;
57563
+ }
57564
+ }
57449
57565
  function getTypeFromInferTypeNode(node) {
57450
57566
  const links = getNodeLinks(node);
57451
57567
  if (!links.resolvedType) {
@@ -58394,6 +58510,93 @@ function createTypeChecker(host) {
58394
58510
  }
58395
58511
  return type;
58396
58512
  }
58513
+ function instantiateNarrowType(type, narrowMapper, mapper, noTopLevel = false) {
58514
+ return type ? instantiateNarrowTypeWithAlias(
58515
+ type,
58516
+ narrowMapper,
58517
+ mapper,
58518
+ /*aliasSymbol*/
58519
+ void 0,
58520
+ /*aliasTypeArguments*/
58521
+ void 0,
58522
+ noTopLevel
58523
+ ) : type;
58524
+ }
58525
+ function instantiateNarrowTypeWithAlias(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
58526
+ var _a;
58527
+ if (!couldContainTypeVariables(type)) {
58528
+ return type;
58529
+ }
58530
+ if (instantiationDepth === 100 || instantiationCount >= 5e6) {
58531
+ (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
58532
+ error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
58533
+ return errorType;
58534
+ }
58535
+ totalInstantiationCount++;
58536
+ instantiationCount++;
58537
+ instantiationDepth++;
58538
+ const result = instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel);
58539
+ instantiationDepth--;
58540
+ return result;
58541
+ }
58542
+ function instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
58543
+ const flags = type.flags;
58544
+ if (flags & 262144 /* TypeParameter */) {
58545
+ if (noTopLevel) {
58546
+ return type;
58547
+ }
58548
+ return getMappedType(type, combineTypeMappers(mapper, narrowMapper));
58549
+ }
58550
+ if (flags & 8388608 /* IndexedAccess */) {
58551
+ const newAliasSymbol = aliasSymbol || type.aliasSymbol;
58552
+ const newAliasTypeArguments = aliasSymbol || !mapper ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
58553
+ const objectType = instantiateType(type.objectType, mapper);
58554
+ let indexType = instantiateType(type.indexType, mapper);
58555
+ if (indexType.flags & 262144 /* TypeParameter */) {
58556
+ indexType = getMappedType(indexType, narrowMapper);
58557
+ }
58558
+ return getIndexedAccessType(
58559
+ objectType,
58560
+ indexType,
58561
+ type.accessFlags | 4 /* Writing */,
58562
+ // Get the writing type
58563
+ /*accessNode*/
58564
+ void 0,
58565
+ newAliasSymbol,
58566
+ newAliasTypeArguments
58567
+ );
58568
+ }
58569
+ if (flags & 16777216 /* Conditional */) {
58570
+ return getNarrowConditionalTypeInstantiation(
58571
+ type,
58572
+ narrowMapper,
58573
+ mapper ? combineTypeMappers(type.mapper, mapper) : type.mapper,
58574
+ aliasSymbol,
58575
+ aliasTypeArguments
58576
+ );
58577
+ }
58578
+ return type;
58579
+ }
58580
+ function getNarrowConditionalTypeInstantiation(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
58581
+ const root = type.root;
58582
+ if (root.outerTypeParameters) {
58583
+ const typeArguments = mapper ? map(root.outerTypeParameters, (t) => getMappedType(t, mapper)) : root.outerTypeParameters;
58584
+ let result;
58585
+ const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
58586
+ const checkType = root.checkType;
58587
+ const distributionType = root.isDistributive ? getMappedType(checkType, combineTypeMappers(newMapper, narrowMapper)) : void 0;
58588
+ if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
58589
+ result = mapTypeWithAlias(getReducedType(distributionType), (t) => getNarrowConditionalType(root, narrowMapper, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments);
58590
+ if (result.flags & 1048576 /* Union */) {
58591
+ result = getIntersectionType(result.types, aliasSymbol, aliasTypeArguments);
58592
+ }
58593
+ } else {
58594
+ result = getNarrowConditionalType(root, narrowMapper, newMapper, aliasSymbol, aliasTypeArguments);
58595
+ }
58596
+ return result;
58597
+ }
58598
+ return type;
58599
+ }
58397
58600
  function instantiateReverseMappedType(type, mapper) {
58398
58601
  const innerMappedType = instantiateType(type.mappedType, mapper);
58399
58602
  if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
@@ -65827,7 +66030,7 @@ function createTypeChecker(host) {
65827
66030
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
65828
66031
  }
65829
66032
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
65830
- const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
66033
+ const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
65831
66034
  node,
65832
66035
  /*contextFlags*/
65833
66036
  void 0
@@ -65835,7 +66038,7 @@ function createTypeChecker(host) {
65835
66038
  return contextualType && !isGenericType(contextualType);
65836
66039
  }
65837
66040
  function getNarrowableTypeForReference(type, reference, checkMode) {
65838
- const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
66041
+ const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (reference.flags & 8 /* Synthesized */ || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
65839
66042
  return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
65840
66043
  }
65841
66044
  function isExportOrExportExpression(location) {
@@ -66584,7 +66787,7 @@ function createTypeChecker(host) {
66584
66787
  function getContextualTypeForBindingElement(declaration, contextFlags) {
66585
66788
  const parent = declaration.parent.parent;
66586
66789
  const name = declaration.propertyName || declaration.name;
66587
- const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
66790
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
66588
66791
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
66589
66792
  return void 0;
66590
66793
  if (parent.name.kind === 206 /* ArrayBindingPattern */) {
@@ -66627,9 +66830,16 @@ function createTypeChecker(host) {
66627
66830
  function getContextualTypeForReturnExpression(node, contextFlags) {
66628
66831
  const func = getContainingFunction(node);
66629
66832
  if (func) {
66833
+ const functionFlags = getFunctionFlags(func);
66834
+ const links = getNodeLinks(node);
66835
+ if (links.contextualReturnType) {
66836
+ if (functionFlags & 2 /* Async */) {
66837
+ return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
66838
+ }
66839
+ return links.contextualReturnType;
66840
+ }
66630
66841
  let contextualReturnType = getContextualReturnType(func, contextFlags);
66631
66842
  if (contextualReturnType) {
66632
- const functionFlags = getFunctionFlags(func);
66633
66843
  if (functionFlags & 1 /* Generator */) {
66634
66844
  const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
66635
66845
  if (contextualReturnType.flags & 1048576 /* Union */) {
@@ -66642,7 +66852,7 @@ function createTypeChecker(host) {
66642
66852
  contextualReturnType = iterationReturnType;
66643
66853
  }
66644
66854
  if (functionFlags & 2 /* Async */) {
66645
- const contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias);
66855
+ const contextualAwaitedType = getAwaitedTypeNoAlias(contextualReturnType);
66646
66856
  return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
66647
66857
  }
66648
66858
  return contextualReturnType;
@@ -67633,9 +67843,7 @@ function createTypeChecker(host) {
67633
67843
  elementTypes.push(undefinedOrMissingType);
67634
67844
  elementFlags.push(2 /* Optional */);
67635
67845
  } else {
67636
- const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
67637
- const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67638
- const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
67846
+ const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
67639
67847
  elementTypes.push(addOptionality(
67640
67848
  type,
67641
67849
  /*isProperty*/
@@ -67643,7 +67851,7 @@ function createTypeChecker(host) {
67643
67851
  hasOmittedExpression
67644
67852
  ));
67645
67853
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
67646
- if (shouldAddAsIntraExpressionInferenceSite) {
67854
+ if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
67647
67855
  const inferenceContext = getInferenceContext(node);
67648
67856
  Debug.assert(inferenceContext);
67649
67857
  addIntraExpressionInferenceSite(inferenceContext, e, type);
@@ -67784,13 +67992,11 @@ function createTypeChecker(host) {
67784
67992
  let member = getSymbolOfDeclaration(memberDecl);
67785
67993
  const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
67786
67994
  if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
67787
- const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
67788
- const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67789
- let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
67995
+ let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
67790
67996
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
67791
67997
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
67792
67998
  // we don't want to say "could not find 'a'".
67793
- memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
67999
+ memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
67794
68000
  );
67795
68001
  if (isInJavascript) {
67796
68002
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
@@ -67834,7 +68040,7 @@ function createTypeChecker(host) {
67834
68040
  prop.links.target = member;
67835
68041
  member = prop;
67836
68042
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
67837
- if (shouldAddAsIntraExpressionInferenceSite) {
68043
+ if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
67838
68044
  const inferenceContext = getInferenceContext(node);
67839
68045
  Debug.assert(inferenceContext);
67840
68046
  const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
@@ -68007,9 +68213,7 @@ function createTypeChecker(host) {
68007
68213
  for (const attributeDecl of attributes.properties) {
68008
68214
  const member = attributeDecl.symbol;
68009
68215
  if (isJsxAttribute(attributeDecl)) {
68010
- const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
68011
- const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
68012
- const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
68216
+ const exprType = checkJsxAttribute(attributeDecl, checkMode);
68013
68217
  objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
68014
68218
  const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
68015
68219
  attributeSymbol.declarations = member.declarations;
@@ -68030,7 +68234,7 @@ function createTypeChecker(host) {
68030
68234
  addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
68031
68235
  }
68032
68236
  }
68033
- if (shouldAddAsIntraExpressionInferenceSite) {
68237
+ if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
68034
68238
  const inferenceContext = getInferenceContext(attributes);
68035
68239
  Debug.assert(inferenceContext);
68036
68240
  const inferenceNode = attributeDecl.initializer.expression;
@@ -69648,7 +69852,7 @@ function createTypeChecker(host) {
69648
69852
  }
69649
69853
  for (let i = 0; i < argCount; i++) {
69650
69854
  const arg = args[i];
69651
- if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
69855
+ if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
69652
69856
  const paramType = getTypeAtPosition(signature, i);
69653
69857
  if (couldContainTypeVariables(paramType)) {
69654
69858
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -70261,12 +70465,12 @@ function createTypeChecker(host) {
70261
70465
  const args = getEffectiveCallArguments(node);
70262
70466
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
70263
70467
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
70264
- argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70468
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
70265
70469
  let candidatesForArgumentError;
70266
70470
  let candidateForArgumentArityError;
70267
70471
  let candidateForTypeArgumentError;
70268
70472
  let result;
70269
- const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70473
+ const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70270
70474
  if (candidates.length > 1) {
70271
70475
  result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
70272
70476
  }
@@ -70485,7 +70689,7 @@ function createTypeChecker(host) {
70485
70689
  continue;
70486
70690
  }
70487
70691
  if (argCheckMode) {
70488
- argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70692
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
70489
70693
  if (inferenceContext) {
70490
70694
  const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
70491
70695
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -73563,7 +73767,7 @@ function createTypeChecker(host) {
73563
73767
  case 36 /* ExclamationEqualsToken */:
73564
73768
  case 37 /* EqualsEqualsEqualsToken */:
73565
73769
  case 38 /* ExclamationEqualsEqualsToken */:
73566
- if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
73770
+ if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
73567
73771
  if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
73568
73772
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
73569
73773
  error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
@@ -74222,7 +74426,7 @@ function createTypeChecker(host) {
74222
74426
  }
74223
74427
  }
74224
74428
  const startInvocationCount = flowInvocationCount;
74225
- const type = checkExpression(node, 256 /* TypeOnly */);
74429
+ const type = checkExpression(node, 128 /* TypeOnly */);
74226
74430
  if (flowInvocationCount !== startInvocationCount) {
74227
74431
  const cache = flowTypeCache || (flowTypeCache = []);
74228
74432
  cache[getNodeId(node)] = type;
@@ -76693,7 +76897,7 @@ function createTypeChecker(host) {
76693
76897
  checkComputedPropertyName(node.propertyName);
76694
76898
  }
76695
76899
  const parent = node.parent.parent;
76696
- const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
76900
+ const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
76697
76901
  const parentType = getTypeForBindingElementParent(parent, parentCheckMode);
76698
76902
  const name = node.propertyName || node.name;
76699
76903
  if (parentType && !isBindingPattern(name)) {
@@ -77742,17 +77946,55 @@ function createTypeChecker(host) {
77742
77946
  const returnType = getReturnTypeOfSignature(signature);
77743
77947
  const functionFlags = getFunctionFlags(container);
77744
77948
  if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
77745
- const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
77746
77949
  if (container.kind === 177 /* SetAccessor */) {
77747
77950
  if (node.expression) {
77748
77951
  error(node, Diagnostics.Setters_cannot_return_a_value);
77749
77952
  }
77750
77953
  } else if (container.kind === 175 /* Constructor */) {
77954
+ const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
77751
77955
  if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
77752
77956
  error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
77753
77957
  }
77754
77958
  } else if (getReturnTypeFromAnnotation(container)) {
77755
77959
  const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
77960
+ let actualReturnType = unwrappedReturnType;
77961
+ const links = node.expression && getNodeLinks(node.expression);
77962
+ if (links && !links.contextualReturnType) {
77963
+ const outerTypeParameters = getOuterTypeParameters(
77964
+ container,
77965
+ /*includeThisTypes*/
77966
+ false
77967
+ );
77968
+ const typeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(container));
77969
+ const queryTypeParameters = typeParameters == null ? void 0 : typeParameters.filter(isQueryTypeParameter);
77970
+ if (queryTypeParameters) {
77971
+ const narrowMapper = createTypeMapper(queryTypeParameters, queryTypeParameters.map((tp) => {
77972
+ const originalName = tp.exprName;
77973
+ const fakeName = factory.cloneNode(originalName);
77974
+ setParent(fakeName, node.parent);
77975
+ setNodeFlags(fakeName, fakeName.flags | 8 /* Synthesized */);
77976
+ fakeName.flowNode = node.flowNode;
77977
+ const exprType2 = checkExpression(fakeName);
77978
+ if (getConstraintOfTypeParameter(tp)) {
77979
+ const narrowableConstraintType = mapType(tp.constraint, getBaseConstraintOrType);
77980
+ if (narrowableConstraintType === exprType2) {
77981
+ return tp;
77982
+ }
77983
+ }
77984
+ return exprType2;
77985
+ }));
77986
+ actualReturnType = instantiateNarrowType(
77987
+ unwrappedReturnType,
77988
+ narrowMapper,
77989
+ /*mapper*/
77990
+ void 0,
77991
+ /*noTopLevel*/
77992
+ true
77993
+ );
77994
+ }
77995
+ links.contextualReturnType = actualReturnType;
77996
+ }
77997
+ const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
77756
77998
  const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
77757
77999
  exprType,
77758
78000
  /*withAlias*/
@@ -77760,14 +78002,57 @@ function createTypeChecker(host) {
77760
78002
  node,
77761
78003
  Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
77762
78004
  ) : exprType;
77763
- if (unwrappedReturnType) {
77764
- checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
78005
+ if (actualReturnType) {
78006
+ checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, actualReturnType, node, node.expression);
77765
78007
  }
77766
78008
  }
77767
78009
  } else if (container.kind !== 175 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
77768
78010
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
77769
78011
  }
77770
78012
  }
78013
+ function isQueryTypeParameter(typeParameter) {
78014
+ if (typeParameter.exprName) {
78015
+ return true;
78016
+ }
78017
+ if (isThisTypeParameter(typeParameter)) {
78018
+ return false;
78019
+ }
78020
+ if (!typeParameter.symbol) {
78021
+ return false;
78022
+ }
78023
+ const declaration = getDeclarationOfKind(typeParameter.symbol, 167 /* TypeParameter */);
78024
+ const owner = getTypeParameterOwner(declaration);
78025
+ if (!owner || !isFunctionLikeDeclaration(owner)) {
78026
+ return false;
78027
+ }
78028
+ const references = [];
78029
+ owner.parameters.forEach((parameter) => forEachChild(parameter, collectReferences));
78030
+ if (references.length === 1) {
78031
+ const reference = references[0];
78032
+ let exprName;
78033
+ if (isParameter(reference.parent) && reference.parent.parent === owner && (exprName = getNameOfDeclaration(reference.parent))) {
78034
+ typeParameter.exprName = exprName;
78035
+ return true;
78036
+ }
78037
+ }
78038
+ return false;
78039
+ function collectReferences(node) {
78040
+ if (isFunctionLikeDeclaration(node.parent) && node === node.parent.body) {
78041
+ return;
78042
+ }
78043
+ if (isNodeDescendantOf(node, owner.type)) {
78044
+ return;
78045
+ }
78046
+ if (isTypeReferenceNode(node)) {
78047
+ const type = getTypeFromTypeNode(node);
78048
+ if (type.flags & 262144 /* TypeParameter */ && isTypeIdenticalTo(type, typeParameter)) {
78049
+ references.push(node);
78050
+ }
78051
+ return;
78052
+ }
78053
+ forEachChild(node, collectReferences);
78054
+ }
78055
+ }
77771
78056
  function checkWithStatement(node) {
77772
78057
  if (!checkGrammarStatementInAmbientContext(node)) {
77773
78058
  if (node.flags & 32768 /* AwaitContext */) {