typescript 4.8.0-dev.20220628 → 4.8.0-dev.20220701

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220628";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220701";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -3104,6 +3104,22 @@ var ts;
3104
3104
  return wrapFunction(deprecation, func);
3105
3105
  }
3106
3106
  Debug.deprecate = deprecate;
3107
+ function formatVariance(varianceFlags) {
3108
+ var variance = varianceFlags & 7 /* VarianceMask */;
3109
+ var result = variance === 0 /* Invariant */ ? "in out" :
3110
+ variance === 3 /* Bivariant */ ? "[bivariant]" :
3111
+ variance === 2 /* Contravariant */ ? "in" :
3112
+ variance === 1 /* Covariant */ ? "out" :
3113
+ variance === 4 /* Independent */ ? "[independent]" : "";
3114
+ if (varianceFlags & 8 /* Unmeasurable */) {
3115
+ result += " (unmeasurable)";
3116
+ }
3117
+ else if (varianceFlags & 16 /* Unreliable */) {
3118
+ result += " (unreliable)";
3119
+ }
3120
+ return result;
3121
+ }
3122
+ Debug.formatVariance = formatVariance;
3107
3123
  })(Debug = ts.Debug || (ts.Debug = {}));
3108
3124
  })(ts || (ts = {}));
3109
3125
  /* @internal */
@@ -3845,9 +3861,9 @@ var ts;
3845
3861
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
3846
3862
  }
3847
3863
  tracingEnabled.push = push;
3848
- function pop() {
3864
+ function pop(results) {
3849
3865
  ts.Debug.assert(eventStack.length > 0);
3850
- writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
3866
+ writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results);
3851
3867
  eventStack.length--;
3852
3868
  }
3853
3869
  tracingEnabled.pop = pop;
@@ -3861,14 +3877,15 @@ var ts;
3861
3877
  tracingEnabled.popAll = popAll;
3862
3878
  // sample every 10ms
3863
3879
  var sampleInterval = 1000 * 10;
3864
- function writeStackEvent(index, endTime) {
3880
+ function writeStackEvent(index, endTime, results) {
3865
3881
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
3866
3882
  if (separateBeginAndEnd) {
3883
+ ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
3867
3884
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
3868
3885
  }
3869
3886
  // test if [time,endTime) straddles a sampling point
3870
3887
  else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
3871
- writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3888
+ writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":" + (endTime - time), time);
3872
3889
  }
3873
3890
  }
3874
3891
  function writeEvent(eventType, phase, name, args, extras, time) {
@@ -5239,9 +5256,10 @@ var ts;
5239
5256
  (function (TypeMapKind) {
5240
5257
  TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple";
5241
5258
  TypeMapKind[TypeMapKind["Array"] = 1] = "Array";
5242
- TypeMapKind[TypeMapKind["Function"] = 2] = "Function";
5243
- TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite";
5244
- TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged";
5259
+ TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred";
5260
+ TypeMapKind[TypeMapKind["Function"] = 3] = "Function";
5261
+ TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite";
5262
+ TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged";
5245
5263
  })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {}));
5246
5264
  var InferencePriority;
5247
5265
  (function (InferencePriority) {
@@ -48644,6 +48662,24 @@ var ts;
48644
48662
  var Symbol = ts.objectAllocator.getSymbolConstructor();
48645
48663
  var Type = ts.objectAllocator.getTypeConstructor();
48646
48664
  var Signature = ts.objectAllocator.getSignatureConstructor();
48665
+ var DebugTypeMapper = /** @class */ (function () {
48666
+ function DebugTypeMapper() {
48667
+ }
48668
+ DebugTypeMapper.prototype.__debugToString = function () {
48669
+ var _a;
48670
+ ts.Debug.type(this);
48671
+ switch (this.kind) {
48672
+ case 3 /* Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)";
48673
+ case 0 /* Simple */: return this.source.__debugTypeToString() + " -> " + this.target.__debugTypeToString();
48674
+ case 1 /* Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return anyType; }), function (s, t) { return s.__debugTypeToString() + " -> " + t.__debugTypeToString(); }).join(", ");
48675
+ case 2 /* Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return s.__debugTypeToString() + " -> " + t().__debugTypeToString(); }).join(", ");
48676
+ case 5 /* Merged */:
48677
+ case 4 /* Composite */: return "m1: " + this.mapper1.__debugToString().split("\n").join("\n ") + "\nm2: " + this.mapper2.__debugToString().split("\n").join("\n ");
48678
+ default: return ts.Debug.assertNever(this);
48679
+ }
48680
+ };
48681
+ return DebugTypeMapper;
48682
+ }());
48647
48683
  var typeCount = 0;
48648
48684
  var symbolCount = 0;
48649
48685
  var enumCount = 0;
@@ -49104,10 +49140,23 @@ var ts;
49104
49140
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
49105
49141
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
49106
49142
  var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
49107
- var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
49108
- var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
49143
+ var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; });
49144
+ var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; });
49109
49145
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
49110
- var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
49146
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints)
49147
+ var outofbandVarianceMarkerHandler;
49148
+ var reportUnreliableMapper = makeFunctionTypeMapper(function (t) {
49149
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49150
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
49151
+ }
49152
+ return t;
49153
+ }, function () { return "(unmeasurable reporter)"; });
49154
+ var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) {
49155
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49156
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
49157
+ }
49158
+ return t;
49159
+ }, function () { return "(unreliable reporter)"; });
49111
49160
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49112
49161
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49113
49162
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -49267,7 +49316,6 @@ var ts;
49267
49316
  var typeofType = createTypeofType();
49268
49317
  var _jsxNamespace;
49269
49318
  var _jsxFactoryEntity;
49270
- var outofbandVarianceMarkerHandler;
49271
49319
  var subtypeRelation = new ts.Map();
49272
49320
  var strictSubtypeRelation = new ts.Map();
49273
49321
  var assignableRelation = new ts.Map();
@@ -53034,7 +53082,7 @@ var ts;
53034
53082
  var name = typeParameterToName(newParam, context);
53035
53083
  var newTypeVariable = ts.factory.createTypeReferenceNode(name);
53036
53084
  context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
53037
- var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
53085
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper);
53038
53086
  var saveInferTypeParameters_1 = context.inferTypeParameters;
53039
53087
  context.inferTypeParameters = type.root.inferTypeParameters;
53040
53088
  var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
@@ -60445,8 +60493,7 @@ var ts;
60445
60493
  var _a;
60446
60494
  var inferences;
