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.
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220628";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220701";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -3124,6 +3124,22 @@ var ts;
3124
3124
  return wrapFunction(deprecation, func);
3125
3125
  }
3126
3126
  Debug.deprecate = deprecate;
3127
+ function formatVariance(varianceFlags) {
3128
+ var variance = varianceFlags & 7 /* VarianceMask */;
3129
+ var result = variance === 0 /* Invariant */ ? "in out" :
3130
+ variance === 3 /* Bivariant */ ? "[bivariant]" :
3131
+ variance === 2 /* Contravariant */ ? "in" :
3132
+ variance === 1 /* Covariant */ ? "out" :
3133
+ variance === 4 /* Independent */ ? "[independent]" : "";
3134
+ if (varianceFlags & 8 /* Unmeasurable */) {
3135
+ result += " (unmeasurable)";
3136
+ }
3137
+ else if (varianceFlags & 16 /* Unreliable */) {
3138
+ result += " (unreliable)";
3139
+ }
3140
+ return result;
3141
+ }
3142
+ Debug.formatVariance = formatVariance;
3127
3143
  })(Debug = ts.Debug || (ts.Debug = {}));
3128
3144
  })(ts || (ts = {}));
3129
3145
  /* @internal */
@@ -3865,9 +3881,9 @@ var ts;
3865
3881
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
3866
3882
  }
3867
3883
  tracingEnabled.push = push;
3868
- function pop() {
3884
+ function pop(results) {
3869
3885
  ts.Debug.assert(eventStack.length > 0);
3870
- writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
3886
+ writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results);
3871
3887
  eventStack.length--;
3872
3888
  }
3873
3889
  tracingEnabled.pop = pop;
@@ -3881,14 +3897,15 @@ var ts;
3881
3897
  tracingEnabled.popAll = popAll;
3882
3898
  // sample every 10ms
3883
3899
  var sampleInterval = 1000 * 10;
3884
- function writeStackEvent(index, endTime) {
3900
+ function writeStackEvent(index, endTime, results) {
3885
3901
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
3886
3902
  if (separateBeginAndEnd) {
3903
+ ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
3887
3904
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
3888
3905
  }
3889
3906
  // test if [time,endTime) straddles a sampling point
3890
3907
  else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
3891
- writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3908
+ writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":" + (endTime - time), time);
3892
3909
  }
3893
3910
  }
3894
3911
  function writeEvent(eventType, phase, name, args, extras, time) {
@@ -5259,9 +5276,10 @@ var ts;
5259
5276
  (function (TypeMapKind) {
5260
5277
  TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple";
5261
5278
  TypeMapKind[TypeMapKind["Array"] = 1] = "Array";
5262
- TypeMapKind[TypeMapKind["Function"] = 2] = "Function";
5263
- TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite";
5264
- TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged";
5279
+ TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred";
5280
+ TypeMapKind[TypeMapKind["Function"] = 3] = "Function";
5281
+ TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite";
5282
+ TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged";
5265
5283
  })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {}));
5266
5284
  var InferencePriority;
5267
5285
  (function (InferencePriority) {
@@ -48664,6 +48682,24 @@ var ts;
48664
48682
  var Symbol = ts.objectAllocator.getSymbolConstructor();
48665
48683
  var Type = ts.objectAllocator.getTypeConstructor();
48666
48684
  var Signature = ts.objectAllocator.getSignatureConstructor();
48685
+ var DebugTypeMapper = /** @class */ (function () {
48686
+ function DebugTypeMapper() {
48687
+ }
48688
+ DebugTypeMapper.prototype.__debugToString = function () {
48689
+ var _a;
48690
+ ts.Debug.type(this);
48691
+ switch (this.kind) {
48692
+ case 3 /* Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)";
48693
+ case 0 /* Simple */: return this.source.__debugTypeToString() + " -> " + this.target.__debugTypeToString();
48694
+ 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(", ");
48695
+ case 2 /* Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return s.__debugTypeToString() + " -> " + t().__debugTypeToString(); }).join(", ");
48696
+ case 5 /* Merged */:
48697
+ case 4 /* Composite */: return "m1: " + this.mapper1.__debugToString().split("\n").join("\n ") + "\nm2: " + this.mapper2.__debugToString().split("\n").join("\n ");
48698
+ default: return ts.Debug.assertNever(this);
48699
+ }
48700
+ };
48701
+ return DebugTypeMapper;
48702
+ }());
48667
48703
  var typeCount = 0;
48668
48704
  var symbolCount = 0;
48669
48705
  var enumCount = 0;
@@ -49124,10 +49160,23 @@ var ts;
49124
49160
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
49125
49161
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
49126
49162
  var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
49127
- var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
49128
- var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
49163
+ var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; });
49164
+ var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; });
49129
49165
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
49130
- var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
49166
+ 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)
49167
+ var outofbandVarianceMarkerHandler;
49168
+ var reportUnreliableMapper = makeFunctionTypeMapper(function (t) {
49169
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49170
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
49171
+ }
49172
+ return t;
49173
+ }, function () { return "(unmeasurable reporter)"; });
49174
+ var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) {
49175
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49176
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
49177
+ }
49178
+ return t;
49179
+ }, function () { return "(unreliable reporter)"; });
49131
49180
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49132
49181
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49133
49182
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -49287,7 +49336,6 @@ var ts;
49287
49336
  var typeofType = createTypeofType();
49288
49337
  var _jsxNamespace;
49289
49338
  var _jsxFactoryEntity;
49290
- var outofbandVarianceMarkerHandler;
49291
49339
  var subtypeRelation = new ts.Map();
49292
49340
  var strictSubtypeRelation = new ts.Map();
49293
49341
  var assignableRelation = new ts.Map();
@@ -53054,7 +53102,7 @@ var ts;
53054
53102
  var name = typeParameterToName(newParam, context);
53055
53103
  var newTypeVariable = ts.factory.createTypeReferenceNode(name);
53056
53104
  context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
53057
- var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
53105
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper);
53058
53106
  var saveInferTypeParameters_1 = context.inferTypeParameters;
53059
53107
  context.inferTypeParameters = type.root.inferTypeParameters;
53060
53108
  var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
@@ -60465,8 +60513,7 @@ var ts;
60465
60513
  var _a;
60466
60514
  var inferences;
