typescript 4.8.0-dev.20220629 → 4.8.0-dev.20220703

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220629";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220703";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -3309,6 +3309,22 @@ var ts;
3309
3309
  return wrapFunction(deprecation, func);
3310
3310
  }
3311
3311
  Debug.deprecate = deprecate;
3312
+ function formatVariance(varianceFlags) {
3313
+ var variance = varianceFlags & 7 /* VarianceMask */;
3314
+ var result = variance === 0 /* Invariant */ ? "in out" :
3315
+ variance === 3 /* Bivariant */ ? "[bivariant]" :
3316
+ variance === 2 /* Contravariant */ ? "in" :
3317
+ variance === 1 /* Covariant */ ? "out" :
3318
+ variance === 4 /* Independent */ ? "[independent]" : "";
3319
+ if (varianceFlags & 8 /* Unmeasurable */) {
3320
+ result += " (unmeasurable)";
3321
+ }
3322
+ else if (varianceFlags & 16 /* Unreliable */) {
3323
+ result += " (unreliable)";
3324
+ }
3325
+ return result;
3326
+ }
3327
+ Debug.formatVariance = formatVariance;
3312
3328
  })(Debug = ts.Debug || (ts.Debug = {}));
3313
3329
  })(ts || (ts = {}));
3314
3330
  /* @internal */
@@ -4050,9 +4066,9 @@ var ts;
4050
4066
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
4051
4067
  }
4052
4068
  tracingEnabled.push = push;
4053
- function pop() {
4069
+ function pop(results) {
4054
4070
  ts.Debug.assert(eventStack.length > 0);
4055
- writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
4071
+ writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results);
4056
4072
  eventStack.length--;
4057
4073
  }
4058
4074
  tracingEnabled.pop = pop;
@@ -4066,14 +4082,15 @@ var ts;
4066
4082
  tracingEnabled.popAll = popAll;
4067
4083
  // sample every 10ms
4068
4084
  var sampleInterval = 1000 * 10;
4069
- function writeStackEvent(index, endTime) {
4085
+ function writeStackEvent(index, endTime, results) {
4070
4086
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
4071
4087
  if (separateBeginAndEnd) {
4088
+ ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
4072
4089
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
4073
4090
  }
4074
4091
  // test if [time,endTime) straddles a sampling point
4075
4092
  else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
4076
- writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
4093
+ writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":" + (endTime - time), time);
4077
4094
  }
4078
4095
  }
4079
4096
  function writeEvent(eventType, phase, name, args, extras, time) {
@@ -5444,9 +5461,10 @@ var ts;
5444
5461
  (function (TypeMapKind) {
5445
5462
  TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple";
5446
5463
  TypeMapKind[TypeMapKind["Array"] = 1] = "Array";
5447
- TypeMapKind[TypeMapKind["Function"] = 2] = "Function";
5448
- TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite";
5449
- TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged";
5464
+ TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred";
5465
+ TypeMapKind[TypeMapKind["Function"] = 3] = "Function";
5466
+ TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite";
5467
+ TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged";
5450
5468
  })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {}));
5451
5469
  var InferencePriority;
5452
5470
  (function (InferencePriority) {
@@ -48849,6 +48867,24 @@ var ts;
48849
48867
  var Symbol = ts.objectAllocator.getSymbolConstructor();
48850
48868
  var Type = ts.objectAllocator.getTypeConstructor();
48851
48869
  var Signature = ts.objectAllocator.getSignatureConstructor();
48870
+ var DebugTypeMapper = /** @class */ (function () {
48871
+ function DebugTypeMapper() {
48872
+ }
48873
+ DebugTypeMapper.prototype.__debugToString = function () {
48874
+ var _a;
48875
+ ts.Debug.type(this);
48876
+ switch (this.kind) {
48877
+ case 3 /* Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)";
48878
+ case 0 /* Simple */: return this.source.__debugTypeToString() + " -> " + this.target.__debugTypeToString();
48879
+ 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(", ");
48880
+ case 2 /* Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return s.__debugTypeToString() + " -> " + t().__debugTypeToString(); }).join(", ");
48881
+ case 5 /* Merged */:
48882
+ case 4 /* Composite */: return "m1: " + this.mapper1.__debugToString().split("\n").join("\n ") + "\nm2: " + this.mapper2.__debugToString().split("\n").join("\n ");
48883
+ default: return ts.Debug.assertNever(this);
48884
+ }
48885
+ };
48886
+ return DebugTypeMapper;
48887
+ }());
48852
48888
  var typeCount = 0;
48853
48889
  var symbolCount = 0;
48854
48890
  var enumCount = 0;
@@ -49309,10 +49345,23 @@ var ts;
49309
49345
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
49310
49346
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
49311
49347
  var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
49312
- var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
49313
- var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
49348
+ var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; });
49349
+ var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; });
49314
49350
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
49315
- var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
49351
+ 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)
49352
+ var outofbandVarianceMarkerHandler;
49353
+ var reportUnreliableMapper = makeFunctionTypeMapper(function (t) {
49354
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49355
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
49356
+ }
49357
+ return t;
49358
+ }, function () { return "(unmeasurable reporter)"; });
49359
+ var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) {
49360
+ if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) {
49361
+ outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
49362
+ }
49363
+ return t;
49364
+ }, function () { return "(unreliable reporter)"; });
49316
49365
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49317
49366
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49318
49367
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -49472,7 +49521,6 @@ var ts;
49472
49521
  var typeofType = createTypeofType();
49473
49522
  var _jsxNamespace;
49474
49523
  var _jsxFactoryEntity;
49475
- var outofbandVarianceMarkerHandler;
49476
49524
  var subtypeRelation = new ts.Map();
49477
49525
  var strictSubtypeRelation = new ts.Map();
49478
49526
  var assignableRelation = new ts.Map();
@@ -53239,7 +53287,7 @@ var ts;
53239
53287
  var name = typeParameterToName(newParam, context);
53240
53288
  var newTypeVariable = ts.factory.createTypeReferenceNode(name);
53241
53289
  context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
53242
- var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
53290
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper);
53243
53291
  var saveInferTypeParameters_1 = context.inferTypeParameters;
53244
53292
  context.inferTypeParameters = type.root.inferTypeParameters;
53245
53293
  var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
@@ -60650,8 +60698,7 @@ var ts;
60650
60698
  var _a;
60651
60699
  var inferences;