60447
60495
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
60448
- for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60449
- var declaration = _b[_i];
60496
+ var _loop_15 = function (declaration) {
60450
60497
  if (declaration.parent.kind === 190 /* InferType */) {
60451
60498
  // When an 'infer T' declaration is immediately contained in a type reference node
60452
60499
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -60454,12 +60501,12 @@ var ts;
60454
60501
  // present, we form an intersection of the inferred constraint types.
60455
60502
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
60456
60503
  if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
60457
- var typeReference = grandParent;
60458
- var typeParameters = getTypeParametersForTypeReference(typeReference);
60459
- if (typeParameters) {
60460
- var index = typeReference.typeArguments.indexOf(childTypeParameter);
60461
- if (index < typeParameters.length) {
60462
- var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
60504
+ var typeReference_1 = grandParent;
60505
+ var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1);
60506
+ if (typeParameters_1) {
60507
+ var index = typeReference_1.typeArguments.indexOf(childTypeParameter);
60508
+ if (index < typeParameters_1.length) {
60509
+ var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]);
60463
60510
  if (declaredConstraint) {
60464
60511
  // Type parameter constraints can reference other type parameters so
60465
60512
  // constraints need to be instantiated. If instantiation produces the
@@ -60467,7 +60514,9 @@ var ts;
60467
60514
  // type Foo<T extends string, U extends T> = [T, U];
60468
60515
  // type Bar<T> = T extends Foo<infer X, infer X> ? Foo<X, X> : T;
60469
60516
  // the instantiated constraint for U is X, so we discard that inference.
60470
- var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
60517
+ var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () {
60518
+ return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index);
60519
+ }; }));
60471
60520
  var constraint = instantiateType(declaredConstraint, mapper);
60472
60521
  if (constraint !== typeParameter) {
60473
60522
  inferences = ts.append(inferences, constraint);
@@ -60505,6 +60554,10 @@ var ts;
60505
60554
  inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType)));
60506
60555
  }
60507
60556
  }
60557
+ };
60558
+ for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60559
+ var declaration = _b[_i];
60560
+ _loop_15(declaration);
60508
60561
  }
60509
60562
  }
60510
60563
  return inferences && getIntersectionType(inferences);
@@ -61393,7 +61446,7 @@ var ts;
61393
61446
  var lastRequiredIndex = -1;
61394
61447
  var firstRestIndex = -1;
61395
61448
  var lastOptionalOrRestIndex = -1;
61396
- var _loop_15 = function (i) {
61449
+ var _loop_16 = function (i) {
61397
61450
  var type = elementTypes[i];
61398
61451
  var flags = target.elementFlags[i];
61399
61452
  if (flags & 8 /* Variadic */) {
@@ -61423,7 +61476,7 @@ var ts;
61423
61476
  }
61424
61477
  };
61425
61478
  for (var i = 0; i < elementTypes.length; i++) {
61426
- var state_4 = _loop_15(i);
61479
+ var state_4 = _loop_16(i);
61427
61480
  if (typeof state_4 === "object")
61428
61481
  return state_4.value;
61429
61482
  }
@@ -61619,7 +61672,7 @@ var ts;
61619
61672
  var templates = ts.filter(types, isPatternLiteralType);
61620
61673
  if (templates.length) {
61621
61674
  var i = types.length;
61622
- var _loop_16 = function () {
61675
+ var _loop_17 = function () {
61623
61676
  i--;
61624
61677
  var t = types[i];
61625
61678
  if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -61627,7 +61680,7 @@ var ts;
61627
61680
  }
61628
61681
  };
61629
61682
  while (i > 0) {
61630
- _loop_16();
61683
+ _loop_17();
61631
61684
  }
61632
61685
  }
61633
61686
  }
@@ -61704,14 +61757,14 @@ var ts;
61704
61757
  var namedUnions = [];
61705
61758
  addNamedUnions(namedUnions, types);
61706
61759
  var reducedTypes = [];
61707
- var _loop_17 = function (t) {
61760
+ var _loop_18 = function (t) {
61708
61761
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
61709
61762
  reducedTypes.push(t);
61710
61763
  }
61711
61764
  };
61712
61765
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
61713
61766
  var t = typeSet_1[_i];
61714
- _loop_17(t);
61767
+ _loop_18(t);
61715
61768
  }
61716
61769
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
61717
61770
  return namedUnions[0];
@@ -62935,7 +62988,7 @@ var ts;
62935
62988
  var result;
62936
62989
  var extraTypes;
62937
62990
  var tailCount = 0;
62938
- var _loop_18 = function () {
62991
+ var _loop_19 = function () {
62939
62992
  if (tailCount === 1000) {
62940
62993
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
62941
62994
  result = errorType;
@@ -63056,7 +63109,7 @@ var ts;
63056
63109
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63057
63110
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63058
63111
  while (true) {
63059
- var state_5 = _loop_18();
63112
+ var state_5 = _loop_19();
63060
63113
  if (typeof state_5 === "object")
63061
63114
  return state_5.value;
63062
63115
  if (state_5 === "break")
@@ -63686,7 +63739,7 @@ var ts;
63686
63739
  switch (mapper.kind) {
63687
63740
  case 0 /* Simple */:
63688
63741
  return type === mapper.source ? mapper.target : type;
63689
- case 1 /* Array */:
63742
+ case 1 /* Array */: {
63690
63743
  var sources = mapper.sources;
63691
63744
  var targets = mapper.targets;
63692
63745
  for (var i = 0; i < sources.length; i++) {
@@ -63695,25 +63748,45 @@ var ts;
63695
63748
  }
63696
63749
  }
63697
63750
  return type;
63698
- case 2 /* Function */:
63751
+ }
63752
+ case 2 /* Deferred */: {
63753
+ var sources = mapper.sources;
63754
+ var targets = mapper.targets;
63755
+ for (var i = 0; i < sources.length; i++) {
63756
+ if (type === sources[i]) {
63757
+ return targets[i]();
63758
+ }
63759
+ }
63760
+ return type;
63761
+ }
63762
+ case 3 /* Function */:
63699
63763
  return mapper.func(type);
63700
- case 3 /* Composite */:
63701
- case 4 /* Merged */:
63764
+ case 4 /* Composite */:
63765
+ case 5 /* Merged */:
63702
63766
  var t1 = getMappedType(type, mapper.mapper1);
63703
- return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63767
+ return t1 !== type && mapper.kind === 4 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63704
63768
  }
63705
63769
  }
63770
+ function attachDebugPrototypeIfDebug(mapper) {
63771
+ if (ts.Debug.isDebugging) {
63772
+ return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype);
63773
+ }
63774
+ return mapper;
63775
+ }
63706
63776
  function makeUnaryTypeMapper(source, target) {
63707
- return { kind: 0 /* Simple */, source: source, target: target };
63777
+ return attachDebugPrototypeIfDebug({ kind: 0 /* Simple */, source: source, target: target });
63708
63778
  }
63709
63779
  function makeArrayTypeMapper(sources, targets) {
63710
- return { kind: 1 /* Array */, sources: sources, targets: targets };
63780
+ return attachDebugPrototypeIfDebug({ kind: 1 /* Array */, sources: sources, targets: targets });
63781
+ }
63782
+ function makeFunctionTypeMapper(func, debugInfo) {
63783
+ return attachDebugPrototypeIfDebug({ kind: 3 /* Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined });
63711
63784
  }
63712
- function makeFunctionTypeMapper(func) {
63713
- return { kind: 2 /* Function */, func: func };
63785
+ function makeDeferredTypeMapper(sources, targets) {
63786
+ return attachDebugPrototypeIfDebug({ kind: 2 /* Deferred */, sources: sources, targets: targets });
63714
63787
  }
63715
63788
  function makeCompositeTypeMapper(kind, mapper1, mapper2) {
63716
- return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
63789
+ return attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 });
63717
63790
  }
63718
63791
  function createTypeEraser(sources) {
63719
63792
  return createTypeMapper(sources, /*targets*/ undefined);
@@ -63723,19 +63796,20 @@ var ts;
63723
63796
  * This is used during inference when instantiating type parameter defaults.
63724
63797
  */
63725
63798
  function createBackreferenceMapper(context, index) {
63726
- return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
63799
+ var forwardInferences = context.inferences.slice(index);
63800
+ return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; }));
63727
63801
  }
