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.
package/lib/tsserver.js CHANGED
@@ -96,7 +96,7 @@ var ts;
96
96
  // The following is baselined as a literal template type without intervention
97
97
  /** The version of the TypeScript compiler release */
98
98
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
99
- ts.version = ts.versionMajorMinor + ".0-dev.20210208";
99
+ ts.version = "4.2.2";
100
100
  /* @internal */
101
101
  var Comparison;
102
102
  (function (Comparison) {
@@ -3463,39 +3463,41 @@ var ts;
3463
3463
  /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */
3464
3464
  ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
3465
3465
  })(ts || (ts = {}));
3466
+ /* Tracing events for the compiler. */
3466
3467
  /*@internal*/
3467
- /** Tracing events for the compiler. */
3468
3468
  var ts;
3469
3469
  (function (ts) {
3470
- var tracing;
3471
- (function (tracing) {
3470
+ // enable the above using startTracing()
3471
+ })(ts || (ts = {}));
3472
+ // `tracingEnabled` should never be used directly, only through the above
3473
+ /* @internal */
3474
+ (function (ts) {
3475
+ var tracingEnabled;
3476
+ (function (tracingEnabled) {
3472
3477
  var Mode;
3473
3478
  (function (Mode) {
3474
3479
  Mode[Mode["Project"] = 0] = "Project";
3475
3480
  Mode[Mode["Build"] = 1] = "Build";
3476
3481
  Mode[Mode["Server"] = 2] = "Server";
3477
- })(Mode = tracing.Mode || (tracing.Mode = {}));
3482
+ })(Mode = tracingEnabled.Mode || (tracingEnabled.Mode = {}));
3478
3483
  var fs;
3479
3484
  var traceCount = 0;
3480
- var traceFd;
3485
+ var traceFd = 0;
3481
3486
  var mode;
3482
3487
  var legendPath;
3483
3488
  var legend = [];
3484
3489
  ;
3485
- /** Starts tracing for the given project (unless the `fs` module is unavailable). */
3490
+ /** Starts tracing for the given project. */
3486
3491
  function startTracing(tracingMode, traceDir, configFilePath) {
3487
- ts.Debug.assert(!traceFd, "Tracing already started");
3492
+ ts.Debug.assert(!ts.tracing, "Tracing already started");
3488
3493
  if (fs === undefined) {
3489
3494
  try {
3490
3495
  fs = require("fs");
3491
3496
  }
3492
- catch (_a) {
3493
- fs = false;
3497
+ catch (e) {
3498
+ throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")");
3494
3499
  }
3495
3500
  }
3496
- if (!fs) {
3497
- return;
3498
- }
3499
3501
  mode = tracingMode;
3500
3502
  if (legendPath === undefined) {
3501
3503
  legendPath = ts.combinePaths(traceDir, "legend.json");
@@ -3504,9 +3506,9 @@ var ts;
3504
3506
  if (!fs.existsSync(traceDir)) {
3505
3507
  fs.mkdirSync(traceDir, { recursive: true });
3506
3508
  }
3507
- var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount :
3508
- mode === 2 /* Server */ ? "." + process.pid :
3509
- "";
3509
+ var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount
3510
+ : mode === 2 /* Server */ ? "." + process.pid
3511
+ : "";
3510
3512
  var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json");
3511
3513
  var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json");
3512
3514
  legend.push({
@@ -3515,24 +3517,21 @@ var ts;
3515
3517
  typesPath: typesPath,
3516
3518
  });
3517
3519
  traceFd = fs.openSync(tracePath, "w");
3520
+ ts.tracing = tracingEnabled; // only when traceFd is properly set
3518
3521
  // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import)
3519
3522
  var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 };
3520
3523
  fs.writeSync(traceFd, "[\n"
3521
3524
  + [__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" })]
3522
3525
  .map(function (v) { return JSON.stringify(v); }).join(",\n"));
3523
3526
  }
3524
- tracing.startTracing = startTracing;
3525
- /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */
3527
+ tracingEnabled.startTracing = startTracing;
3528
+ /** Stops tracing for the in-progress project and dumps the type catalog. */
3526
3529
  function stopTracing(typeCatalog) {
3527
- if (!traceFd) {
3528
- ts.Debug.assert(!fs, "Tracing is not in progress");
3529
- return;
3530
- }
3531
- ts.Debug.assert(fs);
3530
+ ts.Debug.assert(ts.tracing, "Tracing is not in progress");
3532
3531
  ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode
3533
3532
  fs.writeSync(traceFd, "\n]\n");
3534
3533
  fs.closeSync(traceFd);
3535
- traceFd = undefined;
3534
+ ts.tracing = undefined;
3536
3535
  if (typeCatalog) {
3537
3536
  dumpTypes(typeCatalog);
3538
3537
  }
@@ -3542,11 +3541,7 @@ var ts;
3542
3541
  legend[legend.length - 1].typesPath = undefined;
3543
3542
  }
3544
3543
  }
3545
- tracing.stopTracing = stopTracing;
3546
- function isTracing() {
3547
- return !!traceFd;
3548
- }
3549
- tracing.isTracing = isTracing;
3544
+ tracingEnabled.stopTracing = stopTracing;
3550
3545
  var Phase;
3551
3546
  (function (Phase) {
3552
3547
  Phase["Parse"] = "parse";
@@ -3556,13 +3551,11 @@ var ts;
3556
3551
  Phase["CheckTypes"] = "checkTypes";
3557
3552
  Phase["Emit"] = "emit";
3558
3553
  Phase["Session"] = "session";
3559
- })(Phase = tracing.Phase || (tracing.Phase = {}));
3554
+ })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {}));
3560
3555
  function instant(phase, name, args) {
3561
- if (!traceFd)
3562
- return;
3563
3556
  writeEvent("I", phase, name, args, "\"s\":\"g\"");
3564
3557
  }