60652
60700
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
60653
- for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60654
- var declaration = _b[_i];
60701
+ var _loop_15 = function (declaration) {
60655
60702
  if (declaration.parent.kind === 190 /* InferType */) {
60656
60703
  // When an 'infer T' declaration is immediately contained in a type reference node
60657
60704
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -60659,12 +60706,12 @@ var ts;
60659
60706
  // present, we form an intersection of the inferred constraint types.
60660
60707
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
60661
60708
  if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
60662
- var typeReference = grandParent;
60663
- var typeParameters = getTypeParametersForTypeReference(typeReference);
60664
- if (typeParameters) {
60665
- var index = typeReference.typeArguments.indexOf(childTypeParameter);
60666
- if (index < typeParameters.length) {
60667
- var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
60709
+ var typeReference_1 = grandParent;
60710
+ var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1);
60711
+ if (typeParameters_1) {
60712
+ var index = typeReference_1.typeArguments.indexOf(childTypeParameter);
60713
+ if (index < typeParameters_1.length) {
60714
+ var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]);
60668
60715
  if (declaredConstraint) {
60669
60716
  // Type parameter constraints can reference other type parameters so
60670
60717
  // constraints need to be instantiated. If instantiation produces the
@@ -60672,7 +60719,9 @@ var ts;
60672
60719
  // type Foo<T extends string, U extends T> = [T, U];
60673
60720
  // type Bar<T> = T extends Foo<infer X, infer X> ? Foo<X, X> : T;
60674
60721
  // the instantiated constraint for U is X, so we discard that inference.
60675
- var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
60722
+ var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () {
60723
+ return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index);
60724
+ }; }));
60676
60725
  var constraint = instantiateType(declaredConstraint, mapper);
60677
60726
  if (constraint !== typeParameter) {
60678
60727
  inferences = ts.append(inferences, constraint);
@@ -60710,6 +60759,10 @@ var ts;
60710
60759
  inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType)));
60711
60760
  }
60712
60761
  }
60762
+ };
60763
+ for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
60764
+ var declaration = _b[_i];
60765
+ _loop_15(declaration);
60713
60766
  }
60714
60767
  }
60715
60768
  return inferences && getIntersectionType(inferences);
@@ -61598,7 +61651,7 @@ var ts;
61598
61651
  var lastRequiredIndex = -1;
61599
61652
  var firstRestIndex = -1;
61600
61653
  var lastOptionalOrRestIndex = -1;
61601
- var _loop_15 = function (i) {
61654
+ var _loop_16 = function (i) {
61602
61655
  var type = elementTypes[i];
61603
61656
  var flags = target.elementFlags[i];
61604
61657
  if (flags & 8 /* Variadic */) {
@@ -61628,7 +61681,7 @@ var ts;
61628
61681
  }
61629
61682
  };
61630
61683
  for (var i = 0; i < elementTypes.length; i++) {
61631
- var state_4 = _loop_15(i);
61684
+ var state_4 = _loop_16(i);
61632
61685
  if (typeof state_4 === "object")
61633
61686
  return state_4.value;
61634
61687
  }
@@ -61824,7 +61877,7 @@ var ts;
61824
61877
  var templates = ts.filter(types, isPatternLiteralType);
61825
61878
  if (templates.length) {
61826
61879
  var i = types.length;
61827
- var _loop_16 = function () {
61880
+ var _loop_17 = function () {
61828
61881
  i--;
61829
61882
  var t = types[i];
61830
61883
  if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -61832,7 +61885,7 @@ var ts;
61832
61885
  }
61833
61886
  };
61834
61887
  while (i > 0) {
61835
- _loop_16();
61888
+ _loop_17();
61836
61889
  }
61837
61890
  }
61838
61891
  }
@@ -61909,14 +61962,14 @@ var ts;
61909
61962
  var namedUnions = [];
61910
61963
  addNamedUnions(namedUnions, types);
61911
61964
  var reducedTypes = [];
61912
- var _loop_17 = function (t) {
61965
+ var _loop_18 = function (t) {
61913
61966
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
61914
61967
  reducedTypes.push(t);
61915
61968
  }
61916
61969
  };
61917
61970
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
61918
61971
  var t = typeSet_1[_i];
61919
- _loop_17(t);
61972
+ _loop_18(t);
61920
61973
  }
61921
61974
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
61922
61975
  return namedUnions[0];
@@ -63140,7 +63193,7 @@ var ts;
63140
63193
  var result;
63141
63194
  var extraTypes;
63142
63195
  var tailCount = 0;
63143
- var _loop_18 = function () {
63196
+ var _loop_19 = function () {
63144
63197
  if (tailCount === 1000) {
63145
63198
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63146
63199
  result = errorType;
@@ -63261,7 +63314,7 @@ var ts;
63261
63314
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63262
63315
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63263
63316
  while (true) {
63264
- var state_5 = _loop_18();
63317
+ var state_5 = _loop_19();
63265
63318
  if (typeof state_5 === "object")
63266
63319
  return state_5.value;
63267
63320
  if (state_5 === "break")
@@ -63891,7 +63944,7 @@ var ts;
63891
63944
  switch (mapper.kind) {
63892
63945
  case 0 /* Simple */:
63893
63946
  return type === mapper.source ? mapper.target : type;
63894
- case 1 /* Array */:
63947
+ case 1 /* Array */: {
63895
63948
  var sources = mapper.sources;
63896
63949
  var targets = mapper.targets;
63897
63950
  for (var i = 0; i < sources.length; i++) {
@@ -63900,25 +63953,45 @@ var ts;
63900
63953
  }
63901
63954
  }
63902
63955
  return type;
63903
- case 2 /* Function */:
63956
+ }
63957
+ case 2 /* Deferred */: {
63958
+ var sources = mapper.sources;
63959
+ var targets = mapper.targets;
63960
+ for (var i = 0; i < sources.length; i++) {
63961
+ if (type === sources[i]) {
63962
+ return targets[i]();
63963
+ }
63964
+ }
63965
+ return type;
63966
+ }
63967
+ case 3 /* Function */:
63904
63968
  return mapper.func(type);
63905
- case 3 /* Composite */:
63906
- case 4 /* Merged */:
63969
+ case 4 /* Composite */:
63970
+ case 5 /* Merged */:
63907
63971
  var t1 = getMappedType(type, mapper.mapper1);
63908
- return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63972
+ return t1 !== type && mapper.kind === 4 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
63973
+ }
63974
+ }
63975
+ function attachDebugPrototypeIfDebug(mapper) {
63976
+ if (ts.Debug.isDebugging) {
63977
+ return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype);
63909
63978
  }
63979
+ return mapper;
63910
63980
  }
63911
63981
  function makeUnaryTypeMapper(source, target) {
63912
- return { kind: 0 /* Simple */, source: source, target: target };
63982
+ return attachDebugPrototypeIfDebug({ kind: 0 /* Simple */, source: source, target: target });
63913
63983
  }
63914
63984
  function makeArrayTypeMapper(sources, targets) {
63915
- return { kind: 1 /* Array */, sources: sources, targets: targets };
63985
+ return attachDebugPrototypeIfDebug({ kind: 1 /* Array */, sources: sources, targets: targets });
63916
63986
  }
63917
- function makeFunctionTypeMapper(func) {
63918
- return { kind: 2 /* Function */, func: func };
63987
+ function makeFunctionTypeMapper(func, debugInfo) {
63988
+ return attachDebugPrototypeIfDebug({ kind: 3 /* Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined });
63989
+ }
63990
+ function makeDeferredTypeMapper(sources, targets) {
63991
+ return attachDebugPrototypeIfDebug({ kind: 2 /* Deferred */, sources: sources, targets: targets });
63919
63992
  }
63920
63993
  function makeCompositeTypeMapper(kind, mapper1, mapper2) {
63921
- return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
63994
+ return attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 });
63922
63995
  }