60467
60515
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
60468
- for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60469
- var declaration = _b[_i];
60516
+ var _loop_15 = function (declaration) {
60470
60517
  if (declaration.parent.kind === 190 /* InferType */) {
60471
60518
  // When an 'infer T' declaration is immediately contained in a type reference node
60472
60519
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -60474,12 +60521,12 @@ var ts;
60474
60521
  // present, we form an intersection of the inferred constraint types.
60475
60522
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
60476
60523
  if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
60477
- var typeReference = grandParent;
60478
- var typeParameters = getTypeParametersForTypeReference(typeReference);
60479
- if (typeParameters) {
60480
- var index = typeReference.typeArguments.indexOf(childTypeParameter);
60481
- if (index < typeParameters.length) {
60482
- var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
60524
+ var typeReference_1 = grandParent;
60525
+ var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1);
60526
+ if (typeParameters_1) {
60527
+ var index = typeReference_1.typeArguments.indexOf(childTypeParameter);
60528
+ if (index < typeParameters_1.length) {
60529
+ var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]);
60483
60530
  if (declaredConstraint) {
60484
60531
  // Type parameter constraints can reference other type parameters so
60485
60532
  // constraints need to be instantiated. If instantiation produces the
@@ -60487,7 +60534,9 @@ var ts;
60487
60534
  // type Foo<T extends string, U extends T> = [T, U];
60488
60535
  // type Bar<T> = T extends Foo<infer X, infer X> ? Foo<X, X> : T;
60489
60536
  // the instantiated constraint for U is X, so we discard that inference.
60490
- var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
60537
+ var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () {
60538
+ return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index);
60539
+ }; }));
60491
60540
  var constraint = instantiateType(declaredConstraint, mapper);
60492
60541
  if (constraint !== typeParameter) {
60493
60542
  inferences = ts.append(inferences, constraint);
@@ -60525,6 +60574,10 @@ var ts;
60525
60574
  inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType)));
60526
60575
  }
60527
60576
  }
60577
+ };
60578
+ for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60579
+ var declaration = _b[_i];
60580
+ _loop_15(declaration);
60528
60581
  }
60529
60582
  }
60530
60583
  return inferences && getIntersectionType(inferences);
@@ -61413,7 +61466,7 @@ var ts;
61413
61466
  var lastRequiredIndex = -1;
61414
61467
  var firstRestIndex = -1;
61415
61468
  var lastOptionalOrRestIndex = -1;
61416
- var _loop_15 = function (i) {
61469
+ var _loop_16 = function (i) {
61417
61470
  var type = elementTypes[i];
61418
61471
  var flags = target.elementFlags[i];
61419
61472
  if (flags & 8 /* Variadic */) {
@@ -61443,7 +61496,7 @@ var ts;
61443
61496
  }
61444
61497
  };
61445
61498
  for (var i = 0; i < elementTypes.length; i++) {
61446
- var state_4 = _loop_15(i);
61499
+ var state_4 = _loop_16(i);
61447
61500
  if (typeof state_4 === "object")
61448
61501
  return state_4.value;
61449
61502
  }
@@ -61639,7 +61692,7 @@ var ts;
61639
61692
  var templates = ts.filter(types, isPatternLiteralType);
61640
61693
  if (templates.length) {
61641
61694
  var i = types.length;
61642
- var _loop_16 = function () {
61695
+ var _loop_17 = function () {
61643
61696
  i--;
61644
61697
  var t = types[i];
61645
61698
  if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -61647,7 +61700,7 @@ var ts;
61647
61700
  }
61648
61701
  };
61649
61702
  while (i > 0) {
61650
- _loop_16();
61703
+ _loop_17();
61651
61704
  }
61652
61705
  }
61653
61706
  }
@@ -61724,14 +61777,14 @@ var ts;
61724
61777
  var namedUnions = [];
61725
61778
  addNamedUnions(namedUnions, types);
61726
61779
  var reducedTypes = [];
61727
- var _loop_17 = function (t) {
61780
+ var _loop_18 = function (t) {
61728
61781
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
61729
61782
  reducedTypes.push(t);
61730
61783
  }
61731
61784
  };
61732
61785
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
61733
61786
  var t = typeSet_1[_i];
61734
- _loop_17(t);
61787
+ _loop_18(t);
61735
61788
  }
61736
61789
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
61737
61790
  return namedUnions[0];
@@ -62955,7 +63008,7 @@ var ts;
62955
63008
  var result;
62956
63009
  var extraTypes;
62957
63010
  var tailCount = 0;
62958
- var _loop_18 = function () {
63011
+ var _loop_19 = function () {
62959
63012
  if (tailCount === 1000) {
62960
63013
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
62961
63014
  result = errorType;
@@ -63076,7 +63129,7 @@ var ts;
63076
63129
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63077
63130
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63078
63131
  while (true) {
63079
- var state_5 = _loop_18();
63132
+ var state_5 = _loop_19();
63080
63133
  if (typeof state_5 === "object")
63081
63134
  return state_5.value;
63082
63135
  if (state_5 === "break")
@@ -63706,7 +63759,7 @@ var ts;
63706
63759
  switch (mapper.kind) {
63707
63760
  case 0 /* Simple */:
63708
63761
  return type === mapper.source ? mapper.target : type;
63709
- case 1 /* Array */:
63762
+ case 1 /* Array */: {
63710
63763
  var sources = mapper.sources;
63711
63764
  var targets = mapper.targets;
63712
63765
  for (var i = 0; i < sources.length; i++) {
@@ -63715,25 +63768,45 @@ var ts;
63715
63768
  }
63716
63769
  }
63717
63770
  return type;
63718
- case 2 /* Function */:
63771
+ }
63772
+ case 2 /* Deferred */: {
63773
+ var sources = mapper.sources;
63774
+ var targets = mapper.targets;
63775
+ for (var i = 0; i < sources.length; i++) {
63776
+ if (type === sources[i]) {
63777
+ return targets[i]();
63778
+ }
63779
+ }
63780
+ return type;
63781
+ }
63782
+ case 3 /* Function */:
63719
63783
  return mapper.func(type);
63720
- case 3 /* Composite */:
63721
- case 4 /* Merged */:
63784
+ case 4 /* Composite */:
63785
+ case 5 /* Merged */:
63722
63786
  var t1 = getMappedType(type, mapper.mapper1);
63723
- return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63787
+ return t1 !== type && mapper.kind === 4 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63724
63788
  }
63725
63789
  }
63790
+ function attachDebugPrototypeIfDebug(mapper) {
63791
+ if (ts.Debug.isDebugging) {
63792
+ return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype);
63793
+ }
63794
+ return mapper;
63795
+ }
63726
63796
  function makeUnaryTypeMapper(source, target) {
63727
- return { kind: 0 /* Simple */, source: source, target: target };
63797
+ return attachDebugPrototypeIfDebug({ kind: 0 /* Simple */, source: source, target: target });
63728
63798
  }
63729
63799
  function makeArrayTypeMapper(sources, targets) {
63730
- return { kind: 1 /* Array */, sources: sources, targets: targets };
63800
+ return attachDebugPrototypeIfDebug({ kind: 1 /* Array */, sources: sources, targets: targets });
63801
+ }
63802
+ function makeFunctionTypeMapper(func, debugInfo) {
63803
+ return attachDebugPrototypeIfDebug({ kind: 3 /* Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined });
63731
63804
  }
63732
- function makeFunctionTypeMapper(func) {
63733
- return { kind: 2 /* Function */, func: func };
63805
+ function makeDeferredTypeMapper(sources, targets) {
63806
+ return attachDebugPrototypeIfDebug({ kind: 2 /* Deferred */, sources: sources, targets: targets });
63734
63807
  }
63735
63808
  function makeCompositeTypeMapper(kind, mapper1, mapper2) {
63736
- return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
63809
+ return attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 });
63737
63810
  }
63738
63811
  function createTypeEraser(sources) {
63739
63812
  return createTypeMapper(sources, /*targets*/ undefined);
@@ -63743,19 +63816,20 @@ var ts;
63743
63816
  * This is used during inference when instantiating type parameter defaults.
63744
63817
  */
63745
63818
  function createBackreferenceMapper(context, index) {
63746
- return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
63819
+ var forwardInferences = context.inferences.slice(index);
63820
+ return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; }));
63747
63821
  }
