@typescript-deploys/pr-build 5.0.0-pr-52944-9 → 5.0.0-pr-52947-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.0";
26
- var version = `${versionMajorMinor}.0-insiders.20230223`;
26
+ var version = `${versionMajorMinor}.0-insiders.20230224`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -3783,6 +3783,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3783
3783
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
3784
3784
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
3785
3785
  TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
3786
+ TypeFlags2[TypeFlags2["HasWrapper"] = 402668540] = "HasWrapper";
3786
3787
  return TypeFlags2;
3787
3788
  })(TypeFlags || {});
3788
3789
  var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
@@ -54421,15 +54422,27 @@ function createTypeChecker(host) {
54421
54422
  isInJSFile(signature.declaration)
54422
54423
  );
54423
54424
  }
54424
- function getTypeParameterConstraintMapper(typeParameters) {
54425
- const typeEraser = createTypeEraser(typeParameters);
54426
- const baseConstraintMapper = createTypeMapper(typeParameters, map(typeParameters, (tp) => getConstraintOfTypeParameter(tp) || unknownType));
54427
- let baseConstraints = map(typeParameters, (tp) => instantiateType(tp, baseConstraintMapper) || unknownType);
54428
- for (let i = 0; i < typeParameters.length - 1; i++) {
54429
- baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper);
54425
+ function getBaseSignature(signature) {
54426
+ const typeParameters = signature.typeParameters;
54427
+ if (typeParameters) {
54428
+ if (signature.baseSignatureCache) {
54429
+ return signature.baseSignatureCache;
54430
+ }
54431
+ const typeEraser = createTypeEraser(typeParameters);
54432
+ const baseConstraintMapper = createTypeMapper(typeParameters, map(typeParameters, (tp) => getConstraintOfTypeParameter(tp) || unknownType));
54433
+ let baseConstraints = map(typeParameters, (tp) => instantiateType(tp, baseConstraintMapper) || unknownType);
54434
+ for (let i = 0; i < typeParameters.length - 1; i++) {
54435
+ baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper);
54436
+ }
54437
+ baseConstraints = instantiateTypes(baseConstraints, typeEraser);
54438
+ return signature.baseSignatureCache = instantiateSignature(
54439
+ signature,
54440
+ createTypeMapper(typeParameters, baseConstraints),
54441
+ /*eraseTypeParameters*/
54442
+ true
54443
+ );
54430
54444
  }
54431
- baseConstraints = instantiateTypes(baseConstraints, typeEraser);
54432
- return createTypeMapper(typeParameters, baseConstraints);
54445
+ return signature;
54433
54446
  }
54434
54447
  function getOrCreateTypeFromSignature(signature) {
54435
54448
  var _a2;
@@ -56954,9 +56967,9 @@ function createTypeChecker(host) {
56954
56967
  }
56955
56968
  }
56956
56969
  if (!checkTypeDeferred) {
56957
- inferTypes(context, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
56970
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
56958
56971
  }
56959
- const innerMapper = combineTypeMappers(freshMapper, getMapperFromContext(context));
56972
+ const innerMapper = combineTypeMappers(freshMapper, context.mapper);
56960
56973
  combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
56961
56974
  }
56962
56975
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
@@ -57643,11 +57656,8 @@ function createTypeChecker(host) {
57643
57656
  void 0
57644
57657
  );
57645
57658
  }