3565
- tracing.instant = instant;
3558
+ tracingEnabled.instant = instant;
3566
3559
  var eventStack = [];
3567
3560
  /**
3568
3561
  * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event
@@ -3572,45 +3565,40 @@ var ts;
3572
3565
  */
3573
3566
  function push(phase, name, args, separateBeginAndEnd) {
3574
3567
  if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; }
3575
- if (!traceFd)
3576
- return;
3577
3568
  if (separateBeginAndEnd) {
3578
3569
  writeEvent("B", phase, name, args);
3579
3570
  }
3580
3571
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
3581
3572
  }
3582
- tracing.push = push;
3573
+ tracingEnabled.push = push;
3583
3574
  function pop() {
3584
- if (!traceFd)
3585
- return;
3586
3575
  ts.Debug.assert(eventStack.length > 0);
3587
3576
  writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
3588
3577
  eventStack.length--;
3589
3578
  }
3590
- tracing.pop = pop;
3579
+ tracingEnabled.pop = pop;
3591
3580
  function popAll() {
3592
- if (!traceFd)
3593
- return;
3594
3581
  var endTime = 1000 * ts.timestamp();
3595
3582
  for (var i = eventStack.length - 1; i >= 0; i--) {
3596
3583
  writeStackEvent(i, endTime);
3597
3584
  }
3598
3585
  eventStack.length = 0;
3599
3586
  }
3600
- tracing.popAll = popAll;
3587
+ tracingEnabled.popAll = popAll;
3588
+ // sample every 10ms
3589
+ var sampleInterval = 1000 * 10;
3601
3590
  function writeStackEvent(index, endTime) {
3602
3591
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
3603
3592
  if (separateBeginAndEnd) {
3604
3593
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
3605
3594
  }
3606
- else {
3595
+ // test if [time,endTime) straddles a sampling point
3596
+ else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
3607
3597
  writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3608
3598
  }
3609
3599
  }
3610
3600
  function writeEvent(eventType, phase, name, args, extras, time) {
3611
3601
  if (time === void 0) { time = 1000 * ts.timestamp(); }
3612
- ts.Debug.assert(traceFd);
3613
- ts.Debug.assert(fs);
3614
3602
  // In server mode, there's no easy way to dump type information, so we drop events that would require it.
3615
3603
  if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */)
3616
3604
  return;
@@ -3632,7 +3620,6 @@ var ts;
3632
3620
  }
3633
3621
  function dumpTypes(types) {
3634
3622
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
3635
- ts.Debug.assert(fs);
3636
3623
  ts.performance.mark("beginDumpTypes");
3637
3624
  var typesPath = legend[legend.length - 1].typesPath;
3638
3625
  var typesFd = fs.openSync(typesPath, "w");
@@ -3712,11 +3699,15 @@ var ts;
3712
3699
  if (!legendPath) {
3713
3700
  return;
3714
3701
  }
3715
- ts.Debug.assert(fs);
3716
3702
  fs.writeFileSync(legendPath, JSON.stringify(legend));
3717
3703
  }
3718
- tracing.dumpLegend = dumpLegend;
3719
- })(tracing = ts.tracing || (ts.tracing = {}));
3704
+ tracingEnabled.dumpLegend = dumpLegend;
3705
+ })(tracingEnabled = ts.tracingEnabled || (ts.tracingEnabled = {}));
3706
+ })(ts || (ts = {}));
3707
+ /*@internal*/
3708
+ (function (ts) {
3709
+ // define after tracingEnabled is initialized
3710
+ ts.startTracing = ts.tracingEnabled.startTracing;
3720
3711
  })(ts || (ts = {}));