63748
63822
  function combineTypeMappers(mapper1, mapper2) {
63749
- return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2;
63823
+ return mapper1 ? makeCompositeTypeMapper(4 /* Composite */, mapper1, mapper2) : mapper2;
63750
63824
  }
63751
63825
  function mergeTypeMappers(mapper1, mapper2) {
63752
- return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2;
63826
+ return mapper1 ? makeCompositeTypeMapper(5 /* Merged */, mapper1, mapper2) : mapper2;
63753
63827
  }
63754
63828
  function prependTypeMapping(source, target, mapper) {
63755
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
63829
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
63756
63830
  }
63757
63831
  function appendTypeMapping(mapper, source, target) {
63758
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
63832
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
63759
63833
  }
63760
63834
  function getRestrictiveTypeParameter(tp) {
63761
63835
  return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
@@ -65651,7 +65725,7 @@ var ts;
65651
65725
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
65652
65726
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
65653
65727
  }
65654
- var _loop_19 = function (prop) {
65728
+ var _loop_20 = function (prop) {
65655
65729
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
65656
65730
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
65657
65731
  if (reportErrors) {
@@ -65714,7 +65788,7 @@ var ts;
65714
65788
  };
65715
65789
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
65716
65790
  var prop = _b[_i];
65717
- var state_6 = _loop_19(prop);
65791
+ var state_6 = _loop_20(prop);
65718
65792
  if (typeof state_6 === "object")
65719
65793
  return state_6.value;
65720
65794
  }
@@ -65946,10 +66020,10 @@ var ts;
65946
66020
  // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component
65947
66021
  var saved = entry & 24 /* ReportsMask */;
65948
66022
  if (saved & 8 /* ReportsUnmeasurable */) {
65949
- instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
66023
+ instantiateType(source, reportUnmeasurableMapper);
65950
66024
  }
65951
66025
  if (saved & 16 /* ReportsUnreliable */) {
65952
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66026
+ instantiateType(source, reportUnreliableMapper);
65953
66027
  }
65954
66028
  }
65955
66029
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
@@ -66375,7 +66449,7 @@ var ts;
66375
66449
  }
66376
66450
  // Report unreliable variance for type variables referenced in template literal type placeholders.
66377
66451
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
66378
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66452
+ instantiateType(source, reportUnreliableMapper);
66379
66453
  }
66380
66454
  if (isTypeMatchedByTemplateLiteralType(source, target)) {
66381
66455
  return -1 /* True */;
@@ -66647,18 +66721,6 @@ var ts;
66647
66721
  }
66648
66722
  }
66649
66723
  }
66650
- function reportUnmeasurableMarkers(p) {
66651
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66652
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
66653
- }
66654
- return p;
66655
- }
66656
- function reportUnreliableMarkers(p) {
66657
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66658
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
66659
- }
66660
- return p;
66661
- }
66662
66724
  // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is
66663
66725
  // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
66664
66726
  // that S and T are contra-variant whereas X and Y are co-variant.
@@ -66668,7 +66730,7 @@ var ts;
66668
66730
  if (modifiersRelated) {
66669
66731
  var result_10;
66670
66732
  var targetConstraint = getConstraintTypeFromMappedType(target);
66671
- var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
66733
+ var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper);
66672
66734
  if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
66673
66735
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
66674
66736
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
@@ -66722,11 +66784,11 @@ var ts;
66722
66784
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
66723
66785
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
66724
66786
  var matchingTypes = [];
66725
- var _loop_20 = function (combination) {
66787
+ var _loop_21 = function (combination) {
66726
66788
  var hasMatch = false;
66727
66789
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
66728
66790
  var type = _d[_c];
66729
- var _loop_21 = function (i) {
66791
+ var _loop_22 = function (i) {
66730
66792
  var sourceProperty = sourcePropertiesFiltered[i];
66731
66793
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
66732
66794
  if (!targetProperty)
@@ -66742,7 +66804,7 @@ var ts;
66742
66804
  }
66743
66805
  };
66744
66806
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
66745
- var state_8 = _loop_21(i);
66807
+ var state_8 = _loop_22(i);
66746
66808
  switch (state_8) {
66747
66809
  case "continue-outer": continue outer;
66748
66810
  }
@@ -66756,7 +66818,7 @@ var ts;
66756
66818
  };
66757
66819
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
66758
66820
  var combination = discriminantCombinations_1[_a];
66759
- var state_7 = _loop_20(combination);
66821
+ var state_7 = _loop_21(combination);
66760
66822
  if (typeof state_7 === "object")
66761
66823
  return state_7.value;
66762
66824
  }
@@ -67204,7 +67266,7 @@ var ts;
67204
67266
  * See signatureAssignableTo, compareSignaturesIdentical
67205
67267
  */
67206
67268
  function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
67207
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
67269
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper);
67208
67270
  }
67209
67271
  function signaturesIdenticalTo(source, target, kind) {
67210
67272
  var sourceSignatures = getSignaturesOfType(source, kind);
@@ -67463,7 +67525,7 @@ var ts;
67463
67525
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
67464
67526
  links.variances = ts.emptyArray;
67465
67527
  var variances = [];
67466
- var _loop_22 = function (tp) {
67528
+ var _loop_23 = function (tp) {
67467
67529
  var modifiers = getVarianceModifiers(tp);
67468
67530
  var variance = modifiers & 65536 /* Out */ ?
67469
67531
  modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ :
@@ -67499,12 +67561,12 @@ var ts;
67499
67561
  }
67500
67562
  variances.push(variance);
67501
67563
  };
67502
- for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
67503
- var tp = typeParameters_1[_i];
67504
- _loop_22(tp);
67564
+ for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
67565
+ var tp = typeParameters_2[_i];
67566
+ _loop_23(tp);
67505
67567
  }
67506
67568
  links.variances = variances;
67507
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
67569
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
67508
67570
  }
67509
67571
  return links.variances;
67510
67572
  }
@@ -68496,27 +68558,29 @@ var ts;
68496
68558
  signature: signature,
68497
68559
  flags: flags,
68498
68560
  compareTypes: compareTypes,
68499
- mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }),
68500
- nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }),
68561
+ mapper: reportUnmeasurableMapper,
68562
+ nonFixingMapper: reportUnmeasurableMapper,
68501
68563
  };
68564
+ context.mapper = makeFixingMapperForContext(context);
68565
+ context.nonFixingMapper = makeNonFixingMapperForContext(context);
68502
68566
  return context;
68503
68567
  }
