typescript 4.2.0-dev.20210208 → 4.2.2

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.
@@ -290,7 +290,7 @@ var ts;
290
290
  // The following is baselined as a literal template type without intervention
291
291
  /** The version of the TypeScript compiler release */
292
292
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
293
- ts.version = ts.versionMajorMinor + ".0-dev.20210208";
293
+ ts.version = "4.2.2";
294
294
  /* @internal */
295
295
  var Comparison;
296
296
  (function (Comparison) {
@@ -3657,39 +3657,41 @@ var ts;
3657
3657
  /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */
3658
3658
  ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
3659
3659
  })(ts || (ts = {}));
3660
+ /* Tracing events for the compiler. */
3660
3661
  /*@internal*/
3661
- /** Tracing events for the compiler. */
3662
3662
  var ts;
3663
3663
  (function (ts) {
3664
- var tracing;
3665
- (function (tracing) {
3664
+ // enable the above using startTracing()
3665
+ })(ts || (ts = {}));
3666
+ // `tracingEnabled` should never be used directly, only through the above
3667
+ /* @internal */
3668
+ (function (ts) {
3669
+ var tracingEnabled;
3670
+ (function (tracingEnabled) {
3666
3671
  var Mode;
3667
3672
  (function (Mode) {
3668
3673
  Mode[Mode["Project"] = 0] = "Project";
3669
3674
  Mode[Mode["Build"] = 1] = "Build";
3670
3675
  Mode[Mode["Server"] = 2] = "Server";
3671
- })(Mode = tracing.Mode || (tracing.Mode = {}));
3676
+ })(Mode = tracingEnabled.Mode || (tracingEnabled.Mode = {}));
3672
3677
  var fs;
3673
3678
  var traceCount = 0;
3674
- var traceFd;
3679
+ var traceFd = 0;
3675
3680
  var mode;
3676
3681
  var legendPath;
3677
3682
  var legend = [];
3678
3683
  ;
3679
- /** Starts tracing for the given project (unless the `fs` module is unavailable). */
3684
+ /** Starts tracing for the given project. */
3680
3685
  function startTracing(tracingMode, traceDir, configFilePath) {
3681
- ts.Debug.assert(!traceFd, "Tracing already started");
3686
+ ts.Debug.assert(!ts.tracing, "Tracing already started");
3682
3687
  if (fs === undefined) {
3683
3688
  try {
3684
3689
  fs = require("fs");
3685
3690
  }
3686
- catch (_a) {
3687
- fs = false;
3691
+ catch (e) {
3692
+ throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")");
3688
3693
  }
3689
3694
  }
3690
- if (!fs) {
3691
- return;
3692
- }
3693
3695
  mode = tracingMode;
3694
3696
  if (legendPath === undefined) {
3695
3697
  legendPath = ts.combinePaths(traceDir, "legend.json");
@@ -3698,9 +3700,9 @@ var ts;
3698
3700
  if (!fs.existsSync(traceDir)) {
3699
3701
  fs.mkdirSync(traceDir, { recursive: true });
3700
3702
  }
3701
- var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount :
3702
- mode === 2 /* Server */ ? "." + process.pid :
3703
- "";
3703
+ var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount
3704
+ : mode === 2 /* Server */ ? "." + process.pid
3705
+ : "";
3704
3706
  var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json");
3705
3707
  var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json");
3706
3708
  legend.push({
@@ -3709,24 +3711,21 @@ var ts;
3709
3711
  typesPath: typesPath,
3710
3712
  });
3711
3713
  traceFd = fs.openSync(tracePath, "w");
3714
+ ts.tracing = tracingEnabled; // only when traceFd is properly set
3712
3715
  // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import)
3713
3716
  var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 };
3714
3717
  fs.writeSync(traceFd, "[\n"
3715
3718
  + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })]
3716
3719
  .map(function (v) { return JSON.stringify(v); }).join(",\n"));
3717
3720
  }
3718
- tracing.startTracing = startTracing;
3719
- /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */
3721
+ tracingEnabled.startTracing = startTracing;
3722
+ /** Stops tracing for the in-progress project and dumps the type catalog. */
3720
3723
  function stopTracing(typeCatalog) {
3721
- if (!traceFd) {
3722
- ts.Debug.assert(!fs, "Tracing is not in progress");
3723
- return;
3724
- }
3725
- ts.Debug.assert(fs);
3724
+ ts.Debug.assert(ts.tracing, "Tracing is not in progress");
3726
3725
  ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode
3727
3726
  fs.writeSync(traceFd, "\n]\n");
3728
3727
  fs.closeSync(traceFd);
3729
- traceFd = undefined;
3728
+ ts.tracing = undefined;
3730
3729
  if (typeCatalog) {
3731
3730
  dumpTypes(typeCatalog);
3732
3731
  }
@@ -3736,11 +3735,7 @@ var ts;
3736
3735
  legend[legend.length - 1].typesPath = undefined;
3737
3736
  }
3738
3737
  }