63728
63802
  function combineTypeMappers(mapper1, mapper2) {
63729
- return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2;
63803
+ return mapper1 ? makeCompositeTypeMapper(4 /* Composite */, mapper1, mapper2) : mapper2;
63730
63804
  }
63731
63805
  function mergeTypeMappers(mapper1, mapper2) {
63732
- return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2;
63806
+ return mapper1 ? makeCompositeTypeMapper(5 /* Merged */, mapper1, mapper2) : mapper2;
63733
63807
  }
63734
63808
  function prependTypeMapping(source, target, mapper) {
63735
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
63809
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
63736
63810
  }
63737
63811
  function appendTypeMapping(mapper, source, target) {
63738
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
63812
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
63739
63813
  }
63740
63814
  function getRestrictiveTypeParameter(tp) {
63741
63815
  return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
@@ -65631,7 +65705,7 @@ var ts;
65631
65705
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
65632
65706
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
65633
65707
  }
65634
- var _loop_19 = function (prop) {
65708
+ var _loop_20 = function (prop) {
65635
65709
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
65636
65710
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
65637
65711
  if (reportErrors) {
@@ -65694,7 +65768,7 @@ var ts;
65694
65768
  };
65695
65769
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
65696
65770
  var prop = _b[_i];
65697
- var state_6 = _loop_19(prop);
65771
+ var state_6 = _loop_20(prop);
65698
65772
  if (typeof state_6 === "object")
65699
65773
  return state_6.value;
65700
65774
  }
@@ -65926,10 +66000,10 @@ var ts;
65926
66000
  // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component
65927
66001
  var saved = entry & 24 /* ReportsMask */;
65928
66002
  if (saved & 8 /* ReportsUnmeasurable */) {
65929
- instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
66003
+ instantiateType(source, reportUnmeasurableMapper);
65930
66004
  }
65931
66005
  if (saved & 16 /* ReportsUnreliable */) {
65932
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66006
+ instantiateType(source, reportUnreliableMapper);
65933
66007
  }
65934
66008
  }
65935
66009
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
@@ -66355,7 +66429,7 @@ var ts;
66355
66429
  }
66356
66430
  // Report unreliable variance for type variables referenced in template literal type placeholders.
66357
66431
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
66358
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66432
+ instantiateType(source, reportUnreliableMapper);
66359
66433
  }
66360
66434
  if (isTypeMatchedByTemplateLiteralType(source, target)) {
66361
66435
  return -1 /* True */;
@@ -66627,18 +66701,6 @@ var ts;
66627
66701
  }
66628
66702
  }
66629
66703
  }
66630
- function reportUnmeasurableMarkers(p) {
66631
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66632
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
66633
- }
66634
- return p;
66635
- }
66636
- function reportUnreliableMarkers(p) {
66637
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66638
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
66639
- }
66640
- return p;
66641
- }
66642
66704
  // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is
66643
66705
  // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
66644
66706
  // that S and T are contra-variant whereas X and Y are co-variant.
@@ -66648,7 +66710,7 @@ var ts;
66648
66710
  if (modifiersRelated) {
66649
66711
  var result_10;
66650
66712
  var targetConstraint = getConstraintTypeFromMappedType(target);
66651
- var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
66713
+ var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper);
66652
66714
  if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
66653
66715
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
66654
66716
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
@@ -66702,11 +66764,11 @@ var ts;
66702
66764
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
66703
66765
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
66704
66766
  var matchingTypes = [];
66705
- var _loop_20 = function (combination) {
66767
+ var _loop_21 = function (combination) {
66706
66768
  var hasMatch = false;
66707
66769
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
66708
66770
  var type = _d[_c];
66709
- var _loop_21 = function (i) {
66771
+ var _loop_22 = function (i) {
66710
66772
  var sourceProperty = sourcePropertiesFiltered[i];
66711
66773
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
66712
66774
  if (!targetProperty)
@@ -66722,7 +66784,7 @@ var ts;
66722
66784
  }
66723
66785
  };
66724
66786
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
66725
- var state_8 = _loop_21(i);
66787
+ var state_8 = _loop_22(i);
66726
66788
  switch (state_8) {
66727
66789
  case "continue-outer": continue outer;
66728
66790
  }
@@ -66736,7 +66798,7 @@ var ts;
66736
66798
  };
66737
66799
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
66738
66800
  var combination = discriminantCombinations_1[_a];
66739
- var state_7 = _loop_20(combination);
66801
+ var state_7 = _loop_21(combination);
66740
66802
  if (typeof state_7 === "object")
66741
66803
  return state_7.value;
66742
66804
  }
@@ -67184,7 +67246,7 @@ var ts;
67184
67246
  * See signatureAssignableTo, compareSignaturesIdentical
67185
67247
  */
67186
67248
  function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