63923
63996
  function createTypeEraser(sources) {
63924
63997
  return createTypeMapper(sources, /*targets*/ undefined);
@@ -63928,19 +64001,20 @@ var ts;
63928
64001
  * This is used during inference when instantiating type parameter defaults.
63929
64002
  */
63930
64003
  function createBackreferenceMapper(context, index) {
63931
- return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
64004
+ var forwardInferences = context.inferences.slice(index);
64005
+ return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; }));
63932
64006
  }
63933
64007
  function combineTypeMappers(mapper1, mapper2) {
63934
- return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2;
64008
+ return mapper1 ? makeCompositeTypeMapper(4 /* Composite */, mapper1, mapper2) : mapper2;
63935
64009
  }
63936
64010
  function mergeTypeMappers(mapper1, mapper2) {
63937
- return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2;
64011
+ return mapper1 ? makeCompositeTypeMapper(5 /* Merged */, mapper1, mapper2) : mapper2;
63938
64012
  }
63939
64013
  function prependTypeMapping(source, target, mapper) {
63940
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
64014
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
63941
64015
  }
63942
64016
  function appendTypeMapping(mapper, source, target) {
63943
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
64017
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
63944
64018
  }
63945
64019
  function getRestrictiveTypeParameter(tp) {
63946
64020
  return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
@@ -65836,7 +65910,7 @@ var ts;
65836
65910
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
65837
65911
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
65838
65912
  }
65839
- var _loop_19 = function (prop) {
65913
+ var _loop_20 = function (prop) {
65840
65914
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
65841
65915
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
65842
65916
  if (reportErrors) {
@@ -65899,7 +65973,7 @@ var ts;
65899
65973
  };
65900
65974
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
65901
65975
  var prop = _b[_i];
65902
- var state_6 = _loop_19(prop);
65976
+ var state_6 = _loop_20(prop);
65903
65977
  if (typeof state_6 === "object")
65904
65978
  return state_6.value;
65905
65979
  }
@@ -66131,10 +66205,10 @@ var ts;
66131
66205
  // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component
66132
66206
  var saved = entry & 24 /* ReportsMask */;
66133
66207
  if (saved & 8 /* ReportsUnmeasurable */) {
66134
- instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
66208
+ instantiateType(source, reportUnmeasurableMapper);
66135
66209
  }
66136
66210
  if (saved & 16 /* ReportsUnreliable */) {
66137
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66211
+ instantiateType(source, reportUnreliableMapper);
66138
66212
  }
66139
66213
  }
66140
66214
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
@@ -66560,7 +66634,7 @@ var ts;
66560
66634
  }
66561
66635
  // Report unreliable variance for type variables referenced in template literal type placeholders.
66562
66636
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
66563
- instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
66637
+ instantiateType(source, reportUnreliableMapper);
66564
66638
  }
66565
66639
  if (isTypeMatchedByTemplateLiteralType(source, target)) {
66566
66640
  return -1 /* True */;
@@ -66832,18 +66906,6 @@ var ts;
66832
66906
  }
66833
66907
  }
66834
66908
  }
66835
- function reportUnmeasurableMarkers(p) {
66836
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66837
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
66838
- }
66839
- return p;
66840
- }
66841
- function reportUnreliableMarkers(p) {
66842
- if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
66843
- outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
66844
- }
66845
- return p;
66846
- }
66847
66909
  // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is
66848
66910
  // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice
66849
66911
  // that S and T are contra-variant whereas X and Y are co-variant.
@@ -66853,7 +66915,7 @@ var ts;
66853
66915
  if (modifiersRelated) {
66854
66916
  var result_10;
66855
66917
  var targetConstraint = getConstraintTypeFromMappedType(target);
66856
- var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
66918
+ var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper);
66857
66919
  if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
66858
66920
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
66859
66921
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
@@ -66907,11 +66969,11 @@ var ts;
66907
66969
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
66908
66970
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
66909
66971
  var matchingTypes = [];
66910
- var _loop_20 = function (combination) {
66972
+ var _loop_21 = function (combination) {
66911
66973
  var hasMatch = false;
66912
66974
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
66913
66975
  var type = _d[_c];
66914
- var _loop_21 = function (i) {
66976
+ var _loop_22 = function (i) {
66915
66977
  var sourceProperty = sourcePropertiesFiltered[i];
66916
66978
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
66917
66979
  if (!targetProperty)
@@ -66927,7 +66989,7 @@ var ts;
66927
66989
  }
66928
66990
  };
66929
66991
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
66930
- var state_8 = _loop_21(i);
66992
+ var state_8 = _loop_22(i);
66931
66993
  switch (state_8) {
66932
66994
  case "continue-outer": continue outer;
66933
66995
  }
@@ -66941,7 +67003,7 @@ var ts;
66941
67003
  };
66942
67004
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
66943
67005
  var combination = discriminantCombinations_1[_a];
66944
- var state_7 = _loop_20(combination);
67006
+ var state_7 = _loop_21(combination);
66945
67007
  if (typeof state_7 === "object")
66946
67008
  return state_7.value;
66947
67009
  }
@@ -67389,7 +67451,7 @@ var ts;
67389
67451
  * See signatureAssignableTo, compareSignaturesIdentical
67390
67452
  */
67391
67453
  function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
67392
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
67454
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper);
67393
67455
  }
67394
67456
  function signaturesIdenticalTo(source, target, kind) {
67395
67457
  var sourceSignatures = getSignaturesOfType(source, kind);
@@ -67648,7 +67710,7 @@ var ts;
67648
67710
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
67649
67711
  links.variances = ts.emptyArray;
67650
67712
  var variances = [];
67651
- var _loop_22 = function (tp) {
67713
+ var _loop_23 = function (tp) {
67652
67714
  var modifiers = getVarianceModifiers(tp);
67653
67715
  var variance = modifiers & 65536 /* Out */ ?
67654
67716
  modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ :
@@ -67684,12 +67746,12 @@ var ts;
67684
67746
  }
67685
67747
  variances.push(variance);
67686
67748
  };
67687
- for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
67688
- var tp = typeParameters_1[_i];
67689
- _loop_22(tp);
67749
+ for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
67750
+ var tp = typeParameters_2[_i];
67751
+ _loop_23(tp);
67690
67752
  }
67691
67753
  links.variances = variances;
67692
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
67754
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
67693
67755
  }
67694
67756
  return links.variances;
67695
67757
  }
@@ -68681,27 +68743,29 @@ var ts;
68681
68743
  signature: signature,
68682
68744
  flags: flags,
68683
68745
  compareTypes: compareTypes,