3739
- tracing.stopTracing = stopTracing;
3740
- function isTracing() {
3741
- return !!traceFd;
3742
- }
3743
- tracing.isTracing = isTracing;
3738
+ tracingEnabled.stopTracing = stopTracing;
3744
3739
  var Phase;
3745
3740
  (function (Phase) {
3746
3741
  Phase["Parse"] = "parse";
@@ -3750,13 +3745,11 @@ var ts;
3750
3745
  Phase["CheckTypes"] = "checkTypes";
3751
3746
  Phase["Emit"] = "emit";
3752
3747
  Phase["Session"] = "session";
3753
- })(Phase = tracing.Phase || (tracing.Phase = {}));
3748
+ })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {}));
3754
3749
  function instant(phase, name, args) {
3755
- if (!traceFd)
3756
- return;
3757
3750
  writeEvent("I", phase, name, args, "\"s\":\"g\"");
3758
3751
  }
3759
- tracing.instant = instant;
3752
+ tracingEnabled.instant = instant;
3760
3753
  var eventStack = [];
3761
3754
  /**
3762
3755
  * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event
@@ -3766,45 +3759,40 @@ var ts;
3766
3759
  */
3767
3760
  function push(phase, name, args, separateBeginAndEnd) {
3768
3761
  if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; }
3769
- if (!traceFd)
3770
- return;
3771
3762
  if (separateBeginAndEnd) {
3772
3763
  writeEvent("B", phase, name, args);
3773
3764
  }
3774
3765
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
3775
3766
  }
3776
- tracing.push = push;
3767
+ tracingEnabled.push = push;
3777
3768
  function pop() {
3778
- if (!traceFd)
3779
- return;
3780
3769
  ts.Debug.assert(eventStack.length > 0);
3781
3770
  writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
3782
3771
  eventStack.length--;
3783
3772
  }
3784
- tracing.pop = pop;
3773
+ tracingEnabled.pop = pop;
3785
3774
  function popAll() {
3786
- if (!traceFd)
3787
- return;
3788
3775
  var endTime = 1000 * ts.timestamp();
3789
3776
  for (var i = eventStack.length - 1; i >= 0; i--) {
3790
3777
  writeStackEvent(i, endTime);
3791
3778
  }
3792
3779
  eventStack.length = 0;
3793
3780
  }
3794
- tracing.popAll = popAll;
3781
+ tracingEnabled.popAll = popAll;
3782
+ // sample every 10ms
3783
+ var sampleInterval = 1000 * 10;
3795
3784
  function writeStackEvent(index, endTime) {
3796
3785
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
3797
3786
  if (separateBeginAndEnd) {
3798
3787
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
3799
3788
  }
3800
- else {
3789
+ // test if [time,endTime) straddles a sampling point
3790
+ else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
3801
3791
  writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3802
3792
  }
3803
3793
  }
3804
3794
  function writeEvent(eventType, phase, name, args, extras, time) {
3805
3795
  if (time === void 0) { time = 1000 * ts.timestamp(); }
3806
- ts.Debug.assert(traceFd);
3807
- ts.Debug.assert(fs);
3808
3796
  // In server mode, there's no easy way to dump type information, so we drop events that would require it.
3809
3797
  if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */)
3810
3798
  return;
@@ -3826,7 +3814,6 @@ var ts;
3826
3814
  }
3827
3815
  function dumpTypes(types) {
3828
3816
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
3829
- ts.Debug.assert(fs);
3830
3817
  ts.performance.mark("beginDumpTypes");
3831
3818
  var typesPath = legend[legend.length - 1].typesPath;
3832
3819
  var typesFd = fs.openSync(typesPath, "w");
@@ -3906,11 +3893,15 @@ var ts;
3906
3893
  if (!legendPath) {
3907
3894
  return;
3908
3895
  }
3909
- ts.Debug.assert(fs);
3910
3896
  fs.writeFileSync(legendPath, JSON.stringify(legend));
3911
3897
  }