3721
3712
  var ts;
3722
3713
  (function (ts) {
@@ -18606,7 +18597,7 @@ var ts;
18606
18597
  }
18607
18598
  function Type(checker, flags) {
18608
18599
  this.flags = flags;
18609
- if (ts.Debug.isDebugging || ts.tracing.isTracing()) {
18600
+ if (ts.Debug.isDebugging || ts.tracing) {
18610
18601
  this.checker = checker;
18611
18602
  }
18612
18603
  }
@@ -28589,7 +28580,7 @@ var ts;
28589
28580
  }
28590
28581
  function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
28591
28582
  if (setParentNodes === void 0) { setParentNodes = false; }
28592
- ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
28583
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
28593
28584
  ts.performance.mark("beforeParse");
28594
28585
  var result;
28595
28586
  ts.perfLogger.logStartParseSourceFile(fileName);
@@ -28602,7 +28593,7 @@ var ts;
28602
28593
  ts.perfLogger.logStopParseSourceFile();
28603
28594
  ts.performance.mark("afterParse");
28604
28595
  ts.performance.measure("Parse", "beforeParse", "afterParse");
28605
- ts.tracing.pop();
28596
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
28606
28597
  return result;
28607
28598
  }
28608
28599
  ts.createSourceFile = createSourceFile;
@@ -40269,14 +40260,14 @@ var ts;
40269
40260
  }
40270
40261
  var binder = createBinder();
40271
40262
  function bindSourceFile(file, options) {
40272
- ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
40263
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
40273
40264
  ts.performance.mark("beforeBind");
40274
40265
  ts.perfLogger.logStartBindFile("" + file.fileName);
40275
40266
  binder(file, options);
40276
40267
  ts.perfLogger.logStopBindFile();
40277
40268
  ts.performance.mark("afterBind");
40278
40269
  ts.performance.measure("Bind", "beforeBind", "afterBind");
40279
- ts.tracing.pop();
40270
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
40280
40271
  }
40281
40272
  ts.bindSourceFile = bindSourceFile;
40282
40273
  function createBinder() {
@@ -55668,7 +55659,7 @@ var ts;
55668
55659
  // caps union types at 1000 unique object types.
55669
55660
  var estimatedCount = (count / (len - i)) * len;
55670
55661
  if (estimatedCount > 1000000) {
55671
- ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
55662
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
55672
55663
  error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
55673
55664
  return false;
55674
55665
  }
@@ -55686,7 +55677,7 @@ var ts;
55686
55677
  }
55687
55678
  return true;
55688
55679
  }
55689
- function removeRedundantLiteralTypes(types, includes) {
55680
+ function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) {
55690
55681
  var i = types.length;
55691
55682
  while (i > 0) {
55692
55683
  i--;
@@ -55696,7 +55687,7 @@ var ts;
55696
55687
  flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ ||
55697
55688
  flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ ||
55698
55689
  flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ ||
55699
- flags & 32768 /* Undefined */ && includes & 16384 /* Void */ ||
55690
+ reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ ||
55700
55691
  isFreshLiteralType(t) && containsType(types, t.regularType);
55701
55692
  if (remove) {
55702
55693
  ts.orderedRemoveItemAt(types, i);
@@ -55764,7 +55755,7 @@ var ts;
55764
55755
  }
55765
55756
  if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) {
55766
55757
  if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
55767
- removeRedundantLiteralTypes(typeSet, includes);
55758
+ removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
55768
55759
  }
55769
55760
  if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
55770
55761
  removeStringLiteralsMatchedByTemplateLiterals(typeSet);
@@ -56138,7 +56129,7 @@ var ts;
56138
56129
  function checkCrossProductUnion(types) {
56139
56130
  var size = getCrossProductUnionSize(types);
56140
56131
  if (size >= 100000) {
56141
- ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
56132
+ 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 });
56142
56133
  error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
56143
56134
  return false;
56144
56135
  }
@@ -57910,7 +57901,7 @@ var ts;
57910
57901
  // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing
57911
57902
  // with a combination of infinite generic types that perpetually generate new type identities. We stop
57912
57903
  // the recursion here by yielding the error type.
57913
- ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
57904
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
57914
57905
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
57915
57906
  return errorType;
57916
57907
  }
@@ -58946,7 +58937,7 @@ var ts;
58946
58937
  reportIncompatibleStack();
58947
58938
  }
58948
58939
  if (overflow) {
58949
- ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
58940
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
58950
58941
  var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
58951
58942
  if (errorOutputContainer) {
58952
58943
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -59397,7 +59388,7 @@ var ts;
59397
59388
  }
59398
59389
  }