57646
- function createBackreferenceMapper(context, inference) {
57647
- const inferences = context.inferences.indexOf(inference) >= 0 ? context.inferences : context.freeTypeVariables;
57648
- Debug.assert(inferences, "Inference for backreference mapper must exist within provided context");
57649
- const index = inferences.indexOf(inference);
57650
- const forwardInferences = inferences.slice(index);
57659
+ function createBackreferenceMapper(context, index) {
57660
+ const forwardInferences = context.inferences.slice(index);
57651
57661
  return createTypeMapper(map(forwardInferences, (i) => i.typeParameter), map(forwardInferences, () => unknownType));
57652
57662
  }
57653
57663
  function combineTypeMappers(mapper1, mapper2) {
@@ -59297,7 +59307,7 @@ function createTypeChecker(host) {
59297
59307
  function tryElaborateErrorsForPrimitivesAndObjects(source2, target2) {
59298
59308
  const sourceType = symbolValueDeclarationIsContextSensitive(source2.symbol) ? typeToString(source2, source2.symbol.valueDeclaration) : typeToString(source2);
59299
59309
  const targetType = symbolValueDeclarationIsContextSensitive(target2.symbol) ? typeToString(target2, target2.symbol.valueDeclaration) : typeToString(target2);
59300
- if (globalStringType === source2 && stringType === target2 || globalNumberType === source2 && numberType === target2 || globalBooleanType === source2 && booleanType === target2 || getGlobalESSymbolType() === source2 && esSymbolType === target2) {
59310
+ if (globalStringType === source2 && stringType === target2 || globalNumberType === source2 && numberType === target2 || globalBooleanType === source2 && booleanType === target2 || getGlobalESSymbolType() === source2 && esSymbolType === target2 || getGlobalBigIntType() === source2 && bigintType === target2) {
59301
59311
  reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
59302
59312
  }
59303
59313
  }
@@ -59454,6 +59464,9 @@ function createTypeChecker(host) {
59454
59464
  }
59455
59465
  if (source2.flags & 524288 /* Object */ && target2.flags & 134348796 /* Primitive */) {
59456
59466
  tryElaborateErrorsForPrimitivesAndObjects(source2, target2);
59467
+ }
59468
+ if (target2.flags & 524288 /* Object */ && source2.flags & 134348796 /* Primitive */) {
59469
+ tryElaborateErrorsForPrimitivesAndObjects(target2, source2);
59457
59470
  } else if (source2.symbol && source2.flags & 524288 /* Object */ && globalObjectType === source2) {
59458
59471
  reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
59459
59472
  } else if (getObjectFlags(source2) & 2048 /* JsxAttributes */ && target2.flags & 2097152 /* Intersection */) {
@@ -60461,10 +60474,9 @@ function createTypeChecker(host) {
60461
60474
  0 /* None */,
60462
60475
  isRelatedToWorker
60463
60476
  );
60464
- inferTypes(ctx, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
60465
- const newMapper = getMapperFromContext(ctx);
60466
- sourceExtends = instantiateType(sourceExtends, newMapper);
60467
- mapper = newMapper;
60477
+ inferTypes(ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
60478
+ sourceExtends = instantiateType(sourceExtends, ctx.mapper);
60479
+ mapper = ctx.mapper;
60468
60480
  }
60469
60481
  if (isTypeIdenticalTo(sourceExtends, target2.extendsType) && (isRelatedTo(source2.checkType, target2.checkType, 3 /* Both */) || isRelatedTo(target2.checkType, source2.checkType, 3 /* Both */))) {
60470
60482
  if (result2 = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source2), mapper), getTrueTypeFromConditionalType(target2), 3 /* Both */, reportErrors2)) {
@@ -60502,8 +60514,13 @@ function createTypeChecker(host) {
60502
60514
  }
60503
60515
  const sourceIsPrimitive = !!(sourceFlags & 134348796 /* Primitive */);
60504
60516
  if (relation !== identityRelation) {
60517
+ const originalSource = source2;
60518
+ const originalFlags = sourceFlags;
60505
60519
  source2 = getApparentType(source2);
60506
60520
  sourceFlags = source2.flags;
60521
+ if (source2 !== originalSource && originalFlags & 402668540 /* HasWrapper */ && !(sourceFlags & 402668540 /* HasWrapper */) && source2 === target2) {
60522
+ return 0 /* False */;
60523
+ }
60507
60524
  } else if (isGenericMappedType(source2)) {
60508
60525
  return 0 /* False */;
60509
60526
  }
@@ -62302,12 +62319,7 @@ function createTypeChecker(host) {
62302
62319
  return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
62303
62320
  }
62304
62321
  function cloneInferenceContext(context, extraFlags = 0) {
62305
- const newContext = context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
62306
- if (context && context.freeTypeVariables) {
62307
- newContext.freeTypeVariables = map(context.freeTypeVariables, cloneInferenceInfo);
62308
- newContext.freeTypeVariableSourceSignatures = new Map(mapIterator(context.freeTypeVariableSourceSignatures.entries(), ([k, v]) => [k, new Map(v.entries())]));
62309
- }
62310
- return newContext;
62322
+ return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
62311
62323
  }
62312
62324
  function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
62313
62325
  const context = {
@@ -62324,29 +62336,20 @@ function createTypeChecker(host) {
62324
62336
  return context;
62325
62337
  }
62326
62338
  function makeFixingMapperForContext(context) {
62327
- return makeDeferredTypeMapper(map(context.inferences, (i) => i.typeParameter), map(context.inferences, (inference) => () => {
62339
+ return makeDeferredTypeMapper(map(context.inferences, (i) => i.typeParameter), map(context.inferences, (inference, i) => () => {
62328
62340
  if (!inference.isFixed) {
62329
62341
  inferFromIntraExpressionSites(context);
62330
62342
  clearCachedInferences(context.inferences);
62331
62343
  inference.isFixed = true;
62332
62344
  }
62333
- return getInferredType(context, inference);
62345
+ return getInferredType(context, i);
62334
62346
  }));
62335
62347
  }
62336
62348
  function makeNonFixingMapperForContext(context) {
62337
- return makeDeferredTypeMapper(map(context.inferences, (i) => i.typeParameter), map(context.inferences, (inference) => () => {
62338
- return getInferredType(context, inference);
62349
+ return makeDeferredTypeMapper(map(context.inferences, (i) => i.typeParameter), map(context.inferences, (_, i) => () => {
62350
+ return getInferredType(context, i);
62339
62351
  }));
62340
62352
  }
62341
- function makeFreeTypeVariableMapperForContext(context) {
62342
- if (!context.freeTypeVariables)
62343
- return void 0;
62344
- const baseMapper = getTypeParameterConstraintMapper(map(context.freeTypeVariables, (i) => i.typeParameter));
62345
- return context.freeTypeVariables.reduceRight(
62346
- (previous, i) => combineTypeMappers(makeDeferredTypeMapper([i.typeParameter], [() => hasInferenceCandidatesOrDefault(i) ? getInferredType(context, i) : instantiateType(i.typeParameter, baseMapper)]), previous),
62347
- baseMapper
62348
- );
62349
- }
62350
62353
  function clearCachedInferences(inferences) {
62351
62354
  for (const inference of inferences) {
62352
62355
  if (!inference.isFixed) {
@@ -62363,7 +62366,7 @@ function createTypeChecker(host) {
62363
62366
  for (const { node, type } of context.intraExpressionInferenceSites) {
62364
62367
  const contextualType = node.kind === 171 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType(node, 2 /* NoConstraints */);
62365
62368
  if (contextualType) {
62366
- inferTypes(context, type, contextualType);
62369
+ inferTypes(context.inferences, type, contextualType);
62367
62370
  }
62368
62371
  }
62369
62372
  context.intraExpressionInferenceSites = void 0;
@@ -62398,8 +62401,7 @@ function createTypeChecker(host) {
62398
62401
  return inferences.length ? createInferenceContextWorker(map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : void 0;
62399
62402
  }
62400
62403
  function getMapperFromContext(context) {
62401
- const innerContext = context && last(flattenInferenceContextAlternatives(context));
62402
- return innerContext && innerContext.mapper && (innerContext.freeTypeVariables ? combineTypeMappers(innerContext.mapper, makeFreeTypeVariableMapperForContext(innerContext)) : innerContext.mapper);
62404
+ return context && context.mapper;
62403
62405
  }
62404
62406
  function couldContainTypeVariables(type) {
62405
62407
  const objectFlags = getObjectFlags(type);
@@ -62499,15 +62501,8 @@ function createTypeChecker(host) {
62499
62501
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
62500
62502
  const templateType = getTemplateTypeFromMappedType(target);
62501
62503
  const inference = createInferenceInfo(typeParameter);
62502
- const context = createInferenceContextWorker(
62503
- [inference],
62504
- /*signature*/
62505
- void 0,
62506
- 0 /* None */,
62507
- compareTypesAssignable
62508
- );
62509
- inferTypes(context, sourceType, templateType);
62510
- return getInferredTypes(context, returnFalse)[0] || unknownType;
62504
+ inferTypes([inference], sourceType, templateType);
62505
+ return getTypeFromInference(inference) || unknownType;
62511
62506
  }
62512
62507
  function* getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
62513
62508
  const properties = getPropertiesOfType(target);
@@ -62684,15 +62679,7 @@ function createTypeChecker(host) {
62684
62679
  pos = p;
62685
62680
  }
62686
62681
  }
62687
- function flattenInferenceContextAlternatives(context) {
62688
- return context.alternatives ? (context.alternatives.forEach((a) => mergeInferenceContexts(
62689
- a,
62690
- context,
62691
- /*clone*/
62692
- true
62693
- )), context.alternatives) : [context];
62694
- }
62695
- function inferTypes(context, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
62682
+ function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
62696
62683
  let bivariant = false;
62697
62684
  let propagationType;
62698
62685
  let inferencePriority = 2048 /* MaxValue */;
@@ -62701,21 +62688,7 @@ function createTypeChecker(host) {
62701
62688
  let sourceStack;
62702
62689
  let targetStack;
62703
62690
  let expandingFlags = 0 /* None */;
62704
- let useOnlyCachedAlternativeRoutes = false;
62705
62691
  inferFromTypes(originalSource, originalTarget);
62706
- useOnlyCachedAlternativeRoutes = true;
62707
- const group2 = forkInferenceContext();
62708
- spawnAlternativeInferenceContext(
62709
- group2,
62710
- () => {
62711
- if (length(context.freeTypeVariables)) {
62712
- inferFromTypes(originalSource, instantiateType(originalTarget, context.nonFixingMapper));
62713
- }
62714
- },
62715
- /*fork*/
62716
- false
62717
- );
62718
- joinInferenceContext(group2);
62719
62692
  function inferFromTypes(source, target) {
62720
62693
  if (!couldContainTypeVariables(target)) {
62721
62694
  return;
@@ -62776,9 +62749,6 @@ function createTypeChecker(host) {
62776
62749
  if (getObjectFlags(source) & 262144 /* NonInferrableType */ || source === nonInferrableAnyType) {
62777
62750
  return;
62778
62751
  }
62779
- if (useOnlyCachedAlternativeRoutes && source === target) {
62780
- return;
62781
- }
62782
62752
  if (!inference.isFixed) {
62783
62753
  if (inference.priority === void 0 || priority < inference.priority) {
62784
62754
  inference.candidates = void 0;
@@ -62791,16 +62761,16 @@ function createTypeChecker(host) {
62791
62761
  if (contravariant && !bivariant) {
62792
62762
  if (!contains(inference.contraCandidates, candidate)) {
62793
62763
  inference.contraCandidates = append(inference.contraCandidates, candidate);
62794
- clearCachedInferences(context.inferences);
62764
+ clearCachedInferences(inferences);
62795
62765
  }
62796
62766
  } else if (!contains(inference.candidates, candidate)) {
62797
62767
  inference.candidates = append(inference.candidates, candidate);
62798
- clearCachedInferences(context.inferences);
62768
+ clearCachedInferences(inferences);
62799
62769
  }
62800
62770
  }
62801
62771
  if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
62802
62772
  inference.topLevel = false;
62803
- clearCachedInferences(context.inferences);
62773
+ clearCachedInferences(inferences);
62804
62774
  }
62805
62775
  }
62806
62776
  inferencePriority = Math.min(inferencePriority, priority);
@@ -62968,12 +62938,7 @@ function createTypeChecker(host) {
62968
62938
  }
62969
62939
  function getInferenceInfoForType(type) {
62970
62940
  if (type.flags & 8650752 /* TypeVariable */) {
62971
- for (const inference of context.inferences) {
62972
- if (type === inference.typeParameter) {
62973
- return inference;
62974
- }
62975
- }
62976
- for (const inference of context.freeTypeVariables || []) {
62941
+ for (const inference of inferences) {
62977
62942
  if (type === inference.typeParameter) {
62978
62943
  return inference;
62979
62944
  }
@@ -63254,88 +63219,17 @@ function createTypeChecker(host) {
63254
63219
  }
63255
63220
  }
63256
63221
  }
63257
- function forkInferenceContext() {
63258
- return [];
63259
- }
63260
- function spawnAlternativeInferenceContext(group3, action, fork = true) {
63261
- const oldContext = context;
63262
- flattenInferenceContextAlternatives(context).forEach((alternative) => {
63263
- const newContext = fork ? cloneInferenceContext(alternative) : alternative;
63264
- context = newContext;
63265
- action();
63266
- context = oldContext;
63267
- group3.push(...flattenInferenceContextAlternatives(newContext));
63268
- });
63269
- }
63270
- function joinInferenceContext(group3) {
63271
- group3 = group3.length < 10 ? deduplicate(group3, compareInferenceContext) : group3;
63272
- if (group3.length === 1) {
63273
- mergeInferenceContexts(context, group3[0]);
63274
- context.freeTypeVariables = group3[0].freeTypeVariables;
63275
- context.freeTypeVariableSourceSignatures = group3[0].freeTypeVariableSourceSignatures;
63276
- context.inferredTypeParameters = group3[0].inferredTypeParameters;
63277
- context.flags = group3[0].flags;
63278
- context.alternatives = void 0;
63279
- return;
63280
- }
63281
- context.alternatives = group3;
63282
- }
63283
- function compareInferenceContext(a, b) {
63284
- return a.compareTypes === b.compareTypes && a.flags === b.flags && a.inferredTypeParameters === b.inferredTypeParameters && a.intraExpressionInferenceSites === b.intraExpressionInferenceSites && a.signature === b.signature && compareInferencesIdentical(a, a.inferences, b, b.inferences) && compareInferencesIdentical(a, a.freeTypeVariables, b, b.freeTypeVariables);
63285
- }
63286
- function compareInferencesIdentical(ctxA, a, ctxB, b) {
63287
- if (length(a) !== length(b))
63288
- return false;
63289
- if (length(a) === 0)
63290
- return true;
63291
- for (let i = 0; i < length(a); i++) {
63292
- if (a[i].typeParameter !== b[i].typeParameter || a[i].impliedArity !== b[i].impliedArity || a[i].isFixed !== b[i].isFixed || a[i].priority !== b[i].priority || a[i].topLevel !== b[i].topLevel || forEach(a, (_, i2) => getInferredType(ctxA, a[i2]) !== getInferredType(ctxB, b[i2])))
63293
- return false;
63294
- }
63295
- return true;
63296
- }
63297
63222
  function inferFromSignatures(source, target, kind) {
63298
- var _a2, _b;
63299
63223
  const sourceSignatures = getSignaturesOfType(source, kind);
63300
63224
  const targetSignatures = getSignaturesOfType(target, kind);
63301
63225
  const sourceLen = sourceSignatures.length;
63302
63226
  const targetLen = targetSignatures.length;
63303
- if (targetLen === 1 && sourceLen > 1) {
63304
- const group3 = forkInferenceContext();
63305
- for (let i = 0; i < sourceLen; i++) {
63306
- if (useOnlyCachedAlternativeRoutes && !((_b = (_a2 = context.freeTypeVariableSourceSignatures) == null ? void 0 : _a2.get(last(sourceStack))) == null ? void 0 : _b.get(sourceSignatures[i]))) {
63307
- continue;
63308
- }
63309
- spawnAlternativeInferenceContext(
63310
- group3,
63311
- () => inferFromSignature(sourceSignatures[i], targetSignatures[0])
63312
- );
63313
- }
63314
- joinInferenceContext(group3);
63315
- } else {
63316
- const len = sourceLen < targetLen ? sourceLen : targetLen;
63317
- for (let i = 0; i < len; i++) {
63318
- inferFromSignature(sourceSignatures[sourceLen - len + i], targetSignatures[targetLen - len + i]);
63319
- }
63227
+ const len = sourceLen < targetLen ? sourceLen : targetLen;
63228
+ for (let i = 0; i < len; i++) {
63229
+ inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
63320
63230
  }
63321
63231
  }
63322
63232
  function inferFromSignature(source, target) {
63323
- target = getErasedSignature(target);
63324
- if (source.typeParameters) {
63325
- let cache = (context.freeTypeVariableSourceSignatures || (context.freeTypeVariableSourceSignatures = /* @__PURE__ */ new Map())).get(last(sourceStack));
63326
- if (!cache) {
63327
- context.freeTypeVariableSourceSignatures.set(last(sourceStack), cache = /* @__PURE__ */ new Map());
63328
- }
63329
- const cached = cache.get(source);
63330
- if (cached) {
63331
- source = cached;
63332
- } else {
63333
- const originalSignature = source;
63334
- source = instantiateSignature(source, makeUnaryTypeMapper(unknownType, unknownType));
63335
- cache.set(originalSignature, source);
63336
- (context.freeTypeVariables || (context.freeTypeVariables = [])).push(...map(source.typeParameters, createInferenceInfo));
63337
- }
63338
- }
63339
63233
  const saveBivariant = bivariant;
63340
63234
  const kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
63341
63235
  bivariant = bivariant || kind === 171 /* MethodDeclaration */ || kind === 170 /* MethodSignature */ || kind === 173 /* Constructor */;
@@ -63410,7 +63304,8 @@ function createTypeChecker(host) {
63410
63304
  const unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates);
63411
63305
  return getWidenedType(unwidenedType);
63412
63306
  }
63413
- function getInferredType(context, inference) {
63307
+ function getInferredType(context, index) {
63308
+ const inference = context.inferences[index];
63414
63309
  if (!inference.inferredType) {
63415
63310
  let inferredType;
63416
63311
  const signature = context.signature;
@@ -63426,7 +63321,7 @@ function createTypeChecker(host) {
63426
63321
  } else {
63427
63322
  const defaultType = getDefaultFromTypeParameter(inference.typeParameter);
63428
63323
  if (defaultType) {
63429
- inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, inference), context.nonFixingMapper));
63324
+ inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
63430
63325
  }
63431
63326
  }
63432
63327
  } else {
@@ -63446,24 +63341,12 @@ function createTypeChecker(host) {
63446
63341
  function getDefaultTypeArgumentType(isInJavaScriptFile) {
63447
63342
  return isInJavaScriptFile ? anyType : unknownType;
63448
63343
  }
63449
- function getInferredTypes(context, accept) {
63450
- const alternatives = flattenInferenceContextAlternatives(context);
63451
- let finalAlternative;
63452
- for (let a = alternatives.length - 1; a >= 0; a--) {
63453
- const context2 = alternatives[a];
63454
- const freeTypeVariableMapper = makeFreeTypeVariableMapperForContext(context2);
63455
- const result = [];
63456
- for (const inference of context2.inferences) {
63457
- result.push(instantiateType(getInferredType(context2, inference), freeTypeVariableMapper));
63458
- }
63459
- if (alternatives.length === 1 || accept(result)) {
63460
- return result;
63461
- }
63462
- if (!finalAlternative) {
63463
- finalAlternative = result;
63464
- }
63344
+ function getInferredTypes(context) {
63345
+ const result = [];
63346
+ for (let i = 0; i < context.inferences.length; i++) {
63347
+ result.push(getInferredType(context, i));
63465
63348
  }
63466
- return finalAlternative;
63349
+ return result;
63467
63350
  }
63468
63351
  function getCannotFindNameDiagnosticForName(node) {
63469
63352
  switch (node.escapedText) {
@@ -66841,11 +66724,8 @@ function createTypeChecker(host) {
66841
66724
  function instantiateContextualType(contextualType, node, contextFlags) {
66842
66725
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) {
66843
66726
  const inferenceContext = getInferenceContext(node);
66844
- if (inferenceContext && contextFlags & 1 /* Signature */ && some(flatMap(flattenInferenceContextAlternatives(inferenceContext), (c) => c.inferences), hasInferenceCandidatesOrDefault)) {
66845
- return getUnionType(map(
66846
- flattenInferenceContextAlternatives(inferenceContext),
66847
- (c) => instantiateInstantiableTypes(contextualType, c.nonFixingMapper)
66848
- ));
66727
+ if (inferenceContext && contextFlags & 1 /* Signature */ && some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
66728
+ return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
66849
66729
  }
66850
66730
  if (inferenceContext == null ? void 0 : inferenceContext.returnMapper) {
66851
66731
  const type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
@@ -69204,23 +69084,23 @@ function createTypeChecker(host) {
69204
69084
  function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
69205
69085
  const context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes);
69206
69086
  const restType = getEffectiveRestType(contextualSignature);
69207
- const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : getMapperFromContext(inferenceContext));
69087
+ const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
69208
69088
  const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
69209
69089
  applyToParameterTypes(sourceSignature, signature, (source, target) => {
69210
- inferTypes(context, source, target);
69090
+ inferTypes(context.inferences, source, target);
69211
69091
  });
69212
69092
  if (!inferenceContext) {
69213
69093
  applyToReturnTypes(contextualSignature, signature, (source, target) => {
69214
- inferTypes(context, source, target, 128 /* ReturnType */);
69094
+ inferTypes(context.inferences, source, target, 128 /* ReturnType */);
69215
69095
  });
69216
69096
  }
69217
- return getSignatureInstantiation(signature, getInferredTypes(context, returnFalse), isInJSFile(contextualSignature.declaration));
69097
+ return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
69218
69098
  }
69219
- function inferJsxTypeArguments(node, signature, checkMode, context, accept) {
69099
+ function inferJsxTypeArguments(node, signature, checkMode, context) {
69220
69100
  const paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
69221
69101
  const checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
69222
- inferTypes(context, checkAttrType, paramType);
69223
- return getInferredTypes(context, accept);
69102
+ inferTypes(context.inferences, checkAttrType, paramType);
69103
+ return getInferredTypes(context);
69224
69104
  }
69225
69105
  function getThisArgumentType(thisArgumentNode) {
69226
69106
  if (!thisArgumentNode) {
@@ -69229,9 +69109,9 @@ function createTypeChecker(host) {
69229
69109
  const thisArgumentType = checkExpression(thisArgumentNode);
69230
69110
  return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : thisArgumentType;
69231
69111
  }
69232
- function inferTypeArguments(node, signature, args, checkMode, context, accept) {
69112
+ function inferTypeArguments(node, signature, args, checkMode, context) {
69233
69113
  if (isJsxOpeningLikeElement(node)) {
69234
- return inferJsxTypeArguments(node, signature, checkMode, context, accept);
69114
+ return inferJsxTypeArguments(node, signature, checkMode, context);
69235
69115
  }
69236
69116
  if (node.kind !== 167 /* Decorator */) {
69237
69117
  const skipBindingPatterns = every(signature.typeParameters, (p) => !!getDefaultFromTypeParameter(p));
@@ -69246,11 +69126,11 @@ function createTypeChecker(host) {
69246
69126
  const instantiatedType = instantiateType(contextualType, outerMapper);
69247
69127
  const contextualSignature = getSingleCallSignature(instantiatedType);
69248
69128
  const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType;
69249
- inferTypes(context, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
69129
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
69250
69130
  }
69251
69131
  const returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
69252
69132
  const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
69253
- inferTypes(returnContext, returnSourceType, inferenceTargetType);
69133
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
69254
69134
  context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : void 0;
69255
69135
  }
69256
69136
  }
@@ -69266,7 +69146,7 @@ function createTypeChecker(host) {
69266
69146
  const thisType = getThisTypeOfSignature(signature);
69267
69147
  if (thisType && couldContainTypeVariables(thisType)) {
69268
69148
  const thisArgumentNode = getThisArgumentOfCall(node);
69269
- inferTypes(context, getThisArgumentType(thisArgumentNode), thisType);
69149
+ inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
69270
69150
  }
69271
69151
  for (let i = 0; i < argCount; i++) {
69272
69152
  const arg = args[i];
@@ -69274,15 +69154,15 @@ function createTypeChecker(host) {
69274
69154
  const paramType = getTypeAtPosition(signature, i);
69275
69155
  if (couldContainTypeVariables(paramType)) {
69276
69156
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
69277
- inferTypes(context, argType, paramType);
69157
+ inferTypes(context.inferences, argType, paramType);
69278
69158
  }
69279
69159
  }
69280
69160
  }
69281
69161
  if (restType && couldContainTypeVariables(restType)) {
69282
69162
  const spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
69283
- inferTypes(context, spreadType, restType);
69163
+ inferTypes(context.inferences, spreadType, restType);
69284
69164
  }
69285
- return getInferredTypes(context, accept);
69165
+ return getInferredTypes(context);
69286
69166
  }
69287
69167
  function getMutableArrayOrTupleType(type) {
69288
69168
  return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(
@@ -70049,26 +69929,6 @@ function createTypeChecker(host) {
70049
69929
  }
70050
69930
  let checkCandidate;
70051
69931
  let inferenceContext;
70052
- const acceptor = (types) => {
70053
- const checkCandidate2 = getSignatureInstantiation(candidate, types, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
70054
- if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate2, signatureHelpTrailingComma2)) {
70055
- return false;
70056
- }
70057
- if (getSignatureApplicabilityError(
70058
- node,
70059
- args,
70060
- checkCandidate2,
70061
- relation,
70062
- argCheckMode,
70063
- /*reportErrors*/
70064
- false,
70065
- /*containingMessageChain*/
70066
- void 0
70067
- )) {
70068
- return false;
70069
- }
70070
- return true;
70071
- };
70072
69932
  if (candidate.typeParameters) {
70073
69933
  let typeArgumentTypes;
70074
69934
  if (some(typeArguments)) {
@@ -70089,7 +69949,7 @@ function createTypeChecker(host) {
70089
69949
  /*flags*/
70090
69950
  isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
70091
69951
  );
70092
- typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext, acceptor);
69952
+ typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext);
70093
69953
  argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
70094
69954
  }
70095
69955
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -70117,7 +69977,7 @@ function createTypeChecker(host) {
70117
69977
  if (argCheckMode) {
70118
69978
  argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
70119
69979
  if (inferenceContext) {
70120
- const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext, acceptor);
69980
+ const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
70121
69981
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
70122
69982
  if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
70123
69983
  candidateForArgumentArityError = checkCandidate;
@@ -70227,7 +70087,7 @@ function createTypeChecker(host) {
70227
70087
  /*flags*/
70228
70088
  isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
70229
70089
  );
70230
- const typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext, returnFalse);
70090
+ const typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
70231
70091
  return createSignatureInstantiation(candidate, typeArgumentTypes);
70232
70092
  }
70233
70093
  function getLongestCandidateIndex(candidates, argsCount) {
@@ -71495,7 +71355,7 @@ function createTypeChecker(host) {
71495
71355
  if (declaration.type) {
71496
71356
  const typeNode = getEffectiveTypeAnnotationNode(declaration);
71497
71357
  if (typeNode) {
71498
- inferTypes(inferenceContext, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
71358
+ inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
71499
71359
  }
71500
71360
  }
71501
71361
  }
@@ -72207,7 +72067,7 @@ function createTypeChecker(host) {
72207
72067
  instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
72208
72068
  }
72209
72069
  }
72210
- instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? instantiateSignature(contextualSignature, getMapperFromContext(inferenceContext)) : contextualSignature);
72070
+ instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
72211
72071
  assignContextualParameterTypes(signature, instantiatedContextualSignature);
72212
72072
  } else {
72213
72073
  assignNonContextualParameterTypes(signature);
@@ -73588,7 +73448,7 @@ function createTypeChecker(host) {
73588
73448
  return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || isValidConstAssertionArgument(node) && isConstTypeParameterContext(node) || (isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) || (isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
73589
73449
  }
73590
73450
  function isConstTypeParameterContext(node) {
73591
- const contextualType = getContextualType(node, 1 /* Signature */);
73451
+ const contextualType = getContextualType(node, 0 /* None */);
73592
73452
  return !!contextualType && someType(contextualType, isConstTypeVariable);
73593
73453
  }
73594
73454
  function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
@@ -73653,11 +73513,10 @@ function createTypeChecker(host) {
73653
73513
  if (returnSignature && !returnSignature.typeParameters && !every(context.inferences, hasInferenceCandidates)) {
73654
73514
  const uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
73655
73515
  const instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
73656
- const subcontext = cloneInferenceContext(context);
73657
- subcontext.inferences = map(context.inferences, (info) => createInferenceInfo(info.typeParameter));
73516
+ const inferences = map(context.inferences, (info) => createInferenceInfo(info.typeParameter));
73658
73517
  applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
73659
73518
  inferTypes(
73660
- subcontext,
73519
+ inferences,
73661
73520
  source,
73662
73521
  target,
73663
73522
  /*priority*/
@@ -73666,12 +73525,12 @@ function createTypeChecker(host) {
73666
73525
  true
73667
73526
  );
73668
73527
  });
73669
- if (some(subcontext.inferences, hasInferenceCandidates)) {
73528
+ if (some(inferences, hasInferenceCandidates)) {
73670
73529
  applyToReturnTypes(instantiatedSignature, contextualSignature, (source, target) => {
73671
- inferTypes(subcontext, source, target);
73530
+ inferTypes(inferences, source, target);
73672
73531
  });
73673
- if (!hasOverlappingInferences(context.inferences, subcontext.inferences)) {
73674
- mergeInferenceContexts(context, subcontext);
73532
+ if (!hasOverlappingInferences(context.inferences, inferences)) {
73533
+ mergeInferences(context.inferences, inferences);
73675
73534
  context.inferredTypeParameters = concatenate(context.inferredTypeParameters, uniqueTypeParameters);
73676
73535
  return getOrCreateTypeFromSignature(instantiatedSignature);
73677
73536
  }
@@ -73704,22 +73563,13 @@ function createTypeChecker(host) {
73704
73563
  }
73705
73564
  return false;
73706
73565
  }
73707
- function mergeInferences(target, source, clone2 = false) {
73566
+ function mergeInferences(target, source) {
73708
73567
  for (let i = 0; i < target.length; i++) {
73709
73568
  if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
73710
- target[i] = clone2 ? {
73711
- ...source[i],
73712
- candidates: source[i].candidates && [...source[i].candidates],
73713
- contraCandidates: source[i].contraCandidates && [...source[i].contraCandidates]
73714
- } : source[i];
73569
+ target[i] = source[i];
73715
73570
  }
73716
73571
  }
73717
73572
  }
73718
- function mergeInferenceContexts(target, source, cloneInferences = false) {
73719
- mergeInferences(target.inferences, source.inferences, cloneInferences);
73720
- target.mapper = makeFixingMapperForContext(target);
73721
- target.nonFixingMapper = makeNonFixingMapperForContext(target);
73722
- }
73723
73573
  function getUniqueTypeParameters(context, typeParameters) {
73724
73574
  const result = [];
73725
73575
  let oldTypeParameters;