68684
- mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }),
68685
- nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }),
68746
+ mapper: reportUnmeasurableMapper,
68747
+ nonFixingMapper: reportUnmeasurableMapper,
68686
68748
  };
68749
+ context.mapper = makeFixingMapperForContext(context);
68750
+ context.nonFixingMapper = makeNonFixingMapperForContext(context);
68687
68751
  return context;
68688
68752
  }
68689
- function mapToInferredType(context, t, fix) {
68690
- var inferences = context.inferences;
68691
- for (var i = 0; i < inferences.length; i++) {
68692
- var inference = inferences[i];
68693
- if (t === inference.typeParameter) {
68694
- if (fix && !inference.isFixed) {
68695
- // Before we commit to a particular inference (and thus lock out any further inferences),
68696
- // we infer from any intra-expression inference sites we have collected.
68697
- inferFromIntraExpressionSites(context);
68698
- clearCachedInferences(inferences);
68699
- inference.isFixed = true;
68700
- }
68701
- return getInferredType(context, i);
68753
+ function makeFixingMapperForContext(context) {
68754
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () {
68755
+ if (!inference.isFixed) {
68756
+ // Before we commit to a particular inference (and thus lock out any further inferences),
68757
+ // we infer from any intra-expression inference sites we have collected.
68758
+ inferFromIntraExpressionSites(context);
68759
+ clearCachedInferences(context.inferences);
68760
+ inference.isFixed = true;
68702
68761
  }
68703
- }
68704
- return t;
68762
+ return getInferredType(context, i);
68763
+ }; }));
68764
+ }
68765
+ function makeNonFixingMapperForContext(context) {
68766
+ return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () {
68767
+ return getInferredType(context, i);
68768
+ }; }));
68705
68769
  }
68706
68770
  function clearCachedInferences(inferences) {
68707
68771
  for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
@@ -69621,7 +69685,7 @@ var ts;
69621
69685
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
69622
69686
  // succeed. That would be a pointless and confusing outcome.
69623
69687
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69624
- var _loop_23 = function (i) {
69688
+ var _loop_24 = function (i) {
69625
69689
  var source_1 = matches ? matches[i] : neverType;
69626
69690
  var target_3 = types[i];
69627
69691
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -69671,7 +69735,7 @@ var ts;
69671
69735
  inferFromTypes(source_1, target_3);
69672
69736
  };
69673
69737
  for (var i = 0; i < types.length; i++) {
69674
- _loop_23(i);
69738
+ _loop_24(i);
69675
69739
  }
69676
69740
  }
69677
69741
  }
@@ -70189,7 +70253,7 @@ var ts;
70189
70253
  function mapTypesByKeyProperty(types, name) {
70190
70254
  var map = new ts.Map();
70191
70255
  var count = 0;
70192
- var _loop_24 = function (type) {
70256
+ var _loop_25 = function (type) {
70193
70257
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
70194
70258
  var discriminant = getTypeOfPropertyOfType(type, name);
70195
70259
  if (discriminant) {
@@ -70215,7 +70279,7 @@ var ts;
70215
70279
  };
70216
70280
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70217
70281
  var type = types_15[_i];
70218
- var state_9 = _loop_24(type);
70282
+ var state_9 = _loop_25(type);
70219
70283
  if (typeof state_9 === "object")
70220
70284
  return state_9.value;
70221
70285
  }
@@ -76564,7 +76628,7 @@ var ts;
76564
76628
  if (spreadIndex >= 0) {
76565
76629
  // Create synthetic arguments from spreads of tuple types.
76566
76630
  var effectiveArgs_1 = args.slice(0, spreadIndex);
76567
- var _loop_25 = function (i) {
76631
+ var _loop_26 = function (i) {
76568
76632
  var arg = args[i];
76569
76633
  // We can call checkExpressionCached because spread expressions never have a contextual type.
76570
76634
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -76581,7 +76645,7 @@ var ts;
76581
76645
  }
76582
76646
  };
76583
76647
  for (var i = spreadIndex; i < args.length; i++) {
76584
- _loop_25(i);
76648
+ _loop_26(i);
76585
76649
  }
76586
76650
  return effectiveArgs_1;
76587
76651
  }
@@ -76910,7 +76974,7 @@ var ts;
76910
76974
  var min_3 = Number.MAX_VALUE;
76911
76975
  var minIndex = 0;
76912
76976
  var i_1 = 0;
76913
- var _loop_26 = function (c) {
76977
+ var _loop_27 = function (c) {
76914
76978
  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)); };
76915
76979
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76916
76980
  if (diags_2) {
@@ -76928,7 +76992,7 @@ var ts;
76928
76992
  };
76929
76993
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76930
76994
  var c = candidatesForArgumentError_1[_a];
76931
- _loop_26(c);
76995
+ _loop_27(c);
76932
76996
  }
76933
76997
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76934
76998
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77086,7 +77150,7 @@ var ts;
77086
77150
  }
77087
77151
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77088
77152
  var parameters = [];
77089
- var _loop_27 = function (i) {
77153
+ var _loop_28 = function (i) {
77090
77154
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77091
77155
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77092
77156
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77094,7 +77158,7 @@ var ts;
77094
77158
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77095
77159
  };
77096
77160
  for (var i = 0; i < maxNonRestParam; i++) {
77097
- _loop_27(i);
77161
+ _loop_28(i);
77098
77162
  }
77099
77163
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77100
77164
  var flags = 0 /* None */;
@@ -80447,8 +80511,8 @@ var ts;
80447
80511
  var result = [];
80448
80512
  var oldTypeParameters;
80449
80513
  var newTypeParameters;
80450
- for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
80451
- var tp = typeParameters_2[_i];
80514
+ for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
80515
+ var tp = typeParameters_3[_i];
80452
80516
  var name = tp.symbol.escapedName;
80453
80517
  if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
80454
80518
  var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
@@ -80770,12 +80834,14 @@ var ts;
80770
80834
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80771
80835
  }
80772
80836
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80837
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
80773
80838
  var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80774
80839
  var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80775
80840
  var saveVarianceTypeParameter = typeParameter;
80776
80841
  varianceTypeParameter = typeParameter;
80777
80842
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
80778
80843
  varianceTypeParameter = saveVarianceTypeParameter;
80844
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
80779
80845
  }
80780
80846
  }
80781
80847
  }
@@ -81125,7 +81191,7 @@ var ts;
81125
81191
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81126
81192
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81127
81193
  var indexSignatureMap_1 = new ts.Map();
81128
- var _loop_28 = function (declaration) {
81194
+ var _loop_29 = function (declaration) {
81129
81195
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81130
81196
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81131
81197
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81140,7 +81206,7 @@ var ts;
81140
81206
  };
81141
81207
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81142
81208
  var declaration = _a[_i];
81143
- _loop_28(declaration);
81209
+ _loop_29(declaration);
81144
81210
  }