59399
59390
  function traceUnionsOrIntersectionsTooLarge(source, target) {
59400
- if (!ts.tracing.isTracing()) {
59391
+ if (!ts.tracing) {
59401
59392
  return;
59402
59393
  }
59403
59394
  if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) {
@@ -59754,7 +59745,7 @@ var ts;
59754
59745
  };
59755
59746
  }
59756
59747
  if (expandingFlags === 3 /* Both */) {
59757
- ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
59748
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
59758
59749
  sourceId: source.id,
59759
59750
  sourceIdStack: sourceStack.map(function (t) { return t.id; }),
59760
59751
  targetId: target.id,
@@ -59789,9 +59780,9 @@ var ts;
59789
59780
  return result;
59790
59781
  }
59791
59782
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
59792
- ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
59783
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
59793
59784
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
59794
- ts.tracing.pop();
59785
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
59795
59786
  return result;
59796
59787
  }
59797
59788
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
@@ -60303,7 +60294,7 @@ var ts;
60303
60294
  numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
60304
60295
  if (numCombinations > 25) {
60305
60296
  // We've reached the complexity limit.
60306
- ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
60297
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
60307
60298
  return 0 /* False */;
60308
60299
  }
60309
60300
  }
@@ -61058,7 +61049,7 @@ var ts;
61058
61049
  if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
61059
61050
  var variances = cache.variances;
61060
61051
  if (!variances) {
61061
- 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 });
61052
+ 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 });
61062
61053
  // The emptyArray singleton is used to signal a recursive invocation.
61063
61054
  cache.variances = ts.emptyArray;
61064
61055
  variances = [];
@@ -61097,7 +61088,7 @@ var ts;
61097
61088
  _loop_19(tp);
61098
61089
  }
61099
61090
  cache.variances = variances;
61100
- ts.tracing.pop();
61091
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
61101
61092
  }
61102
61093
  return variances;
61103
61094
  }
@@ -63785,7 +63776,16 @@ var ts;
63785
63776
  var type = getTypeOfDottedName(node.expression, diagnostic);
63786
63777
  if (type) {
63787
63778
  var name = node.name;
63788
- var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText);
63779
+ var prop = void 0;
63780
+ if (ts.isPrivateIdentifier(name)) {
63781
+ if (!type.symbol) {
63782
+ return undefined;
63783
+ }
63784
+ prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText));
63785
+ }
63786
+ else {
63787
+ prop = getPropertyOfType(type, name.escapedText);
63788
+ }
63789
63789
  return prop && getExplicitTypeOfSymbol(prop, diagnostic);
63790
63790
  }
63791
63791
  return undefined;
@@ -63998,7 +63998,7 @@ var ts;
63998
63998
  if (flowDepth === 2000) {
63999
63999
  // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error
64000
64000
  // and disable further control flow analysis in the containing function or module body.
64001
- ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
64001
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
64002
64002
  flowAnalysisDisabled = true;
64003
64003
  reportFlowControlError(reference);
64004
64004
  return errorType;
@@ -64851,10 +64851,15 @@ var ts;
64851
64851
  return assignableType;
64852
64852
  }
64853
64853
  }
64854
- // If the candidate type is a subtype of the target type, narrow to the candidate type,
64855
- // if the target type is a subtype of the candidate type, narrow to the target type,
64856
- // otherwise, narrow to an intersection of the two types.
64857
- return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
64854
+ // If the candidate type is a subtype of the target type, narrow to the candidate type.
64855
+ // Otherwise, if the target type is assignable to the candidate type, keep the target type.
64856
+ // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate
64857
+ // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
64858
+ // two types.
64859
+ return isTypeSubtypeOf(candidate, type) ? candidate :
64860
+ isTypeAssignableTo(type, candidate) ? type :
64861
+ isTypeAssignableTo(candidate, type) ? candidate :
64862
+ getIntersectionType([type, candidate]);
64858
64863
  }
64859
64864
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
64860
64865
  if (hasMatchingArgument(callExpression, reference)) {
@@ -72625,7 +72630,7 @@ var ts;
72625
72630
  }
72626
72631
  }
72627
72632
  function checkExpression(node, checkMode, forceTuple) {
72628
- ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
72633
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
72629
72634
  var saveCurrentNode = currentNode;
72630
72635
  currentNode = node;
72631
72636
  instantiationCount = 0;
@@ -72635,7 +72640,7 @@ var ts;
72635
72640
  checkConstEnumAccess(node, type);
72636
72641
  }
72637
72642
  currentNode = saveCurrentNode;
72638
- ts.tracing.pop();
72643
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
72639
72644
  return type;
72640
72645
  }