67187
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
67249
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper);
67188
67250
  }
67189
67251
  function signaturesIdenticalTo(source, target, kind) {
67190
67252
  var sourceSignatures = getSignaturesOfType(source, kind);
@@ -67443,7 +67505,7 @@ var ts;
67443
67505
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
67444
67506
  links.variances = ts.emptyArray;
67445
67507
  var variances = [];
67446
- var _loop_22 = function (tp) {
67508
+ var _loop_23 = function (tp) {
67447
67509
  var modifiers = getVarianceModifiers(tp);
67448
67510
  var variance = modifiers & 65536 /* Out */ ?
67449
67511
  modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ :
@@ -67479,12 +67541,12 @@ var ts;
67479
67541
  }
67480
67542
  variances.push(variance);
67481
67543
  };
67482
- for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
67483
- var tp = typeParameters_1[_i];
67484
- _loop_22(tp);
67544
+ for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
67545
+ var tp = typeParameters_2[_i];
67546
+ _loop_23(tp);
67485
67547
  }
67486
67548
  links.variances = variances;
67487
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
67549
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
67488
67550
  }
67489
67551
  return links.variances;
67490
67552
  }
@@ -68476,27 +68538,29 @@ var ts;
68476
68538
  signature: signature,
68477
68539
  flags: flags,
68478
68540
  compareTypes: compareTypes,
68479
- mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }),
68480
- nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }),
68541
+ mapper: reportUnmeasurableMapper,
68542
+ nonFixingMapper: reportUnmeasurableMapper,
68481
68543
  };
68544
+ context.mapper = makeFixingMapperForContext(context);
68545
+ context.nonFixingMapper = makeNonFixingMapperForContext(context);
68482
68546
  return context;
68483
68547
  }
68484
- function mapToInferredType(context, t, fix) {
68485
- var inferences = context.inferences;
68486
- for (var i = 0; i < inferences.length; i++) {
68487
- var inference = inferences[i];
68488
- if (t === inference.typeParameter) {
68489
- if (fix && !inference.isFixed) {
68490
- // Before we commit to a particular inference (and thus lock out any further inferences),
68491
- // we infer from any intra-expression inference sites we have collected.
68492
- inferFromIntraExpressionSites(context);
68493
- clearCachedInferences(inferences);
68494
- inference.isFixed = true;
68495
- }
68496
- return getInferredType(context, i);
68548
+ function makeFixingMapperForContext(context) {
68549
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () {
68550
+ if (!inference.isFixed) {
68551
+ // Before we commit to a particular inference (and thus lock out any further inferences),
68552
+ // we infer from any intra-expression inference sites we have collected.
68553
+ inferFromIntraExpressionSites(context);
68554
+ clearCachedInferences(context.inferences);
68555
+ inference.isFixed = true;
68497
68556
  }
68498
- }
68499
- return t;
68557
+ return getInferredType(context, i);
68558
+ }; }));
68559
+ }
68560
+ function makeNonFixingMapperForContext(context) {
68561
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () {
68562
+ return getInferredType(context, i);
68563
+ }; }));
68500
68564
  }
68501
68565
  function clearCachedInferences(inferences) {
68502
68566
  for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
@@ -69416,7 +69480,7 @@ var ts;
69416
69480
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
69417
69481
  // succeed. That would be a pointless and confusing outcome.
69418
69482
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69419
- var _loop_23 = function (i) {
69483
+ var _loop_24 = function (i) {
69420
69484
  var source_1 = matches ? matches[i] : neverType;
69421
69485
  var target_3 = types[i];
69422
69486
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -69466,7 +69530,7 @@ var ts;
69466
69530
  inferFromTypes(source_1, target_3);
69467
69531
  };
69468
69532
  for (var i = 0; i < types.length; i++) {
69469
- _loop_23(i);
69533
+ _loop_24(i);
69470
69534
  }
69471
69535
  }
69472
69536
  }
@@ -69984,7 +70048,7 @@ var ts;
69984
70048
  function mapTypesByKeyProperty(types, name) {
69985
70049
  var map = new ts.Map();
69986
70050
  var count = 0;
69987
- var _loop_24 = function (type) {
70051
+ var _loop_25 = function (type) {
69988
70052
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69989
70053
  var discriminant = getTypeOfPropertyOfType(type, name);
69990
70054
  if (discriminant) {
@@ -70010,7 +70074,7 @@ var ts;
70010
70074
  };
70011
70075
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70012
70076
  var type = types_15[_i];
70013
- var state_9 = _loop_24(type);
70077
+ var state_9 = _loop_25(type);
70014
70078
  if (typeof state_9 === "object")
70015
70079
  return state_9.value;
70016
70080
  }
@@ -73357,8 +73421,8 @@ var ts;
73357
73421
  var conditional = node.parent;
73358
73422
  return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
73359
73423
  }
73360
- function getContextualTypeForChildJsxExpression(node, child) {
73361
- var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
73424
+ function getContextualTypeForChildJsxExpression(node, child, contextFlags) {
73425
+ var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags);
73362
73426
  // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty)
73363
73427
  var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
73364
73428
  if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
@@ -73376,27 +73440,27 @@ var ts;
73376
73440
  }
73377
73441
  }, /*noReductions*/ true));
73378
73442
  }
73379
- function getContextualTypeForJsxExpression(node) {
73443
+ function getContextualTypeForJsxExpression(node, contextFlags) {
73380
73444
  var exprParent = node.parent;
73381
73445
  return ts.isJsxAttributeLike(exprParent)
73382
- ? getContextualType(node)
73446
+ ? getContextualType(node, contextFlags)
73383
73447
  : ts.isJsxElement(exprParent)
73384
- ? getContextualTypeForChildJsxExpression(exprParent, node)
73448
+ ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags)
73385
73449
  : undefined;
73386
73450
  }
73387
- function getContextualTypeForJsxAttribute(attribute) {
73451
+ function getContextualTypeForJsxAttribute(attribute, contextFlags) {
73388
73452
  // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
73389
73453
  // which is a type of the parameter of the signature we are trying out.
73390
73454
  // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
73391
73455
  if (ts.isJsxAttribute(attribute)) {
73392
- var attributesType = getApparentTypeOfContextualType(attribute.parent);
73456
+ var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags);
73393
73457
  if (!attributesType || isTypeAny(attributesType)) {
73394
73458
  return undefined;
73395
73459
  }
73396
73460
  return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
73397
73461
  }
73398
73462
  else {
73399
- return getContextualType(attribute.parent);
73463
+ return getContextualType(attribute.parent, contextFlags);
73400
73464
  }
73401
73465
  }