3912
- tracing.dumpLegend = dumpLegend;
3913
- })(tracing = ts.tracing || (ts.tracing = {}));
3898
+ tracingEnabled.dumpLegend = dumpLegend;
3899
+ })(tracingEnabled = ts.tracingEnabled || (ts.tracingEnabled = {}));
3900
+ })(ts || (ts = {}));
3901
+ /*@internal*/
3902
+ (function (ts) {
3903
+ // define after tracingEnabled is initialized
3904
+ ts.startTracing = ts.tracingEnabled.startTracing;
3914
3905
  })(ts || (ts = {}));
3915
3906
  var ts;
3916
3907
  (function (ts) {
@@ -18800,7 +18791,7 @@ var ts;
18800
18791
  }
18801
18792
  function Type(checker, flags) {
18802
18793
  this.flags = flags;
18803
- if (ts.Debug.isDebugging || ts.tracing.isTracing()) {
18794
+ if (ts.Debug.isDebugging || ts.tracing) {
18804
18795
  this.checker = checker;
18805
18796
  }
18806
18797
  }
@@ -28783,7 +28774,7 @@ var ts;
28783
28774
  }
28784
28775
  function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
28785
28776
  if (setParentNodes === void 0) { setParentNodes = false; }
28786
- ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
28777
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
28787
28778
  ts.performance.mark("beforeParse");
28788
28779
  var result;
28789
28780
  ts.perfLogger.logStartParseSourceFile(fileName);
@@ -28796,7 +28787,7 @@ var ts;
28796
28787
  ts.perfLogger.logStopParseSourceFile();
28797
28788
  ts.performance.mark("afterParse");
28798
28789
  ts.performance.measure("Parse", "beforeParse", "afterParse");
28799
- ts.tracing.pop();
28790
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
28800
28791
  return result;
28801
28792
  }
28802
28793
  ts.createSourceFile = createSourceFile;
@@ -40463,14 +40454,14 @@ var ts;
40463
40454
  }
40464
40455
  var binder = createBinder();
40465
40456
  function bindSourceFile(file, options) {
40466
- ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
40457
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
40467
40458
  ts.performance.mark("beforeBind");
40468
40459
  ts.perfLogger.logStartBindFile("" + file.fileName);
40469
40460
  binder(file, options);
40470
40461
  ts.perfLogger.logStopBindFile();
40471
40462
  ts.performance.mark("afterBind");
40472
40463
  ts.performance.measure("Bind", "beforeBind", "afterBind");
40473
- ts.tracing.pop();
40464
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
40474
40465
  }
40475
40466
  ts.bindSourceFile = bindSourceFile;
40476
40467
  function createBinder() {
@@ -55862,7 +55853,7 @@ var ts;
55862
55853
  // caps union types at 1000 unique object types.
55863
55854
  var estimatedCount = (count / (len - i)) * len;
55864
55855
  if (estimatedCount > 1000000) {
55865
- ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
55856
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
55866
55857
  error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
55867
55858
  return false;
55868
55859
  }
@@ -55880,7 +55871,7 @@ var ts;
55880
55871
  }
55881
55872
  return true;
55882
55873
  }
55883
- function removeRedundantLiteralTypes(types, includes) {
55874
+ function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) {
55884
55875
  var i = types.length;
55885
55876
  while (i > 0) {
55886
55877
  i--;
@@ -55890,7 +55881,7 @@ var ts;
55890
55881
  flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ ||
55891
55882
  flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ ||
55892
55883
  flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ ||
55893
- flags & 32768 /* Undefined */ && includes & 16384 /* Void */ ||
55884
+ reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ ||
55894
55885
  isFreshLiteralType(t) && containsType(types, t.regularType);
55895
55886
  if (remove) {
55896
55887
  ts.orderedRemoveItemAt(types, i);
@@ -55958,7 +55949,7 @@ var ts;
55958
55949
  }
55959
55950
  if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) {
55960
55951
  if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
55961
- removeRedundantLiteralTypes(typeSet, includes);
55952
+ removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
55962
55953
  }
55963
55954
  if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
55964
55955
  removeStringLiteralsMatchedByTemplateLiterals(typeSet);
@@ -56332,7 +56323,7 @@ var ts;
56332
56323
  function checkCrossProductUnion(types) {
56333
56324
  var size = getCrossProductUnionSize(types);
56334
56325
  if (size >= 100000) {
56335
- ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
56326
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
56336
56327
  error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
56337
56328
  return false;
56338
56329
  }
@@ -58104,7 +58095,7 @@ var ts;
58104
58095
  // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing
58105
58096
  // with a combination of infinite generic types that perpetually generate new type identities. We stop
58106
58097
  // the recursion here by yielding the error type.
58107
- ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
58098
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
58108
58099
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
58109
58100
  return errorType;
58110
58101
  }
@@ -59140,7 +59131,7 @@ var ts;
59140
59131
  reportIncompatibleStack();
59141
59132
  }