68504
- function mapToInferredType(context, t, fix) {
68505
- var inferences = context.inferences;
68506
- for (var i = 0; i < inferences.length; i++) {
68507
- var inference = inferences[i];
68508
- if (t === inference.typeParameter) {
68509
- if (fix && !inference.isFixed) {
68510
- // Before we commit to a particular inference (and thus lock out any further inferences),
68511
- // we infer from any intra-expression inference sites we have collected.
68512
- inferFromIntraExpressionSites(context);
68513
- clearCachedInferences(inferences);
68514
- inference.isFixed = true;
68515
- }
68516
- return getInferredType(context, i);
68568
+ function makeFixingMapperForContext(context) {
68569
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () {
68570
+ if (!inference.isFixed) {
68571
+ // Before we commit to a particular inference (and thus lock out any further inferences),
68572
+ // we infer from any intra-expression inference sites we have collected.
68573
+ inferFromIntraExpressionSites(context);
68574
+ clearCachedInferences(context.inferences);
68575
+ inference.isFixed = true;
68517
68576
  }
68518
- }
68519
- return t;
68577
+ return getInferredType(context, i);
68578
+ }; }));
68579
+ }
68580
+ function makeNonFixingMapperForContext(context) {
68581
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () {
68582
+ return getInferredType(context, i);
68583
+ }; }));
68520
68584
  }
68521
68585
  function clearCachedInferences(inferences) {
68522
68586
  for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
@@ -69436,7 +69500,7 @@ var ts;
69436
69500
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
69437
69501
  // succeed. That would be a pointless and confusing outcome.
69438
69502
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69439
- var _loop_23 = function (i) {
69503
+ var _loop_24 = function (i) {
69440
69504
  var source_1 = matches ? matches[i] : neverType;
69441
69505
  var target_3 = types[i];
69442
69506
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -69486,7 +69550,7 @@ var ts;
69486
69550
  inferFromTypes(source_1, target_3);
69487
69551
  };
69488
69552
  for (var i = 0; i < types.length; i++) {
69489
- _loop_23(i);
69553
+ _loop_24(i);
69490
69554
  }
69491
69555
  }
69492
69556
  }
@@ -70004,7 +70068,7 @@ var ts;
70004
70068
  function mapTypesByKeyProperty(types, name) {
70005
70069
  var map = new ts.Map();
70006
70070
  var count = 0;
70007
- var _loop_24 = function (type) {
70071
+ var _loop_25 = function (type) {
70008
70072
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
70009
70073
  var discriminant = getTypeOfPropertyOfType(type, name);
70010
70074
  if (discriminant) {
@@ -70030,7 +70094,7 @@ var ts;
70030
70094
  };
70031
70095
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70032
70096
  var type = types_15[_i];
70033
- var state_9 = _loop_24(type);
70097
+ var state_9 = _loop_25(type);
70034
70098
  if (typeof state_9 === "object")
70035
70099
  return state_9.value;
70036
70100
  }
@@ -73377,8 +73441,8 @@ var ts;
73377
73441
  var conditional = node.parent;
73378
73442
  return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
73379
73443
  }
73380
- function getContextualTypeForChildJsxExpression(node, child) {
73381
- var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
73444
+ function getContextualTypeForChildJsxExpression(node, child, contextFlags) {
73445
+ var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags);
73382
73446
  // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty)
73383
73447
  var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
73384
73448
  if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
@@ -73396,27 +73460,27 @@ var ts;
73396
73460
  }
73397
73461
  }, /*noReductions*/ true));
73398
73462
  }
73399
- function getContextualTypeForJsxExpression(node) {
73463
+ function getContextualTypeForJsxExpression(node, contextFlags) {
73400
73464
  var exprParent = node.parent;
73401
73465
  return ts.isJsxAttributeLike(exprParent)
73402
- ? getContextualType(node)
73466
+ ? getContextualType(node, contextFlags)
73403
73467
  : ts.isJsxElement(exprParent)
73404
- ? getContextualTypeForChildJsxExpression(exprParent, node)
73468
+ ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags)
73405
73469
  : undefined;
73406
73470
  }
73407
- function getContextualTypeForJsxAttribute(attribute) {
73471
+ function getContextualTypeForJsxAttribute(attribute, contextFlags) {
73408
73472
  // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
73409
73473
  // which is a type of the parameter of the signature we are trying out.
73410
73474
  // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
73411
73475
  if (ts.isJsxAttribute(attribute)) {
73412
- var attributesType = getApparentTypeOfContextualType(attribute.parent);
73476
+ var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags);
73413
73477
  if (!attributesType || isTypeAny(attributesType)) {
73414
73478
  return undefined;
73415
73479
  }
73416
73480
  return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
73417
73481
  }
73418
73482
  else {
73419
- return getContextualType(attribute.parent);
73483
+ return getContextualType(attribute.parent, contextFlags);
73420
73484
  }
73421
73485
  }
73422
73486
  // Return true if the given expression is possibly a discriminant value. We limit the kinds of
@@ -73577,10 +73641,10 @@ var ts;
73577
73641
  case 271 /* ExportAssignment */:
73578
73642
  return tryGetTypeFromEffectiveTypeNode(parent);
73579
73643
  case 288 /* JsxExpression */:
73580
- return getContextualTypeForJsxExpression(parent);
73644
+ return getContextualTypeForJsxExpression(parent, contextFlags);
73581
73645
  case 285 /* JsxAttribute */:
73582
73646
  case 287 /* JsxSpreadAttribute */:
73583
- return getContextualTypeForJsxAttribute(parent);
73647
+ return getContextualTypeForJsxAttribute(parent, contextFlags);
73584
73648
  case 280 /* JsxOpeningElement */:
73585
73649
  case 279 /* JsxSelfClosingElement */:
73586
73650
  return getContextualJsxElementAttributesType(parent, contextFlags);
@@ -76379,7 +76443,7 @@ var ts;
76379
76443
  if (spreadIndex >= 0) {
76380
76444
  // Create synthetic arguments from spreads of tuple types.
76381
76445
  var effectiveArgs_1 = args.slice(0, spreadIndex);
76382
- var _loop_25 = function (i) {
76446
+ var _loop_26 = function (i) {
76383
76447
  var arg = args[i];
76384
76448
  // We can call checkExpressionCached because spread expressions never have a contextual type.
76385
76449
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -76396,7 +76460,7 @@ var ts;
76396
76460
  }
76397
76461
  };
76398
76462
  for (var i = spreadIndex; i < args.length; i++) {
76399
- _loop_25(i);
76463
+ _loop_26(i);
76400
76464
  }
76401
76465
  return effectiveArgs_1;
76402
76466
  }
@@ -76725,7 +76789,7 @@ var ts;
76725
76789
  var min_3 = Number.MAX_VALUE;
76726
76790
  var minIndex = 0;
76727
76791
  var i_1 = 0;
76728
- var _loop_26 = function (c) {
76792
+ var _loop_27 = function (c) {
76729
76793
  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)); };