72641
72646
  function checkConstEnumAccess(node, type) {
@@ -75157,10 +75162,10 @@ var ts;
75157
75162
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
75158
75163
  }
75159
75164
  function checkVariableDeclaration(node) {
75160
- ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
75165
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
75161
75166
  checkGrammarVariableDeclaration(node);
75162
75167
  checkVariableLikeDeclaration(node);
75163
- ts.tracing.pop();
75168
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
75164
75169
  }
75165
75170
  function checkBindingElement(node) {
75166
75171
  checkGrammarBindingElement(node);
@@ -75197,7 +75202,9 @@ var ts;
75197
75202
  : ts.isPropertyAccessExpression(location) ? location.name
75198
75203
  : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
75199
75204
  : undefined;
75200
- if (!testedNode) {
75205
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location)
75206
+ && ts.isAssertionExpression(ts.skipParentheses(location.expression));
75207
+ if (!testedNode || isPropertyExpressionCast) {
75201
75208
  return;
75202
75209
  }
75203
75210
  var possiblyFalsy = getFalsyFlags(type);
@@ -77967,7 +77974,7 @@ var ts;
77967
77974
  }
77968
77975
  }
77969
77976
  function checkDeferredNode(node) {
77970
- ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
77977
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
77971
77978
  var saveCurrentNode = currentNode;
77972
77979
  currentNode = node;
77973
77980
  instantiationCount = 0;
@@ -78003,15 +78010,15 @@ var ts;
78003
78010
  break;
78004
78011
  }
78005
78012
  currentNode = saveCurrentNode;
78006
- ts.tracing.pop();
78013
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
78007
78014
  }
78008
78015
  function checkSourceFile(node) {
78009
- ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
78016
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
78010
78017
  ts.performance.mark("beforeCheck");
78011
78018
  checkSourceFileWorker(node);
78012
78019
  ts.performance.mark("afterCheck");
78013
78020
  ts.performance.measure("Check", "beforeCheck", "afterCheck");
78014
- ts.tracing.pop();
78021
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
78015
78022
  }
78016
78023
  function unusedIsError(kind, isAmbient) {
78017
78024
  if (isAmbient) {
@@ -99988,9 +99995,9 @@ var ts;
99988
99995
  var transformed = [];
99989
99996
  for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
99990
99997
  var node = nodes_3[_a];
99991
- ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
99998
+ 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 });
99992
99999
  transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
99993
- ts.tracing.pop();
100000
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99994
100001
  }
99995
100002
  // prevent modification of the lexical environment.
99996
100003
  state = 2 /* Completed */;
@@ -100586,15 +100593,15 @@ var ts;
100586
100593
  sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
100587
100594
  };
100588
100595
  }
100589
- ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
100596
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
100590
100597
  emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
100591
- ts.tracing.pop();
100592
- ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
100598
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100599
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
100593
100600
  emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
100594
- ts.tracing.pop();
100595
- ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
100601
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100602
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
100596
100603
  emitBuildInfo(bundleBuildInfo, buildInfoPath);
100597
- ts.tracing.pop();
100604
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
100598
100605
  if (!emitSkipped && emittedFilesList) {
100599
100606
  if (!emitOnlyDtsFiles) {
100600
100607
  if (jsFilePath) {
@@ -106331,7 +106338,7 @@ var ts;
106331
106338
  var modulesWithElidedImports = new ts.Map();
106332
106339
  // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
106333
106340
  var sourceFilesFoundSearchingNodeModules = new ts.Map();
106334
- ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
106341
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
106335
106342
  ts.performance.mark("beforeProgram");
106336
106343
  var host = createProgramOptions.host || createCompilerHost(options);
106337
106344
  var configParsingHost = parseConfigHostFromCompilerHostLike(host);
@@ -106407,15 +106414,15 @@ var ts;
106407
106414
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
106408
106415
  forEachResolvedProjectReference: forEachResolvedProjectReference
106409
106416
  }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists;
106410
- ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
106417
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
106411
106418
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
106412
- ts.tracing.pop();
106419
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106413
106420
  // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
106414
106421
  // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
106415
106422
  var structureIsReused;
106416
- ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
106423
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
106417
106424
  structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
106418
- ts.tracing.pop();
106425
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106419
106426
  if (structureIsReused !== 2 /* Completely */) {
106420
106427
  processingDefaultLibFiles = [];
106421
106428
  processingOtherFiles = [];
@@ -106453,13 +106460,13 @@ var ts;
106453
106460
  });
106454
106461
  }
106455
106462
  }
106456
- ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length });
106463
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length });
106457
106464
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
106458
- ts.tracing.pop();
106465
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106459
106466
  // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
106460
106467
  var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