59142
59133
  if (overflow) {
59143
- ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
59134
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
59144
59135
  var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
59145
59136
  if (errorOutputContainer) {
59146
59137
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -59591,7 +59582,7 @@ var ts;
59591
59582
  }
59592
59583
  }
59593
59584
  function traceUnionsOrIntersectionsTooLarge(source, target) {
59594
- if (!ts.tracing.isTracing()) {
59585
+ if (!ts.tracing) {
59595
59586
  return;
59596
59587
  }
59597
59588
  if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) {
@@ -59948,7 +59939,7 @@ var ts;
59948
59939
  };
59949
59940
  }
59950
59941
  if (expandingFlags === 3 /* Both */) {
59951
- ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
59942
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
59952
59943
  sourceId: source.id,
59953
59944
  sourceIdStack: sourceStack.map(function (t) { return t.id; }),
59954
59945
  targetId: target.id,
@@ -59983,9 +59974,9 @@ var ts;
59983
59974
  return result;
59984
59975
  }
59985
59976
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
59986
- ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
59977
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
59987
59978
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
59988
- ts.tracing.pop();
59979
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
59989
59980
  return result;
59990
59981
  }
59991
59982
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
@@ -60497,7 +60488,7 @@ var ts;
60497
60488
  numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
60498
60489
  if (numCombinations > 25) {
60499
60490
  // We've reached the complexity limit.
60500
- ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
60491
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
60501
60492
  return 0 /* False */;
60502
60493
  }
60503
60494
  }
@@ -61252,7 +61243,7 @@ var ts;
61252
61243
  if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
61253
61244
  var variances = cache.variances;
61254
61245
  if (!variances) {
61255
- ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 });
61246
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 });
61256
61247
  // The emptyArray singleton is used to signal a recursive invocation.
61257
61248
  cache.variances = ts.emptyArray;
61258
61249
  variances = [];
@@ -61291,7 +61282,7 @@ var ts;
61291
61282
  _loop_19(tp);
61292
61283
  }
61293
61284
  cache.variances = variances;
61294
- ts.tracing.pop();
61285
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
61295
61286
  }
61296
61287
  return variances;
61297
61288
  }
@@ -63979,7 +63970,16 @@ var ts;
63979
63970
  var type = getTypeOfDottedName(node.expression, diagnostic);
63980
63971
  if (type) {
63981
63972
  var name = node.name;
63982
- var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText);
63973
+ var prop = void 0;
63974
+ if (ts.isPrivateIdentifier(name)) {
63975
+ if (!type.symbol) {
63976
+ return undefined;
63977
+ }
63978
+ prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText));
63979
+ }
63980
+ else {
63981
+ prop = getPropertyOfType(type, name.escapedText);
63982
+ }
63983
63983
  return prop && getExplicitTypeOfSymbol(prop, diagnostic);
63984
63984
  }
63985
63985
  return undefined;
@@ -64192,7 +64192,7 @@ var ts;
64192
64192
  if (flowDepth === 2000) {
64193
64193
  // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error
64194
64194
  // and disable further control flow analysis in the containing function or module body.
64195
- ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
64195
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
64196
64196
  flowAnalysisDisabled = true;
64197
64197
  reportFlowControlError(reference);
64198
64198
  return errorType;
@@ -65045,10 +65045,15 @@ var ts;
65045
65045
  return assignableType;
65046
65046
  }
65047
65047
  }
65048
- // If the candidate type is a subtype of the target type, narrow to the candidate type,
65049
- // if the target type is a subtype of the candidate type, narrow to the target type,
65050
- // otherwise, narrow to an intersection of the two types.
65051
- return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
65048
+ // If the candidate type is a subtype of the target type, narrow to the candidate type.
65049
+ // Otherwise, if the target type is assignable to the candidate type, keep the target type.
65050
+ // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate
65051
+ // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
65052
+ // two types.
65053
+ return isTypeSubtypeOf(candidate, type) ? candidate :
65054
+ isTypeAssignableTo(type, candidate) ? type :
65055
+ isTypeAssignableTo(candidate, type) ? candidate :
65056
+ getIntersectionType([type, candidate]);
65052
65057
  }
65053
65058
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
65054
65059
  if (hasMatchingArgument(callExpression, reference)) {
@@ -72819,7 +72824,7 @@ var ts;
72819
72824
  }
72820
72825
  }
