@typescript-deploys/pr-build 5.9.0-pr-61359-4 → 5.9.0-pr-61505-16

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.
Files changed (3) hide show
  1. package/lib/_tsc.js +64 -480
  2. package/lib/typescript.js +71 -481
  3. package/package.json +1 -1
package/lib/typescript.js CHANGED
@@ -2270,6 +2270,7 @@ __export(typescript_exports, {
2270
2270
  visitNode: () => visitNode,
2271
2271
  visitNodes: () => visitNodes2,
2272
2272
  visitParameterList: () => visitParameterList,
2273
+ voidMap: () => voidMap,
2273
2274
  walkUpBindingElementsAndPatterns: () => walkUpBindingElementsAndPatterns,
2274
2275
  walkUpOuterExpressions: () => walkUpOuterExpressions,
2275
2276
  walkUpParenthesizedExpressions: () => walkUpParenthesizedExpressions,
@@ -2285,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
2285
2286
 
2286
2287
  // src/compiler/corePublic.ts
2287
2288
  var versionMajorMinor = "5.9";
2288
- var version = `${versionMajorMinor}.0-insiders.20250320`;
2289
+ var version = `${versionMajorMinor}.0-insiders.20250401`;
2289
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2290
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2291
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -2296,6 +2297,10 @@ var Comparison = /* @__PURE__ */ ((Comparison3) => {
2296
2297
  // src/compiler/core.ts
2297
2298
  var emptyArray = [];
2298
2299
  var emptyMap = /* @__PURE__ */ new Map();
2300
+ var voidMap = /* @__PURE__ */ new Map();
2301
+ voidMap.set = function() {
2302
+ return this;
2303
+ };
2299
2304
  function length(array) {
2300
2305
  return array !== void 0 ? array.length : 0;
2301
2306
  }
@@ -6538,7 +6543,6 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
6538
6543
  ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
6539
6544
  ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
6540
6545
  ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
6541
- ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
6542
6546
  ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
6543
6547
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
6544
6548
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
@@ -51429,6 +51433,7 @@ function createTypeChecker(host) {
51429
51433
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
51430
51434
  var numericStringType = getTemplateLiteralType(["", ""], [numberType]);
51431
51435
  var restrictiveMapper = makeFunctionTypeMapper((t) => t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t, () => "(restrictive mapper)");
51436
+ restrictiveMapper.instantiations = voidMap;
51432
51437
  var permissiveMapper = makeFunctionTypeMapper((t) => t.flags & 262144 /* TypeParameter */ ? wildcardType : t, () => "(permissive mapper)");
51433
51438
  var uniqueLiteralType = createIntrinsicType(
51434
51439
  131072 /* Never */,
@@ -51448,6 +51453,7 @@ function createTypeChecker(host) {
51448
51453
  }
51449
51454
  return t;
51450
51455
  }, () => "(unmeasurable reporter)");
51456
+ reportUnreliableMapper.instantiations = voidMap;
51451
51457
  var reportUnmeasurableMapper = makeFunctionTypeMapper((t) => {
51452
51458
  if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
51453
51459
  outofbandVarianceMarkerHandler(
@@ -51457,6 +51463,7 @@ function createTypeChecker(host) {
51457
51463
  }
51458
51464
  return t;
51459
51465
  }, () => "(unreliable reporter)");
51466
+ reportUnmeasurableMapper.instantiations = voidMap;
51460
51467
  var emptyObjectType = createAnonymousType(
51461
51468
  /*symbol*/
51462
51469
  void 0,
@@ -51789,7 +51796,6 @@ function createTypeChecker(host) {
51789
51796
  [".jsx", ".jsx"],
51790
51797
  [".json", ".json"]
51791
51798
  ];
51792
- var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
51793
51799
  initializeTypeChecker();
51794
51800
  return checker;
51795
51801
  function isDefinitelyReferenceToGlobalSymbolObject(node) {
@@ -64053,14 +64059,11 @@ function createTypeChecker(host) {
64053
64059
  function isNoInferType(type) {
64054
64060
  return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
64055
64061
  }
64056
- function isNarrowingSubstitutionType(type) {
64057
- return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /* IsNarrowingType */);
64058
- }
64059
- function getSubstitutionType(baseType, constraint, isNarrowed) {
64060
- return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
64062
+ function getSubstitutionType(baseType, constraint) {
64063
+ return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
64061
64064
  }
64062
- function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
64063
- const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
64065
+ function getOrCreateSubstitutionType(baseType, constraint) {
64066
+ const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
64064
64067
  const cached = substitutionTypes.get(id);
64065
64068
  if (cached) {
64066
64069
  return cached;
@@ -64068,9 +64071,6 @@ function createTypeChecker(host) {
64068
64071
  const result = createType(33554432 /* Substitution */);
64069
64072
  result.baseType = baseType;
64070
64073
  result.constraint = constraint;
64071
- if (isNarrowed) {
64072
- result.objectFlags |= 16777216 /* IsNarrowingType */;
64073
- }
64074
64074
  substitutionTypes.set(id, result);
64075
64075
  return result;
64076
64076
  }
@@ -66276,7 +66276,7 @@ function createTypeChecker(host) {
66276
66276
  function isDeferredType(type, checkTuples) {
66277
66277
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
66278
66278
  }
66279
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing) {
66279
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
66280
66280
  let result;
66281
66281
  let extraTypes;
66282
66282
  let tailCount = 0;
@@ -66293,11 +66293,10 @@ function createTypeChecker(host) {
66293
66293
  if (checkType === wildcardType || extendsType === wildcardType) {
66294
66294
  return wildcardType;
66295
66295
  }
66296
- const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
66297
66296
  const checkTypeNode = skipTypeParentheses(root.node.checkType);
66298
66297
  const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
66299
66298
  const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
66300
- const checkTypeDeferred = isDeferredType(effectiveCheckType, checkTuples);
66299
+ const checkTypeDeferred = isDeferredType(checkType, checkTuples);
66301
66300
  let combinedMapper;
66302
66301
  if (root.inferTypeParameters) {
66303
66302
  const context = createInferenceContext(
@@ -66310,14 +66309,14 @@ function createTypeChecker(host) {
66310
66309
  context.nonFixingMapper = combineTypeMappers(context.nonFixingMapper, mapper);
66311
66310
  }
66312
66311
  if (!checkTypeDeferred) {
66313
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
66312
+ inferTypes(context, context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
66314
66313
  }
66315
66314
  combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
66316
66315
  }
66317
66316
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
66318
66317
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
66319
- if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (effectiveCheckType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(effectiveCheckType), getPermissiveInstantiation(inferredExtendsType)))) {
66320
- if (effectiveCheckType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(effectiveCheckType)))) {
66318
+ if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
66319
+ if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
66321
66320
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
66322
66321
  }
66323
66322
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -66334,7 +66333,7 @@ function createTypeChecker(host) {
66334
66333
  result = instantiateType(falseType2, mapper);
66335
66334
  break;
66336
66335
  }
66337
- if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(effectiveCheckType), getRestrictiveInstantiation(inferredExtendsType))) {
66336
+ if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
66338
66337
  const trueType2 = getTypeFromTypeNode(root.node.trueType);
66339
66338
  const trueMapper = combinedMapper || mapper;
66340
66339
  if (canTailRecurse(trueType2, trueMapper)) {
@@ -67300,44 +67299,8 @@ function createTypeChecker(host) {
67300
67299
  if (!result) {
67301
67300
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
67302
67301
  const checkType = root.checkType;
67303
- let distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
67304
- let narrowingBaseType;
67305
- const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(
67306
- type,
67307
- /*hadNonPrimitiveExtendsType*/
67308
- [],
67309
- mapper
67310
- );
67311
- if (forNarrowing) {
67312
- narrowingBaseType = distributionType.baseType;
67313
- distributionType = getReducedType(distributionType.constraint);
67314
- }
67315
- if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
67316
- if (narrowingBaseType) {
67317
- result = mapTypeToIntersection(
67318
- distributionType,
67319
- (t) => getConditionalType(
67320
- root,
67321
- prependTypeMapping(checkType, getSubstitutionType(
67322
- narrowingBaseType,
67323
- t,
67324
- /*isNarrowed*/
67325
- true
67326
- ), newMapper),
67327
- forConstraint,
67328
- /*aliasSymbol*/
67329
- void 0,
67330
- /*aliasTypeArguments*/
67331
- void 0,
67332
- forNarrowing
67333
- )
67334
- );
67335
- } else {
67336
- result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
67337
- }
67338
- } else {
67339
- result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
67340
- }
67302
+ const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
67303
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
67341
67304
  root.instantiations.set(id, result);
67342
67305
  }
67343
67306
  return result;
@@ -67355,7 +67318,7 @@ function createTypeChecker(host) {
67355
67318
  ) : type;
67356
67319
  }
67357
67320
  function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
67358
- var _a;
67321
+ var _a, _b;
67359
67322
  if (!couldContainTypeVariables(type)) {
67360
67323
  return type;
67361
67324
  }
@@ -67364,10 +67327,16 @@ function createTypeChecker(host) {
67364
67327
  error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
67365
67328
  return errorType;
67366
67329
  }
67330
+ const key = type.id + getAliasId(aliasSymbol, aliasTypeArguments);
67331
+ const cached = (mapper.instantiations ?? (mapper.instantiations = /* @__PURE__ */ new Map())).get(key);
67332
+ if (cached) {
67333
+ return cached;
67334
+ }
67367
67335
  totalInstantiationCount++;
67368
67336
  instantiationCount++;
67369
67337
  instantiationDepth++;
67370
67338
  const result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
67339
+ (_b = mapper.instantiations) == null ? void 0 : _b.set(key, result);
67371
67340
  instantiationDepth--;
67372
67341
  return result;
67373
67342
  }
@@ -68480,12 +68449,10 @@ function createTypeChecker(host) {
68480
68449
  function shouldNormalizeIntersection(type) {
68481
68450
  let hasInstantiable = false;
68482
68451
  let hasNullableOrEmpty = false;
68483
- let hasSubstitution = false;
68484
68452
  for (const t of type.types) {
68485
68453
  hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
68486
68454
  hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
68487
- hasSubstitution || (hasSubstitution = isNarrowingSubstitutionType(t));
68488
- if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
68455
+ if (hasInstantiable && hasNullableOrEmpty) return true;
68489
68456
  }
68490
68457
  return false;
68491
68458
  }
@@ -69992,7 +69959,7 @@ function createTypeChecker(host) {
69992
69959
  0 /* None */,
69993
69960
  isRelatedToWorker
69994
69961
  );
69995
- inferTypes(ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
69962
+ inferTypes(ctx, ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
69996
69963
  sourceExtends = instantiateType(sourceExtends, ctx.mapper);
69997
69964
  mapper = ctx.mapper;
69998
69965
  }
@@ -71872,7 +71839,7 @@ function createTypeChecker(host) {
71872
71839
  map(context.inferences, (inference, i) => () => {
71873
71840
  if (!inference.isFixed) {
71874
71841
  inferFromIntraExpressionSites(context);
71875
- clearCachedInferences(context.inferences);
71842
+ clearCachedInferences(context, context.inferences);
71876
71843
  inference.isFixed = true;
71877
71844
  }
71878
71845
  return getInferredType(context, i);
@@ -71887,7 +71854,10 @@ function createTypeChecker(host) {
71887
71854
  })
71888
71855
  );
71889
71856
  }
71890
- function clearCachedInferences(inferences) {
71857
+ function clearCachedInferences(context, inferences) {
71858
+ if (context) {
71859
+ context.nonFixingMapper.instantiations = void 0;
71860
+ }
71891
71861
  for (const inference of inferences) {
71892
71862
  if (!inference.isFixed) {
71893
71863
  inference.inferredType = void 0;
@@ -71902,7 +71872,7 @@ function createTypeChecker(host) {
71902
71872
  for (const { node, type } of context.intraExpressionInferenceSites) {
71903
71873
  const contextualType = node.kind === 174 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
71904
71874
  if (contextualType) {
71905
- inferTypes(context.inferences, type, contextualType);
71875
+ inferTypes(context, context.inferences, type, contextualType);
71906
71876
  }
71907
71877
  }
71908
71878
  context.intraExpressionInferenceSites = void 0;
@@ -72046,7 +72016,13 @@ function createTypeChecker(host) {
72046
72016
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
72047
72017
  const templateType = getTemplateTypeFromMappedType(target);
72048
72018
  const inference = createInferenceInfo(typeParameter);
72049
- inferTypes([inference], sourceType, templateType);
72019
+ inferTypes(
72020
+ /*context*/
72021
+ void 0,
72022
+ [inference],
72023
+ sourceType,
72024
+ templateType
72025
+ );
72050
72026
  return getTypeFromInference(inference) || unknownType;
72051
72027
  }
72052
72028
  function inferReverseMappedType(source, target, constraint) {
@@ -72248,7 +72224,7 @@ function createTypeChecker(host) {
72248
72224
  function isTupleOfSelf(typeParameter, type) {
72249
72225
  return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
72250
72226
  }
72251
- function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
72227
+ function inferTypes(context, inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
72252
72228
  let bivariant = false;
72253
72229
  let propagationType;
72254
72230
  let inferencePriority = 2048 /* MaxValue */;
@@ -72339,16 +72315,16 @@ function createTypeChecker(host) {
72339
72315
  if (contravariant && !bivariant) {
72340
72316
  if (!contains(inference.contraCandidates, candidate)) {
72341
72317
  inference.contraCandidates = append(inference.contraCandidates, candidate);
72342
- clearCachedInferences(inferences);
72318
+ clearCachedInferences(context, inferences);
72343
72319
  }
72344
72320
  } else if (!contains(inference.candidates, candidate)) {
72345
72321
  inference.candidates = append(inference.candidates, candidate);
72346
- clearCachedInferences(inferences);
72322
+ clearCachedInferences(context, inferences);
72347
72323
  }
72348
72324
  }
72349
72325
  if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
72350
72326
  inference.topLevel = false;
72351
- clearCachedInferences(inferences);
72327
+ clearCachedInferences(context, inferences);
72352
72328
  }
72353
72329
  }
72354
72330
  inferencePriority = Math.min(inferencePriority, priority);
@@ -72914,6 +72890,7 @@ function createTypeChecker(host) {
72914
72890
  const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
72915
72891
  if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
72916
72892
  inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
72893
+ context.nonFixingMapper.instantiations = void 0;
72917
72894
  }
72918
72895
  }
72919
72896
  }
@@ -73645,18 +73622,6 @@ function createTypeChecker(host) {
73645
73622
  }
73646
73623
  return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
73647
73624
  }
73648
- function mapTypeToIntersection(type, mapper) {
73649
- if (type.flags & 131072 /* Never */) {
73650
- return type;
73651
- }
73652
- if (!(type.flags & 1048576 /* Union */)) {
73653
- return mapper(type);
73654
- }
73655
- const origin = type.origin;
73656
- const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
73657
- const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
73658
- return getIntersectionType(mappedTypes);
73659
- }
73660
73625
  function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
73661
73626
  return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
73662
73627
  }
@@ -75241,11 +75206,11 @@ function createTypeChecker(host) {
75241
75206
  ));
75242
75207
  return contextualType && !isGenericType(contextualType);
75243
75208
  }
75244
- function getNarrowableTypeForReference(type, reference, checkMode, forReturnTypeNarrowing) {
75209
+ function getNarrowableTypeForReference(type, reference, checkMode) {
75245
75210
  if (isNoInferType(type)) {
75246
75211
  type = type.baseType;
75247
75212
  }
75248
- const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (forReturnTypeNarrowing || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
75213
+ const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
75249
75214
  return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
75250
75215
  }
75251
75216
  function isExportOrExportExpression(location) {
@@ -76372,16 +76337,9 @@ function createTypeChecker(host) {
76372
76337
  function getContextualTypeForReturnExpression(node, contextFlags) {
76373
76338
  const func = getContainingFunction(node);
76374
76339
  if (func) {
76375
- const functionFlags = getFunctionFlags(func);
76376
- const links = getNodeLinks(node);
76377
- if (links.contextualReturnType) {
76378
- if (functionFlags & 2 /* Async */) {
76379
- return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
76380
- }
76381
- return links.contextualReturnType;
76382
- }
76383
76340
  let contextualReturnType = getContextualReturnType(func, contextFlags);
76384
76341
  if (contextualReturnType) {
76342
+ const functionFlags = getFunctionFlags(func);
76385
76343
  if (functionFlags & 1 /* Generator */) {
76386
76344
  const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
76387
76345
  if (contextualReturnType.flags & 1048576 /* Union */) {
@@ -77079,13 +77037,6 @@ function createTypeChecker(host) {
77079
77037
  if (index >= 0) {
77080
77038
  return contextualTypes[index];
77081
77039
  }
77082
- const links = getNodeLinks(node);
77083
- if (links.contextualReturnType) {
77084
- if (node.flags & 65536 /* AwaitContext */) {
77085
- return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
77086
- }
77087
- return links.contextualReturnType;
77088
- }
77089
77040
  const { parent: parent2 } = node;
77090
77041
  switch (parent2.kind) {
77091
77042
  case 260 /* VariableDeclaration */:
@@ -79067,7 +79018,7 @@ function createTypeChecker(host) {
79067
79018
  addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic);
79068
79019
  }
79069
79020
  function containerSeemsToBeEmptyDomElement(containingType) {
79070
- return compilerOptions.lib && !compilerOptions.lib.includes("dom") && everyContainedType(containingType, (type) => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) && isEmptyObjectType(containingType);
79021
+ return compilerOptions.lib && !compilerOptions.lib.includes("lib.dom.d.ts") && everyContainedType(containingType, (type) => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) && isEmptyObjectType(containingType);
79071
79022
  }
79072
79023
  function typeHasStaticProperty(propName, containingType) {
79073
79024
  const prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
@@ -79514,11 +79465,11 @@ function createTypeChecker(host) {
79514
79465
  const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
79515
79466
  const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
79516
79467
  applyToParameterTypes(sourceSignature, signature, (source, target) => {
79517
- inferTypes(context.inferences, source, target);
79468
+ inferTypes(context, context.inferences, source, target);
79518
79469
  });
79519
79470
  if (!inferenceContext) {
79520
79471
  applyToReturnTypes(contextualSignature, signature, (source, target) => {
79521
- inferTypes(context.inferences, source, target, 128 /* ReturnType */);
79472
+ inferTypes(context, context.inferences, source, target, 128 /* ReturnType */);
79522
79473
  });
79523
79474
  }
79524
79475
  return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
@@ -79526,7 +79477,7 @@ function createTypeChecker(host) {
79526
79477
  function inferJsxTypeArguments(node, signature, checkMode, context) {
79527
79478
  const paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
79528
79479
  const checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
79529
- inferTypes(context.inferences, checkAttrType, paramType);
79480
+ inferTypes(context, context.inferences, checkAttrType, paramType);
79530
79481
  return getInferredTypes(context);
79531
79482
  }
79532
79483
  function getThisArgumentType(thisArgumentNode) {
@@ -79553,11 +79504,11 @@ function createTypeChecker(host) {
79553
79504
  const instantiatedType = instantiateType(contextualType, outerMapper);
79554
79505
  const contextualSignature = getSingleCallSignature(instantiatedType);
79555
79506
  const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType;
79556
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
79507
+ inferTypes(context, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
79557
79508
  }
79558
79509
  const returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
79559
79510
  const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
79560
- inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
79511
+ inferTypes(returnContext, returnContext.inferences, returnSourceType, inferenceTargetType);
79561
79512
  context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : void 0;
79562
79513
  }
79563
79514
  }
@@ -79573,7 +79524,7 @@ function createTypeChecker(host) {
79573
79524
  const thisType = getThisTypeOfSignature(signature);
79574
79525
  if (thisType && couldContainTypeVariables(thisType)) {
79575
79526
  const thisArgumentNode = getThisArgumentOfCall(node);
79576
- inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
79527
+ inferTypes(context, context.inferences, getThisArgumentType(thisArgumentNode), thisType);
79577
79528
  }
79578
79529
  for (let i = 0; i < argCount; i++) {
79579
79530
  const arg = args[i];
@@ -79581,13 +79532,13 @@ function createTypeChecker(host) {
79581
79532
  const paramType = getTypeAtPosition(signature, i);
79582
79533
  if (couldContainTypeVariables(paramType)) {
79583
79534
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
79584
- inferTypes(context.inferences, argType, paramType);
79535
+ inferTypes(context, context.inferences, argType, paramType);
79585
79536
  }
79586
79537
  }
79587
79538
  }
79588
79539
  if (restType && couldContainTypeVariables(restType)) {
79589
79540
  const spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
79590
- inferTypes(context.inferences, spreadType, restType);
79541
+ inferTypes(context, context.inferences, spreadType, restType);
79591
79542
  }
79592
79543
  return getInferredTypes(context);
79593
79544
  }
@@ -81960,14 +81911,14 @@ function createTypeChecker(host) {
81960
81911
  isOptionalDeclaration(declaration)
81961
81912
  );
81962
81913
  const target = getTypeAtPosition(context, i);
81963
- inferTypes(inferenceContext.inferences, source, target);
81914
+ inferTypes(inferenceContext, inferenceContext.inferences, source, target);
81964
81915
  }
81965
81916
  }
81966
81917
  const typeNode = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
81967
81918
  if (typeNode) {
81968
81919
  const source = getTypeFromTypeNode(typeNode);
81969
81920
  const target = getReturnTypeOfSignature(context);
81970
- inferTypes(inferenceContext.inferences, source, target);
81921
+ inferTypes(inferenceContext, inferenceContext.inferences, source, target);
81971
81922
  }
81972
81923
  }
81973
81924
  function assignContextualParameterTypes(signature, context) {
@@ -84383,6 +84334,7 @@ function createTypeChecker(host) {
84383
84334
  const inferences = map(context.inferences, (info) => createInferenceInfo(info.typeParameter));
84384
84335
  applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
84385
84336
  inferTypes(
84337
+ context,
84386
84338
  inferences,
84387
84339
  source,
84388
84340
  target,
@@ -84394,7 +84346,7 @@ function createTypeChecker(host) {
84394
84346
  });
84395
84347
  if (some(inferences, hasInferenceCandidates)) {
84396
84348
  applyToReturnTypes(instantiatedSignature, contextualSignature, (source, target) => {
84397
- inferTypes(inferences, source, target);
84349
+ inferTypes(context, inferences, source, target);
84398
84350
  });
84399
84351
  if (!hasOverlappingInferences(context.inferences, inferences)) {
84400
84352
  mergeInferences(context.inferences, inferences);
@@ -88100,374 +88052,7 @@ function createTypeChecker(host) {
88100
88052
  ) : exprType;
88101
88053
  const effectiveExpr = expr && getEffectiveCheckNode(expr);
88102
88054
  const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
88103
- if (!(unwrappedReturnType.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */)) || !couldContainTypeVariables(unwrappedReturnType)) {
88104
- checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
88105
- return;
88106
- }
88107
- if (checkTypeAssignableTo(
88108
- unwrappedExprType,
88109
- unwrappedReturnType,
88110
- /*errorNode*/
88111
- void 0
88112
- )) {
88113
- return;
88114
- }
88115
- let narrowPosition = node;
88116
- let narrowFlowNode = inReturnStatement && node.flowNode;
88117
- if (expr && isConditionalExpression(expr.parent)) {
88118
- narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
88119
- narrowPosition = expr;
88120
- }
88121
- if (!narrowFlowNode) {
88122
- checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
88123
- return;
88124
- }
88125
- const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
88126
- container,
88127
- /*includeThisTypes*/
88128
- false
88129
- ), getEffectiveTypeParameterDeclarations(container));
88130
- const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
88131
- if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
88132
- checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
88133
- return;
88134
- }
88135
- const narrowedTypeParameters = [];
88136
- const narrowedTypes = [];
88137
- for (const [typeParam, symbol, narrowReference] of narrowableTypeParameters) {
88138
- resetNodeId(narrowReference);
88139
- let baseReference = narrowReference;
88140
- while (isAccessExpression(baseReference)) {
88141
- baseReference = baseReference.expression;
88142
- }
88143
- getNodeLinks(baseReference).resolvedSymbol = symbol;
88144
- setParent(narrowReference, narrowPosition.parent);
88145
- narrowReference.flowNode = narrowFlowNode;
88146
- const initialType = getNarrowableTypeForReference(
88147
- typeParam,
88148
- narrowReference,
88149
- /*checkMode*/
88150
- void 0,
88151
- /*forReturnTypeNarrowing*/
88152
- true
88153
- );
88154
- if (initialType === typeParam) {
88155
- continue;
88156
- }
88157
- const flowType = getFlowTypeOfReference(narrowReference, initialType);
88158
- const exprType2 = getTypeFromFlowType(flowType);
88159
- if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
88160
- continue;
88161
- }
88162
- const narrowedType = getSubstitutionType(
88163
- typeParam,
88164
- exprType2,
88165
- /*isNarrowed*/
88166
- true
88167
- );
88168
- narrowedTypeParameters.push(typeParam);
88169
- narrowedTypes.push(narrowedType);
88170
- }
88171
- const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
88172
- const narrowedReturnType = instantiateType(
88173
- unwrappedReturnType,
88174
- narrowMapper
88175
- );
88176
- if (expr) {
88177
- const links = getNodeLinks(expr);
88178
- if (!links.contextualReturnType) {
88179
- links.contextualReturnType = narrowedReturnType;
88180
- }
88181
- }
88182
- const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
88183
- const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
88184
- narrowedExprType,
88185
- /*withAlias*/
88186
- false,
88187
- node,
88188
- Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
88189
- ) : narrowedExprType;
88190
- checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
88191
- }
88192
- function resetNodeId(node) {
88193
- node.id = void 0;
88194
- forEachChildRecursively(node, resetNodeId);
88195
- }
88196
- function getNarrowableTypeParameters(candidates) {
88197
- const narrowableParams = [];
88198
- for (const typeParam of candidates) {
88199
- const constraint = getConstraintOfTypeParameter(typeParam);
88200
- if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
88201
- if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
88202
- const declaration = typeParam.symbol.declarations[0];
88203
- const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
88204
- if (!isFunctionLike(container)) continue;
88205
- let paramReference;
88206
- let referencePath;
88207
- let hasInvalidReference = false;
88208
- for (const paramDecl of container.parameters) {
88209
- const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
88210
- if (!typeNode) continue;
88211
- const result = getValidTypeParameterReference(typeNode, typeParam, []);
88212
- if (!result) {
88213
- hasInvalidReference = true;
88214
- break;
88215
- }
88216
- if (isArray(result)) {
88217
- if (referencePath) {
88218
- hasInvalidReference = true;
88219
- break;
88220
- }
88221
- referencePath = result;
88222
- paramReference = paramDecl;
88223
- }
88224
- }
88225
- if (!hasInvalidReference && referencePath && validateOptionality(paramReference, constraint, referencePath)) {
88226
- const symbolAndReference = constructNarrowableReference(paramReference, referencePath);
88227
- if (symbolAndReference) {
88228
- if (symbolAndReference[0] && symbolAndReference[0] !== unknownSymbol) {
88229
- narrowableParams.push([typeParam, symbolAndReference[0], symbolAndReference[1]]);
88230
- }
88231
- }
88232
- }
88233
- }
88234
- }
88235
- return narrowableParams;
88236
- function isReferenceToTypeParameter(typeParam, node) {
88237
- return getTypeFromTypeReference(node) === typeParam;
88238
- }
88239
- function isTypeParameterReferenced(typeParam, node) {
88240
- return isReferenced(node);
88241
- function isReferenced(node2) {
88242
- if (isTypeReferenceNode(node2)) {
88243
- return isReferenceToTypeParameter(typeParam, node2) || some(node2.typeArguments, isReferenced);
88244
- }
88245
- if (isTypeQueryNode(node2)) {
88246
- return isTypeParameterPossiblyReferenced(typeParam, node2);
88247
- }
88248
- return !!forEachChild(node2, isReferenced);
88249
- }
88250
- }
88251
- function getValidTypeParameterReference(typeNode, typeParam, path) {
88252
- var _a;
88253
- switch (typeNode.kind) {
88254
- case 183 /* TypeReference */:
88255
- const type = getTypeFromTypeReference(typeNode);
88256
- if (type === typeParam) {
88257
- return path;
88258
- }
88259
- const typeArgs = typeNode.typeArguments;
88260
- const typeArgsReferencingT = typeArgs == null ? void 0 : typeArgs.filter((node) => isTypeParameterReferenced(typeParam, node));
88261
- if (!typeArgsReferencingT || typeArgsReferencingT.length === 0) return true;
88262
- if (typeArgsReferencingT && typeArgsReferencingT.length > 1) return false;
88263
- const typeArg = typeArgsReferencingT[0];
88264
- if (!(typeArg.kind & 183 /* TypeReference */)) return false;
88265
- if (!type.symbol || !type.symbol.declarations || type.symbol.declarations.length !== 1) return false;
88266
- const typeDeclaration = type.symbol.declarations[0];
88267
- let aliasDeclaration;
88268
- if (isTypeLiteralNode(typeDeclaration)) {
88269
- aliasDeclaration = walkUpParenthesizedTypes(typeDeclaration.parent);
88270
- if (!isTypeAliasDeclaration(aliasDeclaration)) return false;
88271
- } else if (isInterfaceDeclaration(typeDeclaration)) {
88272
- aliasDeclaration = typeDeclaration;
88273
- } else {
88274
- return false;
88275
- }
88276
- const typeArgIndex = typeArgs.findIndex((arg) => arg === typeArg);
88277
- const matchingTypeParamDecl = (_a = aliasDeclaration.typeParameters) == null ? void 0 : _a[typeArgIndex];
88278
- if (!matchingTypeParamDecl) return false;
88279
- const matchingTypeParam = getDeclaredTypeOfTypeParameter(matchingTypeParamDecl.symbol);
88280
- return getValidTypeParameterReference(typeDeclaration, matchingTypeParam, path);
88281
- case 264 /* InterfaceDeclaration */:
88282
- const extendsTypes = flatMap(typeNode.heritageClauses, (clause) => clause.types);
88283
- const relevantExtendsTypes = extendsTypes.filter((node) => isTypeParameterReferenced(typeParam, node));
88284
- if (relevantExtendsTypes && relevantExtendsTypes.length > 1) {
88285
- return false;
88286
- }
88287
- const result = getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
88288
- if (relevantExtendsTypes && relevantExtendsTypes.length === 1) {
88289
- if (result !== true) {
88290
- return false;
88291
- }
88292
- return getValidTypeParameterReference(relevantExtendsTypes[0], typeParam, path);
88293
- }
88294
- return result;
88295
- case 187 /* TypeLiteral */:
88296
- return getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
88297
- case 193 /* IntersectionType */:
88298
- let validPath;
88299
- for (const type2 of typeNode.types) {
88300
- const result2 = getValidTypeParameterReference(type2, typeParam, path);
88301
- if (!result2) {
88302
- return false;
88303
- }
88304
- if (isArray(result2)) {
88305
- if (validPath) {
88306
- return false;
88307
- }
88308
- validPath = result2;
88309
- }
88310
- }
88311
- return validPath ?? true;
88312
- default:
88313
- return !isTypeParameterReferenced(typeParam, typeNode);
88314
- }
88315
- }
88316
- function getValidTypeParameterReferenceFromTypeElements(members, typeParam, path) {
88317
- let validPath;
88318
- for (const member of members) {
88319
- if (!isTypeParameterReferenced(typeParam, member)) {
88320
- continue;
88321
- }
88322
- if (!isPropertySignature(member)) {
88323
- return false;
88324
- }
88325
- if (!isIdentifier(member.name) && !isStringLiteral(member.name)) {
88326
- return false;
88327
- }
88328
- const result = getValidTypeParameterReference(member.type, typeParam, [...path, member]);
88329
- if (!result) {
88330
- return false;
88331
- }
88332
- if (isArray(result)) {
88333
- if (validPath) {
88334
- return false;
88335
- }
88336
- validPath = result;
88337
- }
88338
- }
88339
- return validPath ?? true;
88340
- }
88341
- function validateOptionality(paramDecl, constraint, path) {
88342
- for (let i = 0; i < path.length - 1; i++) {
88343
- if (path[i].questionToken) {
88344
- return false;
88345
- }
88346
- }
88347
- const paramIsOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
88348
- if (paramIsOptional && path.length > 0) {
88349
- return false;
88350
- }
88351
- const isOptional = paramIsOptional || path.length > 0 && path[path.length - 1].questionToken;
88352
- if (isOptional && strictNullChecks && !containsUndefinedType(constraint)) {
88353
- return false;
88354
- }
88355
- return true;
88356
- }
88357
- function constructNarrowableReference(paramDecl, path) {
88358
- let currentName = paramDecl.name;
88359
- let i = 0;
88360
- for (; i < path.length; i++) {
88361
- if (isIdentifier(currentName)) {
88362
- break;
88363
- } else if (isObjectBindingPattern(currentName)) {
88364
- const name = path[i].name;
88365
- let nameText;
88366
- if (isIdentifier(name)) nameText = name.escapedText;
88367
- else {
88368
- const rawText = getLiteralPropertyNameText(name);
88369
- if (rawText) nameText = escapeLeadingUnderscores(rawText);
88370
- }
88371
- const element = currentName.elements.find((element2) => {
88372
- const propertyName = getDestructuringPropertyName(element2);
88373
- const propertyNameText = propertyName && escapeLeadingUnderscores(propertyName);
88374
- return nameText && propertyNameText && nameText === propertyNameText;
88375
- });
88376
- if (!element) {
88377
- return void 0;
88378
- }
88379
- currentName = element.name;
88380
- } else {
88381
- return void 0;
88382
- }
88383
- }
88384
- if (!isIdentifier(currentName)) {
88385
- return void 0;
88386
- }
88387
- let result = factory.cloneNode(currentName);
88388
- const initialSymbol = getSymbolOfDeclaration(currentName.parent);
88389
- for (let j = i; j < path.length; j++) {
88390
- result = addName(result, path[j].name);
88391
- }
88392
- return [initialSymbol, result];
88393
- }
88394
- function addName(exp, name) {
88395
- name = factory.cloneNode(name);
88396
- if (isIdentifier(name)) {
88397
- const accessExp = factory.createPropertyAccessExpression(exp, name);
88398
- setParent(name, accessExp);
88399
- setParent(exp, accessExp);
88400
- return accessExp;
88401
- } else {
88402
- const accessExp = factory.createElementAccessExpression(exp, name);
88403
- setParent(name, accessExp);
88404
- setParent(exp, accessExp);
88405
- return accessExp;
88406
- }
88407
- }
88408
- }
88409
- function isNarrowableReturnType(returnType) {
88410
- return isConditionalType(returnType) ? isNarrowableConditionalType(
88411
- returnType,
88412
- /*hadNonPrimitiveExtendsType*/
88413
- []
88414
- ) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
88415
- }
88416
- function isNarrowableConditionalType(type, hadNonPrimitiveExtendsType, mapper) {
88417
- const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
88418
- const mapped = getMappedType(t, mapper);
88419
- if (isNarrowingSubstitutionType(mapped)) {
88420
- return mapped.baseType;
88421
- }
88422
- return mapped;
88423
- });
88424
- const id = `${type.id}:${getTypeListId(typeArguments)}:${getTypeListId(hadNonPrimitiveExtendsType)}`;
88425
- let result = narrowableReturnTypeCache.get(id);
88426
- if (result === void 0) {
88427
- const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
88428
- const instantiatedType = instantiateType(type, nonNarrowingMapper);
88429
- result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType, hadNonPrimitiveExtendsType);
88430
- narrowableReturnTypeCache.set(id, result);
88431
- }
88432
- return result;
88433
- }
88434
- function isNarrowableConditionalTypeWorker(type, hadNonPrimitiveExtendsType) {
88435
- if (!type.root.isDistributive) {
88436
- return false;
88437
- }
88438
- if (type.root.inferTypeParameters) {
88439
- return false;
88440
- }
88441
- if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
88442
- return false;
88443
- }
88444
- const constraintType = getConstraintOfTypeParameter(type.checkType);
88445
- if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
88446
- return false;
88447
- }
88448
- if (!everyType(type.extendsType, (extendsType) => some(
88449
- constraintType.types,
88450
- (constraintType2) => isTypeAssignableTo(constraintType2, extendsType)
88451
- ))) {
88452
- return false;
88453
- }
88454
- const hasNonPrimitive = someType(type.extendsType, (type2) => (type2.flags & 402784252 /* Primitive */) === 0);
88455
- if (hasNonPrimitive && hadNonPrimitiveExtendsType.includes(type.checkType)) {
88456
- return false;
88457
- }
88458
- if (hasNonPrimitive) {
88459
- hadNonPrimitiveExtendsType = hadNonPrimitiveExtendsType.slice();
88460
- hadNonPrimitiveExtendsType.push(type.checkType);
88461
- }
88462
- const trueType2 = getTrueTypeFromConditionalType(type);
88463
- const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2, hadNonPrimitiveExtendsType) : true;
88464
- if (!isValidTrueType) return false;
88465
- const falseType2 = getFalseTypeFromConditionalType(type);
88466
- const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2, hadNonPrimitiveExtendsType) : falseType2 === neverType;
88467
- return isValidFalseType;
88468
- }
88469
- function isConditionalType(type) {
88470
- return !!(type.flags & 16777216 /* Conditional */);
88055
+ checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
88471
88056
  }
88472
88057
  function checkWithStatement(node) {
88473
88058
  if (!checkGrammarStatementInAmbientContext(node)) {
@@ -177824,7 +177409,10 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
177824
177409
  }
177825
177410
  if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
177826
177411
  if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
177827
- const declaration = find(symbol.declarations, (declaration2) => declaration2.name === location);
177412
+ const declaration = find(
177413
+ symbol.declarations,
177414
+ (declaration2) => declaration2.name === location && declaration2.kind !== 211 /* PropertyAccessExpression */
177415
+ );
177828
177416
  if (declaration) {
177829
177417
  switch (declaration.kind) {
177830
177418
  case 177 /* GetAccessor */:
@@ -184839,6 +184427,7 @@ __export(ts_exports2, {
184839
184427
  visitNode: () => visitNode,
184840
184428
  visitNodes: () => visitNodes2,
184841
184429
  visitParameterList: () => visitParameterList,
184430
+ voidMap: () => voidMap,
184842
184431
  walkUpBindingElementsAndPatterns: () => walkUpBindingElementsAndPatterns,
184843
184432
  walkUpOuterExpressions: () => walkUpOuterExpressions,
184844
184433
  walkUpParenthesizedExpressions: () => walkUpParenthesizedExpressions,
@@ -199592,6 +199181,7 @@ if (typeof console !== "undefined") {
199592
199181
  visitNode,
199593
199182
  visitNodes,
199594
199183
  visitParameterList,
199184
+ voidMap,
199595
199185
  walkUpBindingElementsAndPatterns,
199596
199186
  walkUpOuterExpressions,
199597
199187
  walkUpParenthesizedExpressions,