76730
76794
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76731
76795
  if (diags_2) {
@@ -76743,7 +76807,7 @@ var ts;
76743
76807
  };
76744
76808
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76745
76809
  var c = candidatesForArgumentError_1[_a];
76746
- _loop_26(c);
76810
+ _loop_27(c);
76747
76811
  }
76748
76812
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76749
76813
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76901,7 +76965,7 @@ var ts;
76901
76965
  }
76902
76966
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76903
76967
  var parameters = [];
76904
- var _loop_27 = function (i) {
76968
+ var _loop_28 = function (i) {
76905
76969
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76906
76970
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76907
76971
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76909,7 +76973,7 @@ var ts;
76909
76973
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76910
76974
  };
76911
76975
  for (var i = 0; i < maxNonRestParam; i++) {
76912
- _loop_27(i);
76976
+ _loop_28(i);
76913
76977
  }
76914
76978
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76915
76979
  var flags = 0 /* None */;
@@ -80262,8 +80326,8 @@ var ts;
80262
80326
  var result = [];
80263
80327
  var oldTypeParameters;
80264
80328
  var newTypeParameters;
80265
- for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
80266
- var tp = typeParameters_2[_i];
80329
+ for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
80330
+ var tp = typeParameters_3[_i];
80267
80331
  var name = tp.symbol.escapedName;
80268
80332
  if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
80269
80333
  var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
@@ -80585,12 +80649,14 @@ var ts;
80585
80649
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80586
80650
  }
80587
80651
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80652
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
80588
80653
  var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80589
80654
  var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80590
80655
  var saveVarianceTypeParameter = typeParameter;
80591
80656
  varianceTypeParameter = typeParameter;
80592
80657
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
80593
80658
  varianceTypeParameter = saveVarianceTypeParameter;
80659
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
80594
80660
  }
80595
80661
  }
80596
80662
  }
@@ -80940,7 +81006,7 @@ var ts;
80940
81006
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80941
81007
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80942
81008
  var indexSignatureMap_1 = new ts.Map();
80943
- var _loop_28 = function (declaration) {
81009
+ var _loop_29 = function (declaration) {
80944
81010
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80945
81011
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80946
81012
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80955,7 +81021,7 @@ var ts;
80955
81021
  };
80956
81022
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80957
81023
  var declaration = _a[_i];
80958
- _loop_28(declaration);
81024
+ _loop_29(declaration);
80959
81025
  }
80960
81026
  indexSignatureMap_1.forEach(function (entry) {
80961
81027
  if (entry.declarations.length > 1) {
@@ -81178,6 +81244,12 @@ var ts;
81178
81244
  function checkMissingDeclaration(node) {
81179
81245
  checkDecorators(node);
81180
81246
  }
81247
+ function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) {
81248
+ if (index < typeParameters.length) {
81249
+ return getTypeFromTypeNode(node.typeArguments[index]);
81250
+ }
81251
+ return getEffectiveTypeArguments(node, typeParameters)[index];
81252
+ }
81181
81253
  function getEffectiveTypeArguments(node, typeParameters) {
81182
81254
  return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
81183
81255
  }
@@ -81986,8 +82058,17 @@ var ts;
81986
82058
  }
81987
82059
  // For a union, get a union of the awaited types of each constituent.
81988
82060
  if (type.flags & 1048576 /* Union */) {
82061
+ if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
82062
+ if (errorNode) {
82063
+ error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
82064
+ }
82065
+ return undefined;
82066
+ }
81989
82067
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
81990
- return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
82068
+ awaitedTypeStack.push(type.id);
82069
+ var mapped = mapType(type, mapper);
82070
+ awaitedTypeStack.pop();
82071
+ return typeAsAwaitable.awaitedTypeOfType = mapped;
81991
82072
  }
81992
82073
  var thisTypeForErrorOut = { value: undefined };
81993
82074
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
@@ -82636,8 +82717,8 @@ var ts;
82636
82717
  return;
82637
82718
  var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
82638
82719
  var seenParentsWithEveryUnused = new ts.Set();
82639
- for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
82640
- var typeParameter = typeParameters_3[_i];
82720
+ for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) {
82721
+ var typeParameter = typeParameters_4[_i];
82641
82722
  if (!isTypeParameterUnused(typeParameter))
82642
82723
  continue;
82643
82724
  var name = ts.idText(typeParameter.name);
@@ -84456,7 +84537,7 @@ var ts;
84456
84537
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84457
84538
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
84458
84539
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
84459
- var _loop_29 = function (info) {
84540
+ var _loop_30 = function (info) {
84460
84541
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
84461
84542
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
84462
84543
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -84469,7 +84550,7 @@ var ts;
84469
84550
  };
84470
84551
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
84471
84552
  var info = indexInfos_9[_i];
84472
- _loop_29(info);
84553
+ _loop_30(info);
84473
84554
  }
84474
84555
  }
84475
84556
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -84477,7 +84558,7 @@ var ts;
84477
84558
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
84478
84559
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84479
84560
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
84480
- var _loop_30 = function (info) {
84561
+ var _loop_31 = function (info) {
84481
84562
  if (info === checkInfo)
84482
84563
  return "continue";
84483
84564
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -84492,7 +84573,7 @@ var ts;
84492
84573
  };
84493
84574
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
84494
84575
  var info = indexInfos_10[_i];
84495
- _loop_30(info);
84576
+ _loop_31(info);
84496
84577
  }
84497
84578
  }
84498
84579
  function checkTypeNameIsReserved(name, message) {
@@ -84812,7 +84893,7 @@ var ts;
84812
84893
  var baseTypes = baseTypeNode && getBaseTypes(type);
84813
84894
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84814
84895
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84815
- var _loop_31 = function (member) {
84896
+ var _loop_32 = function (member) {
84816
84897
  if (ts.hasAmbientModifier(member)) {
84817
84898
  return "continue";
84818
84899
  }
@@ -84829,7 +84910,7 @@ var ts;
84829
84910
  };
84830
84911
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84831
84912
  var member = _a[_i];
84832
- _loop_31(member);
84913
+ _loop_32(member);
84833
84914
  }
84834
84915
  }
84835
84916
  /**
@@ -84917,7 +84998,7 @@ var ts;
84917
84998
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84918
84999
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84919
85000
  var issuedMemberError = false;
84920
- var _loop_32 = function (member) {
85001
+ var _loop_33 = function (member) {
84921
85002
  if (ts.isStatic(member)) {
84922
85003
  return "continue";
84923
85004
  }
@@ -84936,7 +85017,7 @@ var ts;
84936
85017
  };
84937
85018
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84938
85019
  var member = _a[_i];
84939
- _loop_32(member);
85020
+ _loop_33(member);
84940
85021
  }
84941
85022
  if (!issuedMemberError) {
84942
85023
  // check again with diagnostics to generate a less-specific error
@@ -85007,7 +85088,7 @@ var ts;
85007
85088
  var _a, _b, _c, _d;
85008
85089
  // NOTE: assignability is checked in checkClassDeclaration
85009
85090
  var baseProperties = getPropertiesOfType(baseType);
85010
- var _loop_33 = function (baseProperty) {
85091
+ var _loop_34 = function (baseProperty) {
85011
85092
  var base = getTargetSymbol(baseProperty);
85012
85093
  if (base.flags & 4194304 /* Prototype */) {
85013
85094
  return "continue";
@@ -85117,7 +85198,7 @@ var ts;
85117
85198
  };