72821
72826
  function checkExpression(node, checkMode, forceTuple) {
72822
- ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
72827
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
72823
72828
  var saveCurrentNode = currentNode;
72824
72829
  currentNode = node;
72825
72830
  instantiationCount = 0;
@@ -72829,7 +72834,7 @@ var ts;
72829
72834
  checkConstEnumAccess(node, type);
72830
72835
  }
72831
72836
  currentNode = saveCurrentNode;
72832
- ts.tracing.pop();
72837
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
72833
72838
  return type;
72834
72839
  }
72835
72840
  function checkConstEnumAccess(node, type) {
@@ -75351,10 +75356,10 @@ var ts;
75351
75356
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
75352
75357
  }
75353
75358
  function checkVariableDeclaration(node) {
75354
- ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
75359
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
75355
75360
  checkGrammarVariableDeclaration(node);
75356
75361
  checkVariableLikeDeclaration(node);
75357
- ts.tracing.pop();
75362
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
75358
75363
  }
75359
75364
  function checkBindingElement(node) {
75360
75365
  checkGrammarBindingElement(node);
@@ -75391,7 +75396,9 @@ var ts;
75391
75396
  : ts.isPropertyAccessExpression(location) ? location.name
75392
75397
  : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
75393
75398
  : undefined;
75394
- if (!testedNode) {
75399
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location)
75400
+ && ts.isAssertionExpression(ts.skipParentheses(location.expression));
75401
+ if (!testedNode || isPropertyExpressionCast) {
75395
75402
  return;
75396
75403
  }
75397
75404
  var possiblyFalsy = getFalsyFlags(type);
@@ -78161,7 +78168,7 @@ var ts;
78161
78168
  }
78162
78169
  }
78163
78170
  function checkDeferredNode(node) {
78164
- ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
78171
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
78165
78172
  var saveCurrentNode = currentNode;
78166
78173
  currentNode = node;
78167
78174
  instantiationCount = 0;
@@ -78197,15 +78204,15 @@ var ts;
78197
78204
  break;
78198
78205
  }
78199
78206
  currentNode = saveCurrentNode;
78200
- ts.tracing.pop();
78207
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
78201
78208
  }
78202
78209
  function checkSourceFile(node) {
78203
- ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
78210
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
78204
78211
  ts.performance.mark("beforeCheck");
78205
78212
  checkSourceFileWorker(node);
78206
78213
  ts.performance.mark("afterCheck");
78207
78214
  ts.performance.measure("Check", "beforeCheck", "afterCheck");
78208
- ts.tracing.pop();
78215
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
78209
78216
  }
78210
78217
  function unusedIsError(kind, isAmbient) {
78211
78218
  if (isAmbient) {
@@ -100182,9 +100189,9 @@ var ts;
100182
100189
  var transformed = [];
100183
100190
  for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
100184
100191
  var node = nodes_3[_a];
100185
- ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
100192
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
100186
100193
  transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
100187
- ts.tracing.pop();
100194
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100188
100195
  }
100189
100196
  // prevent modification of the lexical environment.
100190
100197
  state = 2 /* Completed */;
@@ -100780,15 +100787,15 @@ var ts;
100780
100787
  sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
100781
100788
  };
100782
100789
  }
100783
- ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
100790
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
100784
100791
  emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
100785
- ts.tracing.pop();
100786
- ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
100792
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100793
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
100787
100794
  emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
100788
- ts.tracing.pop();
100789
- ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
100795
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100796
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
100790
100797
  emitBuildInfo(bundleBuildInfo, buildInfoPath);
100791
- ts.tracing.pop();
100798
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100792
100799
  if (!emitSkipped && emittedFilesList) {
100793
100800
  if (!emitOnlyDtsFiles) {
100794
100801
  if (jsFilePath) {
@@ -106525,7 +106532,7 @@ var ts;
106525
106532
  var modulesWithElidedImports = new ts.Map();
106526
106533
  // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
106527
106534
  var sourceFilesFoundSearchingNodeModules = new ts.Map();
106528
- ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
106535
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
106529
106536
  ts.performance.mark("beforeProgram");
106530
106537
  var host = createProgramOptions.host || createCompilerHost(options);
106531
106538
  var configParsingHost = parseConfigHostFromCompilerHostLike(host);
@@ -106601,15 +106608,15 @@ var ts;
106601
106608
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
106602
106609
  forEachResolvedProjectReference: forEachResolvedProjectReference
106603
106610
  }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists;
106604
- ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
106611
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
106605
106612
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
106606
- ts.tracing.pop();
106613
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106607
106614
  // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
106608
106615
  // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
106609
106616
  var structureIsReused;
106610
- ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
106617
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
106611
106618
  structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
106612
- ts.tracing.pop();
106619
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106613
106620
  if (structureIsReused !== 2 /* Completely */) {
106614
106621
  processingDefaultLibFiles = [];
106615
106622
  processingOtherFiles = [];
@@ -106647,13 +106654,13 @@ var ts;
106647
106654
  });
106648
106655
  }