81145
81211
  indexSignatureMap_1.forEach(function (entry) {
81146
81212
  if (entry.declarations.length > 1) {
@@ -81363,6 +81429,12 @@ var ts;
81363
81429
  function checkMissingDeclaration(node) {
81364
81430
  checkDecorators(node);
81365
81431
  }
81432
+ function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) {
81433
+ if (index < typeParameters.length) {
81434
+ return getTypeFromTypeNode(node.typeArguments[index]);
81435
+ }
81436
+ return getEffectiveTypeArguments(node, typeParameters)[index];
81437
+ }
81366
81438
  function getEffectiveTypeArguments(node, typeParameters) {
81367
81439
  return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
81368
81440
  }
@@ -82104,6 +82176,32 @@ var ts;
82104
82176
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
82105
82177
  type;
82106
82178
  }
82179
+ function isAwaitedTypeNeeded(type) {
82180
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82181
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
82182
+ return false;
82183
+ }
82184
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82185
+ if (isGenericObjectType(type)) {
82186
+ var baseConstraint = getBaseConstraintOfType(type);
82187
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82188
+ // or is promise-like.
82189
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82190
+ return true;
82191
+ }
82192
+ }
82193
+ return false;
82194
+ }
82195
+ function tryCreateAwaitedType(type) {
82196
+ // Nothing to do if `Awaited<T>` doesn't exist
82197
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82198
+ if (awaitedSymbol) {
82199
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82200
+ // an `Awaited<T | U>` would suffice.
82201
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82202
+ }
82203
+ return undefined;
82204
+ }
82107
82205
  function createAwaitedTypeIfNeeded(type) {
82108
82206
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
82109
82207
  // - `T` is not already an `Awaited<U>`, and
@@ -82112,26 +82210,10 @@ var ts;
82112
82210
  // - `T` has no base constraint, or
82113
82211
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
82114
82212
  // - The base constraint of `T` is an object type with a callable `then` method.
82115
- if (isTypeAny(type)) {
82116
- return type;
82117
- }
82118
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82119
- if (isAwaitedTypeInstantiation(type)) {
82120
- return type;
82121
- }
82122
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
82123
- if (isGenericObjectType(type)) {
82124
- var baseConstraint = getBaseConstraintOfType(type);
82125
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82126
- // or is promise-like.
82127
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82128
- // Nothing to do if `Awaited<T>` doesn't exist
82129
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82130
- if (awaitedSymbol) {
82131
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82132
- // an `Awaited<T | U>` would suffice.
82133
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82134
- }
82213
+ if (isAwaitedTypeNeeded(type)) {
82214
+ var awaitedType = tryCreateAwaitedType(type);
82215
+ if (awaitedType) {
82216
+ return awaitedType;
82135
82217
  }
82136
82218
  }
82137
82219
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82171,8 +82253,21 @@ var ts;
82171
82253
  }
82172
82254
  // For a union, get a union of the awaited types of each constituent.
82173
82255
  if (type.flags & 1048576 /* Union */) {
82256
+ if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
82257
+ if (errorNode) {
82258
+ error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
82259
+ }
82260
+ return undefined;
82261
+ }
82174
82262
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
82175
- return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
82263
+ awaitedTypeStack.push(type.id);
82264
+ var mapped = mapType(type, mapper);
82265
+ awaitedTypeStack.pop();
82266
+ return typeAsAwaitable.awaitedTypeOfType = mapped;
82267
+ }
82268
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82269
+ if (isAwaitedTypeNeeded(type)) {
82270
+ return typeAsAwaitable.awaitedTypeOfType = type;
82176
82271
  }
82177
82272
  var thisTypeForErrorOut = { value: undefined };
82178
82273
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
@@ -82821,8 +82916,8 @@ var ts;
82821
82916
  return;
82822
82917
  var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
82823
82918
  var seenParentsWithEveryUnused = new ts.Set();
82824
- for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
82825
- var typeParameter = typeParameters_3[_i];
82919
+ for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) {
82920
+ var typeParameter = typeParameters_4[_i];
82826
82921
  if (!isTypeParameterUnused(typeParameter))
82827
82922
  continue;
82828
82923
  var name = ts.idText(typeParameter.name);
@@ -84641,7 +84736,7 @@ var ts;
84641
84736
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84642
84737
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
84643
84738
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
84644
- var _loop_29 = function (info) {
84739
+ var _loop_30 = function (info) {
84645
84740
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
84646
84741
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
84647
84742
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -84654,7 +84749,7 @@ var ts;
84654
84749
  };
84655
84750
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
84656
84751
  var info = indexInfos_9[_i];
84657
- _loop_29(info);
84752
+ _loop_30(info);
84658
84753
  }
84659
84754
  }
84660
84755
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -84662,7 +84757,7 @@ var ts;
84662
84757
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
84663
84758
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84664
84759
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
84665
- var _loop_30 = function (info) {
84760
+ var _loop_31 = function (info) {
84666
84761
  if (info === checkInfo)
84667
84762
  return "continue";
84668
84763
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -84677,7 +84772,7 @@ var ts;
84677
84772
  };
84678
84773
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
84679
84774
  var info = indexInfos_10[_i];
84680
- _loop_30(info);
84775
+ _loop_31(info);
84681
84776
  }
84682
84777
  }
84683
84778
  function checkTypeNameIsReserved(name, message) {
@@ -84997,7 +85092,7 @@ var ts;
84997
85092
  var baseTypes = baseTypeNode && getBaseTypes(type);
84998
85093
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84999
85094
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85000
- var _loop_31 = function (member) {
85095
+ var _loop_32 = function (member) {
85001
85096
  if (ts.hasAmbientModifier(member)) {
85002
85097
  return "continue";
85003
85098
  }
@@ -85014,7 +85109,7 @@ var ts;
85014
85109
  };
85015
85110
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85016
85111
  var member = _a[_i];
85017
- _loop_31(member);
85112
+ _loop_32(member);
85018
85113
  }
85019
85114
  }
85020
85115
  /**
@@ -85102,7 +85197,7 @@ var ts;
85102
85197
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85103
85198
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85104
85199
  var issuedMemberError = false;
85105
- var _loop_32 = function (member) {
85200
+ var _loop_33 = function (member) {
85106
85201
  if (ts.isStatic(member)) {
85107
85202
  return "continue";
85108
85203
  }
@@ -85121,7 +85216,7 @@ var ts;
85121
85216
  };
85122
85217
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85123
85218
  var member = _a[_i];
85124
- _loop_32(member);
85219
+ _loop_33(member);
85125
85220
  }
85126
85221
  if (!issuedMemberError) {
85127
85222
  // check again with diagnostics to generate a less-specific error
@@ -85192,7 +85287,7 @@ var ts;
85192
85287
  var _a, _b, _c, _d;
85193
85288
  // NOTE: assignability is checked in checkClassDeclaration
85194
85289
  var baseProperties = getPropertiesOfType(baseType);
85195
- var _loop_33 = function (baseProperty) {
85290
+ var _loop_34 = function (baseProperty) {
85196
85291
  var base = getTargetSymbol(baseProperty);
85197
85292
  if (base.flags & 4194304 /* Prototype */) {
85198
85293
  return "continue";
@@ -85302,7 +85397,7 @@ var ts;
85302
85397
  };