106461
106468
  if (typeReferences.length) {
106462
- ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
106469
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
106463
106470
  // This containingFilename needs to match with the one used in managed-side
106464
106471
  var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
106465
106472
  var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
@@ -106467,7 +106474,7 @@ var ts;
106467
106474
  for (var i = 0; i < typeReferences.length; i++) {
106468
106475
  processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId });
106469
106476
  }
106470
- ts.tracing.pop();
106477
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106471
106478
  }
106472
106479
  // Do not process the default library if:
106473
106480
  // - The '--noLib' flag is used.
@@ -106590,19 +106597,19 @@ var ts;
106590
106597
  verifyCompilerOptions();
106591
106598
  ts.performance.mark("afterProgram");
106592
106599
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
106593
- ts.tracing.pop();
106600
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106594
106601
  return program;
106595
106602
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
106596
106603
  if (!moduleNames.length)
106597
106604
  return ts.emptyArray;
106598
106605
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
106599
106606
  var redirectedReference = getRedirectReferenceForResolution(containingFile);
106600
- ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
106607
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
106601
106608
  ts.performance.mark("beforeResolveModule");
106602
106609
  var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
106603
106610
  ts.performance.mark("afterResolveModule");
106604
106611
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
106605
- ts.tracing.pop();
106612
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106606
106613
  return result;
106607
106614
  }
106608
106615
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -106610,12 +106617,12 @@ var ts;
106610
106617
  return [];
106611
106618
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
106612
106619
  var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
106613
- ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
106620
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
106614
106621
  ts.performance.mark("beforeResolveTypeReference");
106615
106622
  var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
106616
106623
  ts.performance.mark("afterResolveTypeReference");
106617
106624
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
106618
- ts.tracing.pop();
106625
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
106619
106626
  return result;
106620
106627
  }
106621
106628
  function getRedirectReferenceForResolution(file) {
@@ -107087,7 +107094,7 @@ var ts;
107087
107094
  }
107088
107095
  function emitBuildInfo(writeFileCallback) {
107089
107096
  ts.Debug.assert(!ts.outFile(options));
107090
- ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
107097
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
107091
107098
  ts.performance.mark("beforeEmit");
107092
107099
  var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback),
107093
107100
  /*targetSourceFile*/ undefined,
@@ -107096,7 +107103,7 @@ var ts;
107096
107103
  /*onlyBuildInfo*/ true);
107097
107104
  ts.performance.mark("afterEmit");
107098
107105
  ts.performance.measure("Emit", "beforeEmit", "afterEmit");
107099
- ts.tracing.pop();
107106
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
107100
107107
  return emitResult;
107101
107108
  }
107102
107109
  function getResolvedProjectReferences() {
@@ -107142,9 +107149,9 @@ var ts;
107142
107149
  return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
107143
107150
  }
107144
107151
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
107145
- ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
107152
+ 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);
107146
107153
  var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
107147
- ts.tracing.pop();
107154
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
107148
107155
  return result;
107149
107156
  }
107150
107157
  function isEmitBlocked(emitFileName) {
@@ -107805,13 +107812,13 @@ var ts;
107805
107812
  }
107806
107813
  // Get source file from normalized fileName
107807
107814
  function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
107808
- ts.tracing.push("program" /* Program */, "findSourceFile", {
107815
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", {
107809
107816
  fileName: fileName,
107810
107817
  isDefaultLib: isDefaultLib || undefined,
107811
107818
  fileIncludeKind: ts.FileIncludeKind[reason.kind],
107812
107819
  });
107813
107820
  var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
107814
- ts.tracing.pop();
107821
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
107815
107822
  return result;
107816
107823
  }
107817
107824
  function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -108070,9 +108077,9 @@ var ts;
108070
108077
  }
108071
108078
  }
108072
108079
  function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
108073
- ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
108080
+ 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 });
108074
108081
  processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
108075
- ts.tracing.pop();
108082
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
108076
108083
  }
108077
108084
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
108078
108085
  // If we already found this library as a primary reference - nothing to do
@@ -146970,13 +146977,13 @@ var ts;
146970
146977
  return { edits: [] }; // TODO: GH#30113
146971
146978
  }
146972
146979
  function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
146973
- var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
146974
- changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ",
146975
- // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
146976
- indentation: 0,
146977
- leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
146978
- trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include
146979
- });
146980
+ var signature = groupedReferences.signature;
146981
+ var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
146982
+ if (signature) {
146983
+ var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); });
146984
+ replaceParameters(signature, newSignatureParams);
146985
+ }
146986
+ replaceParameters(functionDeclaration, newFunctionDeclarationParams);
146980
146987
  var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); });
146981
146988
  for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) {
146982
146989
  var call = functionCalls_1[_i];
@@ -146985,6 +146992,15 @@ var ts;
146985
146992
  changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include });