73402
73466
  // Return true if the given expression is possibly a discriminant value. We limit the kinds of
@@ -73557,10 +73621,10 @@ var ts;
73557
73621
  case 271 /* ExportAssignment */:
73558
73622
  return tryGetTypeFromEffectiveTypeNode(parent);
73559
73623
  case 288 /* JsxExpression */:
73560
- return getContextualTypeForJsxExpression(parent);
73624
+ return getContextualTypeForJsxExpression(parent, contextFlags);
73561
73625
  case 285 /* JsxAttribute */:
73562
73626
  case 287 /* JsxSpreadAttribute */:
73563
- return getContextualTypeForJsxAttribute(parent);
73627
+ return getContextualTypeForJsxAttribute(parent, contextFlags);
73564
73628
  case 280 /* JsxOpeningElement */:
73565
73629
  case 279 /* JsxSelfClosingElement */:
73566
73630
  return getContextualJsxElementAttributesType(parent, contextFlags);
@@ -76359,7 +76423,7 @@ var ts;
76359
76423
  if (spreadIndex >= 0) {
76360
76424
  // Create synthetic arguments from spreads of tuple types.
76361
76425
  var effectiveArgs_1 = args.slice(0, spreadIndex);
76362
- var _loop_25 = function (i) {
76426
+ var _loop_26 = function (i) {
76363
76427
  var arg = args[i];
76364
76428
  // We can call checkExpressionCached because spread expressions never have a contextual type.
76365
76429
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -76376,7 +76440,7 @@ var ts;
76376
76440
  }
76377
76441
  };
76378
76442
  for (var i = spreadIndex; i < args.length; i++) {
76379
- _loop_25(i);
76443
+ _loop_26(i);
76380
76444
  }
76381
76445
  return effectiveArgs_1;
76382
76446
  }
@@ -76705,7 +76769,7 @@ var ts;
76705
76769
  var min_3 = Number.MAX_VALUE;
76706
76770
  var minIndex = 0;
76707
76771
  var i_1 = 0;
76708
- var _loop_26 = function (c) {
76772
+ var _loop_27 = function (c) {
76709
76773
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76710
76774
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76711
76775
  if (diags_2) {
@@ -76723,7 +76787,7 @@ var ts;
76723
76787
  };
76724
76788
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76725
76789
  var c = candidatesForArgumentError_1[_a];
76726
- _loop_26(c);
76790
+ _loop_27(c);
76727
76791
  }
76728
76792
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76729
76793
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76881,7 +76945,7 @@ var ts;
76881
76945
  }
76882
76946
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76883
76947
  var parameters = [];
76884
- var _loop_27 = function (i) {
76948
+ var _loop_28 = function (i) {
76885
76949
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76886
76950
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76887
76951
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76889,7 +76953,7 @@ var ts;
76889
76953
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76890
76954
  };
76891
76955
  for (var i = 0; i < maxNonRestParam; i++) {
76892
- _loop_27(i);
76956
+ _loop_28(i);
76893
76957
  }
76894
76958
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76895
76959
  var flags = 0 /* None */;
@@ -80242,8 +80306,8 @@ var ts;
80242
80306
  var result = [];
80243
80307
  var oldTypeParameters;
80244
80308
  var newTypeParameters;
80245
- for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
80246
- var tp = typeParameters_2[_i];
80309
+ for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
80310
+ var tp = typeParameters_3[_i];
80247
80311
  var name = tp.symbol.escapedName;
80248
80312
  if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
80249
80313
  var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
@@ -80565,12 +80629,14 @@ var ts;
80565
80629
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80566
80630
  }
80567
80631
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80632
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
80568
80633
  var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80569
80634
  var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80570
80635
  var saveVarianceTypeParameter = typeParameter;
80571
80636
  varianceTypeParameter = typeParameter;
80572
80637
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
80573
80638
  varianceTypeParameter = saveVarianceTypeParameter;
80639
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
80574
80640
  }
80575
80641
  }
80576
80642
  }
@@ -80920,7 +80986,7 @@ var ts;
80920
80986
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80921
80987
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80922
80988
  var indexSignatureMap_1 = new ts.Map();
80923
- var _loop_28 = function (declaration) {
80989
+ var _loop_29 = function (declaration) {
80924
80990
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80925
80991
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80926
80992
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80935,7 +81001,7 @@ var ts;
80935
81001
  };
80936
81002
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80937
81003
  var declaration = _a[_i];
80938
- _loop_28(declaration);
81004
+ _loop_29(declaration);
80939
81005
  }
80940
81006
  indexSignatureMap_1.forEach(function (entry) {
80941
81007
  if (entry.declarations.length > 1) {
@@ -81158,6 +81224,12 @@ var ts;
81158
81224
  function checkMissingDeclaration(node) {
81159
81225
  checkDecorators(node);
81160
81226
  }
81227
+ function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) {
81228
+ if (index < typeParameters.length) {
81229
+ return getTypeFromTypeNode(node.typeArguments[index]);
81230
+ }
81231
+ return getEffectiveTypeArguments(node, typeParameters)[index];
81232
+ }
81161
81233
  function getEffectiveTypeArguments(node, typeParameters) {
81162
81234
  return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
81163
81235
  }
@@ -81966,8 +82038,17 @@ var ts;
81966
82038
  }
81967
82039
  // For a union, get a union of the awaited types of each constituent.
81968
82040
  if (type.flags & 1048576 /* Union */) {
82041
+ if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
82042
+ if (errorNode) {
82043
+ error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
82044
+ }
82045
+ return undefined;
82046
+ }
81969
82047
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
81970
- return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
82048
+ awaitedTypeStack.push(type.id);
82049
+ var mapped = mapType(type, mapper);
82050
+ awaitedTypeStack.pop();
82051
+ return typeAsAwaitable.awaitedTypeOfType = mapped;
81971
82052
  }
81972
82053
  var thisTypeForErrorOut = { value: undefined };
81973
82054
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
@@ -82616,8 +82697,8 @@ var ts;
82616
82697
  return;
82617
82698
  var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
82618
82699
  var seenParentsWithEveryUnused = new ts.Set();