85303
85398
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
85304
85399
  var baseProperty = baseProperties_1[_i];
85305
- var state_10 = _loop_33(baseProperty);
85400
+ var state_10 = _loop_34(baseProperty);
85306
85401
  switch (state_10) {
85307
85402
  case "continue-basePropertyCheck": continue basePropertyCheck;
85308
85403
  }
@@ -111817,7 +111912,6 @@ var ts;
111817
111912
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111818
111913
  // Update the output signature
111819
111914
  newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111820
- newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111821
111915
  }
111822
111916
  // Update sourceFileInfo
111823
111917
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
@@ -121204,7 +121298,7 @@ var ts;
121204
121298
  state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
121205
121299
  }
121206
121300
  state.changedFilesSet = new ts.Set();
121207
- state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
121301
+ state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined;
121208
121302
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
121209
121303
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
121210
121304
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
@@ -121328,7 +121422,7 @@ var ts;
121328
121422
  programEmitComplete: state.programEmitComplete,
121329
121423
  emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
121330
121424
  outSignature: state.outSignature,
121331
- dtsChangeTime: state.dtsChangeTime,
121425
+ latestChangedDtsFile: state.latestChangedDtsFile,
121332
121426
  hasChangedEmitSignature: state.hasChangedEmitSignature,
121333
121427
  changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
121334
121428
  };
@@ -121341,7 +121435,7 @@ var ts;
121341
121435
  state.programEmitComplete = savedEmitState.programEmitComplete;
121342
121436
  state.emitSignatures = savedEmitState.emitSignatures;
121343
121437
  state.outSignature = savedEmitState.outSignature;
121344
- state.dtsChangeTime = savedEmitState.dtsChangeTime;
121438
+ state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile;
121345
121439
  state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
121346
121440
  if (savedEmitState.changedFilesSet)
121347
121441
  state.changedFilesSet = savedEmitState.changedFilesSet;
@@ -121655,14 +121749,14 @@ var ts;
121655
121749
  /**
121656
121750
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121657
121751
  */
121658
- function getProgramBuildInfo(state, getCanonicalFileName, host) {
121752
+ function getProgramBuildInfo(state, getCanonicalFileName) {
121659
121753
  var outFilePath = ts.outFile(state.compilerOptions);
121660
121754
  if (outFilePath && !state.compilerOptions.composite)
121661
121755
  return;
121662
121756
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121663
121757
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121664
- // Update the dtsChange time in buildInfo
121665
- state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121758
+ // 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
121759
+ var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
121666
121760
  if (outFilePath) {
121667
121761
  var fileNames_1 = [];
121668
121762
  var fileInfos_1 = [];
@@ -121678,7 +121772,7 @@ var ts;
121678
121772
  fileInfos: fileInfos_1,
121679
121773
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121680
121774
  outSignature: state.outSignature,
121681
- dtsChangeTime: state.dtsChangeTime,
121775
+ latestChangedDtsFile: latestChangedDtsFile,
121682
121776
  };
121683
121777
  return result_15;
121684
121778
  }
@@ -121780,7 +121874,7 @@ var ts;
121780
121874
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121781
121875
  changeFileSet: changeFileSet,
121782
121876
  emitSignatures: emitSignatures,
121783
- dtsChangeTime: state.dtsChangeTime,
121877
+ latestChangedDtsFile: latestChangedDtsFile,
121784
121878
  };
121785
121879
  return result;
121786
121880
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -121948,7 +122042,7 @@ var ts;
121948
122042
  */
121949
122043
  var computeHash = ts.maybeBind(host, host.createHash);
121950
122044
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121951
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
122045
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121952
122046
  // To ensure that we arent storing any references to old program or new program without state
121953
122047
  newProgram = undefined; // TODO: GH#18217
121954
122048
  oldProgram = undefined;
@@ -121958,6 +122052,7 @@ var ts;
121958
122052
  builderProgram.getState = getState;
121959
122053
  builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121960
122054
  builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
122055
+ builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; };
121961
122056
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121962
122057
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121963
122058
  builderProgram.emit = emit;
@@ -122065,18 +122160,22 @@ var ts;
122065
122160
  var filePath = sourceFiles[0].resolvedPath;
122066
122161
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122067
122162
  emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122068
- if (emitSignature !== oldSignature) {
122069
- ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
122070
- state.hasChangedEmitSignature = true;
122071
- }
122163
+ // Dont write dts files if they didn't change
122164
+ if (emitSignature === oldSignature)
122165
+ return;
122166
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
122167
+ state.hasChangedEmitSignature = true;
122168
+ state.latestChangedDtsFile = fileName;
122072
122169
  }
122073
122170
  }
122074
122171
  else if (state.compilerOptions.composite) {
122075
122172
  var newSignature = computeSignature(text, computeHash, data);
122076
- if (newSignature !== state.outSignature) {
122077
- state.outSignature = newSignature;
122078
- state.hasChangedEmitSignature = true;
122079
- }
122173
+ // Dont write dts files if they didn't change
122174
+ if (newSignature === state.outSignature)
122175
+ return;
122176
+ state.outSignature = newSignature;
122177
+ state.hasChangedEmitSignature = true;
122178
+ state.latestChangedDtsFile = fileName;
122080
122179
  }
122081
122180
  }
122082
122181
  if (writeFile)
@@ -122239,11 +122338,12 @@ var ts;
122239
122338
  var state;
122240
122339
  var filePaths;
122241
122340
  var filePathsSetList;
122341
+ var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
122242
122342
  if (isProgramBundleEmitBuildInfo(program)) {
122243
122343
  state = {
122244
122344
  fileInfos: new ts.Map(),
122245
122345
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
122246
- dtsChangeTime: program.dtsChangeTime,
122346
+ latestChangedDtsFile: latestChangedDtsFile,
122247
122347
  outSignature: program.outSignature,
122248
122348
  };
122249
122349
  }
@@ -122276,7 +122376,7 @@ var ts;
122276
122376
  affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
122277
122377
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
122278
122378
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
122279
- dtsChangeTime: program.dtsChangeTime,
122379
+ latestChangedDtsFile: latestChangedDtsFile,
122280
122380
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
122281
122381
  };
122282
122382
  }
@@ -122303,6 +122403,7 @@ var ts;
122303
122403
  getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
122304
122404
  emitBuildInfo: ts.notImplemented,
122305
122405
  close: ts.noop,
122406
+ hasChangedEmitSignature: ts.returnFalse,
122306
122407
  };
122307
122408
  function toPath(path) {
122308
122409
  return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
@@ -123617,7 +123718,7 @@ var ts;
123617
123718
  });
123618
123719
  // Sort by paths closest to importing file Name directory
123619
123720
  var sortedPaths = [];