146986
146993
  }
146987
146994
  }
146995
+ function replaceParameters(declarationOrSignature, parameterDeclarations) {
146996
+ changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, {
146997
+ joiner: ", ",
146998
+ // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
146999
+ indentation: 0,
147000
+ leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
147001
+ trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include
147002
+ });
147003
+ }
146988
147004
  }
146989
147005
  function getGroupedReferences(functionDeclaration, program, cancellationToken) {
146990
147006
  var functionNames = getFunctionNames(functionDeclaration);
@@ -147003,12 +147019,38 @@ var ts;
147003
147019
  var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation);
147004
147020
  var classSymbols = ts.map(classNames, getSymbolTargetAtLocation);
147005
147021
  var isConstructor = ts.isConstructorDeclaration(functionDeclaration);
147022
+ var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); });
147006
147023
  for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) {
147007
147024
  var entry = referenceEntries_1[_i];
147008
- if (entry.kind !== 1 /* Node */) {
147025
+ if (entry.kind === 0 /* Span */) {
147009
147026
  groupedReferences.valid = false;
147010
147027
  continue;
147011
147028
  }
147029
+ /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration
147030
+ For example:
147031
+ interface IFoo { m(a: number): void }
147032
+ const foo: IFoo = { m(a: number): void {} }
147033
+ In these cases we get the symbol for the signature from the contextual type.
147034
+ */
147035
+ if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) {
147036
+ if (isValidMethodSignature(entry.node.parent)) {
147037
+ groupedReferences.signature = entry.node.parent;
147038
+ continue;
147039
+ }
147040
+ var call = entryToFunctionCall(entry);
147041
+ if (call) {
147042
+ groupedReferences.functionCalls.push(call);
147043
+ continue;
147044
+ }
147045
+ }
147046
+ var contextualSymbol = getSymbolForContextualType(entry.node, checker);
147047
+ if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) {
147048
+ var decl = entryToDeclaration(entry);
147049
+ if (decl) {
147050
+ groupedReferences.declarations.push(decl);
147051
+ continue;
147052
+ }
147053
+ }
147012
147054
  /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function.
147013
147055
  Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test:
147014
147056
  class A { foo(a: number, b: number) { return a + b; } }
@@ -147071,6 +147113,19 @@ var ts;
147071
147113
  return symbol && ts.getSymbolTarget(symbol, checker);
147072
147114
  }
147073
147115
  }
147116
+ /**
147117
+ * Gets the symbol for the contextual type of the node if it is not a union or intersection.
147118
+ */
147119
+ function getSymbolForContextualType(node, checker) {
147120
+ var element = ts.getContainingObjectLiteralElement(node);
147121
+ if (element) {
147122
+ var contextualType = checker.getContextualTypeForObjectLiteralElement(element);
147123
+ var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol();
147124
+ if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) {
147125
+ return symbol;
147126
+ }
147127
+ }
147128
+ }
147074
147129
  function entryToImportOrExport(entry) {
147075
147130
  var node = entry.node;
147076
147131
  if (ts.isImportSpecifier(node.parent)
@@ -147178,6 +147233,9 @@ var ts;
147178
147233
  }
147179
147234
  return false;
147180
147235
  }
147236
+ function isValidMethodSignature(node) {
147237
+ return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent));
147238
+ }
147181
147239
  function isValidFunctionDeclaration(functionDeclaration, checker) {
147182
147240
  if (!isValidParameterNodeArray(functionDeclaration.parameters, checker))
147183
147241
  return false;
@@ -147185,6 +147243,11 @@ var ts;
147185
147243
  case 251 /* FunctionDeclaration */:
147186
147244
  return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker);
147187
147245
  case 165 /* MethodDeclaration */:
147246
+ if (ts.isObjectLiteralExpression(functionDeclaration.parent)) {
147247
+ var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker);
147248
+ // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change
147249
+ return (contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations.length) === 1 && isSingleImplementation(functionDeclaration, checker);
147250
+ }
147188
147251
  return isSingleImplementation(functionDeclaration, checker);
147189
147252
  case 166 /* Constructor */:
147190
147253
  if (ts.isClassDeclaration(functionDeclaration.parent)) {
@@ -148807,7 +148870,7 @@ var ts;
148807
148870
  };
148808
148871
  CancellationTokenObject.prototype.throwIfCancellationRequested = function () {
148809
148872
  if (this.isCancellationRequested()) {
148810
- ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
148873
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
148811
148874
  throw new ts.OperationCanceledException();
148812
148875
  }
148813
148876
  };
@@ -148837,7 +148900,7 @@ var ts;
148837
148900
  };