82619
- for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
82620
- var typeParameter = typeParameters_3[_i];
82700
+ for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) {
82701
+ var typeParameter = typeParameters_4[_i];
82621
82702
  if (!isTypeParameterUnused(typeParameter))
82622
82703
  continue;
82623
82704
  var name = ts.idText(typeParameter.name);
@@ -84436,7 +84517,7 @@ var ts;
84436
84517
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84437
84518
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
84438
84519
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
84439
- var _loop_29 = function (info) {
84520
+ var _loop_30 = function (info) {
84440
84521
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
84441
84522
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
84442
84523
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -84449,7 +84530,7 @@ var ts;
84449
84530
  };
84450
84531
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
84451
84532
  var info = indexInfos_9[_i];
84452
- _loop_29(info);
84533
+ _loop_30(info);
84453
84534
  }
84454
84535
  }
84455
84536
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -84457,7 +84538,7 @@ var ts;
84457
84538
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
84458
84539
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84459
84540
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
84460
- var _loop_30 = function (info) {
84541
+ var _loop_31 = function (info) {
84461
84542
  if (info === checkInfo)
84462
84543
  return "continue";
84463
84544
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -84472,7 +84553,7 @@ var ts;
84472
84553
  };
84473
84554
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
84474
84555
  var info = indexInfos_10[_i];
84475
- _loop_30(info);
84556
+ _loop_31(info);
84476
84557
  }
84477
84558
  }
84478
84559
  function checkTypeNameIsReserved(name, message) {
@@ -84792,7 +84873,7 @@ var ts;
84792
84873
  var baseTypes = baseTypeNode && getBaseTypes(type);
84793
84874
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84794
84875
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84795
- var _loop_31 = function (member) {
84876
+ var _loop_32 = function (member) {
84796
84877
  if (ts.hasAmbientModifier(member)) {
84797
84878
  return "continue";
84798
84879
  }
@@ -84809,7 +84890,7 @@ var ts;
84809
84890
  };
84810
84891
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84811
84892
  var member = _a[_i];
84812
- _loop_31(member);
84893
+ _loop_32(member);
84813
84894
  }
84814
84895
  }
84815
84896
  /**
@@ -84897,7 +84978,7 @@ var ts;
84897
84978
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84898
84979
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84899
84980
  var issuedMemberError = false;
84900
- var _loop_32 = function (member) {
84981
+ var _loop_33 = function (member) {
84901
84982
  if (ts.isStatic(member)) {
84902
84983
  return "continue";
84903
84984
  }
@@ -84916,7 +84997,7 @@ var ts;
84916
84997
  };
84917
84998
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84918
84999
  var member = _a[_i];
84919
- _loop_32(member);
85000
+ _loop_33(member);
84920
85001
  }
84921
85002
  if (!issuedMemberError) {
84922
85003
  // check again with diagnostics to generate a less-specific error
@@ -84987,7 +85068,7 @@ var ts;
84987
85068
  var _a, _b, _c, _d;
84988
85069
  // NOTE: assignability is checked in checkClassDeclaration
84989
85070
  var baseProperties = getPropertiesOfType(baseType);
84990
- var _loop_33 = function (baseProperty) {
85071
+ var _loop_34 = function (baseProperty) {
84991
85072
  var base = getTargetSymbol(baseProperty);
84992
85073
  if (base.flags & 4194304 /* Prototype */) {
84993
85074
  return "continue";
@@ -85097,7 +85178,7 @@ var ts;
85097
85178
  };
85098
85179
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
85099
85180
  var baseProperty = baseProperties_1[_i];
85100
- var state_10 = _loop_33(baseProperty);
85181
+ var state_10 = _loop_34(baseProperty);
85101
85182
  switch (state_10) {
85102
85183
  case "continue-basePropertyCheck": continue basePropertyCheck;
85103
85184
  }
@@ -111612,7 +111693,6 @@ var ts;
111612
111693
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111613
111694
  // Update the output signature
111614
111695
  newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111615
- newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111616
111696
  }
111617
111697
  // Update sourceFileInfo
111618
111698
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
@@ -119417,7 +119497,7 @@ var ts;
119417
119497
  }
119418
119498
  }
119419
119499
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119420
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
119500
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
119421
119501
  processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
119422
119502
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119423
119503
  }
@@ -120999,7 +121079,7 @@ var ts;
120999
121079
  state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
121000
121080
  }
121001
121081
  state.changedFilesSet = new ts.Set();
121002
- state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
121082
+ state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined;
121003
121083
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
121004
121084
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
121005
121085
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
@@ -121123,7 +121203,7 @@ var ts;
121123
121203
  programEmitComplete: state.programEmitComplete,
121124
121204
  emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
121125
121205
  outSignature: state.outSignature,
121126
- dtsChangeTime: state.dtsChangeTime,
121206
+ latestChangedDtsFile: state.latestChangedDtsFile,
121127
121207
  hasChangedEmitSignature: state.hasChangedEmitSignature,
121128
121208
  changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
121129
121209
  };
@@ -121136,7 +121216,7 @@ var ts;
121136
121216
  state.programEmitComplete = savedEmitState.programEmitComplete;
121137
121217
  state.emitSignatures = savedEmitState.emitSignatures;
121138
121218
  state.outSignature = savedEmitState.outSignature;
121139
- state.dtsChangeTime = savedEmitState.dtsChangeTime;
121219
+ state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile;
121140
121220
  state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
121141
121221
  if (savedEmitState.changedFilesSet)
121142
121222
  state.changedFilesSet = savedEmitState.changedFilesSet;
@@ -121450,14 +121530,14 @@ var ts;
121450
121530
  /**
121451
121531
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121452
121532
  */
121453
- function getProgramBuildInfo(state, getCanonicalFileName, host) {
121533
+ function getProgramBuildInfo(state, getCanonicalFileName) {
121454
121534
  var outFilePath = ts.outFile(state.compilerOptions);
121455
121535
  if (outFilePath && !state.compilerOptions.composite)
121456
121536
  return;
121457
121537
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121458
121538
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121459
- // Update the dtsChange time in buildInfo
121460
- state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121539
+ // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path
121540
+ var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
121461
121541
  if (outFilePath) {
121462
121542
  var fileNames_1 = [];
121463
121543
  var fileInfos_1 = [];
@@ -121473,7 +121553,7 @@ var ts;
121473
121553
  fileInfos: fileInfos_1,
121474
121554
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121475
121555
  outSignature: state.outSignature,
121476
- dtsChangeTime: state.dtsChangeTime,
121556
+ latestChangedDtsFile: latestChangedDtsFile,
121477
121557
  };
121478
121558
  return result_15;
121479
121559
  }
@@ -121575,7 +121655,7 @@ var ts;
121575
121655
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121576
121656
  changeFileSet: changeFileSet,
121577
121657
  emitSignatures: emitSignatures,
121578
- dtsChangeTime: state.dtsChangeTime,
121658
+ latestChangedDtsFile: latestChangedDtsFile,
121579
121659
  };