123620
- var _loop_34 = function (directory) {
123721
+ var _loop_35 = function (directory) {
123621
123722
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
123622
123723
  var pathsInDirectory;
123623
123724
  allFileNames.forEach(function (_a, fileName) {
@@ -123641,7 +123742,7 @@ var ts;
123641
123742
  };
123642
123743
  var out_directory_1;
123643
123744
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
123644
- var state_11 = _loop_34(directory);
123745
+ var state_11 = _loop_35(directory);
123645
123746
  directory = out_directory_1;
123646
123747
  if (state_11 === "break")
123647
123748
  break;
@@ -124485,7 +124586,6 @@ var ts;
124485
124586
  readDirectory: ts.maybeBind(host, host.readDirectory),
124486
124587
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
124487
124588
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
124488
- now: ts.maybeBind(host, host.now),
124489
124589
  };
124490
124590
  function writeFile(fileName, text, writeByteOrderMark, onError) {
124491
124591
  try {
@@ -124643,7 +124743,6 @@ var ts;
124643
124743
  host.createHash = ts.maybeBind(system, system.createHash);
124644
124744
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
124645
124745
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124646
- host.now = ts.maybeBind(system, system.now);
124647
124746
  ts.setGetSourceFileAsHashVersioned(host, system);
124648
124747
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
124649
124748
  return host;
@@ -125971,8 +126070,7 @@ var ts;
125971
126070
  }
125972
126071
  // Actual Emit
125973
126072
  var host = state.host, compilerHost = state.compilerHost;
125974
- var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125975
- var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
126073
+ var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
125976
126074
  var emitterDiagnostics = ts.createDiagnosticCollection();
125977
126075
  var emittedOutputs = new ts.Map();
125978
126076
  var options = program.getCompilerOptions();
@@ -125980,17 +126078,11 @@ var ts;
125980
126078
  var outputTimeStampMap;
125981
126079
  var now;
125982
126080
  outputFiles.forEach(function (_a) {
125983
- var _b, _c;
125984
126081
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125985
126082
  var path = toPath(state, name);
125986
126083
  emittedOutputs.set(toPath(state, name), name);
125987
- if (buildInfo) {
125988
- setBuildInfo(state, buildInfo, projectPath, options);
125989
- // Buildinfo has information on when last dts change time
125990
- 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)) {
125991
- resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125992
- }
125993
- }
126084
+ if (buildInfo)
126085
+ setBuildInfo(state, buildInfo, projectPath, options, resultFlags);
125994
126086
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125995
126087
  if (!isIncremental && state.watch) {
125996
126088
  (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
@@ -126004,7 +126096,7 @@ var ts;
126004
126096
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
126005
126097
  var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
126006
126098
  if (data === null || data === void 0 ? void 0 : data.buildInfo)
126007
- setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
126099
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged);
126008
126100
  if (writeFileCallback)
126009
126101
  writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
126010
126102
  else
@@ -126037,7 +126129,6 @@ var ts;
126037
126129
  state.diagnostics.delete(projectPath);
126038
126130
  state.projectStatus.set(projectPath, {
126039
126131
  type: ts.UpToDateStatusType.UpToDate,
126040
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
126041
126132
  oldestOutputFileName: oldestOutputFileName
126042
126133
  });
126043
126134
  afterProgramDone(state, program, config);
@@ -126079,10 +126170,10 @@ var ts;
126079
126170
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126080
126171
  emittedOutputs.set(toPath(state, name), name);
126081
126172
  if (buildInfo) {
126082
- setBuildInfo(state, buildInfo, projectPath, config.options);
126083
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
126173
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126084
126174
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126085
126175
  }
126176
+ setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
126086
126177
  }
126087
126178
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
126088
126179
  });
@@ -126341,15 +126432,23 @@ var ts;
126341
126432
  state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
126342
126433
  return result;
126343
126434
  }
126344
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
126435
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) {
126345
126436
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126346
126437
  var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
126438
+ var modifiedTime = getCurrentTime(state.host);
126347
126439
  if (existing) {
126348
126440
  existing.buildInfo = buildInfo;
126349
- existing.modifiedTime = getCurrentTime(state.host);
126441
+ existing.modifiedTime = modifiedTime;
126442
+ if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged))
126443
+ existing.latestChangedDtsTime = modifiedTime;
126350
126444
  }
126351
126445
  else {
126352
- state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
126446
+ state.buildInfoCache.set(resolvedConfigPath, {
126447
+ path: toPath(state, buildInfoPath),
126448
+ buildInfo: buildInfo,
126449
+ modifiedTime: modifiedTime,
126450
+ latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime,
126451
+ });
126353
126452
  }
126354
126453
  }
126355
126454
  function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
@@ -126381,7 +126480,7 @@ var ts;
126381
126480
  }
126382
126481
  }
126383
126482
  function getUpToDateStatusWorker(state, project, resolvedPath) {
126384
- var _a, _b, _c;
126483
+ var _a, _b;
126385
126484
  // Container if no files are specified in the project
126386
126485
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
126387
126486
  return {
@@ -126393,8 +126492,8 @@ var ts;
126393
126492
  var force = !!state.options.force;
126394
126493
  if (project.projectReferences) {
126395
126494
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
126396
- for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
126397
- var ref = _d[_i];
126495
+ for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) {
126496
+ var ref = _c[_i];
126398
126497
  var resolvedRef = ts.resolveProjectReferencePath(ref);
126399
126498
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
126400
126499
  var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
@@ -126434,7 +126533,6 @@ var ts;
126434
126533
  var buildInfoTime;
126435
126534
  var buildInfoProgram;
126436
126535
  var buildInfoVersionMap;
126437
- var newestDeclarationFileContentChangedTime;
126438
126536
  if (buildInfoPath) {
126439
126537
  var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
126440
126538
  buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
@@ -126471,8 +126569,6 @@ var ts;
126471
126569
  }
126472
126570
  oldestOutputFileTime = buildInfoTime;
126473
126571
  oldestOutputFileName = buildInfoPath;
126474
- // Get the last dtsChange time from build info
126475
- newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
126476
126572
  }
126477
126573
  // Check input files
126478
126574
  var newestInputFileName = undefined;
@@ -126480,8 +126576,8 @@ var ts;
126480
126576
  /** 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 */
126481
126577
  var pseudoInputUpToDate = false;
126482
126578
  // Get timestamps of input files
126483
- for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
126484
- var inputFile = _f[_e];
126579
+ for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) {
126580
+ var inputFile = _e[_d];
126485
126581
  var inputTime = getModifiedTime(state, inputFile);
126486
126582
  if (inputTime === ts.missingFileModifiedTime) {
126487
126583
  return {
@@ -126522,8 +126618,8 @@ var ts;
126522
126618
  // Collect the expected outputs of this project
126523
126619
  var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
126524
126620
  var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
126525
- for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
126526
- var output = outputs_1[_g];
126621
+ for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) {
126622
+ var output = outputs_1[_f];
126527
126623
  var path = toPath(state, output);
126528
126624
  // Output is missing; can stop checking
126529
126625
  var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
@@ -126561,8 +126657,8 @@ var ts;
126561
126657
  var usesPrepend = false;
126562
126658
  var upstreamChangedProject;
126563
126659
  if (referenceStatuses) {
126564
- for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
126565
- var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
126660
+ for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) {
126661
+ var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath;
126566
126662
  usesPrepend = usesPrepend || !!(ref.prepend);
126567
126663
  // If the upstream project's newest file is older than our oldest output, we
126568
126664
  // can't be out of date because of it
@@ -126579,7 +126675,8 @@ var ts;
126579
126675
  }
126580
126676
  // If the upstream project has only change .d.ts files, and we've built
126581
126677
  // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
126582
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126678
+ var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath);
126679
+ if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126583
126680
  pseudoUpToDate = true;
126584
126681
  upstreamChangedProject = ref.path;
126585
126682
  continue;
@@ -126622,7 +126719,6 @@ var ts;
126622
126719
  pseudoInputUpToDate ?
126623
126720
  ts.UpToDateStatusType.UpToDateWithInputFileText :
126624
126721
  ts.UpToDateStatusType.UpToDate,
126625
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
126626
126722
  newestInputFileTime: newestInputFileTime,
126627
126723
  newestInputFileName: newestInputFileName,
126628
126724
  oldestOutputFileName: oldestOutputFileName
@@ -126706,13 +126802,17 @@ var ts;
126706
126802
  outputTimeStampMap.delete(key);
126707
126803
  });
126708
126804
  }