85118
85199
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
85119
85200
  var baseProperty = baseProperties_1[_i];
85120
- var state_10 = _loop_33(baseProperty);
85201
+ var state_10 = _loop_34(baseProperty);
85121
85202
  switch (state_10) {
85122
85203
  case "continue-basePropertyCheck": continue basePropertyCheck;
85123
85204
  }
@@ -111632,7 +111713,6 @@ var ts;
111632
111713
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111633
111714
  // Update the output signature
111634
111715
  newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111635
- newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111636
111716
  }
111637
111717
  // Update sourceFileInfo
111638
111718
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
@@ -119437,7 +119517,7 @@ var ts;
119437
119517
  }
119438
119518
  }
119439
119519
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119440
- 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 });
119520
+ 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 });
119441
119521
  processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
119442
119522
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119443
119523
  }
@@ -121019,7 +121099,7 @@ var ts;
121019
121099
  state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
121020
121100
  }
121021
121101
  state.changedFilesSet = new ts.Set();
121022
- state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
121102
+ state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined;
121023
121103
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
121024
121104
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
121025
121105
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
@@ -121143,7 +121223,7 @@ var ts;
121143
121223
  programEmitComplete: state.programEmitComplete,
121144
121224
  emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
121145
121225
  outSignature: state.outSignature,
121146
- dtsChangeTime: state.dtsChangeTime,
121226
+ latestChangedDtsFile: state.latestChangedDtsFile,
121147
121227
  hasChangedEmitSignature: state.hasChangedEmitSignature,
121148
121228
  changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
121149
121229
  };
@@ -121156,7 +121236,7 @@ var ts;
121156
121236
  state.programEmitComplete = savedEmitState.programEmitComplete;
121157
121237
  state.emitSignatures = savedEmitState.emitSignatures;
121158
121238
  state.outSignature = savedEmitState.outSignature;
121159
- state.dtsChangeTime = savedEmitState.dtsChangeTime;
121239
+ state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile;
121160
121240
  state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
121161
121241
  if (savedEmitState.changedFilesSet)
121162
121242
  state.changedFilesSet = savedEmitState.changedFilesSet;
@@ -121470,14 +121550,14 @@ var ts;
121470
121550
  /**
121471
121551
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121472
121552
  */
121473
- function getProgramBuildInfo(state, getCanonicalFileName, host) {
121553
+ function getProgramBuildInfo(state, getCanonicalFileName) {
121474
121554
  var outFilePath = ts.outFile(state.compilerOptions);
121475
121555
  if (outFilePath && !state.compilerOptions.composite)
121476
121556
  return;
121477
121557
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121478
121558
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121479
- // Update the dtsChange time in buildInfo
121480
- state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121559
+ // 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
121560
+ var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
121481
121561
  if (outFilePath) {
121482
121562
  var fileNames_1 = [];
121483
121563
  var fileInfos_1 = [];
@@ -121493,7 +121573,7 @@ var ts;
121493
121573
  fileInfos: fileInfos_1,
121494
121574
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121495
121575
  outSignature: state.outSignature,
121496
- dtsChangeTime: state.dtsChangeTime,
121576
+ latestChangedDtsFile: latestChangedDtsFile,
121497
121577
  };
121498
121578
  return result_15;
121499
121579
  }
@@ -121595,7 +121675,7 @@ var ts;
121595
121675
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121596
121676
  changeFileSet: changeFileSet,
121597
121677
  emitSignatures: emitSignatures,
121598
- dtsChangeTime: state.dtsChangeTime,
121678
+ latestChangedDtsFile: latestChangedDtsFile,
121599
121679
  };
121600
121680
  return result;
121601
121681
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -121763,7 +121843,7 @@ var ts;
121763
121843
  */
121764
121844
  var computeHash = ts.maybeBind(host, host.createHash);
121765
121845
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121766
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121846
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121767
121847
  // To ensure that we arent storing any references to old program or new program without state
121768
121848
  newProgram = undefined; // TODO: GH#18217
121769
121849
  oldProgram = undefined;
@@ -121773,6 +121853,7 @@ var ts;
121773
121853
  builderProgram.getState = getState;
121774
121854
  builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121775
121855
  builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121856
+ builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; };
121776
121857
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121777
121858
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121778
121859
  builderProgram.emit = emit;
@@ -121880,18 +121961,22 @@ var ts;
121880
121961
  var filePath = sourceFiles[0].resolvedPath;
121881
121962
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
121882
121963
  emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
121883
- if (emitSignature !== oldSignature) {
121884
- ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121885
- state.hasChangedEmitSignature = true;
121886
- }
121964
+ // Dont write dts files if they didn't change
121965
+ if (emitSignature === oldSignature)
121966
+ return;
121967
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121968
+ state.hasChangedEmitSignature = true;
121969
+ state.latestChangedDtsFile = fileName;
121887
121970
  }
121888
121971
  }
121889
121972
  else if (state.compilerOptions.composite) {
121890
121973
  var newSignature = computeSignature(text, computeHash, data);
121891
- if (newSignature !== state.outSignature) {
121892
- state.outSignature = newSignature;
121893
- state.hasChangedEmitSignature = true;
121894
- }
121974
+ // Dont write dts files if they didn't change
121975
+ if (newSignature === state.outSignature)
121976
+ return;
121977
+ state.outSignature = newSignature;
121978
+ state.hasChangedEmitSignature = true;
121979
+ state.latestChangedDtsFile = fileName;
121895
121980
  }
121896
121981
  }
121897
121982
  if (writeFile)
@@ -122054,11 +122139,12 @@ var ts;
122054
122139
  var state;
122055
122140
  var filePaths;
122056
122141
  var filePathsSetList;
122142
+ var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
122057
122143
  if (isProgramBundleEmitBuildInfo(program)) {
122058
122144
  state = {
122059
122145
  fileInfos: new ts.Map(),
122060
122146
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
122061
- dtsChangeTime: program.dtsChangeTime,
122147
+ latestChangedDtsFile: latestChangedDtsFile,
122062
122148
  outSignature: program.outSignature,
122063
122149
  };
122064
122150
  }
@@ -122091,7 +122177,7 @@ var ts;
122091
122177
  affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
122092
122178
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
122093
122179
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
122094
- dtsChangeTime: program.dtsChangeTime,
122180
+ latestChangedDtsFile: latestChangedDtsFile,
122095
122181
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
122096
122182
  };
122097
122183
  }
@@ -122118,6 +122204,7 @@ var ts;
122118
122204
  getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
122119
122205
  emitBuildInfo: ts.notImplemented,
122120
122206
  close: ts.noop,
122207
+ hasChangedEmitSignature: ts.returnFalse,
122121
122208
  };