121580
121660
  return result;
121581
121661
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -121743,7 +121823,7 @@ var ts;
121743
121823
  */
121744
121824
  var computeHash = ts.maybeBind(host, host.createHash);
121745
121825
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121746
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121826
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121747
121827
  // To ensure that we arent storing any references to old program or new program without state
121748
121828
  newProgram = undefined; // TODO: GH#18217
121749
121829
  oldProgram = undefined;
@@ -121753,6 +121833,7 @@ var ts;
121753
121833
  builderProgram.getState = getState;
121754
121834
  builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121755
121835
  builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121836
+ builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; };
121756
121837
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121757
121838
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121758
121839
  builderProgram.emit = emit;
@@ -121860,18 +121941,22 @@ var ts;
121860
121941
  var filePath = sourceFiles[0].resolvedPath;
121861
121942
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
121862
121943
  emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
121863
- if (emitSignature !== oldSignature) {
121864
- ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121865
- state.hasChangedEmitSignature = true;
121866
- }
121944
+ // Dont write dts files if they didn't change
121945
+ if (emitSignature === oldSignature)
121946
+ return;
121947
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121948
+ state.hasChangedEmitSignature = true;
121949
+ state.latestChangedDtsFile = fileName;
121867
121950
  }
121868
121951
  }
121869
121952
  else if (state.compilerOptions.composite) {
121870
121953
  var newSignature = computeSignature(text, computeHash, data);
121871
- if (newSignature !== state.outSignature) {
121872
- state.outSignature = newSignature;
121873
- state.hasChangedEmitSignature = true;
121874
- }
121954
+ // Dont write dts files if they didn't change
121955
+ if (newSignature === state.outSignature)
121956
+ return;
121957
+ state.outSignature = newSignature;
121958
+ state.hasChangedEmitSignature = true;
121959
+ state.latestChangedDtsFile = fileName;
121875
121960
  }
121876
121961
  }
121877
121962
  if (writeFile)
@@ -122034,11 +122119,12 @@ var ts;
122034
122119
  var state;
122035
122120
  var filePaths;
122036
122121
  var filePathsSetList;
122122
+ var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
122037
122123
  if (isProgramBundleEmitBuildInfo(program)) {
122038
122124
  state = {
122039
122125
  fileInfos: new ts.Map(),
122040
122126
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
122041
- dtsChangeTime: program.dtsChangeTime,
122127
+ latestChangedDtsFile: latestChangedDtsFile,
122042
122128
  outSignature: program.outSignature,
122043
122129
  };
122044
122130
  }
@@ -122071,7 +122157,7 @@ var ts;
122071
122157
  affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
122072
122158
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
122073
122159
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
122074
- dtsChangeTime: program.dtsChangeTime,
122160
+ latestChangedDtsFile: latestChangedDtsFile,
122075
122161
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
122076
122162
  };
122077
122163
  }
@@ -122098,6 +122184,7 @@ var ts;
122098
122184
  getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
122099
122185
  emitBuildInfo: ts.notImplemented,
122100
122186
  close: ts.noop,
122187
+ hasChangedEmitSignature: ts.returnFalse,
122101
122188
  };
122102
122189
  function toPath(path) {
122103
122190
  return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
@@ -123412,7 +123499,7 @@ var ts;
123412
123499
  });
123413
123500
  // Sort by paths closest to importing file Name directory
123414
123501
  var sortedPaths = [];
123415
- var _loop_34 = function (directory) {
123502
+ var _loop_35 = function (directory) {
123416
123503
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
123417
123504
  var pathsInDirectory;
123418
123505
  allFileNames.forEach(function (_a, fileName) {
@@ -123436,7 +123523,7 @@ var ts;
123436
123523
  };
123437
123524
  var out_directory_1;
123438
123525
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
123439
- var state_11 = _loop_34(directory);
123526
+ var state_11 = _loop_35(directory);
123440
123527
  directory = out_directory_1;
123441
123528
  if (state_11 === "break")
123442
123529
  break;
@@ -124280,7 +124367,6 @@ var ts;
124280
124367
  readDirectory: ts.maybeBind(host, host.readDirectory),
124281
124368
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
124282
124369
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
124283
- now: ts.maybeBind(host, host.now),
124284
124370
  };
124285
124371
  function writeFile(fileName, text, writeByteOrderMark, onError) {
124286
124372
  try {
@@ -124438,7 +124524,6 @@ var ts;
124438
124524
  host.createHash = ts.maybeBind(system, system.createHash);
124439
124525
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
124440
124526
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124441
- host.now = ts.maybeBind(system, system.now);
124442
124527
  ts.setGetSourceFileAsHashVersioned(host, system);
124443
124528
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
124444
124529
  return host;
@@ -125766,8 +125851,7 @@ var ts;
125766
125851
  }
125767
125852
  // Actual Emit
125768
125853
  var host = state.host, compilerHost = state.compilerHost;
125769
- var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125770
- var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125854
+ var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
125771
125855
  var emitterDiagnostics = ts.createDiagnosticCollection();
125772
125856
  var emittedOutputs = new ts.Map();
125773
125857
  var options = program.getCompilerOptions();
@@ -125775,17 +125859,11 @@ var ts;
125775
125859
  var outputTimeStampMap;
125776
125860
  var now;
125777
125861
  outputFiles.forEach(function (_a) {
125778
- var _b, _c;
125779
125862
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125780
125863
  var path = toPath(state, name);
125781
125864
  emittedOutputs.set(toPath(state, name), name);
125782
- if (buildInfo) {
125783
- setBuildInfo(state, buildInfo, projectPath, options);
125784
- // Buildinfo has information on when last dts change time
125785
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125786
- resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125787
- }
125788
- }
125865
+ if (buildInfo)
125866
+ setBuildInfo(state, buildInfo, projectPath, options, resultFlags);
125789
125867
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125790
125868
  if (!isIncremental && state.watch) {
125791
125869
  (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
@@ -125799,7 +125877,7 @@ var ts;
125799
125877
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125800
125878
  var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125801
125879
  if (data === null || data === void 0 ? void 0 : data.buildInfo)
125802
- setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125880
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged);
125803
125881
  if (writeFileCallback)
125804
125882
  writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125805
125883
  else
@@ -125832,7 +125910,6 @@ var ts;
125832
125910
  state.diagnostics.delete(projectPath);
125833
125911
  state.projectStatus.set(projectPath, {
125834
125912
  type: ts.UpToDateStatusType.UpToDate,
125835
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125836
125913
  oldestOutputFileName: oldestOutputFileName
125837
125914
  });
125838
125915
  afterProgramDone(state, program, config);
@@ -125874,10 +125951,10 @@ var ts;
125874
125951
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125875
125952
  emittedOutputs.set(toPath(state, name), name);
125876
125953
  if (buildInfo) {
125877
- setBuildInfo(state, buildInfo, projectPath, config.options);
125878
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125954
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
125879
125955
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125880
125956
  }
125957
+ setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
125881
125958
  }
125882
125959
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125883
125960
  });
@@ -126136,15 +126213,23 @@ var ts;
126136
126213
  state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
126137
126214
  return result;
126138
126215
  }
126139
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
126216
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) {
126140
126217
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126141
126218
  var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
126219
+ var modifiedTime = getCurrentTime(state.host);
126142
126220
  if (existing) {
126143
126221
  existing.buildInfo = buildInfo;
126144
- existing.modifiedTime = getCurrentTime(state.host);
126222
+ existing.modifiedTime = modifiedTime;
126223
+ if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged))
126224
+ existing.latestChangedDtsTime = modifiedTime;
126145
126225
  }