126709
- function getDtsChangeTime(state, options, resolvedConfigPath) {
126710
- var _a;
126805
+ function getLatestChangedDtsTime(state, options, resolvedConfigPath) {
126711
126806
  if (!options.composite)
126712
126807
  return undefined;
126713
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126714
- var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126715
- 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;
126808
+ var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
126809
+ if (entry.latestChangedDtsTime !== undefined)
126810
+ return entry.latestChangedDtsTime || undefined;
126811
+ var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ?
126812
+ state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) :
126813
+ undefined;
126814
+ entry.latestChangedDtsTime = latestChangedDtsTime || false;
126815
+ return latestChangedDtsTime;
126716
126816
  }
126717
126817
  function updateOutputTimestamps(state, proj, resolvedPath) {
126718
126818
  if (state.options.dry) {
@@ -126721,7 +126821,6 @@ var ts;
126721
126821
  updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126722
126822
  state.projectStatus.set(resolvedPath, {
126723
126823
  type: ts.UpToDateStatusType.UpToDate,
126724
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
126725
126824
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
126726
126825
  });
126727
126826
  }
@@ -133966,37 +134065,36 @@ var ts;
133966
134065
  }
133967
134066
  }
133968
134067
  var entries = ts.createSortedArray();
133969
- if (isUncheckedFile(sourceFile, compilerOptions)) {
133970
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133971
- /*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);
133972
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133973
- }
133974
- else {
133975
- if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133976
- return undefined;
133977
- }
133978
- getCompletionEntriesFromSymbols(symbols, entries,
133979
- /*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);
134068
+ var isChecked = isCheckedFile(sourceFile, compilerOptions);
134069
+ if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
134070
+ return undefined;
133980
134071
  }
134072
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
134073
+ /*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);
133981
134074
  if (keywordFilters !== 0 /* None */) {
133982
- var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
133983
134075
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
133984
134076
  var keywordEntry = _a[_i];
133985
- if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) {
134077
+ if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
134078
+ uniqueNames.add(keywordEntry.name);
133986
134079
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133987
134080
  }
133988
134081
  }
133989
134082
  }
133990
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
133991
134083
  for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
133992
134084
  var keywordEntry = _c[_b];
133993
- if (!entryNames.has(keywordEntry.name)) {
134085
+ if (!uniqueNames.has(keywordEntry.name)) {
134086
+ uniqueNames.add(keywordEntry.name);
133994
134087
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133995
134088
  }
133996
134089
  }
133997
134090
  for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
133998
134091
  var literal = literals_1[_d];
133999
- ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
134092
+ var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal);
134093
+ uniqueNames.add(literalEntry.name);
134094
+ ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true);
134095
+ }
134096
+ if (!isChecked) {
134097
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
134000
134098
  }
134001
134099
  return {
134002
134100
  flags: completionData.flags,
@@ -134008,8 +134106,8 @@ var ts;
134008
134106
  entries: entries,
134009
134107
  };
134010
134108
  }
134011
- function isUncheckedFile(sourceFile, compilerOptions) {
134012
- return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
134109
+ function isCheckedFile(sourceFile, compilerOptions) {
134110
+ return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
134013
134111
  }
134014
134112
  function isMemberCompletionKind(kind) {
134015
134113
  switch (kind) {
@@ -134967,7 +135065,7 @@ var ts;
134967
135065
  }
134968
135066
  function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
134969
135067
  var typeChecker = program.getTypeChecker();
134970
- var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
135068
+ var inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
134971
135069
  var start = ts.timestamp();
134972
135070
  var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
134973
135071
  // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
@@ -135383,15 +135481,7 @@ var ts;
135383
135481
  isNewIdentifierLocation = true;
135384
135482
  }
135385
135483
  var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
135386
- if (inUncheckedFile) {
135387
- // In javascript files, for union types, we don't just get the members that
135388
- // the individual types have in common, we also include all the members that
135389
- // each individual type has. This is because we're going to add all identifiers
135390
- // anyways. So we might as well elevate the members that were at least part
135391
- // of the individual types to a higher status since we know what they are.
135392
- symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
135393
- }
135394
- else {
135484
+ if (inCheckedFile) {
135395
135485
  for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) {
135396
135486
  var symbol = _a[_i];
135397
135487
  if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
@@ -135399,6 +135489,14 @@ var ts;
135399
135489
  }
135400
135490
  }
135401
135491
  }
135492
+ else {
135493
+ // In javascript files, for union types, we don't just get the members that
135494
+ // the individual types have in common, we also include all the members that
135495
+ // each individual type has. This is because we're going to add all identifiers
135496
+ // anyways. So we might as well elevate the members that were at least part
135497
+ // of the individual types to a higher status since we know what they are.
135498
+ symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
135499
+ }
135402
135500
  if (insertAwait && preferences.includeCompletionsWithInsertText) {
135403
135501
  var promiseType = typeChecker.getPromisedTypeOfPromise(type);
135404
135502
  if (promiseType) {
@@ -155761,7 +155859,7 @@ var ts;
155761
155859
  if (!newConstraint)
155762
155860
  return;
155763
155861
  var newConstraintText = newConstraint[1];
155764
- changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155862
+ changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
155765
155863
  }
155766
155864
  function findAncestorMatchingSpan(sourceFile, span) {
155767
155865
  var token = ts.getTokenAtPosition(sourceFile, span.start);