122122
122209
  function toPath(path) {
122123
122210
  return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
@@ -123432,7 +123519,7 @@ var ts;
123432
123519
  });
123433
123520
  // Sort by paths closest to importing file Name directory
123434
123521
  var sortedPaths = [];
123435
- var _loop_34 = function (directory) {
123522
+ var _loop_35 = function (directory) {
123436
123523
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
123437
123524
  var pathsInDirectory;
123438
123525
  allFileNames.forEach(function (_a, fileName) {
@@ -123456,7 +123543,7 @@ var ts;
123456
123543
  };
123457
123544
  var out_directory_1;
123458
123545
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
123459
- var state_11 = _loop_34(directory);
123546
+ var state_11 = _loop_35(directory);
123460
123547
  directory = out_directory_1;
123461
123548
  if (state_11 === "break")
123462
123549
  break;
@@ -124300,7 +124387,6 @@ var ts;
124300
124387
  readDirectory: ts.maybeBind(host, host.readDirectory),
124301
124388
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
124302
124389
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
124303
- now: ts.maybeBind(host, host.now),
124304
124390
  };
124305
124391
  function writeFile(fileName, text, writeByteOrderMark, onError) {
124306
124392
  try {
@@ -124458,7 +124544,6 @@ var ts;
124458
124544
  host.createHash = ts.maybeBind(system, system.createHash);
124459
124545
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
124460
124546
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124461
- host.now = ts.maybeBind(system, system.now);
124462
124547
  ts.setGetSourceFileAsHashVersioned(host, system);
124463
124548
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
124464
124549
  return host;
@@ -125786,8 +125871,7 @@ var ts;
125786
125871
  }
125787
125872
  // Actual Emit
125788
125873
  var host = state.host, compilerHost = state.compilerHost;
125789
- var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125790
- var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125874
+ var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
125791
125875
  var emitterDiagnostics = ts.createDiagnosticCollection();
125792
125876
  var emittedOutputs = new ts.Map();
125793
125877
  var options = program.getCompilerOptions();
@@ -125795,17 +125879,11 @@ var ts;
125795
125879
  var outputTimeStampMap;
125796
125880
  var now;
125797
125881
  outputFiles.forEach(function (_a) {
125798
- var _b, _c;
125799
125882
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125800
125883
  var path = toPath(state, name);
125801
125884
  emittedOutputs.set(toPath(state, name), name);
125802
- if (buildInfo) {
125803
- setBuildInfo(state, buildInfo, projectPath, options);
125804
- // Buildinfo has information on when last dts change time
125805
- 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)) {
125806
- resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125807
- }
125808
- }
125885
+ if (buildInfo)
125886
+ setBuildInfo(state, buildInfo, projectPath, options, resultFlags);
125809
125887
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125810
125888
  if (!isIncremental && state.watch) {
125811
125889
  (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
@@ -125819,7 +125897,7 @@ var ts;
125819
125897
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125820
125898
  var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125821
125899
  if (data === null || data === void 0 ? void 0 : data.buildInfo)
125822
- setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125900
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged);
125823
125901
  if (writeFileCallback)
125824
125902
  writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125825
125903
  else
@@ -125852,7 +125930,6 @@ var ts;
125852
125930
  state.diagnostics.delete(projectPath);
125853
125931
  state.projectStatus.set(projectPath, {
125854
125932
  type: ts.UpToDateStatusType.UpToDate,
125855
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125856
125933
  oldestOutputFileName: oldestOutputFileName
125857
125934
  });
125858
125935
  afterProgramDone(state, program, config);
@@ -125894,10 +125971,10 @@ var ts;
125894
125971
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125895
125972
  emittedOutputs.set(toPath(state, name), name);
125896
125973
  if (buildInfo) {
125897
- setBuildInfo(state, buildInfo, projectPath, config.options);
125898
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125974
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
125899
125975
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125900
125976
  }
125977
+ setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
125901
125978
  }
125902
125979
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125903
125980
  });
@@ -126156,15 +126233,23 @@ var ts;
126156
126233
  state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
126157
126234
  return result;
126158
126235
  }
126159
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
126236
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) {
126160
126237
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126161
126238
  var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
126239
+ var modifiedTime = getCurrentTime(state.host);
126162
126240
  if (existing) {
126163
126241
  existing.buildInfo = buildInfo;
126164
- existing.modifiedTime = getCurrentTime(state.host);
126242
+ existing.modifiedTime = modifiedTime;
126243
+ if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged))
126244
+ existing.latestChangedDtsTime = modifiedTime;
126165
126245
  }
126166
126246
  else {
126167
- state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
126247
+ state.buildInfoCache.set(resolvedConfigPath, {
126248
+ path: toPath(state, buildInfoPath),
126249
+ buildInfo: buildInfo,
126250
+ modifiedTime: modifiedTime,
126251
+ latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime,
126252
+ });
126168
126253
  }
126169
126254
  }
126170
126255
  function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
@@ -126196,7 +126281,7 @@ var ts;
126196
126281
  }
126197
126282
  }
126198
126283
  function getUpToDateStatusWorker(state, project, resolvedPath) {
126199
- var _a, _b, _c;
126284
+ var _a, _b;
126200
126285
  // Container if no files are specified in the project
126201
126286
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
126202
126287
  return {
@@ -126208,8 +126293,8 @@ var ts;
126208
126293
  var force = !!state.options.force;
126209
126294
  if (project.projectReferences) {
126210
126295
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
126211
- for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
126212
- var ref = _d[_i];
126296
+ for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) {
126297
+ var ref = _c[_i];
126213
126298
  var resolvedRef = ts.resolveProjectReferencePath(ref);
126214
126299
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
126215
126300
  var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
@@ -126249,7 +126334,6 @@ var ts;
126249
126334
  var buildInfoTime;
126250
126335
  var buildInfoProgram;
126251
126336
  var buildInfoVersionMap;
126252
- var newestDeclarationFileContentChangedTime;
126253
126337
  if (buildInfoPath) {
126254
126338
  var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
126255
126339
  buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
@@ -126286,8 +126370,6 @@ var ts;
126286
126370
  }
126287
126371
  oldestOutputFileTime = buildInfoTime;
126288
126372
  oldestOutputFileName = buildInfoPath;
126289
- // Get the last dtsChange time from build info
126290
- newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
126291
126373
  }
126292
126374
  // Check input files
126293
126375
  var newestInputFileName = undefined;
@@ -126295,8 +126377,8 @@ var ts;
126295
126377
  /** 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 */
126296
126378
  var pseudoInputUpToDate = false;
126297
126379
  // Get timestamps of input files
126298
- for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
126299
- var inputFile = _f[_e];
126380
+ for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) {
126381
+ var inputFile = _e[_d];
126300
126382
  var inputTime = getModifiedTime(state, inputFile);
126301
126383
  if (inputTime === ts.missingFileModifiedTime) {
126302
126384
  return {
@@ -126337,8 +126419,8 @@ var ts;
126337
126419
  // Collect the expected outputs of this project
126338
126420
  var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
126339
126421
  var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
126340
- for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
126341
- var output = outputs_1[_g];
126422
+ for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) {
126423
+ var output = outputs_1[_f];
126342
126424
  var path = toPath(state, output);
126343
126425
  // Output is missing; can stop checking
126344
126426
  var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
@@ -126376,8 +126458,8 @@ var ts;
126376
126458
  var usesPrepend = false;
126377
126459
  var upstreamChangedProject;
126378
126460
  if (referenceStatuses) {
126379
- for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
126380
- var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
126461
+ for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) {
126462
+ var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath;
126381
126463
  usesPrepend = usesPrepend || !!(ref.prepend);
126382
126464
  // If the upstream project's newest file is older than our oldest output, we
126383
126465
  // can't be out of date because of it
@@ -126394,7 +126476,8 @@ var ts;
126394
126476
  }
126395
126477
  // If the upstream project has only change .d.ts files, and we've built
126396
126478
  // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
126397
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126479
+ var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath);
126480
+ if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126398
126481
  pseudoUpToDate = true;
126399
126482
  upstreamChangedProject = ref.path;
126400
126483
  continue;
@@ -126437,7 +126520,6 @@ var ts;
126437
126520
  pseudoInputUpToDate ?
126438
126521
  ts.UpToDateStatusType.UpToDateWithInputFileText :
126439
126522
  ts.UpToDateStatusType.UpToDate,
126440
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
126441
126523
  newestInputFileTime: newestInputFileTime,
126442
126524
  newestInputFileName: newestInputFileName,
126443
126525
  oldestOutputFileName: oldestOutputFileName
@@ -126521,13 +126603,17 @@ var ts;
126521
126603
  outputTimeStampMap.delete(key);
126522
126604
  });
126523
126605
  }