126146
126226
  else {
126147
- state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
126227
+ state.buildInfoCache.set(resolvedConfigPath, {
126228
+ path: toPath(state, buildInfoPath),
126229
+ buildInfo: buildInfo,
126230
+ modifiedTime: modifiedTime,
126231
+ latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime,
126232
+ });
126148
126233
  }
126149
126234
  }
126150
126235
  function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
@@ -126176,7 +126261,7 @@ var ts;
126176
126261
  }
126177
126262
  }
126178
126263
  function getUpToDateStatusWorker(state, project, resolvedPath) {
126179
- var _a, _b, _c;
126264
+ var _a, _b;
126180
126265
  // Container if no files are specified in the project
126181
126266
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
126182
126267
  return {
@@ -126188,8 +126273,8 @@ var ts;
126188
126273
  var force = !!state.options.force;
126189
126274
  if (project.projectReferences) {
126190
126275
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
126191
- for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
126192
- var ref = _d[_i];
126276
+ for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) {
126277
+ var ref = _c[_i];
126193
126278
  var resolvedRef = ts.resolveProjectReferencePath(ref);
126194
126279
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
126195
126280
  var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
@@ -126229,7 +126314,6 @@ var ts;
126229
126314
  var buildInfoTime;
126230
126315
  var buildInfoProgram;
126231
126316
  var buildInfoVersionMap;
126232
- var newestDeclarationFileContentChangedTime;
126233
126317
  if (buildInfoPath) {
126234
126318
  var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
126235
126319
  buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
@@ -126266,8 +126350,6 @@ var ts;
126266
126350
  }
126267
126351
  oldestOutputFileTime = buildInfoTime;
126268
126352
  oldestOutputFileName = buildInfoPath;
126269
- // Get the last dtsChange time from build info
126270
- newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
126271
126353
  }
126272
126354
  // Check input files
126273
126355
  var newestInputFileName = undefined;
@@ -126275,8 +126357,8 @@ var ts;
126275
126357
  /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */
126276
126358
  var pseudoInputUpToDate = false;
126277
126359
  // Get timestamps of input files
126278
- for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
126279
- var inputFile = _f[_e];
126360
+ for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) {
126361
+ var inputFile = _e[_d];
126280
126362
  var inputTime = getModifiedTime(state, inputFile);
126281
126363
  if (inputTime === ts.missingFileModifiedTime) {
126282
126364
  return {
@@ -126317,8 +126399,8 @@ var ts;
126317
126399
  // Collect the expected outputs of this project
126318
126400
  var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
126319
126401
  var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
126320
- for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
126321
- var output = outputs_1[_g];
126402
+ for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) {
126403
+ var output = outputs_1[_f];
126322
126404
  var path = toPath(state, output);
126323
126405
  // Output is missing; can stop checking
126324
126406
  var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
@@ -126356,8 +126438,8 @@ var ts;
126356
126438
  var usesPrepend = false;
126357
126439
  var upstreamChangedProject;
126358
126440
  if (referenceStatuses) {
126359
- for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
126360
- var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
126441
+ for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) {
126442
+ var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath;
126361
126443
  usesPrepend = usesPrepend || !!(ref.prepend);
126362
126444
  // If the upstream project's newest file is older than our oldest output, we
126363
126445
  // can't be out of date because of it
@@ -126374,7 +126456,8 @@ var ts;
126374
126456
  }
126375
126457
  // If the upstream project has only change .d.ts files, and we've built
126376
126458
  // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
126377
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126459
+ var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath);
126460
+ if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126378
126461
  pseudoUpToDate = true;
126379
126462
  upstreamChangedProject = ref.path;
126380
126463
  continue;
@@ -126417,7 +126500,6 @@ var ts;
126417
126500
  pseudoInputUpToDate ?
126418
126501
  ts.UpToDateStatusType.UpToDateWithInputFileText :
126419
126502
  ts.UpToDateStatusType.UpToDate,
126420
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
126421
126503
  newestInputFileTime: newestInputFileTime,
126422
126504
  newestInputFileName: newestInputFileName,
126423
126505
  oldestOutputFileName: oldestOutputFileName
@@ -126501,13 +126583,17 @@ var ts;
126501
126583
  outputTimeStampMap.delete(key);
126502
126584
  });
126503
126585
  }
126504
- function getDtsChangeTime(state, options, resolvedConfigPath) {
126505
- var _a;
126586
+ function getLatestChangedDtsTime(state, options, resolvedConfigPath) {
126506
126587
  if (!options.composite)
126507
126588
  return undefined;
126508
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126509
- var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126510
- return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
126589
+ var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
126590
+ if (entry.latestChangedDtsTime !== undefined)
126591
+ return entry.latestChangedDtsTime || undefined;
126592
+ var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ?
126593
+ state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) :
126594
+ undefined;
126595
+ entry.latestChangedDtsTime = latestChangedDtsTime || false;
126596
+ return latestChangedDtsTime;
126511
126597
  }
126512
126598
  function updateOutputTimestamps(state, proj, resolvedPath) {
126513
126599
  if (state.options.dry) {
@@ -126516,7 +126602,6 @@ var ts;
126516
126602
  updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126517
126603
  state.projectStatus.set(resolvedPath, {
126518
126604
  type: ts.UpToDateStatusType.UpToDate,
126519
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
126520
126605
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
126521
126606
  });
126522
126607
  }