106649
106656
  }
106650
- ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length });
106657
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length });
106651
106658
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
106652
- ts.tracing.pop();
106659
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106653
106660
  // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
106654
106661
  var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
106655
106662
  if (typeReferences.length) {
106656
- ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
106663
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
106657
106664
  // This containingFilename needs to match with the one used in managed-side
106658
106665
  var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
106659
106666
  var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
@@ -106661,7 +106668,7 @@ var ts;
106661
106668
  for (var i = 0; i < typeReferences.length; i++) {
106662
106669
  processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId });
106663
106670
  }
106664
- ts.tracing.pop();
106671
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106665
106672
  }
106666
106673
  // Do not process the default library if:
106667
106674
  // - The '--noLib' flag is used.
@@ -106784,19 +106791,19 @@ var ts;
106784
106791
  verifyCompilerOptions();
106785
106792
  ts.performance.mark("afterProgram");
106786
106793
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
106787
- ts.tracing.pop();
106794
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106788
106795
  return program;
106789
106796
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
106790
106797
  if (!moduleNames.length)
106791
106798
  return ts.emptyArray;
106792
106799
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
106793
106800
  var redirectedReference = getRedirectReferenceForResolution(containingFile);
106794
- ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
106801
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
106795
106802
  ts.performance.mark("beforeResolveModule");
106796
106803
  var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
106797
106804
  ts.performance.mark("afterResolveModule");
106798
106805
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
106799
- ts.tracing.pop();
106806
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106800
106807
  return result;
106801
106808
  }
106802
106809
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -106804,12 +106811,12 @@ var ts;
106804
106811
  return [];
106805
106812
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
106806
106813
  var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
106807
- ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
106814
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
106808
106815
  ts.performance.mark("beforeResolveTypeReference");
106809
106816
  var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
106810
106817
  ts.performance.mark("afterResolveTypeReference");
106811
106818
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
106812
- ts.tracing.pop();
106819
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106813
106820
  return result;
106814
106821
  }
106815
106822
  function getRedirectReferenceForResolution(file) {
@@ -107281,7 +107288,7 @@ var ts;
107281
107288
  }
107282
107289
  function emitBuildInfo(writeFileCallback) {
107283
107290
  ts.Debug.assert(!ts.outFile(options));
107284
- ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
107291
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
107285
107292
  ts.performance.mark("beforeEmit");
107286
107293
  var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback),
107287
107294
  /*targetSourceFile*/ undefined,
@@ -107290,7 +107297,7 @@ var ts;
107290
107297
  /*onlyBuildInfo*/ true);
107291
107298
  ts.performance.mark("afterEmit");
107292
107299
  ts.performance.measure("Emit", "beforeEmit", "afterEmit");
107293
- ts.tracing.pop();
107300
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
107294
107301
  return emitResult;
107295
107302
  }
107296
107303
  function getResolvedProjectReferences() {
@@ -107336,9 +107343,9 @@ var ts;
107336
107343
  return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
107337
107344
  }
107338
107345
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
107339
- ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
107346
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
107340
107347
  var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
107341
- ts.tracing.pop();
107348
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
107342
107349
  return result;
107343
107350
  }
107344
107351
  function isEmitBlocked(emitFileName) {
@@ -107999,13 +108006,13 @@ var ts;
107999
108006
  }
108000
108007
  // Get source file from normalized fileName
108001
108008
  function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
108002
- ts.tracing.push("program" /* Program */, "findSourceFile", {
108009
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", {
108003
108010
  fileName: fileName,
108004
108011
  isDefaultLib: isDefaultLib || undefined,
108005
108012
  fileIncludeKind: ts.FileIncludeKind[reason.kind],
108006
108013
  });
108007
108014
  var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
108008
- ts.tracing.pop();
108015
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
108009
108016
  return result;
108010
108017
  }
108011
108018
  function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -108264,9 +108271,9 @@ var ts;
108264
108271
  }
108265
108272
  }
108266
108273
  function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
108267
- ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
108274
+ 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 });
108268
108275
  processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
108269
- ts.tracing.pop();
108276
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
108270
108277
  }
108271
108278
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
108272
108279
  // If we already found this library as a primary reference - nothing to do