126524
- function getDtsChangeTime(state, options, resolvedConfigPath) {
126525
- var _a;
126606
+ function getLatestChangedDtsTime(state, options, resolvedConfigPath) {
126526
126607
  if (!options.composite)
126527
126608
  return undefined;
126528
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126529
- var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126530
- 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;
126609
+ var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
126610
+ if (entry.latestChangedDtsTime !== undefined)
126611
+ return entry.latestChangedDtsTime || undefined;
126612
+ var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ?
126613
+ state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) :
126614
+ undefined;
126615
+ entry.latestChangedDtsTime = latestChangedDtsTime || false;
126616
+ return latestChangedDtsTime;
126531
126617
  }
126532
126618
  function updateOutputTimestamps(state, proj, resolvedPath) {
126533
126619
  if (state.options.dry) {
@@ -126536,7 +126622,6 @@ var ts;
126536
126622
  updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126537
126623
  state.projectStatus.set(resolvedPath, {
126538
126624
  type: ts.UpToDateStatusType.UpToDate,
126539
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
126540
126625
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
126541
126626
  });
126542
126627
  }
@@ -133362,37 +133447,36 @@ var ts;
133362
133447
  }
133363
133448
  }
133364
133449
  var entries = ts.createSortedArray();
133365
- if (isUncheckedFile(sourceFile, compilerOptions)) {
133366
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133367
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
133368
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133369
- }
133370
- else {
133371
- if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133372
- return undefined;
133373
- }
133374
- getCompletionEntriesFromSymbols(symbols, entries,
133375
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
133450
+ var isChecked = isCheckedFile(sourceFile, compilerOptions);
133451
+ if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133452
+ return undefined;
133376
133453
  }
133454
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133455
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
133377
133456
  if (keywordFilters !== 0 /* None */) {
133378
- var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
133379
133457
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
133380
133458
  var keywordEntry = _a[_i];
133381
- if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) {
133459
+ if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
133460
+ uniqueNames.add(keywordEntry.name);
133382
133461
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133383
133462
  }
133384
133463
  }
133385
133464
  }
133386
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
133387
133465
  for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
133388
133466
  var keywordEntry = _c[_b];
133389
- if (!entryNames.has(keywordEntry.name)) {
133467
+ if (!uniqueNames.has(keywordEntry.name)) {
133468
+ uniqueNames.add(keywordEntry.name);
133390
133469
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133391
133470
  }
133392
133471
  }
133393
133472
  for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
133394
133473
  var literal = literals_1[_d];
133395
- ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
133474
+ var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal);
133475
+ uniqueNames.add(literalEntry.name);
133476
+ ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133477
+ }
133478
+ if (!isChecked) {
133479
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133396
133480
  }
133397
133481
  return {
133398
133482
  flags: completionData.flags,
@@ -133404,8 +133488,8 @@ var ts;
133404
133488
  entries: entries,
133405
133489
  };
133406
133490
  }
133407
- function isUncheckedFile(sourceFile, compilerOptions) {
133408
- return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
133491
+ function isCheckedFile(sourceFile, compilerOptions) {
133492
+ return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
133409
133493
  }
133410
133494
  function isMemberCompletionKind(kind) {
133411
133495
  switch (kind) {
@@ -134363,7 +134447,7 @@ var ts;
134363
134447
  }
134364
134448
  function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
134365
134449
  var typeChecker = program.getTypeChecker();
134366
- var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
134450
+ var inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
134367
134451
  var start = ts.timestamp();
134368
134452
  var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
134369
134453
  // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
@@ -134779,15 +134863,7 @@ var ts;
134779
134863
  isNewIdentifierLocation = true;
134780
134864
  }
134781
134865
  var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
134782
- if (inUncheckedFile) {
134783
- // In javascript files, for union types, we don't just get the members that
134784
- // the individual types have in common, we also include all the members that
134785
- // each individual type has. This is because we're going to add all identifiers
134786
- // anyways. So we might as well elevate the members that were at least part
134787
- // of the individual types to a higher status since we know what they are.
134788
- symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
134789
- }
134790
- else {
134866
+ if (inCheckedFile) {
134791
134867
  for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) {
134792
134868
  var symbol = _a[_i];
134793
134869
  if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
@@ -134795,6 +134871,14 @@ var ts;
134795
134871
  }
134796
134872
  }
134797
134873
  }
134874
+ else {
134875
+ // In javascript files, for union types, we don't just get the members that
134876
+ // the individual types have in common, we also include all the members that
134877
+ // each individual type has. This is because we're going to add all identifiers
134878
+ // anyways. So we might as well elevate the members that were at least part
134879
+ // of the individual types to a higher status since we know what they are.
134880
+ symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
134881
+ }
134798
134882
  if (insertAwait && preferences.includeCompletionsWithInsertText) {
134799
134883
  var promiseType = typeChecker.getPromisedTypeOfPromise(type);
134800
134884
  if (promiseType) {
@@ -155157,7 +155241,7 @@ var ts;
155157
155241
  if (!newConstraint)
155158
155242
  return;
155159
155243
  var newConstraintText = newConstraint[1];
155160
- changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155244
+ changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
155161
155245
  }
155162
155246
  function findAncestorMatchingSpan(sourceFile, span) {
155163
155247
  var token = ts.getTokenAtPosition(sourceFile, span.start);