148838
148901
  ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () {
148839
148902
  if (this.isCancellationRequested()) {
148840
- ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
148903
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
148841
148904
  throw new ts.OperationCanceledException();
148842
148905
  }
148843
148906
  };
@@ -154424,6 +154487,10 @@ var ts;
154424
154487
  Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
154425
154488
  var _this = this;
154426
154489
  this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
154490
+ if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
154491
+ this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
154492
+ return;
154493
+ }
154427
154494
  var log = function (message) { return _this.projectService.logger.info(message); };
154428
154495
  var errorLogs;
154429
154496
  var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); };
@@ -158561,24 +158628,24 @@ var ts;
158561
158628
  try {
158562
158629
  if (this.operationHost.isCancellationRequested()) {
158563
158630
  stop = true;
158564
- ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true });
158631
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true });
158565
158632
  }
158566
158633
  else {
158567
- ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId });
158634
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId });
158568
158635
  action(this);
158569
- ts.tracing.pop();
158636
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
158570
158637
  }
158571
158638
  }
158572
158639
  catch (e) {
158573
158640
  // Cancellation or an error may have left incomplete events on the tracing stack.
158574
- ts.tracing.popAll();
158641
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll();
158575
158642
  stop = true;
158576
158643
  // ignore cancellation request
158577
158644
  if (e instanceof ts.OperationCanceledException) {
158578
- ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId });
158645
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId });
158579
158646
  }
158580
158647
  else {
158581
- ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message });
158648
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message });
158582
158649
  this.operationHost.logError(e, "delayed processing of request " + this.requestId);
158583
158650
  }
158584
158651
  }
@@ -159508,7 +159575,7 @@ var ts;
159508
159575
  this.host.write(msgText);
159509
159576
  };
159510
159577
  Session.prototype.event = function (body, eventName) {
159511
- ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
159578
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
159512
159579
  this.send(toEvent(eventName, body));
159513
159580
  };
159514
159581
  // For backwards-compatibility only.
@@ -160881,11 +160948,11 @@ var ts;
160881
160948
  try {
160882
160949
  request = this.parseMessage(message);
160883
160950
  relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined;
160884
- ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command });
160951
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command });
160885
160952
  ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100));
160886
- ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
160953
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
160887
160954
  var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired;
160888
- ts.tracing.pop();
160955
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
160889
160956
  if (this.logger.hasLevel(server.LogLevel.requestTime)) {
160890
160957
  var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4);
160891
160958
  if (responseRequired) {
@@ -160897,7 +160964,7 @@ var ts;
160897
160964
  }
160898
160965
  // Note: Log before writing the response, else the editor can complete its activity before the server does
160899
160966
  ts.perfLogger.logStopCommand("" + request.command, "Success");
160900
- ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response });
160967
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response });
160901
160968
  if (response) {
160902
160969
  this.doOutput(response, request.command, request.seq, /*success*/ true);
160903
160970
  }
@@ -160907,17 +160974,17 @@ var ts;
160907
160974
  }
160908
160975
  catch (err) {
160909
160976
  // Cancellation or an error may have left incomplete events on the tracing stack.
160910
- ts.tracing.popAll();
160977
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll();
160911
160978
  if (err instanceof ts.OperationCanceledException) {
160912
160979
  // Handle cancellation exceptions
160913
160980
  ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err);
160914
- 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 });
160981
+ 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 });
160915
160982
  this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true);
160916
160983
  return;
160917
160984
  }
160918
160985
  this.logErrorWorker(err, this.toStringMessage(message), relevantFile);
160919
160986
  ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err);
160920
- 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 });
160987
+ 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 });
160921
160988
  this.doOutput(
160922
160989
  /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0,
160923
160990
  /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack);
@@ -163538,9 +163605,7 @@ var ts;
163538
163605
  IOSession.prototype.exit = function () {
163539
163606
  this.logger.info("Exiting...");
163540
163607
  this.projectService.closeLog();
163541
- if (traceDir) {
163542
- ts.tracing.stopTracing(ts.emptyArray);
163543
- }
163608
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.stopTracing(ts.emptyArray);
163544
163609
  process.exit(0);
163545
163610
  };
163546
163611
  IOSession.prototype.listen = function () {
@@ -163567,7 +163632,7 @@ var ts;
163567
163632
  ? ts.stripQuotes(commandLineTraceDir)
163568
163633
  : process.env.TSS_TRACE;
163569
163634
  if (traceDir) {
163570
- ts.tracing.startTracing(2 /* Server */, traceDir);
163635
+ ts.startTracing(2 /* Server */, traceDir);
163571
163636
  }
163572
163637
  var ioSession = new IOSession();
163573
163638
  process.on("uncaughtException", function (err) {