@@ -147539,13 +147546,13 @@ var ts;
147539
147546
  return { edits: [] }; // TODO: GH#30113
147540
147547
  }
147541
147548
  function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
147542
- var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
147543
- changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ",
147544
- // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
147545
- indentation: 0,
147546
- leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
147547
- trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include
147548
- });
147549
+ var signature = groupedReferences.signature;
147550
+ var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
147551
+ if (signature) {
147552
+ var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
147553
+ replaceParameters(signature, newSignatureParams);
147554
+ }
147555
+ replaceParameters(functionDeclaration, newFunctionDeclarationParams);
147549
147556
  var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); });
147550
147557
  for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) {
147551
147558
  var call = functionCalls_1[_i];
@@ -147554,6 +147561,15 @@ var ts;
147554
147561
  changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include });
147555
147562
  }
147556
147563
  }
147564
+ function replaceParameters(declarationOrSignature, parameterDeclarations) {
147565
+ changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, {
147566
+ joiner: ", ",
147567
+ // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
147568
+ indentation: 0,
147569
+ leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
147570
+ trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include
147571
+ });
147572
+ }
147557
147573
  }
147558
147574
  function getGroupedReferences(functionDeclaration, program, cancellationToken) {
147559
147575
  var functionNames = getFunctionNames(functionDeclaration);
@@ -147572,12 +147588,38 @@ var ts;
147572
147588
  var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation);
147573
147589
  var classSymbols = ts.map(classNames, getSymbolTargetAtLocation);
147574
147590
  var isConstructor = ts.isConstructorDeclaration(functionDeclaration);
147591
+ var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); });
147575
147592
  for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) {
147576
147593
  var entry = referenceEntries_1[_i];
147577
- if (entry.kind !== 1 /* Node */) {
147594
+ if (entry.kind === 0 /* Span */) {
147578
147595
  groupedReferences.valid = false;
147579
147596
  continue;
147580
147597
  }
147598
+ /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration
147599
+ For example:
147600
+ interface IFoo { m(a: number): void }
147601
+ const foo: IFoo = { m(a: number): void {} }
147602
+ In these cases we get the symbol for the signature from the contextual type.
147603
+ */
147604
+ if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) {
147605
+ if (isValidMethodSignature(entry.node.parent)) {
147606
+ groupedReferences.signature = entry.node.parent;
147607
+ continue;
147608
+ }
147609
+ var call = entryToFunctionCall(entry);
147610
+ if (call) {
147611
+ groupedReferences.functionCalls.push(call);
147612
+ continue;
147613
+ }
147614
+ }
147615
+ var contextualSymbol = getSymbolForContextualType(entry.node, checker);
147616
+ if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) {
147617
+ var decl = entryToDeclaration(entry);
147618
+ if (decl) {
147619
+ groupedReferences.declarations.push(decl);
147620
+ continue;
147621
+ }
147622
+ }
147581
147623
  /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function.
147582
147624
  Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test:
147583
147625
  class A { foo(a: number, b: number) { return a + b; } }
@@ -147640,6 +147682,19 @@ var ts;
147640
147682
  return symbol && ts.getSymbolTarget(symbol, checker);
147641
147683
  }
147642
147684
  }
147685
+ /**
147686
+ * Gets the symbol for the contextual type of the node if it is not a union or intersection.
147687
+ */
147688
+ function getSymbolForContextualType(node, checker) {
147689
+ var element = ts.getContainingObjectLiteralElement(node);
147690
+ if (element) {
147691
+ var contextualType = checker.getContextualTypeForObjectLiteralElement(element);
147692
+ var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol();
147693
+ if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) {
147694
+ return symbol;
147695
+ }
147696
+ }
147697
+ }
147643
147698
  function entryToImportOrExport(entry) {
147644
147699
  var node = entry.node;
147645
147700
  if (ts.isImportSpecifier(node.parent)
@@ -147747,6 +147802,9 @@ var ts;
147747
147802
  }
147748
147803
  return false;
147749
147804
  }
147805
+ function isValidMethodSignature(node) {
147806
+ return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent));
147807
+ }
147750
147808
  function isValidFunctionDeclaration(functionDeclaration, checker) {
147751
147809
  if (!isValidParameterNodeArray(functionDeclaration.parameters, checker))
147752
147810
  return false;
@@ -147754,6 +147812,11 @@ var ts;
147754
147812
  case 251 /* FunctionDeclaration */:
147755
147813
  return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker);
147756
147814
  case 165 /* MethodDeclaration */:
147815
+ if (ts.isObjectLiteralExpression(functionDeclaration.parent)) {
147816
+ var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker);
147817
+ // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change
147818
+ return (contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations.length) === 1 && isSingleImplementation(functionDeclaration, checker);
147819
+ }
147757
147820
  return isSingleImplementation(functionDeclaration, checker);
147758
147821
  case 166 /* Constructor */:
147759
147822
  if (ts.isClassDeclaration(functionDeclaration.parent)) {
@@ -149376,7 +149439,7 @@ var ts;
149376
149439
  };
149377
149440
  CancellationTokenObject.prototype.throwIfCancellationRequested = function () {
149378
149441
  if (this.isCancellationRequested()) {
149379
- ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
149442
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
149380
149443
  throw new ts.OperationCanceledException();
149381
149444
  }
149382
149445
  };
@@ -149406,7 +149469,7 @@ var ts;
149406
149469
  };
149407
149470
  ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () {
149408
149471
  if (this.isCancellationRequested()) {
149409
- ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
149472
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
149410
149473
  throw new ts.OperationCanceledException();
149411
149474
  }
149412
149475
  };
@@ -154618,6 +154681,10 @@ var ts;
154618
154681
  Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
154619
154682
  var _this = this;
154620
154683
  this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
154684
+ if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
154685
+ this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
154686
+ return;
154687
+ }
154621
154688
  var log = function (message) { return _this.projectService.logger.info(message); };
154622
154689
  var errorLogs;
154623
154690
  var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); };
@@ -158755,24 +158822,24 @@ var ts;
158755
158822
  try {
158756
158823
  if (this.operationHost.isCancellationRequested()) {
158757
158824
  stop = true;
158758
- ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true });
158825
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true });
158759
158826
  }
158760
158827
  else {
158761
- ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId });
158828
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId });
158762
158829
  action(this);
158763
- ts.tracing.pop();
158830
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
158764
158831
  }
158765
158832
  }
158766
158833
  catch (e) {
158767
158834
  // Cancellation or an error may have left incomplete events on the tracing stack.
158768
- ts.tracing.popAll();
158835
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll();
158769
158836
  stop = true;
158770
158837
  // ignore cancellation request
158771
158838
  if (e instanceof ts.OperationCanceledException) {
158772
- ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId });
158839
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId });
158773
158840
  }
158774
158841
  else {
158775
- ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message });
158842
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message });
158776
158843
  this.operationHost.logError(e, "delayed processing of request " + this.requestId);
158777
158844
  }
158778
158845
  }
@@ -159702,7 +159769,7 @@ var ts;
159702
159769
  this.host.write(msgText);
159703
159770
  };
159704
159771
  Session.prototype.event = function (body, eventName) {
159705
- ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
159772
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
159706
159773
  this.send(toEvent(eventName, body));
159707
159774
  };
159708
159775
  // For backwards-compatibility only.
@@ -161075,11 +161142,11 @@ var ts;
161075
161142
  try {
161076
161143
  request = this.parseMessage(message);
161077
161144
  relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined;
161078
- ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command });
161145
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command });
161079
161146
  ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100));
161080
- ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
161147
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
161081
161148
  var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired;
161082
- ts.tracing.pop();
161149
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
161083
161150
  if (this.logger.hasLevel(server.LogLevel.requestTime)) {
161084
161151
  var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4);
161085
161152
  if (responseRequired) {
@@ -161091,7 +161158,7 @@ var ts;
161091
161158
  }
161092
161159
  // Note: Log before writing the response, else the editor can complete its activity before the server does
161093
161160
  ts.perfLogger.logStopCommand("" + request.command, "Success");
161094
- ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response });
161161
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response });
161095
161162
  if (response) {
161096
161163
  this.doOutput(response, request.command, request.seq, /*success*/ true);
161097
161164
  }
@@ -161101,17 +161168,17 @@ var ts;
161101
161168
  }
161102
161169
  catch (err) {
161103
161170
  // Cancellation or an error may have left incomplete events on the tracing stack.
161104
- ts.tracing.popAll();
161171
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll();
161105
161172
  if (err instanceof ts.OperationCanceledException) {
161106
161173
  // Handle cancellation exceptions
161107
161174
  ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err);
161108
- ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command });
161175
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command });
161109
161176
  this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true);
161110
161177
  return;
161111
161178
  }
161112
161179
  this.logErrorWorker(err, this.toStringMessage(message), relevantFile);
161113
161180
  ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err);
161114
- ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message });
161181
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message });
161115
161182
  this.doOutput(
161116
161183
  /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0,
161117
161184
  /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack);