@typescript-deploys/pr-build 4.8.0-pr-49233-9 → 4.8.0-pr-48784-14

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
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220527";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -3510,16 +3510,34 @@ var ts;
3510
3510
  /** Performance measurements for the compiler. */
3511
3511
  var ts;
3512
3512
  (function (ts) {
3513
- var performance;
3514
- (function (performance) {
3513
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3514
+ ts.performance = createPerformanceTracker();
3515
+ ts.solutionPerformance = createPerformanceTracker();
3516
+ function createPerformanceTracker() {
3515
3517
  var perfHooks;
3516
3518
  // when set, indicates the implementation of `Performance` to use for user timing.
3517
3519
  // when unset, indicates user timing is unavailable or disabled.
3518
3520
  var performanceImpl;
3521
+ var enabled = false;
3522
+ var timeorigin = ts.timestamp();
3523
+ var marks = new ts.Map();
3524
+ var counts = new ts.Map();
3525
+ var durations = new ts.Map();
3526
+ return {
3527
+ createTimerIf: createTimerIf,
3528
+ createTimer: createTimer,
3529
+ mark: mark,
3530
+ measure: measure,
3531
+ getCount: getCount,
3532
+ getDuration: getDuration,
3533
+ forEachMeasure: forEachMeasure,
3534
+ isEnabled: isEnabled,
3535
+ enable: enable,
3536
+ disable: disable,
3537
+ };
3519
3538
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3520
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3539
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3521
3540
  }
3522
- performance.createTimerIf = createTimerIf;
3523
3541
  function createTimer(measureName, startMarkName, endMarkName) {
3524
3542
  var enterCount = 0;
3525
3543
  return {
@@ -3541,13 +3559,6 @@ var ts;
3541
3559
  }
3542
3560
  }
3543
3561
  }
3544
- performance.createTimer = createTimer;
3545
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3546
- var enabled = false;
3547
- var timeorigin = ts.timestamp();
3548
- var marks = new ts.Map();
3549
- var counts = new ts.Map();
3550
- var durations = new ts.Map();
3551
3562
  /**
3552
3563
  * Marks a performance event.
3553
3564
  *
@@ -3562,7 +3573,6 @@ var ts;
3562
3573
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3563
3574
  }
3564
3575
  }
3565
- performance.mark = mark;
3566
3576
  /**
3567
3577
  * Adds a performance measurement with the specified name.
3568
3578
  *
@@ -3575,14 +3585,13 @@ var ts;
3575
3585
  function measure(measureName, startMarkName, endMarkName) {
3576
3586
  var _a, _b;
3577
3587
  if (enabled) {
3578
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3579
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3588
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3589
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3580
3590
  var previousDuration = durations.get(measureName) || 0;
3581
3591
  durations.set(measureName, previousDuration + (end - start));
3582
3592
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3583
3593
  }
3584
3594
  }
3585
- performance.measure = measure;
3586
3595
  /**
3587
3596
  * Gets the number of times a marker was encountered.
3588
3597
  *
@@ -3591,7 +3600,6 @@ var ts;
3591
3600
  function getCount(markName) {
3592
3601
  return counts.get(markName) || 0;
3593
3602
  }
3594
- performance.getCount = getCount;
3595
3603
  /**
3596
3604
  * Gets the total duration of all measurements with the supplied name.
3597
3605
  *
@@ -3600,7 +3608,6 @@ var ts;
3600
3608
  function getDuration(measureName) {
3601
3609
  return durations.get(measureName) || 0;
3602
3610
  }
3603
- performance.getDuration = getDuration;
3604
3611
  /**
3605
3612
  * Iterate over each measure, performing some action
3606
3613
  *
@@ -3609,14 +3616,12 @@ var ts;
3609
3616
  function forEachMeasure(cb) {
3610
3617
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3611
3618
  }
3612
- performance.forEachMeasure = forEachMeasure;
3613
3619
  /**
3614
3620
  * Indicates whether the performance API is enabled.
3615
3621
  */
3616
3622
  function isEnabled() {
3617
3623
  return enabled;
3618
3624
  }
3619
- performance.isEnabled = isEnabled;
3620
3625
  /** Enables (and resets) performance measurements for the compiler. */
3621
3626
  function enable(system) {
3622
3627
  var _a;
@@ -3637,7 +3642,6 @@ var ts;
3637
3642
  }
3638
3643
  return true;
3639
3644
  }
3640
- performance.enable = enable;
3641
3645
  /** Disables performance measurements for the compiler. */
3642
3646
  function disable() {
3643
3647
  if (enabled) {
@@ -3648,8 +3652,7 @@ var ts;
3648
3652
  enabled = false;
3649
3653
  }
3650
3654
  }
3651
- performance.disable = disable;
3652
- })(performance = ts.performance || (ts.performance = {}));
3655
+ }
3653
3656
  })(ts || (ts = {}));
3654
3657
  /* @internal */
3655
3658
  var ts;
@@ -6192,7 +6195,7 @@ var ts;
6192
6195
  };
6193
6196
  }
6194
6197
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6195
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6198
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6196
6199
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6197
6200
  if (!ts.isString(relativeFileName))
6198
6201
  return;
@@ -6202,7 +6205,7 @@ var ts;
6202
6205
  if (callbacks) {
6203
6206
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6204
6207
  var fileCallback = callbacks_1[_i];
6205
- fileCallback(fileName, FileWatcherEventKind.Changed);
6208
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6206
6209
  }
6207
6210
  }
6208
6211
  },
@@ -6256,7 +6259,7 @@ var ts;
6256
6259
  }
6257
6260
  else {
6258
6261
  cache.set(path, {
6259
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6262
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6260
6263
  refCount: 1
6261
6264
  });
6262
6265
  }
@@ -6284,7 +6287,7 @@ var ts;
6284
6287
  var newTime = modifiedTime.getTime();
6285
6288
  if (oldTime !== newTime) {
6286
6289
  watchedFile.mtime = modifiedTime;
6287
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6290
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6288
6291
  return true;
6289
6292
  }
6290
6293
  return false;
@@ -6535,17 +6538,18 @@ var ts;
6535
6538
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6536
6539
  /*@internal*/
6537
6540
  function createFileWatcherCallback(callback) {
6538
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6541
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6539
6542
  }
6540
6543
  ts.createFileWatcherCallback = createFileWatcherCallback;
6541
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6542
- return function (eventName) {
6544
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6545
+ return function (eventName, _relativeFileName, modifiedTime) {
6543
6546
  if (eventName === "rename") {
6544
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6547
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6548
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6545
6549
  }
6546
6550
  else {
6547
6551
  // Change
6548
- callback(fileName, FileWatcherEventKind.Changed);
6552
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6549
6553
  }
6550
6554
  };
6551
6555
  }
@@ -6569,7 +6573,7 @@ var ts;
6569
6573
  }
6570
6574
  /*@internal*/
6571
6575
  function createSystemWatchFunctions(_a) {
6572
- var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6576
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6573
6577
  var dynamicPollingWatchFile;
6574
6578
  var fixedChunkSizePollingWatchFile;
6575
6579
  var nonPollingWatchFile;
@@ -6591,7 +6595,7 @@ var ts;
6591
6595
  case ts.WatchFileKind.FixedChunkSizePolling:
6592
6596
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6593
6597
  case ts.WatchFileKind.UseFsEvents:
6594
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6598
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6595
6599
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6596
6600
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6597
6601
  if (!nonPollingWatchFile) {
@@ -6773,7 +6777,6 @@ var ts;
6773
6777
  fsWatch: fsWatch,
6774
6778
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6775
6779
  getCurrentDirectory: getCurrentDirectory,
6776
- fileExists: fileExists,
6777
6780
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6778
6781
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6779
6782
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
@@ -7033,7 +7036,7 @@ var ts;
7033
7036
  // File changed
7034
7037
  eventKind = FileWatcherEventKind.Changed;
7035
7038
  }
7036
- callback(fileName, eventKind);
7039
+ callback(fileName, eventKind, curr.mtime);
7037
7040
  }
7038
7041
  }
7039
7042
  function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
@@ -7059,10 +7062,10 @@ var ts;
7059
7062
  * Invoke the callback with rename and update the watcher if not closed
7060
7063
  * @param createWatcher
7061
7064
  */
7062
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7065
+ function invokeCallbackAndUpdateWatcher(createWatcher, modifiedTime) {
7063
7066
  sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7064
7067
  // Call the callback for current directory
7065
- callback("rename", "");
7068
+ callback("rename", "", modifiedTime);
7066
7069
  // If watcher is not closed, update it
7067
7070
  if (watcher) {
7068
7071
  watcher.close();
@@ -7108,13 +7111,14 @@ var ts;
7108
7111
  function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7109
7112
  // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7110
7113
  // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7114
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
7111
7115
  return event === "rename" &&
7112
7116
  (!relativeName ||
7113
7117
  relativeName === lastDirectoryPart ||
7114
7118
  (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7115
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7116
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7117
- callback(event, relativeName);
7119
+ modifiedTime === ts.missingFileModifiedTime ?
7120
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry, modifiedTime) :
7121
+ callback(event, relativeName, modifiedTime);
7118
7122
  }
7119
7123
  /**
7120
7124
  * Watch the file or directory using fs.watchFile since fs.watch threw exception
@@ -7128,12 +7132,15 @@ var ts;
7128
7132
  * and switch to existing file or directory when the missing filesystem entry is created
7129
7133
  */
7130
7134
  function watchMissingFileSystemEntry() {
7131
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7132
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7133
- // Call the callback for current file or directory
7134
- // For now it could be callback for the inner directory creation,
7135
- // but just return current directory, better than current no-op
7136
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7135
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7136
+ if (eventKind === FileWatcherEventKind.Created) {
7137
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7138
+ if (modifiedTime !== ts.missingFileModifiedTime) {
7139
+ // Call the callback for current file or directory
7140
+ // For now it could be callback for the inner directory creation,
7141
+ // but just return current directory, better than current no-op
7142
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry, modifiedTime);
7143
+ }
7137
7144
  }
7138
7145
  }, fallbackPollingInterval, fallbackOptions);
7139
7146
  }
@@ -7283,12 +7290,19 @@ var ts;
7283
7290
  }
7284
7291
  function getModifiedTime(path) {
7285
7292
  var _a;
7293
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7294
+ // the CPU time performance.
7295
+ var originalStackTraceLimit = Error.stackTraceLimit;
7296
+ Error.stackTraceLimit = 0;
7286
7297
  try {
7287
7298
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7288
7299
  }
7289
7300
  catch (e) {
7290
7301
  return undefined;
7291
7302
  }
7303
+ finally {
7304
+ Error.stackTraceLimit = originalStackTraceLimit;
7305
+ }
7292
7306
  }
7293
7307
  function setModifiedTime(path, time) {
7294
7308
  try {
@@ -9309,8 +9323,8 @@ var ts;
9309
9323
  Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, ts.DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"),
9310
9324
  Output_file_0_from_project_1_does_not_exist: diag(6309, ts.DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"),
9311
9325
  Referenced_project_0_may_not_disable_emit: diag(6310, ts.DiagnosticCategory.Error, "Referenced_project_0_may_not_disable_emit_6310", "Referenced project '{0}' may not disable emit."),
9312
- Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2_6350", "Project '{0}' is out of date because oldest output '{1}' is older than newest input '{2}'"),
9313
- Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than oldest output '{2}'"),
9326
+ Project_0_is_out_of_date_because_output_1_is_older_than_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_1_is_older_than_input_2_6350", "Project '{0}' is out of date because output '{1}' is older than input '{2}'"),
9327
+ Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than output '{2}'"),
9314
9328
  Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"),
9315
9329
  Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"),
9316
9330
  Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"),
@@ -9354,6 +9368,8 @@ var ts;
9354
9368
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."),
9355
9369
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."),
9356
9370
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."),
9371
+ Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes are not emitted"),
9372
+ Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs update to timestamps of output files that are older than input files"),
9357
9373
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
9358
9374
  The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
9359
9375
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -16218,9 +16234,6 @@ var ts;
16218
16234
  }
16219
16235
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16220
16236
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16221
- if (node.kind === 203 /* BindingElement */) {
16222
- node = node.parent.parent;
16223
- }
16224
16237
  return ts.isVariableDeclaration(node) &&
16225
16238
  !!node.initializer &&
16226
16239
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20032,8 +20045,9 @@ var ts;
20032
20045
  */
20033
20046
  function isFileForcedToBeModuleByFormat(file) {
20034
20047
  // Excludes declaration files - they still require an explicit `export {}` or the like
20035
- // for back compat purposes.
20036
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20048
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20049
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20050
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20037
20051
  }
20038
20052
  function getSetExternalModuleIndicator(options) {
20039
20053
  // TODO: Should this callback be cached?
@@ -20041,7 +20055,7 @@ var ts;
20041
20055
  case ts.ModuleDetectionKind.Force:
20042
20056
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20043
20057
  return function (file) {
20044
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20058
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20045
20059
  };
20046
20060
  case ts.ModuleDetectionKind.Legacy:
20047
20061
  // Files are modules if they have imports, exports, or import.meta
@@ -20101,7 +20115,8 @@ var ts;
20101
20115
  }
20102
20116
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20103
20117
  function getEmitModuleDetectionKind(options) {
20104
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20118
+ return options.moduleDetection ||
20119
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20105
20120
  }
20106
20121
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20107
20122
  function hasJsonModuleEmitEnabled(options) {
@@ -20184,6 +20199,10 @@ var ts;
20184
20199
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20185
20200
  }
20186
20201
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20202
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20203
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20204
+ }
20205
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20187
20206
  function getCompilerOptionValue(options, option) {
20188
20207
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20189
20208
  }
@@ -39224,6 +39243,7 @@ var ts;
39224
39243
  type: "boolean",
39225
39244
  affectsSemanticDiagnostics: true,
39226
39245
  affectsEmit: true,
39246
+ affectsMultiFileEmitBuildInfo: true,
39227
39247
  category: ts.Diagnostics.Watch_and_Build_Modes,
39228
39248
  description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
39229
39249
  defaultValueDescription: false,
@@ -39258,12 +39278,40 @@ var ts;
39258
39278
  affectsSourceFile: true,
39259
39279
  affectsModuleResolution: true,
39260
39280
  affectsEmit: true,
39281
+ affectsMultiFileEmitBuildInfo: true,
39261
39282
  paramType: ts.Diagnostics.VERSION,
39262
39283
  showInSimplifiedHelpView: true,
39263
39284
  category: ts.Diagnostics.Language_and_Environment,
39264
39285
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39265
39286
  defaultValueDescription: 0 /* ES3 */,
39266
39287
  };
39288
+ /*@internal*/
39289
+ ts.moduleOptionDeclaration = {
39290
+ name: "module",
39291
+ shortName: "m",
39292
+ type: new ts.Map(ts.getEntries({
39293
+ none: ts.ModuleKind.None,
39294
+ commonjs: ts.ModuleKind.CommonJS,
39295
+ amd: ts.ModuleKind.AMD,
39296
+ system: ts.ModuleKind.System,
39297
+ umd: ts.ModuleKind.UMD,
39298
+ es6: ts.ModuleKind.ES2015,
39299
+ es2015: ts.ModuleKind.ES2015,
39300
+ es2020: ts.ModuleKind.ES2020,
39301
+ es2022: ts.ModuleKind.ES2022,
39302
+ esnext: ts.ModuleKind.ESNext,
39303
+ node16: ts.ModuleKind.Node16,
39304
+ nodenext: ts.ModuleKind.NodeNext,
39305
+ })),
39306
+ affectsModuleResolution: true,
39307
+ affectsEmit: true,
39308
+ affectsMultiFileEmitBuildInfo: true,
39309
+ paramType: ts.Diagnostics.KIND,
39310
+ showInSimplifiedHelpView: true,
39311
+ category: ts.Diagnostics.Modules,
39312
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39313
+ defaultValueDescription: undefined,
39314
+ };
39267
39315
  var commandOptionsWithoutBuild = [
39268
39316
  // CommandLine only options
39269
39317
  {
@@ -39325,37 +39373,14 @@ var ts;
39325
39373
  category: ts.Diagnostics.Command_line_Options,
39326
39374
  affectsSemanticDiagnostics: true,
39327
39375
  affectsEmit: true,
39376
+ affectsMultiFileEmitBuildInfo: true,
39328
39377
  isCommandLineOnly: true,
39329
39378
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39330
39379
  defaultValueDescription: false,
39331
39380
  },
39332
39381
  // Basic
39333
39382
  ts.targetOptionDeclaration,
39334
- {
39335
- name: "module",
39336
- shortName: "m",
39337
- type: new ts.Map(ts.getEntries({
39338
- none: ts.ModuleKind.None,
39339
- commonjs: ts.ModuleKind.CommonJS,
39340
- amd: ts.ModuleKind.AMD,
39341
- system: ts.ModuleKind.System,
39342
- umd: ts.ModuleKind.UMD,
39343
- es6: ts.ModuleKind.ES2015,
39344
- es2015: ts.ModuleKind.ES2015,
39345
- es2020: ts.ModuleKind.ES2020,
39346
- es2022: ts.ModuleKind.ES2022,
39347
- esnext: ts.ModuleKind.ESNext,
39348
- node16: ts.ModuleKind.Node16,
39349
- nodenext: ts.ModuleKind.NodeNext,
39350
- })),
39351
- affectsModuleResolution: true,
39352
- affectsEmit: true,
39353
- paramType: ts.Diagnostics.KIND,
39354
- showInSimplifiedHelpView: true,
39355
- category: ts.Diagnostics.Modules,
39356
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39357
- defaultValueDescription: undefined,
39358
- },
39383
+ ts.moduleOptionDeclaration,
39359
39384
  {
39360
39385
  name: "lib",
39361
39386
  type: "list",
@@ -39392,6 +39417,7 @@ var ts;
39392
39417
  type: jsxOptionMap,
39393
39418
  affectsSourceFile: true,
39394
39419
  affectsEmit: true,
39420
+ affectsMultiFileEmitBuildInfo: true,
39395
39421
  affectsModuleResolution: true,
39396
39422
  paramType: ts.Diagnostics.KIND,
39397
39423
  showInSimplifiedHelpView: true,
@@ -39404,6 +39430,7 @@ var ts;
39404
39430
  shortName: "d",
39405
39431
  type: "boolean",
39406
39432
  affectsEmit: true,
39433
+ affectsMultiFileEmitBuildInfo: true,
39407
39434
  showInSimplifiedHelpView: true,
39408
39435
  category: ts.Diagnostics.Emit,
39409
39436
  transpileOptionValue: undefined,
@@ -39414,6 +39441,7 @@ var ts;
39414
39441
  name: "declarationMap",
39415
39442
  type: "boolean",
39416
39443
  affectsEmit: true,
39444
+ affectsMultiFileEmitBuildInfo: true,
39417
39445
  showInSimplifiedHelpView: true,
39418
39446
  category: ts.Diagnostics.Emit,
39419
39447
  transpileOptionValue: undefined,
@@ -39424,6 +39452,7 @@ var ts;
39424
39452
  name: "emitDeclarationOnly",
39425
39453
  type: "boolean",
39426
39454
  affectsEmit: true,
39455
+ affectsMultiFileEmitBuildInfo: true,
39427
39456
  showInSimplifiedHelpView: true,
39428
39457
  category: ts.Diagnostics.Emit,
39429
39458
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39434,6 +39463,7 @@ var ts;
39434
39463
  name: "sourceMap",
39435
39464
  type: "boolean",
39436
39465
  affectsEmit: true,
39466
+ affectsMultiFileEmitBuildInfo: true,
39437
39467
  showInSimplifiedHelpView: true,
39438
39468
  category: ts.Diagnostics.Emit,
39439
39469
  defaultValueDescription: false,
@@ -39443,6 +39473,9 @@ var ts;
39443
39473
  name: "outFile",
39444
39474
  type: "string",
39445
39475
  affectsEmit: true,
39476
+ affectsMultiFileEmitBuildInfo: true,
39477
+ affectsDeclarationPath: true,
39478
+ affectsBundleEmitBuildInfo: true,
39446
39479
  isFilePath: true,
39447
39480
  paramType: ts.Diagnostics.FILE,
39448
39481
  showInSimplifiedHelpView: true,
@@ -39454,6 +39487,8 @@ var ts;
39454
39487
  name: "outDir",
39455
39488
  type: "string",
39456
39489
  affectsEmit: true,
39490
+ affectsMultiFileEmitBuildInfo: true,
39491
+ affectsDeclarationPath: true,
39457
39492
  isFilePath: true,
39458
39493
  paramType: ts.Diagnostics.DIRECTORY,
39459
39494
  showInSimplifiedHelpView: true,
@@ -39464,6 +39499,8 @@ var ts;
39464
39499
  name: "rootDir",
39465
39500
  type: "string",
39466
39501
  affectsEmit: true,
39502
+ affectsMultiFileEmitBuildInfo: true,
39503
+ affectsDeclarationPath: true,
39467
39504
  isFilePath: true,
39468
39505
  paramType: ts.Diagnostics.LOCATION,
39469
39506
  category: ts.Diagnostics.Modules,
@@ -39474,6 +39511,8 @@ var ts;
39474
39511
  name: "composite",
39475
39512
  type: "boolean",
39476
39513
  affectsEmit: true,
39514
+ affectsMultiFileEmitBuildInfo: true,
39515
+ affectsBundleEmitBuildInfo: true,
39477
39516
  isTSConfigOnly: true,
39478
39517
  category: ts.Diagnostics.Projects,
39479
39518
  transpileOptionValue: undefined,
@@ -39484,6 +39523,8 @@ var ts;
39484
39523
  name: "tsBuildInfoFile",
39485
39524
  type: "string",
39486
39525
  affectsEmit: true,
39526
+ affectsMultiFileEmitBuildInfo: true,
39527
+ affectsBundleEmitBuildInfo: true,
39487
39528
  isFilePath: true,
39488
39529
  paramType: ts.Diagnostics.FILE,
39489
39530
  category: ts.Diagnostics.Projects,
@@ -39495,6 +39536,7 @@ var ts;
39495
39536
  name: "removeComments",
39496
39537
  type: "boolean",
39497
39538
  affectsEmit: true,
39539
+ affectsMultiFileEmitBuildInfo: true,
39498
39540
  showInSimplifiedHelpView: true,
39499
39541
  category: ts.Diagnostics.Emit,
39500
39542
  defaultValueDescription: false,
@@ -39513,6 +39555,7 @@ var ts;
39513
39555
  name: "importHelpers",
39514
39556
  type: "boolean",
39515
39557
  affectsEmit: true,
39558
+ affectsMultiFileEmitBuildInfo: true,
39516
39559
  category: ts.Diagnostics.Emit,
39517
39560
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39518
39561
  defaultValueDescription: false,
@@ -39526,6 +39569,7 @@ var ts;
39526
39569
  })),
39527
39570
  affectsEmit: true,
39528
39571
  affectsSemanticDiagnostics: true,
39572
+ affectsMultiFileEmitBuildInfo: true,
39529
39573
  category: ts.Diagnostics.Emit,
39530
39574
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39531
39575
  defaultValueDescription: 0 /* Remove */,
@@ -39534,6 +39578,7 @@ var ts;
39534
39578
  name: "downlevelIteration",
39535
39579
  type: "boolean",
39536
39580
  affectsEmit: true,
39581
+ affectsMultiFileEmitBuildInfo: true,
39537
39582
  category: ts.Diagnostics.Emit,
39538
39583
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39539
39584
  defaultValueDescription: false,
@@ -39552,6 +39597,9 @@ var ts;
39552
39597
  type: "boolean",
39553
39598
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39554
39599
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39600
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39601
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39602
+ affectsMultiFileEmitBuildInfo: true,
39555
39603
  showInSimplifiedHelpView: true,
39556
39604
  category: ts.Diagnostics.Type_Checking,
39557
39605
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39561,6 +39609,7 @@ var ts;
39561
39609
  name: "noImplicitAny",
39562
39610
  type: "boolean",
39563
39611
  affectsSemanticDiagnostics: true,
39612
+ affectsMultiFileEmitBuildInfo: true,
39564
39613
  strictFlag: true,
39565
39614
  category: ts.Diagnostics.Type_Checking,
39566
39615
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39570,6 +39619,7 @@ var ts;
39570
39619
  name: "strictNullChecks",
39571
39620
  type: "boolean",
39572
39621
  affectsSemanticDiagnostics: true,
39622
+ affectsMultiFileEmitBuildInfo: true,
39573
39623
  strictFlag: true,
39574
39624
  category: ts.Diagnostics.Type_Checking,
39575
39625
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39578,6 +39628,8 @@ var ts;
39578
39628
  {
39579
39629
  name: "strictFunctionTypes",
39580
39630
  type: "boolean",
39631
+ affectsSemanticDiagnostics: true,
39632
+ affectsMultiFileEmitBuildInfo: true,
39581
39633
  strictFlag: true,
39582
39634
  category: ts.Diagnostics.Type_Checking,
39583
39635
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39586,6 +39638,8 @@ var ts;
39586
39638
  {
39587
39639
  name: "strictBindCallApply",
39588
39640
  type: "boolean",
39641
+ affectsSemanticDiagnostics: true,
39642
+ affectsMultiFileEmitBuildInfo: true,
39589
39643
  strictFlag: true,
39590
39644
  category: ts.Diagnostics.Type_Checking,
39591
39645
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39595,6 +39649,7 @@ var ts;
39595
39649
  name: "strictPropertyInitialization",
39596
39650
  type: "boolean",
39597
39651
  affectsSemanticDiagnostics: true,
39652
+ affectsMultiFileEmitBuildInfo: true,
39598
39653
  strictFlag: true,
39599
39654
  category: ts.Diagnostics.Type_Checking,
39600
39655
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39604,6 +39659,7 @@ var ts;
39604
39659
  name: "noImplicitThis",
39605
39660
  type: "boolean",
39606
39661
  affectsSemanticDiagnostics: true,
39662
+ affectsMultiFileEmitBuildInfo: true,
39607
39663
  strictFlag: true,
39608
39664
  category: ts.Diagnostics.Type_Checking,
39609
39665
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39613,6 +39669,7 @@ var ts;
39613
39669
  name: "useUnknownInCatchVariables",
39614
39670
  type: "boolean",
39615
39671
  affectsSemanticDiagnostics: true,
39672
+ affectsMultiFileEmitBuildInfo: true,
39616
39673
  strictFlag: true,
39617
39674
  category: ts.Diagnostics.Type_Checking,
39618
39675
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39622,6 +39679,8 @@ var ts;
39622
39679
  name: "alwaysStrict",
39623
39680
  type: "boolean",
39624
39681
  affectsSourceFile: true,
39682
+ affectsEmit: true,
39683
+ affectsMultiFileEmitBuildInfo: true,
39625
39684
  strictFlag: true,
39626
39685
  category: ts.Diagnostics.Type_Checking,
39627
39686
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39632,6 +39691,7 @@ var ts;
39632
39691
  name: "noUnusedLocals",
39633
39692
  type: "boolean",
39634
39693
  affectsSemanticDiagnostics: true,
39694
+ affectsMultiFileEmitBuildInfo: true,
39635
39695
  category: ts.Diagnostics.Type_Checking,
39636
39696
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39637
39697
  defaultValueDescription: false,
@@ -39640,6 +39700,7 @@ var ts;
39640
39700
  name: "noUnusedParameters",
39641
39701
  type: "boolean",
39642
39702
  affectsSemanticDiagnostics: true,
39703
+ affectsMultiFileEmitBuildInfo: true,
39643
39704
  category: ts.Diagnostics.Type_Checking,
39644
39705
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39645
39706
  defaultValueDescription: false,
@@ -39648,6 +39709,7 @@ var ts;
39648
39709
  name: "exactOptionalPropertyTypes",
39649
39710
  type: "boolean",
39650
39711
  affectsSemanticDiagnostics: true,
39712
+ affectsMultiFileEmitBuildInfo: true,
39651
39713
  category: ts.Diagnostics.Type_Checking,
39652
39714
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39653
39715
  defaultValueDescription: false,
@@ -39656,6 +39718,7 @@ var ts;
39656
39718
  name: "noImplicitReturns",
39657
39719
  type: "boolean",
39658
39720
  affectsSemanticDiagnostics: true,
39721
+ affectsMultiFileEmitBuildInfo: true,
39659
39722
  category: ts.Diagnostics.Type_Checking,
39660
39723
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39661
39724
  defaultValueDescription: false,
@@ -39665,6 +39728,7 @@ var ts;
39665
39728
  type: "boolean",
39666
39729
  affectsBindDiagnostics: true,
39667
39730
  affectsSemanticDiagnostics: true,
39731
+ affectsMultiFileEmitBuildInfo: true,
39668
39732
  category: ts.Diagnostics.Type_Checking,
39669
39733
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39670
39734
  defaultValueDescription: false,
@@ -39673,6 +39737,7 @@ var ts;
39673
39737
  name: "noUncheckedIndexedAccess",
39674
39738
  type: "boolean",
39675
39739
  affectsSemanticDiagnostics: true,
39740
+ affectsMultiFileEmitBuildInfo: true,
39676
39741
  category: ts.Diagnostics.Type_Checking,
39677
39742
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39678
39743
  defaultValueDescription: false,
@@ -39681,6 +39746,7 @@ var ts;
39681
39746
  name: "noImplicitOverride",
39682
39747
  type: "boolean",
39683
39748
  affectsSemanticDiagnostics: true,
39749
+ affectsMultiFileEmitBuildInfo: true,
39684
39750
  category: ts.Diagnostics.Type_Checking,
39685
39751
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39686
39752
  defaultValueDescription: false,
@@ -39688,6 +39754,8 @@ var ts;
39688
39754
  {
39689
39755
  name: "noPropertyAccessFromIndexSignature",
39690
39756
  type: "boolean",
39757
+ affectsSemanticDiagnostics: true,
39758
+ affectsMultiFileEmitBuildInfo: true,
39691
39759
  showInSimplifiedHelpView: false,
39692
39760
  category: ts.Diagnostics.Type_Checking,
39693
39761
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39773,6 +39841,7 @@ var ts;
39773
39841
  name: "allowSyntheticDefaultImports",
39774
39842
  type: "boolean",
39775
39843
  affectsSemanticDiagnostics: true,
39844
+ affectsMultiFileEmitBuildInfo: true,
39776
39845
  category: ts.Diagnostics.Interop_Constraints,
39777
39846
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39778
39847
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39782,6 +39851,7 @@ var ts;
39782
39851
  type: "boolean",
39783
39852
  affectsSemanticDiagnostics: true,
39784
39853
  affectsEmit: true,
39854
+ affectsMultiFileEmitBuildInfo: true,
39785
39855
  showInSimplifiedHelpView: true,
39786
39856
  category: ts.Diagnostics.Interop_Constraints,
39787
39857
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39798,6 +39868,7 @@ var ts;
39798
39868
  name: "allowUmdGlobalAccess",
39799
39869
  type: "boolean",
39800
39870
  affectsSemanticDiagnostics: true,
39871
+ affectsMultiFileEmitBuildInfo: true,
39801
39872
  category: ts.Diagnostics.Modules,
39802
39873
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39803
39874
  defaultValueDescription: false,
@@ -39819,6 +39890,7 @@ var ts;
39819
39890
  name: "sourceRoot",
39820
39891
  type: "string",
39821
39892
  affectsEmit: true,
39893
+ affectsMultiFileEmitBuildInfo: true,
39822
39894
  paramType: ts.Diagnostics.LOCATION,
39823
39895
  category: ts.Diagnostics.Emit,
39824
39896
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39827,6 +39899,7 @@ var ts;
39827
39899
  name: "mapRoot",
39828
39900
  type: "string",
39829
39901
  affectsEmit: true,
39902
+ affectsMultiFileEmitBuildInfo: true,
39830
39903
  paramType: ts.Diagnostics.LOCATION,
39831
39904
  category: ts.Diagnostics.Emit,
39832
39905
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39835,6 +39908,7 @@ var ts;
39835
39908
  name: "inlineSourceMap",
39836
39909
  type: "boolean",
39837
39910
  affectsEmit: true,
39911
+ affectsMultiFileEmitBuildInfo: true,
39838
39912
  category: ts.Diagnostics.Emit,
39839
39913
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39840
39914
  defaultValueDescription: false,
@@ -39843,6 +39917,7 @@ var ts;
39843
39917
  name: "inlineSources",
39844
39918
  type: "boolean",
39845
39919
  affectsEmit: true,
39920
+ affectsMultiFileEmitBuildInfo: true,
39846
39921
  category: ts.Diagnostics.Emit,
39847
39922
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39848
39923
  defaultValueDescription: false,
@@ -39852,6 +39927,7 @@ var ts;
39852
39927
  name: "experimentalDecorators",
39853
39928
  type: "boolean",
39854
39929
  affectsSemanticDiagnostics: true,
39930
+ affectsMultiFileEmitBuildInfo: true,
39855
39931
  category: ts.Diagnostics.Language_and_Environment,
39856
39932
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39857
39933
  defaultValueDescription: false,
@@ -39861,6 +39937,7 @@ var ts;
39861
39937
  type: "boolean",
39862
39938
  affectsSemanticDiagnostics: true,
39863
39939
  affectsEmit: true,
39940
+ affectsMultiFileEmitBuildInfo: true,
39864
39941
  category: ts.Diagnostics.Language_and_Environment,
39865
39942
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39866
39943
  defaultValueDescription: false,
@@ -39885,6 +39962,7 @@ var ts;
39885
39962
  type: "string",
39886
39963
  affectsSemanticDiagnostics: true,
39887
39964
  affectsEmit: true,
39965
+ affectsMultiFileEmitBuildInfo: true,
39888
39966
  affectsModuleResolution: true,
39889
39967
  category: ts.Diagnostics.Language_and_Environment,
39890
39968
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39902,6 +39980,9 @@ var ts;
39902
39980
  name: "out",
39903
39981
  type: "string",
39904
39982
  affectsEmit: true,
39983
+ affectsMultiFileEmitBuildInfo: true,
39984
+ affectsDeclarationPath: true,
39985
+ affectsBundleEmitBuildInfo: true,
39905
39986
  isFilePath: false,
39906
39987
  // for correct behaviour, please use outFile
39907
39988
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39913,6 +39994,7 @@ var ts;
39913
39994
  name: "reactNamespace",
39914
39995
  type: "string",
39915
39996
  affectsEmit: true,
39997
+ affectsMultiFileEmitBuildInfo: true,
39916
39998
  category: ts.Diagnostics.Language_and_Environment,
39917
39999
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39918
40000
  defaultValueDescription: "`React`",
@@ -39920,6 +40002,8 @@ var ts;
39920
40002
  {
39921
40003
  name: "skipDefaultLibCheck",
39922
40004
  type: "boolean",
40005
+ // We need to store these to determine whether `lib` files need to be rechecked
40006
+ affectsMultiFileEmitBuildInfo: true,
39923
40007
  category: ts.Diagnostics.Completeness,
39924
40008
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39925
40009
  defaultValueDescription: false,
@@ -39935,6 +40019,7 @@ var ts;
39935
40019
  name: "emitBOM",
39936
40020
  type: "boolean",
39937
40021
  affectsEmit: true,
40022
+ affectsMultiFileEmitBuildInfo: true,
39938
40023
  category: ts.Diagnostics.Emit,
39939
40024
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39940
40025
  defaultValueDescription: false,
@@ -39946,6 +40031,7 @@ var ts;
39946
40031
  lf: 1 /* LineFeed */
39947
40032
  })),
39948
40033
  affectsEmit: true,
40034
+ affectsMultiFileEmitBuildInfo: true,
39949
40035
  paramType: ts.Diagnostics.NEWLINE,
39950
40036
  category: ts.Diagnostics.Emit,
39951
40037
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39955,6 +40041,7 @@ var ts;
39955
40041
  name: "noErrorTruncation",
39956
40042
  type: "boolean",
39957
40043
  affectsSemanticDiagnostics: true,
40044
+ affectsMultiFileEmitBuildInfo: true,
39958
40045
  category: ts.Diagnostics.Output_Formatting,
39959
40046
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39960
40047
  defaultValueDescription: false,
@@ -39985,6 +40072,7 @@ var ts;
39985
40072
  name: "stripInternal",
39986
40073
  type: "boolean",
39987
40074
  affectsEmit: true,
40075
+ affectsMultiFileEmitBuildInfo: true,
39988
40076
  category: ts.Diagnostics.Emit,
39989
40077
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
39990
40078
  defaultValueDescription: false,
@@ -40025,6 +40113,7 @@ var ts;
40025
40113
  name: "noImplicitUseStrict",
40026
40114
  type: "boolean",
40027
40115
  affectsSemanticDiagnostics: true,
40116
+ affectsMultiFileEmitBuildInfo: true,
40028
40117
  category: ts.Diagnostics.Backwards_Compatibility,
40029
40118
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40030
40119
  defaultValueDescription: false,
@@ -40033,6 +40122,7 @@ var ts;
40033
40122
  name: "noEmitHelpers",
40034
40123
  type: "boolean",
40035
40124
  affectsEmit: true,
40125
+ affectsMultiFileEmitBuildInfo: true,
40036
40126
  category: ts.Diagnostics.Emit,
40037
40127
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40038
40128
  defaultValueDescription: false,
@@ -40041,6 +40131,7 @@ var ts;
40041
40131
  name: "noEmitOnError",
40042
40132
  type: "boolean",
40043
40133
  affectsEmit: true,
40134
+ affectsMultiFileEmitBuildInfo: true,
40044
40135
  category: ts.Diagnostics.Emit,
40045
40136
  transpileOptionValue: undefined,
40046
40137
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40050,6 +40141,7 @@ var ts;
40050
40141
  name: "preserveConstEnums",
40051
40142
  type: "boolean",
40052
40143
  affectsEmit: true,
40144
+ affectsMultiFileEmitBuildInfo: true,
40053
40145
  category: ts.Diagnostics.Emit,
40054
40146
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40055
40147
  defaultValueDescription: false,
@@ -40058,6 +40150,8 @@ var ts;
40058
40150
  name: "declarationDir",
40059
40151
  type: "string",
40060
40152
  affectsEmit: true,
40153
+ affectsMultiFileEmitBuildInfo: true,
40154
+ affectsDeclarationPath: true,
40061
40155
  isFilePath: true,
40062
40156
  paramType: ts.Diagnostics.DIRECTORY,
40063
40157
  category: ts.Diagnostics.Emit,
@@ -40067,6 +40161,8 @@ var ts;
40067
40161
  {
40068
40162
  name: "skipLibCheck",
40069
40163
  type: "boolean",
40164
+ // We need to store these to determine whether `lib` files need to be rechecked
40165
+ affectsMultiFileEmitBuildInfo: true,
40070
40166
  category: ts.Diagnostics.Completeness,
40071
40167
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40072
40168
  defaultValueDescription: false,
@@ -40076,6 +40172,7 @@ var ts;
40076
40172
  type: "boolean",
40077
40173
  affectsBindDiagnostics: true,
40078
40174
  affectsSemanticDiagnostics: true,
40175
+ affectsMultiFileEmitBuildInfo: true,
40079
40176
  category: ts.Diagnostics.Type_Checking,
40080
40177
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40081
40178
  defaultValueDescription: undefined,
@@ -40085,6 +40182,7 @@ var ts;
40085
40182
  type: "boolean",
40086
40183
  affectsBindDiagnostics: true,
40087
40184
  affectsSemanticDiagnostics: true,
40185
+ affectsMultiFileEmitBuildInfo: true,
40088
40186
  category: ts.Diagnostics.Type_Checking,
40089
40187
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40090
40188
  defaultValueDescription: undefined,
@@ -40093,6 +40191,7 @@ var ts;
40093
40191
  name: "suppressExcessPropertyErrors",
40094
40192
  type: "boolean",
40095
40193
  affectsSemanticDiagnostics: true,
40194
+ affectsMultiFileEmitBuildInfo: true,
40096
40195
  category: ts.Diagnostics.Backwards_Compatibility,
40097
40196
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40098
40197
  defaultValueDescription: false,
@@ -40101,6 +40200,7 @@ var ts;
40101
40200
  name: "suppressImplicitAnyIndexErrors",
40102
40201
  type: "boolean",
40103
40202
  affectsSemanticDiagnostics: true,
40203
+ affectsMultiFileEmitBuildInfo: true,
40104
40204
  category: ts.Diagnostics.Backwards_Compatibility,
40105
40205
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40106
40206
  defaultValueDescription: false,
@@ -40125,6 +40225,7 @@ var ts;
40125
40225
  name: "noStrictGenericChecks",
40126
40226
  type: "boolean",
40127
40227
  affectsSemanticDiagnostics: true,
40228
+ affectsMultiFileEmitBuildInfo: true,
40128
40229
  category: ts.Diagnostics.Backwards_Compatibility,
40129
40230
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40130
40231
  defaultValueDescription: false,
@@ -40134,6 +40235,7 @@ var ts;
40134
40235
  type: "boolean",
40135
40236
  affectsSemanticDiagnostics: true,
40136
40237
  affectsEmit: true,
40238
+ affectsMultiFileEmitBuildInfo: true,
40137
40239
  category: ts.Diagnostics.Language_and_Environment,
40138
40240
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40139
40241
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40142,6 +40244,7 @@ var ts;
40142
40244
  name: "preserveValueImports",
40143
40245
  type: "boolean",
40144
40246
  affectsEmit: true,
40247
+ affectsMultiFileEmitBuildInfo: true,
40145
40248
  category: ts.Diagnostics.Emit,
40146
40249
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40147
40250
  defaultValueDescription: false,
@@ -40185,6 +40288,8 @@ var ts;
40185
40288
  /* @internal */
40186
40289
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40187
40290
  /* @internal */
40291
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40292
+ /* @internal */
40188
40293
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40189
40294
  /* @internal */
40190
40295
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41040,6 +41145,7 @@ var ts;
41040
41145
  return optionDefinition.type;
41041
41146
  }
41042
41147
  }
41148
+ /* @internal */
41043
41149
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41044
41150
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41045
41151
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41048,6 +41154,7 @@ var ts;
41048
41154
  }
41049
41155
  });
41050
41156
  }
41157
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41051
41158
  function serializeCompilerOptions(options, pathOptions) {
41052
41159
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41053
41160
  }
@@ -42043,7 +42150,7 @@ var ts;
42043
42150
  }
42044
42151
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42045
42152
  return {
42046
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42153
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42047
42154
  flags: 1 /* Recursive */
42048
42155
  };
42049
42156
  }
@@ -46946,12 +47053,14 @@ var ts;
46946
47053
  }
46947
47054
  }
46948
47055
  function setCommonJsModuleIndicator(node) {
46949
- if (file.externalModuleIndicator) {
47056
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46950
47057
  return false;
46951
47058
  }
46952
47059
  if (!file.commonJsModuleIndicator) {
46953
47060
  file.commonJsModuleIndicator = node;
46954
- bindSourceFileAsExternalModule();
47061
+ if (!file.externalModuleIndicator) {
47062
+ bindSourceFileAsExternalModule();
47063
+ }
46955
47064
  }
46956
47065
  return true;
46957
47066
  }
@@ -47365,7 +47474,11 @@ var ts;
47365
47474
  checkStrictModeEvalOrArguments(node, node.name);
47366
47475
  }
47367
47476
  if (!ts.isBindingPattern(node.name)) {
47368
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47477
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47478
+ if (ts.isInJSFile(node) &&
47479
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47480
+ !ts.getJSDocTypeTag(node) &&
47481
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47369
47482
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47370
47483
  }
47371
47484
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50192,7 +50305,8 @@ var ts;
50192
50305
  && isAliasableOrJsExpression(node.parent.right)
50193
50306
  || node.kind === 297 /* ShorthandPropertyAssignment */
50194
50307
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50195
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50308
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50309
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50196
50310
  }
50197
50311
  function isAliasableOrJsExpression(e) {
50198
50312
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50285,7 +50399,7 @@ var ts;
50285
50399
  return hasExportAssignmentSymbol(moduleSymbol);
50286
50400
  }
50287
50401
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50288
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50402
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50289
50403
  }
50290
50404
  function getTargetOfImportClause(node, dontResolveAlias) {
50291
50405
  var _a;
@@ -68149,13 +68263,40 @@ var ts;
68149
68263
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68150
68264
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68151
68265
  }
68152
- function isValidBigIntString(s) {
68266
+ /**
68267
+ * Tests whether the provided string can be parsed as a number.
68268
+ * @param s The string to test.
68269
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68270
+ */
68271
+ function isValidNumberString(s, roundTripOnly) {
68272
+ if (s === "")
68273
+ return false;
68274
+ var n = +s;
68275
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68276
+ }
68277
+ /**
68278
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68279
+ */
68280
+ function parseBigIntLiteralType(text) {
68281
+ var negative = text.startsWith("-");
68282
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68283
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68284
+ }
68285
+ /**
68286
+ * Tests whether the provided string can be parsed as a bigint.
68287
+ * @param s The string to test.
68288
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68289
+ */
68290
+ function isValidBigIntString(s, roundTripOnly) {
68291
+ if (s === "")
68292
+ return false;
68153
68293
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68154
68294
  var success = true;
68155
68295
  scanner.setOnError(function () { return success = false; });
68156
68296
  scanner.setText(s + "n");
68157
68297
  var result = scanner.scan();
68158
- if (result === 40 /* MinusToken */) {
68298
+ var negative = result === 40 /* MinusToken */;
68299
+ if (negative) {
68159
68300
  result = scanner.scan();
68160
68301
  }
68161
68302
  var flags = scanner.getTokenFlags();
@@ -68164,7 +68305,8 @@ var ts;
68164
68305
  // * a bigint can be scanned, and that when it is scanned, it is
68165
68306
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68166
68307
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68167
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68308
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68309
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68168
68310
  }
68169
68311
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68170
68312
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68172,8 +68314,8 @@ var ts;
68172
68314
  }
68173
68315
  if (source.flags & 128 /* StringLiteral */) {
68174
68316
  var value = source.value;
68175
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68176
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68317
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68318
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68177
68319
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68178
68320
  }
68179
68321
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68746,8 +68888,57 @@ var ts;
68746
68888
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68747
68889
  // succeed. That would be a pointless and confusing outcome.
68748
68890
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68891
+ var _loop_23 = function (i) {
68892
+ var source_1 = matches ? matches[i] : neverType;
68893
+ var target_3 = types[i];
68894
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68895
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68896
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68897
+ var inferenceContext = getInferenceInfoForType(target_3);
68898
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68899
+ if (constraint && !isTypeAny(constraint)) {
68900
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68901
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68902
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68903
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68904
+ var str_1 = source_1.value;
68905
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68906
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68907
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68908
+ }
68909
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68910
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68911
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68912
+ }
68913
+ // for each type in the constraint, find the highest priority matching type
68914
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68915
+ return !(right.flags & allTypeFlags_1) ? left :
68916
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68917
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68918
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68919
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68920
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68921
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68922
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68923
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68924
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68925
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68926
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68927
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68928
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68929
+ left;
68930
+ }, neverType);
68931
+ if (!(matchingType.flags & 131072 /* Never */)) {
68932
+ inferFromTypes(matchingType, target_3);
68933
+ return "continue";
68934
+ }
68935
+ }
68936
+ }
68937
+ }
68938
+ inferFromTypes(source_1, target_3);
68939
+ };
68749
68940
  for (var i = 0; i < types.length; i++) {
68750
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68941
+ _loop_23(i);
68751
68942
  }
68752
68943
  }
68753
68944
  }
@@ -69265,7 +69456,7 @@ var ts;
69265
69456
  function mapTypesByKeyProperty(types, name) {
69266
69457
  var map = new ts.Map();
69267
69458
  var count = 0;
69268
- var _loop_23 = function (type) {
69459
+ var _loop_24 = function (type) {
69269
69460
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69270
69461
  var discriminant = getTypeOfPropertyOfType(type, name);
69271
69462
  if (discriminant) {
@@ -69291,7 +69482,7 @@ var ts;
69291
69482
  };
69292
69483
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69293
69484
  var type = types_16[_i];
69294
- var state_9 = _loop_23(type);
69485
+ var state_9 = _loop_24(type);
69295
69486
  if (typeof state_9 === "object")
69296
69487
  return state_9.value;
69297
69488
  }
@@ -75679,7 +75870,7 @@ var ts;
75679
75870
  if (spreadIndex >= 0) {
75680
75871
  // Create synthetic arguments from spreads of tuple types.
75681
75872
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75682
- var _loop_24 = function (i) {
75873
+ var _loop_25 = function (i) {
75683
75874
  var arg = args[i];
75684
75875
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75685
75876
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75696,7 +75887,7 @@ var ts;
75696
75887
  }
75697
75888
  };
75698
75889
  for (var i = spreadIndex; i < args.length; i++) {
75699
- _loop_24(i);
75890
+ _loop_25(i);
75700
75891
  }
75701
75892
  return effectiveArgs_1;
75702
75893
  }
@@ -76016,7 +76207,7 @@ var ts;
76016
76207
  var min_3 = Number.MAX_VALUE;
76017
76208
  var minIndex = 0;
76018
76209
  var i_1 = 0;
76019
- var _loop_25 = function (c) {
76210
+ var _loop_26 = function (c) {
76020
76211
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76021
76212
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76022
76213
  if (diags_2) {
@@ -76034,7 +76225,7 @@ var ts;
76034
76225
  };
76035
76226
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76036
76227
  var c = candidatesForArgumentError_1[_a];
76037
- _loop_25(c);
76228
+ _loop_26(c);
76038
76229
  }
76039
76230
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76040
76231
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76192,7 +76383,7 @@ var ts;
76192
76383
  }
76193
76384
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76194
76385
  var parameters = [];
76195
- var _loop_26 = function (i) {
76386
+ var _loop_27 = function (i) {
76196
76387
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76197
76388
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76198
76389
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76200,7 +76391,7 @@ var ts;
76200
76391
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76201
76392
  };
76202
76393
  for (var i = 0; i < maxNonRestParam; i++) {
76203
- _loop_26(i);
76394
+ _loop_27(i);
76204
76395
  }
76205
76396
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76206
76397
  var flags = 0 /* None */;
@@ -80257,7 +80448,7 @@ var ts;
80257
80448
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80258
80449
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80259
80450
  var indexSignatureMap_1 = new ts.Map();
80260
- var _loop_27 = function (declaration) {
80451
+ var _loop_28 = function (declaration) {
80261
80452
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80262
80453
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80263
80454
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80272,7 +80463,7 @@ var ts;
80272
80463
  };
80273
80464
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80274
80465
  var declaration = _a[_i];
80275
- _loop_27(declaration);
80466
+ _loop_28(declaration);
80276
80467
  }
80277
80468
  indexSignatureMap_1.forEach(function (entry) {
80278
80469
  if (entry.declarations.length > 1) {
@@ -82468,7 +82659,7 @@ var ts;
82468
82659
  }
82469
82660
  // For a commonjs `const x = require`, validate the alias and exit
82470
82661
  var symbol = getSymbolOfNode(node);
82471
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82662
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82472
82663
  checkAliasSymbol(node);
82473
82664
  return;
82474
82665
  }
@@ -83733,7 +83924,7 @@ var ts;
83733
83924
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83734
83925
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83735
83926
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83736
- var _loop_28 = function (info) {
83927
+ var _loop_29 = function (info) {
83737
83928
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83738
83929
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83739
83930
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83746,7 +83937,7 @@ var ts;
83746
83937
  };
83747
83938
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83748
83939
  var info = indexInfos_9[_i];
83749
- _loop_28(info);
83940
+ _loop_29(info);
83750
83941
  }
83751
83942
  }
83752
83943
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83754,7 +83945,7 @@ var ts;
83754
83945
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83755
83946
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83756
83947
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83757
- var _loop_29 = function (info) {
83948
+ var _loop_30 = function (info) {
83758
83949
  if (info === checkInfo)
83759
83950
  return "continue";
83760
83951
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83769,7 +83960,7 @@ var ts;
83769
83960
  };
83770
83961
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83771
83962
  var info = indexInfos_10[_i];
83772
- _loop_29(info);
83963
+ _loop_30(info);
83773
83964
  }
83774
83965
  }
83775
83966
  function checkTypeNameIsReserved(name, message) {
@@ -84088,7 +84279,7 @@ var ts;
84088
84279
  var baseTypes = baseTypeNode && getBaseTypes(type);
84089
84280
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84090
84281
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84091
- var _loop_30 = function (member) {
84282
+ var _loop_31 = function (member) {
84092
84283
  if (ts.hasAmbientModifier(member)) {
84093
84284
  return "continue";
84094
84285
  }
@@ -84105,7 +84296,7 @@ var ts;
84105
84296
  };
84106
84297
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84107
84298
  var member = _a[_i];
84108
- _loop_30(member);
84299
+ _loop_31(member);
84109
84300
  }
84110
84301
  }
84111
84302
  /**
@@ -84193,7 +84384,7 @@ var ts;
84193
84384
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84194
84385
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84195
84386
  var issuedMemberError = false;
84196
- var _loop_31 = function (member) {
84387
+ var _loop_32 = function (member) {
84197
84388
  if (ts.isStatic(member)) {
84198
84389
  return "continue";
84199
84390
  }
@@ -84212,7 +84403,7 @@ var ts;
84212
84403
  };
84213
84404
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84214
84405
  var member = _a[_i];
84215
- _loop_31(member);
84406
+ _loop_32(member);
84216
84407
  }
84217
84408
  if (!issuedMemberError) {
84218
84409
  // check again with diagnostics to generate a less-specific error
@@ -89872,9 +90063,7 @@ var ts;
89872
90063
  var ts;
89873
90064
  (function (ts) {
89874
90065
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
89875
- var _a = generatorOptions.extendedDiagnostics
89876
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
89877
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90066
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
89878
90067
  // Current source map file and its index in the sources list
89879
90068
  var rawSources = [];
89880
90069
  var sources = [];
@@ -110191,7 +110380,8 @@ var ts;
110191
110380
  return;
110192
110381
  }
110193
110382
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110194
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110383
+ var buildInfo = { bundle: bundle, program: program, version: version };
110384
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110195
110385
  }
110196
110386
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110197
110387
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110345,13 +110535,18 @@ var ts;
110345
110535
  if (sourceMapFilePath) {
110346
110536
  var sourceMap = sourceMapGenerator.toString();
110347
110537
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
110538
+ if (printer.bundleFileInfo)
110539
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110348
110540
  }
110349
110541
  }
110350
110542
  else {
110351
110543
  writer.writeLine();
110352
110544
  }
110353
110545
  // Write the output file
110354
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110546
+ var text = writer.getText();
110547
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110548
+ if (printer.bundleFileInfo)
110549
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110355
110550
  // Reset state
110356
110551
  writer.clear();
110357
110552
  }
@@ -110494,34 +110689,54 @@ var ts;
110494
110689
  }
110495
110690
  /*@internal*/
110496
110691
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
110692
+ var createHash = ts.maybeBind(host, host.createHash);
110497
110693
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
110498
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
110499
- if (!buildInfoText)
110694
+ var buildInfo;
110695
+ if (host.getBuildInfo) {
110696
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
110697
+ if (!hostBuildInfo)
110698
+ return buildInfoPath;
110699
+ buildInfo = hostBuildInfo;
110700
+ }
110701
+ else {
110702
+ var buildInfoText = host.readFile(buildInfoPath);
110703
+ if (!buildInfoText)
110704
+ return buildInfoPath;
110705
+ buildInfo = getBuildInfo(buildInfoText);
110706
+ }
110707
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
110500
110708
  return buildInfoPath;
110501
110709
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
110502
110710
  if (!jsFileText)
110503
110711
  return jsFilePath;
110712
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
110713
+ return jsFilePath;
110504
110714
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
110505
110715
  // error if no source map or for now if inline sourcemap
110506
110716
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
110507
110717
  return sourceMapFilePath || "inline sourcemap decoding";
110718
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
110719
+ return sourceMapFilePath;
110508
110720
  // read declaration text
110509
110721
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
110510
110722
  if (declarationFilePath && !declarationText)
110511
110723
  return declarationFilePath;
110724
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
110725
+ return declarationFilePath;
110512
110726
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
110513
110727
  // error if no source map or for now if inline sourcemap
110514
110728
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
110515
110729
  return declarationMapPath || "inline sourcemap decoding";
110516
- var buildInfo = getBuildInfo(buildInfoText);
110517
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
110518
- return buildInfoPath;
110730
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
110731
+ return declarationMapPath;
110519
110732
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110520
110733
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
110521
110734
  /*onlyOwnText*/ true);
110522
110735
  var outputFiles = [];
110523
110736
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
110524
110737
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
110738
+ var changedDtsText;
110739
+ var changedDtsData;
110525
110740
  var emitHost = {
110526
110741
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
110527
110742
  getCanonicalFileName: host.getCanonicalFileName,
@@ -110537,7 +110752,7 @@ var ts;
110537
110752
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
110538
110753
  getProjectReferenceRedirect: ts.returnUndefined,
110539
110754
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
110540
- writeFile: function (name, text, writeByteOrderMark) {
110755
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
110541
110756
  switch (name) {
110542
110757
  case jsFilePath:
110543
110758
  if (jsFileText === text)
@@ -110548,8 +110763,13 @@ var ts;
110548
110763
  return;
110549
110764
  break;
110550
110765
  case buildInfoPath:
110551
- var newBuildInfo = getBuildInfo(text);
110766
+ var newBuildInfo = data.buildInfo;
110552
110767
  newBuildInfo.program = buildInfo.program;
110768
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
110769
+ // Update the output signature
110770
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
110771
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
110772
+ }
110553
110773
  // Update sourceFileInfo
110554
110774
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
110555
110775
  newBuildInfo.bundle.js.sources = js.sources;
@@ -110557,11 +110777,13 @@ var ts;
110557
110777
  newBuildInfo.bundle.dts.sources = dts.sources;
110558
110778
  }
110559
110779
  newBuildInfo.bundle.sourceFiles = sourceFiles;
110560
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
110780
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
110561
110781
  return;
110562
110782
  case declarationFilePath:
110563
110783
  if (declarationText === text)
110564
110784
  return;
110785
+ changedDtsText = text;
110786
+ changedDtsData = data;
110565
110787
  break;
110566
110788
  case declarationMapPath:
110567
110789
  if (declarationMapText === text)
@@ -110580,6 +110802,7 @@ var ts;
110580
110802
  getSourceFileFromReference: ts.returnUndefined,
110581
110803
  redirectTargetsMap: ts.createMultiMap(),
110582
110804
  getFileIncludeReasons: ts.notImplemented,
110805
+ createHash: createHash,
110583
110806
  };
110584
110807
  emitFiles(ts.notImplementedResolver, emitHost,
110585
110808
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -115664,12 +115887,10 @@ var ts;
115664
115887
  }
115665
115888
  ts.createCompilerHost = createCompilerHost;
115666
115889
  /*@internal*/
115667
- // TODO(shkamat): update this after reworking ts build API
115668
115890
  function createCompilerHostWorker(options, setParentNodes, system) {
115669
115891
  if (system === void 0) { system = ts.sys; }
115670
115892
  var existingDirectories = new ts.Map();
115671
115893
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
115672
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
115673
115894
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
115674
115895
  var text;
115675
115896
  try {
@@ -115702,7 +115923,7 @@ var ts;
115702
115923
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
115703
115924
  // the system.writeFile will do its own directory creation and
115704
115925
  // the ensureDirectoriesExist call will always be redundant.
115705
- ts.writeFileEnsuringDirectories(fileName, data, writeByteOrderMark, function (path, data, writeByteOrderMark) { return writeFileWorker(path, data, writeByteOrderMark); }, function (path) { return (compilerHost.createDirectory || system.createDirectory)(path); }, function (path) { return directoryExists(path); });
115926
+ ts.writeFileEnsuringDirectories(fileName, data, writeByteOrderMark, function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, function (path) { return (compilerHost.createDirectory || system.createDirectory)(path); }, function (path) { return directoryExists(path); });
115706
115927
  ts.performance.mark("afterIOWrite");
115707
115928
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
115708
115929
  }
@@ -115712,35 +115933,6 @@ var ts;
115712
115933
  }
115713
115934
  }
115714
115935
  }
115715
- var outputFingerprints;
115716
- function writeFileWorker(fileName, data, writeByteOrderMark) {
115717
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
115718
- system.writeFile(fileName, data, writeByteOrderMark);
115719
- return;
115720
- }
115721
- if (!outputFingerprints) {
115722
- outputFingerprints = new ts.Map();
115723
- }
115724
- var hash = computeHash(data);
115725
- var mtimeBefore = system.getModifiedTime(fileName);
115726
- if (mtimeBefore) {
115727
- var fingerprint = outputFingerprints.get(fileName);
115728
- // If output has not been changed, and the file has no external modification
115729
- if (fingerprint &&
115730
- fingerprint.byteOrderMark === writeByteOrderMark &&
115731
- fingerprint.hash === hash &&
115732
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
115733
- return;
115734
- }
115735
- }
115736
- system.writeFile(fileName, data, writeByteOrderMark);
115737
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
115738
- outputFingerprints.set(fileName, {
115739
- hash: hash,
115740
- byteOrderMark: writeByteOrderMark,
115741
- mtime: mtimeAfter
115742
- });
115743
- }
115744
115936
  function getDefaultLibLocation() {
115745
115937
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
115746
115938
  }
@@ -117330,6 +117522,7 @@ var ts;
117330
117522
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117331
117523
  redirectTargetsMap: redirectTargetsMap,
117332
117524
  getFileIncludeReasons: program.getFileIncludeReasons,
117525
+ createHash: ts.maybeBind(host, host.createHash),
117333
117526
  };
117334
117527
  }
117335
117528
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -119443,13 +119636,9 @@ var ts;
119443
119636
  function createManyToManyPathMap() {
119444
119637
  function create(forward, reverse, deleted) {
119445
119638
  var map = {
119446
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
119447
- forEach: function (fn) { return forward.forEach(fn); },
119448
119639
  getKeys: function (v) { return reverse.get(v); },
119449
119640
  getValues: function (k) { return forward.get(k); },
119450
- hasKey: function (k) { return forward.has(k); },
119451
119641
  keys: function () { return forward.keys(); },
119452
- deletedKeys: function () { return deleted; },
119453
119642
  deleteKey: function (k) {
119454
119643
  (deleted || (deleted = new ts.Set())).add(k);
119455
119644
  var set = forward.get(k);
@@ -119476,11 +119665,6 @@ var ts;
119476
119665
  });
119477
119666
  return map;
119478
119667
  },
119479
- clear: function () {
119480
- forward.clear();
119481
- reverse.clear();
119482
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119483
- }
119484
119668
  };
119485
119669
  return map;
119486
119670
  }
@@ -119608,18 +119792,21 @@ var ts;
119608
119792
  * Creates the state of file references and signature for the new program from oldState if it is safe
119609
119793
  */
119610
119794
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
119795
+ var _a, _b, _c;
119611
119796
  var fileInfos = new ts.Map();
119612
119797
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
119613
119798
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
119614
- var hasCalledUpdateShapeSignature = new ts.Set();
119615
119799
  var useOldState = canReuseOldState(referencedMap, oldState);
119616
119800
  // Ensure source files have parent pointers set
119617
119801
  newProgram.getTypeChecker();
119618
119802
  // Create the reference map, and set the file infos
119619
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
119620
- var sourceFile = _a[_i];
119803
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
119804
+ var sourceFile = _d[_i];
119621
119805
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
119622
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
119806
+ var oldUncommitedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
119807
+ var signature = oldUncommitedSignature === undefined ?
119808
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
119809
+ oldUncommitedSignature || undefined;
119623
119810
  if (referencedMap) {
119624
119811
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
119625
119812
  if (newReferences) {
@@ -119627,19 +119814,26 @@ var ts;
119627
119814
  }
119628
119815
  // Copy old visible to outside files map
119629
119816
  if (useOldState) {
119630
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
119817
+ var oldUncommitedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
119818
+ var exportedModules = oldUncommitedExportedModules === undefined ?
119819
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
119820
+ oldUncommitedExportedModules || undefined;
119631
119821
  if (exportedModules) {
119632
119822
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119633
119823
  }
119634
119824
  }
119635
119825
  }
119636
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
119826
+ fileInfos.set(sourceFile.resolvedPath, {
119827
+ version: version_2,
119828
+ signature: signature,
119829
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
119830
+ impliedFormat: sourceFile.impliedNodeFormat
119831
+ });
119637
119832
  }
119638
119833
  return {
119639
119834
  fileInfos: fileInfos,
119640
119835
  referencedMap: referencedMap,
119641
119836
  exportedModulesMap: exportedModulesMap,
119642
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
119643
119837
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
119644
119838
  };
119645
119839
  }
@@ -119653,71 +119847,42 @@ var ts;
119653
119847
  }
119654
119848
  BuilderState.releaseCache = releaseCache;
119655
119849
  /**
119656
- * Creates a clone of the state
119850
+ * Gets the files affected by the path from the program
119657
119851
  */
119658
- function clone(state) {
119852
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
119659
119853
  var _a, _b;
119660
- // Dont need to backup allFiles info since its cache anyway
119661
- return {
119662
- fileInfos: new ts.Map(state.fileInfos),
119663
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
119664
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
119665
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
119666
- useFileVersionAsSignature: state.useFileVersionAsSignature,
119667
- };
119854
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
119855
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
119856
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
119857
+ return result;
119668
119858
  }
119669
- BuilderState.clone = clone;
119670
- /**
119671
- * Gets the files affected by the path from the program
119672
- */
119673
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
119674
- // Since the operation could be cancelled, the signatures are always stored in the cache
119675
- // They will be committed once it is safe to use them
119676
- // eg when calling this api from tsserver, if there is no cancellation of the operation
119677
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
119678
- var signatureCache = cacheToUpdateSignature || new ts.Map();
119859
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119860
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
119679
119861
  var sourceFile = programOfThisState.getSourceFileByPath(path);
119680
119862
  if (!sourceFile) {
119681
119863
  return ts.emptyArray;
119682
119864
  }
119683
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
119865
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
119684
119866
  return [sourceFile];
119685
119867
  }
119686
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
119687
- if (!cacheToUpdateSignature) {
119688
- // Commit all the signatures in the signature cache
119689
- updateSignaturesFromCache(state, signatureCache);
119690
- }
119691
- return result;
119868
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
119692
119869
  }
119693
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119694
- /**
119695
- * Updates the signatures from the cache into state's fileinfo signatures
119696
- * This should be called whenever it is safe to commit the state of the builder
119697
- */
119698
- function updateSignaturesFromCache(state, signatureCache) {
119699
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
119700
- }
119701
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
119870
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
119702
119871
  function updateSignatureOfFile(state, signature, path) {
119703
119872
  state.fileInfos.get(path).signature = signature;
119704
- state.hasCalledUpdateShapeSignature.add(path);
119873
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
119705
119874
  }
119706
119875
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
119707
119876
  /**
119708
119877
  * Returns if the shape of the signature has changed since last emit
119709
119878
  */
119710
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
119879
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
119880
+ var _a;
119711
119881
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
119712
- ts.Debug.assert(!!sourceFile);
119713
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
119714
119882
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
119715
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
119883
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
119716
119884
  return false;
119717
- }
119718
119885
  var info = state.fileInfos.get(sourceFile.resolvedPath);
119719
- if (!info)
119720
- return ts.Debug.fail();
119721
119886
  var prevSignature = info.signature;
119722
119887
  var latestSignature;
119723
119888
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -119728,45 +119893,55 @@ var ts;
119728
119893
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119729
119894
  if (firstDts_1) {
119730
119895
  ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119731
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119732
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
119733
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
119896
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
119897
+ if (latestSignature !== prevSignature) {
119898
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
119734
119899
  }
119735
119900
  }
119736
119901
  }
119737
119902
  // Default is to use file version as signature
119738
119903
  if (latestSignature === undefined) {
119739
119904
  latestSignature = sourceFile.version;
119740
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
119905
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
119906
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119741
119907
  // All the references in this file are exported
119742
119908
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
119743
119909
  if (references) {
119744
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
119910
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
119745
119911
  }
119746
119912
  else {
119747
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119913
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119748
119914
  }
119749
119915
  }
119750
119916
  }
119751
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
119917
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
119918
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
119919
+ info.signature = latestSignature;
119752
119920
  return latestSignature !== prevSignature;
119753
119921
  }
119754
119922
  BuilderState.updateShapeSignature = updateShapeSignature;
119923
+ function computeSignature(text, computeHash) {
119924
+ return (computeHash || ts.generateDjb2Hash)(text);
119925
+ }
119926
+ BuilderState.computeSignature = computeSignature;
119755
119927
  /**
119756
119928
  * Coverts the declaration emit result into exported modules map
119757
119929
  */
119758
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
119930
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
119931
+ if (!state.exportedModulesMap)
119932
+ return;
119933
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119759
119934
  if (!exportedModulesFromDeclarationEmit) {
119760
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119935
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119761
119936
  return;
119762
119937
  }
119763
119938
  var exportedModules;
119764
119939
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
119765
119940
  if (exportedModules) {
119766
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
119941
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119767
119942
  }
119768
119943
  else {
119769
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119944
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119770
119945
  }
119771
119946
  function addExportedModule(exportedModulePaths) {
119772
119947
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -119778,19 +119953,6 @@ var ts;
119778
119953
  }
119779
119954
  }
119780
119955
  BuilderState.updateExportedModules = updateExportedModules;
119781
- /**
119782
- * Updates the exported modules from cache into state's exported modules map
119783
- * This should be called whenever it is safe to commit the state of the builder
119784
- */
119785
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
119786
- var _a;
119787
- if (exportedModulesMapCache) {
119788
- ts.Debug.assert(!!state.exportedModulesMap);
119789
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119790
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119791
- }
119792
- }
119793
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
119794
119956
  /**
119795
119957
  * Get all the dependencies of the sourceFile
119796
119958
  */
@@ -119911,7 +120073,7 @@ var ts;
119911
120073
  /**
119912
120074
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
119913
120075
  */
119914
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120076
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
119915
120077
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
119916
120078
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
119917
120079
  }
@@ -119931,7 +120093,7 @@ var ts;
119931
120093
  if (!seenFileNamesMap.has(currentPath)) {
119932
120094
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
119933
120095
  seenFileNamesMap.set(currentPath, currentSourceFile);
119934
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120096
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
119935
120097
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
119936
120098
  }
119937
120099
  }
@@ -119957,32 +120119,33 @@ var ts;
119957
120119
  * Create the state so that we can iterate on changedFiles/affected files
119958
120120
  */
119959
120121
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120122
+ var _a, _b;
119960
120123
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
119961
120124
  state.program = newProgram;
119962
120125
  var compilerOptions = newProgram.getCompilerOptions();
119963
120126
  state.compilerOptions = compilerOptions;
120127
+ var outFilePath = ts.outFile(compilerOptions);
119964
120128
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
119965
- if (!ts.outFile(compilerOptions)) {
120129
+ if (!outFilePath) {
119966
120130
  state.semanticDiagnosticsPerFile = new ts.Map();
119967
120131
  }
120132
+ else if (compilerOptions.composite && (oldState === null || oldState === void 0 ? void 0 : oldState.outSignature) && outFilePath === ts.outFile(oldState === null || oldState === void 0 ? void 0 : oldState.compilerOptions)) {
120133
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120134
+ }
119968
120135
  state.changedFilesSet = new ts.Set();
120136
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
119969
120137
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
119970
120138
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
119971
120139
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
119972
120140
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120141
+ var canCopyEmitSignatures = compilerOptions.composite &&
120142
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120143
+ !outFilePath &&
120144
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
119973
120145
  if (useOldState) {
119974
- // Verify the sanity of old state
119975
- if (!oldState.currentChangedFilePath) {
119976
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
119977
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
119978
- }
119979
- var changedFilesSet = oldState.changedFilesSet;
119980
- if (canCopySemanticDiagnostics) {
119981
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
119982
- }
119983
120146
  // Copy old state's changed files set
119984
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
119985
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120147
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120148
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
119986
120149
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
119987
120150
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
119988
120151
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120003,6 +120166,8 @@ var ts;
120003
120166
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120004
120167
  // versions dont match
120005
120168
  oldInfo.version !== info.version ||
120169
+ // Implied formats dont match
120170
+ oldInfo.impliedFormat !== info.impliedFormat ||
120006
120171
  // Referenced files changed
120007
120172
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120008
120173
  // Referenced file was deleted in the new program
@@ -120026,27 +120191,25 @@ var ts;
120026
120191
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120027
120192
  }
120028
120193
  }
120194
+ if (canCopyEmitSignatures) {
120195
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120196
+ if (oldEmitSignature)
120197
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120198
+ }
120029
120199
  });
120030
120200
  // If the global file is removed, add all files as changed
120031
120201
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120032
120202
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120033
120203
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120034
120204
  }
120035
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120205
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120036
120206
  // Add all files to affectedFilesPendingEmit since emit changed
120037
120207
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120038
120208
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120039
120209
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120040
120210
  }
120041
- if (useOldState) {
120042
- // Any time the interpretation of a source file changes, mark it as changed
120043
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120044
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120045
- state.changedFilesSet.add(sourceFilePath);
120046
- }
120047
- });
120048
- }
120049
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120211
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120212
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120050
120213
  return state;
120051
120214
  }
120052
120215
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120082,30 +120245,35 @@ var ts;
120082
120245
  ts.BuilderState.releaseCache(state);
120083
120246
  state.program = undefined;
120084
120247
  }
120085
- /**
120086
- * Creates a clone of the state
120087
- */
120088
- function cloneBuilderProgramState(state) {
120089
- var _a;
120090
- var newState = ts.BuilderState.clone(state);
120091
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120092
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120093
- newState.affectedFiles = state.affectedFiles;
120094
- newState.affectedFilesIndex = state.affectedFilesIndex;
120095
- newState.currentChangedFilePath = state.currentChangedFilePath;
120096
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120097
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120098
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120099
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120100
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120101
- newState.program = state.program;
120102
- newState.compilerOptions = state.compilerOptions;
120103
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120104
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120105
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120106
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120107
- newState.programEmitComplete = state.programEmitComplete;
120108
- return newState;
120248
+ function backupEmitBuilderProgramState(state) {
120249
+ var outFilePath = ts.outFile(state.compilerOptions);
120250
+ // Only in --out changeFileSet is kept around till emit
120251
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120252
+ return {
120253
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120254
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120255
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120256
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120257
+ programEmitComplete: state.programEmitComplete,
120258
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120259
+ outSignature: state.outSignature,
120260
+ dtsChangeTime: state.dtsChangeTime,
120261
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120262
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120263
+ };
120264
+ }
120265
+ function restoreEmitBuilderProgramState(state, backupEmitState) {
120266
+ state.affectedFilesPendingEmit = backupEmitState.affectedFilesPendingEmit;
120267
+ state.affectedFilesPendingEmitKind = backupEmitState.affectedFilesPendingEmitKind;
120268
+ state.affectedFilesPendingEmitIndex = backupEmitState.affectedFilesPendingEmitIndex;
120269
+ state.seenEmittedFiles = backupEmitState.seenEmittedFiles;
120270
+ state.programEmitComplete = backupEmitState.programEmitComplete;
120271
+ state.emitSignatures = backupEmitState.emitSignatures;
120272
+ state.outSignature = backupEmitState.outSignature;
120273
+ state.dtsChangeTime = backupEmitState.dtsChangeTime;
120274
+ state.hasChangedEmitSignature = backupEmitState.hasChangedEmitSignature;
120275
+ if (backupEmitState.changedFilesSet)
120276
+ state.changedFilesSet = backupEmitState.changedFilesSet;
120109
120277
  }
120110
120278
  /**
120111
120279
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120120,7 +120288,7 @@ var ts;
120120
120288
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120121
120289
  */
120122
120290
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120123
- var _a;
120291
+ var _a, _b;
120124
120292
  while (true) {
120125
120293
  var affectedFiles = state.affectedFiles;
120126
120294
  if (affectedFiles) {
@@ -120140,10 +120308,8 @@ var ts;
120140
120308
  state.changedFilesSet.delete(state.currentChangedFilePath);
120141
120309
  state.currentChangedFilePath = undefined;
120142
120310
  // Commit the changes in file signature
120143
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120144
- state.currentAffectedFilesSignatures.clear();
120145
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120146
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120311
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120312
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120147
120313
  state.affectedFiles = undefined;
120148
120314
  }
120149
120315
  // Get next changed file
@@ -120161,12 +120327,7 @@ var ts;
120161
120327
  return program;
120162
120328
  }
120163
120329
  // Get next batch of affected files
120164
- if (!state.currentAffectedFilesSignatures)
120165
- state.currentAffectedFilesSignatures = new ts.Map();
120166
- if (state.exportedModulesMap) {
120167
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120168
- }
120169
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120330
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120170
120331
  state.currentChangedFilePath = nextKey.value;
120171
120332
  state.affectedFilesIndex = 0;
120172
120333
  if (!state.seenAffectedFiles)
@@ -120218,7 +120379,6 @@ var ts;
120218
120379
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120219
120380
  */
120220
120381
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120221
- var _a;
120222
120382
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120223
120383
  // If affected files is everything except default library, then nothing more to do
120224
120384
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120226,10 +120386,9 @@ var ts;
120226
120386
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120227
120387
  // That means when affected file is handled, its signature can be out of date
120228
120388
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120229
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120389
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120230
120390
  return;
120231
120391
  }
120232
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120233
120392
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120234
120393
  return;
120235
120394
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120249,7 +120408,7 @@ var ts;
120249
120408
  // This ensures that we dont later during incremental builds considering wrong signature.
120250
120409
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120251
120410
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120252
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120411
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120253
120412
  // If not dts emit, nothing more to do
120254
120413
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120255
120414
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120270,27 +120429,10 @@ var ts;
120270
120429
  return !state.semanticDiagnosticsFromOldState.size;
120271
120430
  }
120272
120431
  function isChangedSignature(state, path) {
120273
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120274
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120432
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120433
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120275
120434
  return newSignature !== oldSignature;
120276
120435
  }
120277
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120278
- // Go through exported modules from cache first
120279
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120280
- var result = keys && ts.forEachKey(keys, fn);
120281
- if (result)
120282
- return result;
120283
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120284
- keys = state.exportedModulesMap.getKeys(filePath);
120285
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120286
- var _a;
120287
- // If the cache had an updated value, skip
120288
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120289
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120290
- fn(exportedFromPath) :
120291
- undefined;
120292
- });
120293
- }
120294
120436
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120295
120437
  var _a;
120296
120438
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120305,6 +120447,7 @@ var ts;
120305
120447
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120306
120448
  */
120307
120449
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120450
+ var _a;
120308
120451
  // If there was change in signature (dts output) for the changed file,
120309
120452
  // then only we need to handle pending file emit
120310
120453
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120331,11 +120474,10 @@ var ts;
120331
120474
  }
120332
120475
  }
120333
120476
  }
120334
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120335
120477
  var seenFileAndExportsOfFile = new ts.Set();
120336
120478
  // Go through exported modules from cache first
120337
120479
  // If exported modules has path, all files referencing file exported from are affected
120338
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120480
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120339
120481
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120340
120482
  return true;
120341
120483
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120349,19 +120491,18 @@ var ts;
120349
120491
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120350
120492
  */
120351
120493
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120352
- var _a;
120494
+ var _a, _b;
120353
120495
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120354
120496
  return undefined;
120355
120497
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120356
120498
  return true;
120357
120499
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120358
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120359
120500
  // If exported modules has path, all files referencing file exported from are affected
120360
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120501
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120361
120502
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120362
120503
  });
120363
120504
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120364
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120505
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120365
120506
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120366
120507
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120367
120508
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120382,12 +120523,13 @@ var ts;
120382
120523
  }
120383
120524
  else {
120384
120525
  state.seenAffectedFiles.add(affected.resolvedPath);
120526
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
120527
+ state.buildInfoEmitPending = true;
120385
120528
  if (emitKind !== undefined) {
120386
120529
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120387
120530
  }
120388
120531
  if (isPendingEmit) {
120389
120532
  state.affectedFilesPendingEmitIndex++;
120390
- state.buildInfoEmitPending = true;
120391
120533
  }
120392
120534
  else {
120393
120535
  state.affectedFilesIndex++;
@@ -120435,25 +120577,61 @@ var ts;
120435
120577
  }
120436
120578
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
120437
120579
  }
120580
+ function isProgramBundleEmitBuildInfo(info) {
120581
+ return !!ts.outFile(info.options || {});
120582
+ }
120583
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
120438
120584
  /**
120439
120585
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
120440
120586
  */
120441
- function getProgramBuildInfo(state, getCanonicalFileName) {
120442
- if (ts.outFile(state.compilerOptions))
120443
- return undefined;
120587
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
120588
+ var outFilePath = ts.outFile(state.compilerOptions);
120589
+ if (outFilePath && !state.compilerOptions.composite)
120590
+ return;
120444
120591
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
120445
120592
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
120593
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
120594
+ if (outFilePath) {
120595
+ var fileNames_1 = [];
120596
+ var fileInfos_1 = [];
120597
+ state.program.getRootFileNames().forEach(function (f) {
120598
+ var sourceFile = state.program.getSourceFile(f);
120599
+ if (!sourceFile)
120600
+ return;
120601
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
120602
+ fileInfos_1.push(sourceFile.version);
120603
+ });
120604
+ var result_15 = {
120605
+ fileNames: fileNames_1,
120606
+ fileInfos: fileInfos_1,
120607
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
120608
+ outSignature: state.outSignature,
120609
+ dtsChangeTime: state.dtsChangeTime,
120610
+ };
120611
+ return result_15;
120612
+ }
120446
120613
  var fileNames = [];
120447
120614
  var fileNameToFileId = new ts.Map();
120448
120615
  var fileIdsList;
120449
120616
  var fileNamesToFileIdListId;
120617
+ var emitSignatures;
120450
120618
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
120619
+ var _b, _c;
120451
120620
  var key = _a[0], value = _a[1];
120452
120621
  // Ensure fileId
120453
120622
  var fileId = toFileId(key);
120454
120623
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
120455
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120456
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120624
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
120625
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
120626
+ if (state.compilerOptions.composite) {
120627
+ var file = state.program.getSourceFileByPath(key);
120628
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
120629
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
120630
+ if (emitSignature !== actualSignature) {
120631
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
120632
+ }
120633
+ }
120634
+ }
120457
120635
  return value.version === actualSignature ?
120458
120636
  value.affectsGlobalScope || value.impliedFormat ?
120459
120637
  // If file version is same as signature, dont serialize signature
@@ -120461,11 +120639,11 @@ var ts;
120461
120639
  // If file info only contains version and signature and both are same we can just write string
120462
120640
  value.version :
120463
120641
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120464
- signature === undefined ?
120642
+ oldSignature === undefined ?
120465
120643
  // If we havent computed signature, use fileInfo as is
120466
120644
  value :
120467
120645
  // Serialize fileInfo with new updated signature
120468
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120646
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120469
120647
  // Signature of the FileInfo is undefined, serialize it as false
120470
120648
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120471
120649
  });
@@ -120480,17 +120658,13 @@ var ts;
120480
120658
  if (state.exportedModulesMap) {
120481
120659
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
120482
120660
  var _a;
120483
- if (state.currentAffectedFilesExportedModulesMap) {
120484
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
120485
- return undefined;
120486
- }
120487
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
120488
- if (newValue) {
120489
- return [toFileId(key), toFileIdListId(newValue)];
120490
- }
120491
- }
120661
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
120492
120662
  // Not in temporary cache, use existing value
120493
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120663
+ if (oldValue === undefined)
120664
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120665
+ if (oldValue)
120666
+ return [toFileId(key), toFileIdListId(oldValue)];
120667
+ return undefined;
120494
120668
  });
120495
120669
  }
120496
120670
  var semanticDiagnosticsPerFile;
@@ -120501,9 +120675,7 @@ var ts;
120501
120675
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
120502
120676
  [
120503
120677
  toFileId(key),
120504
- state.hasReusableDiagnostic ?
120505
- value :
120506
- convertToReusableDiagnostics(value, relativeToBuildInfo)
120678
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
120507
120679
  ] :
120508
120680
  toFileId(key));
120509
120681
  }
@@ -120518,16 +120690,27 @@ var ts;
120518
120690
  }
120519
120691
  }
120520
120692
  }
120521
- return {
120693
+ var changeFileSet;
120694
+ if (state.changedFilesSet.size) {
120695
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
120696
+ var path = _e[_d];
120697
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
120698
+ }
120699
+ }
120700
+ var result = {
120522
120701
  fileNames: fileNames,
120523
120702
  fileInfos: fileInfos,
120524
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
120703
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
120525
120704
  fileIdsList: fileIdsList,
120526
120705
  referencedMap: referencedMap,
120527
120706
  exportedModulesMap: exportedModulesMap,
120528
120707
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
120529
120708
  affectedFilesPendingEmit: affectedFilesPendingEmit,
120709
+ changeFileSet: changeFileSet,
120710
+ emitSignatures: emitSignatures,
120711
+ dtsChangeTime: state.dtsChangeTime,
120530
120712
  };
120713
+ return result;
120531
120714
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
120532
120715
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
120533
120716
  }
@@ -120552,24 +120735,18 @@ var ts;
120552
120735
  }
120553
120736
  return fileIdListId;
120554
120737
  }
120555
- }
120556
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
120557
- var result;
120558
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120559
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120560
- var name = _a[_i];
120561
- var optionKey = name.toLowerCase();
120562
- var optionInfo = optionsNameMap.get(optionKey);
120563
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
120564
- // We need to store `strict`, even though it won't be examined directly, so that the
120565
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
120566
- optionKey === "strict" ||
120567
- // We need to store these to determine whether `lib` files need to be rechecked.
120568
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
120569
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
120738
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
120739
+ var result;
120740
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120741
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120742
+ var name = _a[_i];
120743
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
120744
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
120745
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
120746
+ }
120570
120747
  }
120748
+ return result;
120571
120749
  }
120572
- return result;
120573
120750
  }
120574
120751
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
120575
120752
  if (option) {
@@ -120643,6 +120820,10 @@ var ts;
120643
120820
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
120644
120821
  }
120645
120822
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
120823
+ function computeSignature(text, data, computeHash) {
120824
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
120825
+ }
120826
+ ts.computeSignature = computeSignature;
120646
120827
  function createBuilderProgram(kind, _a) {
120647
120828
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
120648
120829
  // Return same program if underlying program doesnt change
@@ -120661,8 +120842,8 @@ var ts;
120661
120842
  */
120662
120843
  var computeHash = ts.maybeBind(host, host.createHash);
120663
120844
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
120664
- var backupState;
120665
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
120845
+ var backupEmitState;
120846
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
120666
120847
  // To ensure that we arent storing any references to old program or new program without state
120667
120848
  newProgram = undefined; // TODO: GH#18217
120668
120849
  oldProgram = undefined;
@@ -120670,20 +120851,20 @@ var ts;
120670
120851
  var getState = function () { return state; };
120671
120852
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
120672
120853
  builderProgram.getState = getState;
120673
- builderProgram.backupState = function () {
120674
- ts.Debug.assert(backupState === undefined);
120675
- backupState = cloneBuilderProgramState(state);
120854
+ builderProgram.backupEmitState = function () {
120855
+ ts.Debug.assert(backupEmitState === undefined);
120856
+ backupEmitState = backupEmitBuilderProgramState(state);
120676
120857
  };
120677
- builderProgram.restoreState = function () {
120678
- state = ts.Debug.checkDefined(backupState);
120679
- backupState = undefined;
120858
+ builderProgram.restoreEmitState = function () {
120859
+ restoreEmitBuilderProgramState(state, ts.Debug.checkDefined(backupEmitState));
120860
+ backupEmitState = undefined;
120680
120861
  };
120681
120862
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
120682
120863
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
120683
120864
  builderProgram.emit = emit;
120684
120865
  builderProgram.releaseProgram = function () {
120685
120866
  releaseCache(state);
120686
- backupState = undefined;
120867
+ backupEmitState = undefined;
120687
120868
  };
120688
120869
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
120689
120870
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
@@ -120742,35 +120923,59 @@ var ts;
120742
120923
  return toAffectedFileEmitResult(state,
120743
120924
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120744
120925
  // Otherwise just affected file
120745
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120746
- getWriteFileUpdatingSignatureCallback(writeFile) :
120926
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
120927
+ getWriteFileCallback(writeFile, customTransformers) :
120747
120928
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120748
120929
  }
120749
- function getWriteFileUpdatingSignatureCallback(writeFile) {
120930
+ function getWriteFileCallback(writeFile, customTransformers) {
120750
120931
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120751
- var _a;
120932
+ var _a, _b, _c;
120752
120933
  if (ts.isDeclarationFileName(fileName)) {
120753
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120754
- var file = sourceFiles[0];
120755
- var info = state.fileInfos.get(file.resolvedPath);
120756
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120757
- if (signature === file.version) {
120758
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120759
- if (newSignature !== file.version) { // Update it
120760
- if (host.storeFilesChangingSignatureDuringEmit)
120761
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120762
- if (state.exportedModulesMap)
120763
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120764
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120765
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120934
+ if (!ts.outFile(state.compilerOptions)) {
120935
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120936
+ var newSignature = void 0;
120937
+ if (!customTransformers) {
120938
+ var file = sourceFiles[0];
120939
+ var info = state.fileInfos.get(file.resolvedPath);
120940
+ if (info.signature === file.version) {
120941
+ newSignature = computeSignature(text, data, computeHash);
120942
+ if (newSignature !== file.version) { // Update it
120943
+ if (host.storeFilesChangingSignatureDuringEmit)
120944
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120945
+ if (state.exportedModulesMap)
120946
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
120947
+ if (state.affectedFiles) {
120948
+ // Keep old signature so we know what to undo if cancellation happens
120949
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
120950
+ if (existing === undefined)
120951
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
120952
+ info.signature = newSignature;
120953
+ }
120954
+ else {
120955
+ // These are directly commited
120956
+ info.signature = newSignature;
120957
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120958
+ }
120959
+ }
120766
120960
  }
120767
- else {
120768
- info.signature = newSignature;
120769
- if (state.exportedModulesMap)
120770
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120961
+ }
120962
+ if (state.compilerOptions.composite) {
120963
+ var filePath = sourceFiles[0].resolvedPath;
120964
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
120965
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
120966
+ if (newSignature !== oldSignature) {
120967
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
120968
+ state.hasChangedEmitSignature = true;
120771
120969
  }
120772
120970
  }
120773
120971
  }
120972
+ else if (state.compilerOptions.composite) {
120973
+ var newSignature = computeSignature(text, data, computeHash);
120974
+ if (newSignature !== state.outSignature) {
120975
+ state.outSignature = newSignature;
120976
+ state.hasChangedEmitSignature = true;
120977
+ }
120978
+ }
120774
120979
  }
120775
120980
  if (writeFile)
120776
120981
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -120835,8 +121040,8 @@ var ts;
120835
121040
  }
120836
121041
  }
120837
121042
  }
120838
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120839
- getWriteFileUpdatingSignatureCallback(writeFile) :
121043
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121044
+ getWriteFileCallback(writeFile, customTransformers) :
120840
121045
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120841
121046
  }
120842
121047
  /**
@@ -120925,29 +121130,58 @@ var ts;
120925
121130
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
120926
121131
  }
120927
121132
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
120928
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
120929
- var _a;
121133
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121134
+ var _a, _b, _c, _d;
120930
121135
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
120931
121136
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
120932
- var filePaths = program.fileNames.map(toPath);
120933
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
120934
- var fileInfos = new ts.Map();
120935
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
120936
- var state = {
120937
- fileInfos: fileInfos,
120938
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
120939
- referencedMap: toManyToManyPathMap(program.referencedMap),
120940
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
120941
- semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }),
120942
- hasReusableDiagnostic: true,
120943
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
120944
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
120945
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
120946
- };
121137
+ var state;
121138
+ var filePaths;
121139
+ var filePathsSetList;
121140
+ if (isProgramBundleEmitBuildInfo(program)) {
121141
+ state = {
121142
+ fileInfos: new ts.Map(),
121143
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121144
+ dtsChangeTime: program.dtsChangeTime,
121145
+ outSignature: program.outSignature,
121146
+ };
121147
+ }
121148
+ else {
121149
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121150
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121151
+ var fileInfos_2 = new ts.Map();
121152
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121153
+ program.fileInfos.forEach(function (fileInfo, index) {
121154
+ var path = toFilePath(index + 1);
121155
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121156
+ fileInfos_2.set(path, stateFileInfo);
121157
+ if (emitSignatures_1 && stateFileInfo.signature)
121158
+ emitSignatures_1.set(path, stateFileInfo.signature);
121159
+ });
121160
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121161
+ if (ts.isNumber(value))
121162
+ emitSignatures_1.delete(toFilePath(value));
121163
+ else
121164
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121165
+ });
121166
+ state = {
121167
+ fileInfos: fileInfos_2,
121168
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121169
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121170
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121171
+ semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }),
121172
+ hasReusableDiagnostic: true,
121173
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121174
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121175
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121176
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121177
+ dtsChangeTime: program.dtsChangeTime,
121178
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121179
+ };
121180
+ }
120947
121181
  return {
120948
121182
  getState: function () { return state; },
120949
- backupState: ts.noop,
120950
- restoreState: ts.noop,
121183
+ backupEmitState: ts.noop,
121184
+ restoreEmitState: ts.noop,
120951
121185
  getProgram: ts.notImplemented,
120952
121186
  getProgramOrUndefined: ts.returnUndefined,
120953
121187
  releaseProgram: ts.noop,
@@ -120992,12 +121226,24 @@ var ts;
120992
121226
  return map;
120993
121227
  }
120994
121228
  }
120995
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121229
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121230
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121231
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121232
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121233
+ var fileInfos = new ts.Map();
121234
+ program.fileInfos.forEach(function (fileInfo, index) {
121235
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121236
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121237
+ fileInfos.set(path, version);
121238
+ });
121239
+ return fileInfos;
121240
+ }
121241
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
120996
121242
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
120997
121243
  return {
120998
121244
  getState: ts.notImplemented,
120999
- backupState: ts.noop,
121000
- restoreState: ts.noop,
121245
+ backupEmitState: ts.noop,
121246
+ restoreEmitState: ts.noop,
121001
121247
  getProgram: getProgram,
121002
121248
  getProgramOrUndefined: function () { return getState().program; },
121003
121249
  releaseProgram: function () { return getState().program = undefined; },
@@ -122113,9 +122359,9 @@ var ts;
122113
122359
  if (!preferSymlinks) {
122114
122360
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122115
122361
  // so we only need to remove them from the realpath filenames.
122116
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122117
- if (result_15)
122118
- return result_15;
122362
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122363
+ if (result_16)
122364
+ return result_16;
122119
122365
  }
122120
122366
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122121
122367
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122135,10 +122381,10 @@ var ts;
122135
122381
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122136
122382
  var symlinkDirectory = symlinkDirectories_1[_i];
122137
122383
  var option = ts.resolvePath(symlinkDirectory, relative);
122138
- var result_16 = cb(option, target === referenceRedirect);
122384
+ var result_17 = cb(option, target === referenceRedirect);
122139
122385
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122140
- if (result_16)
122141
- return result_16;
122386
+ if (result_17)
122387
+ return result_17;
122142
122388
  }
122143
122389
  });
122144
122390
  });
@@ -122180,7 +122426,7 @@ var ts;
122180
122426
  });
122181
122427
  // Sort by paths closest to importing file Name directory
122182
122428
  var sortedPaths = [];
122183
- var _loop_32 = function (directory) {
122429
+ var _loop_33 = function (directory) {
122184
122430
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122185
122431
  var pathsInDirectory;
122186
122432
  allFileNames.forEach(function (_a, fileName) {
@@ -122204,7 +122450,7 @@ var ts;
122204
122450
  };
122205
122451
  var out_directory_1;
122206
122452
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122207
- var state_10 = _loop_32(directory);
122453
+ var state_10 = _loop_33(directory);
122208
122454
  directory = out_directory_1;
122209
122455
  if (state_10 === "break")
122210
122456
  break;
@@ -123048,6 +123294,7 @@ var ts;
123048
123294
  readDirectory: ts.maybeBind(host, host.readDirectory),
123049
123295
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123050
123296
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123297
+ now: ts.maybeBind(host, host.now),
123051
123298
  };
123052
123299
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123053
123300
  try {
@@ -123108,6 +123355,7 @@ var ts;
123108
123355
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123109
123356
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123110
123357
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123358
+ now: ts.maybeBind(system, system.now),
123111
123359
  };
123112
123360
  }
123113
123361
  ts.createProgramHost = createProgramHost;
@@ -123175,20 +123423,26 @@ var ts;
123175
123423
  var ts;
123176
123424
  (function (ts) {
123177
123425
  function readBuilderProgram(compilerOptions, host) {
123178
- if (ts.outFile(compilerOptions))
123179
- return undefined;
123180
123426
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123181
123427
  if (!buildInfoPath)
123182
123428
  return undefined;
123183
- var content = host.readFile(buildInfoPath);
123184
- if (!content)
123185
- return undefined;
123186
- var buildInfo = ts.getBuildInfo(content);
123429
+ var buildInfo;
123430
+ if (host.getBuildInfo) {
123431
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
123432
+ if (!buildInfo)
123433
+ return undefined;
123434
+ }
123435
+ else {
123436
+ var content = host.readFile(buildInfoPath);
123437
+ if (!content)
123438
+ return undefined;
123439
+ buildInfo = ts.getBuildInfo(content);
123440
+ }
123187
123441
  if (buildInfo.version !== ts.version)
123188
123442
  return undefined;
123189
123443
  if (!buildInfo.program)
123190
123444
  return undefined;
123191
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123445
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123192
123446
  }
123193
123447
  ts.readBuilderProgram = readBuilderProgram;
123194
123448
  function createIncrementalCompilerHost(options, system) {
@@ -123197,6 +123451,7 @@ var ts;
123197
123451
  host.createHash = ts.maybeBind(system, system.createHash);
123198
123452
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123199
123453
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
123454
+ host.now = ts.maybeBind(system, system.now);
123200
123455
  ts.setGetSourceFileAsHashVersioned(host, system);
123201
123456
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123202
123457
  return host;
@@ -123651,6 +123906,7 @@ var ts;
123651
123906
  }
123652
123907
  function reloadFileNamesFromConfigFile() {
123653
123908
  writeLog("Reloading new file names and options");
123909
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123654
123910
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123655
123911
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123656
123912
  hasChangedConfigFileParsingErrors = true;
@@ -123931,14 +124187,17 @@ var ts;
123931
124187
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
123932
124188
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
123933
124189
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
123934
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
123935
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
123936
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
123937
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124190
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124191
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124192
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124193
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124194
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124195
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
123938
124196
  /**
123939
124197
  * Projects with no outputs (i.e. "solution" files)
123940
124198
  */
123941
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124199
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124200
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
123942
124201
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
123943
124202
  function resolveConfigFileProjectName(project) {
123944
124203
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -123983,9 +124242,11 @@ var ts;
123983
124242
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
123984
124243
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
123985
124244
  }
123986
- function newer(date1, date2) {
123987
- return date2 > date1 ? date2 : date1;
124245
+ /*@internal*/
124246
+ function getCurrentTime(host) {
124247
+ return host.now ? host.now() : new Date();
123988
124248
  }
124249
+ ts.getCurrentTime = getCurrentTime;
123989
124250
  /*@internal*/
123990
124251
  function isCircularBuildOrder(buildOrder) {
123991
124252
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124075,6 +124336,7 @@ var ts;
124075
124336
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124076
124337
  };
124077
124338
  }
124339
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124078
124340
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124079
124341
  var state = {
124080
124342
  host: host,
@@ -124091,8 +124353,9 @@ var ts;
124091
124353
  resolvedConfigFilePaths: new ts.Map(),
124092
124354
  configFileCache: new ts.Map(),
124093
124355
  projectStatus: new ts.Map(),
124094
- buildInfoChecked: new ts.Map(),
124095
124356
  extendedConfigCache: new ts.Map(),
124357
+ buildInfoCache: new ts.Map(),
124358
+ outputTimeStamps: new ts.Map(),
124096
124359
  builderPrograms: new ts.Map(),
124097
124360
  diagnostics: new ts.Map(),
124098
124361
  projectPendingBuild: new ts.Map(),
@@ -124115,6 +124378,7 @@ var ts;
124115
124378
  allWatchedConfigFiles: new ts.Map(),
124116
124379
  allWatchedExtendedConfigFiles: new ts.Map(),
124117
124380
  allWatchedPackageJsonFiles: new ts.Map(),
124381
+ filesWatched: new ts.Map(),
124118
124382
  lastCachedPackageJsonLookups: new ts.Map(),
124119
124383
  timerToBuildInvalidatedProject: undefined,
124120
124384
  reportFileChangeDetected: false,
@@ -124149,6 +124413,7 @@ var ts;
124149
124413
  if (value) {
124150
124414
  return isParsedCommandLine(value) ? value : undefined;
124151
124415
  }
124416
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124152
124417
  var diagnostic;
124153
124418
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124154
124419
  var parsed;
@@ -124163,6 +124428,8 @@ var ts;
124163
124428
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124164
124429
  }
124165
124430
  configFileCache.set(configFilePath, parsed || diagnostic);
124431
+ ts.solutionPerformance.mark("afterParseConfigFile");
124432
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124166
124433
  return parsed;
124167
124434
  }
124168
124435
  function resolveProjectName(state, name) {
@@ -124212,6 +124479,7 @@ var ts;
124212
124479
  return state.buildOrder || createStateBuildOrder(state);
124213
124480
  }
124214
124481
  function createStateBuildOrder(state) {
124482
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124215
124483
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124216
124484
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124217
124485
  state.resolvedConfigFilePaths.clear();
@@ -124221,11 +124489,12 @@ var ts;
124221
124489
  // Config file cache
124222
124490
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124223
124491
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124224
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124225
124492
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124226
124493
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124227
124494
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124228
124495
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124496
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124497
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124229
124498
  // Remove watches for the program no longer in the solution
124230
124499
  if (state.watch) {
124231
124500
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -124241,6 +124510,8 @@ var ts;
124241
124510
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124242
124511
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124243
124512
  }
124513
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124514
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124244
124515
  return state.buildOrder = buildOrder;
124245
124516
  }
124246
124517
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124361,6 +124632,7 @@ var ts;
124361
124632
  if (updateOutputFileStampsPending) {
124362
124633
  updateOutputTimestamps(state, config, projectPath);
124363
124634
  }
124635
+ ts.solutionPerformance.mark("timestampUpdated");
124364
124636
  return doneInvalidatedProject(state, projectPath);
124365
124637
  }
124366
124638
  };
@@ -124454,6 +124726,10 @@ var ts;
124454
124726
  };
124455
124727
  function done(cancellationToken, writeFile, customTransformers) {
124456
124728
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124729
+ if (kind === InvalidatedProjectKind.Build)
124730
+ ts.solutionPerformance.mark("projectsBuilt");
124731
+ else
124732
+ ts.solutionPerformance.mark("bundlesUpdated");
124457
124733
  return doneInvalidatedProject(state, projectPath);
124458
124734
  }
124459
124735
  function withProgramOrUndefined(action) {
@@ -124515,21 +124791,21 @@ var ts;
124515
124791
  }
124516
124792
  function emit(writeFileCallback, cancellationToken, customTransformers) {
124517
124793
  var _a;
124518
- var _b, _c;
124794
+ var _b, _c, _d;
124519
124795
  ts.Debug.assertIsDefined(program);
124520
124796
  ts.Debug.assert(step === BuildStep.Emit);
124521
124797
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
124522
- program.backupState();
124798
+ program.backupEmitState();
124523
124799
  var declDiagnostics;
124524
124800
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
124525
124801
  var outputFiles = [];
124526
124802
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
124527
124803
  /*write*/ undefined,
124528
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
124804
+ /*reportSummary*/ undefined, function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark, buildInfo: data === null || data === void 0 ? void 0 : data.buildInfo }); }, cancellationToken,
124529
124805
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
124530
124806
  // Don't emit .d.ts if there are decl file errors
124531
124807
  if (declDiagnostics) {
124532
- program.restoreState();
124808
+ program.restoreEmitState();
124533
124809
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
124534
124810
  return {
124535
124811
  emitSkipped: true,
@@ -124539,37 +124815,46 @@ var ts;
124539
124815
  // Actual Emit
124540
124816
  var host = state.host, compilerHost = state.compilerHost;
124541
124817
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124542
- var newestDeclarationFileContentChangedTime = minimumDate;
124543
- var anyDtsChanged = false;
124818
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
124544
124819
  var emitterDiagnostics = ts.createDiagnosticCollection();
124545
124820
  var emittedOutputs = new ts.Map();
124821
+ var options = program.getCompilerOptions();
124822
+ var isIncremental = ts.isIncrementalCompilation(options);
124823
+ var outputTimeStampMap;
124824
+ var now;
124825
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124546
124826
  outputFiles.forEach(function (_a) {
124547
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124548
- var priorChangeTime;
124549
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124550
- // Check for unchanged .d.ts files
124551
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124552
- priorChangeTime = host.getModifiedTime(name);
124553
- }
124554
- else {
124827
+ var _b, _c;
124828
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124829
+ var path = toPath(state, name);
124830
+ emittedOutputs.set(toPath(state, name), name);
124831
+ if (buildInfo) {
124832
+ setBuildInfo(state, buildInfo, projectPath, options);
124833
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
124555
124834
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124556
- anyDtsChanged = true;
124557
124835
  }
124558
124836
  }
124559
- emittedOutputs.set(toPath(state, name), name);
124560
124837
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124561
- if (priorChangeTime !== undefined) {
124562
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124838
+ if (!isIncremental && state.watch) {
124839
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
124563
124840
  }
124564
124841
  });
124565
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124566
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124842
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124843
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124844
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124567
124845
  return emitResult;
124568
124846
  }
124569
124847
  function emitBuildInfo(writeFileCallback, cancellationToken) {
124570
124848
  ts.Debug.assertIsDefined(program);
124571
124849
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
124572
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
124850
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
124851
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
124852
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
124853
+ if (writeFileCallback)
124854
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
124855
+ else
124856
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
124857
+ }, cancellationToken);
124573
124858
  if (emitResult.diagnostics.length) {
124574
124859
  reportErrors(state, emitResult.diagnostics);
124575
124860
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -124582,7 +124867,7 @@ var ts;
124582
124867
  step = BuildStep.QueueReferencingProjects;
124583
124868
  return emitResult;
124584
124869
  }
124585
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
124870
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
124586
124871
  var _a;
124587
124872
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
124588
124873
  if (emitDiagnostics.length) {
@@ -124593,13 +124878,11 @@ var ts;
124593
124878
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
124594
124879
  }
124595
124880
  // Update time stamps for rest of the outputs
124596
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124881
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124597
124882
  state.diagnostics.delete(projectPath);
124598
124883
  state.projectStatus.set(projectPath, {
124599
124884
  type: ts.UpToDateStatusType.UpToDate,
124600
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
124601
- maximumDate :
124602
- newestDeclarationFileContentChangedTime,
124885
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
124603
124886
  oldestOutputFileName: oldestOutputFileName
124604
124887
  });
124605
124888
  afterProgramDone(state, program, config);
@@ -124634,13 +124917,21 @@ var ts;
124634
124917
  ts.Debug.assert(!!outputFiles.length);
124635
124918
  var emitterDiagnostics = ts.createDiagnosticCollection();
124636
124919
  var emittedOutputs = new ts.Map();
124920
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124921
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
124637
124922
  outputFiles.forEach(function (_a) {
124638
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124923
+ var _b, _c;
124924
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124639
124925
  emittedOutputs.set(toPath(state, name), name);
124926
+ if (buildInfo) {
124927
+ setBuildInfo(state, buildInfo, projectPath, config.options);
124928
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
124929
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124930
+ }
124931
+ }
124640
124932
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124641
124933
  });
124642
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
124643
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
124934
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
124644
124935
  return { emitSkipped: false, diagnostics: emitDiagnostics };
124645
124936
  }
124646
124937
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -124691,6 +124982,13 @@ var ts;
124691
124982
  !ts.isIncrementalCompilation(config.options);
124692
124983
  }
124693
124984
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124985
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
124986
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
124987
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
124988
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
124989
+ return result;
124990
+ }
124991
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124694
124992
  if (!state.projectPendingBuild.size)
124695
124993
  return undefined;
124696
124994
  if (isCircularBuildOrder(buildOrder))
@@ -124739,7 +125037,7 @@ var ts;
124739
125037
  }
124740
125038
  continue;
124741
125039
  }
124742
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125040
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
124743
125041
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124744
125042
  return {
124745
125043
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -124790,9 +125088,7 @@ var ts;
124790
125088
  }
124791
125089
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124792
125090
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124793
- if (!info)
124794
- return info;
124795
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
125091
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124796
125092
  }
124797
125093
  function listEmittedFile(_a, proj, file) {
124798
125094
  var write = _a.write;
@@ -124800,14 +125096,17 @@ var ts;
124800
125096
  write("TSFILE: " + file);
124801
125097
  }
124802
125098
  }
124803
- function getOldProgram(_a, proj, parsed) {
124804
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
124805
- if (options.force)
125099
+ function getOldProgram(state, proj, parsed) {
125100
+ if (state.options.force)
124806
125101
  return undefined;
124807
- var value = builderPrograms.get(proj);
125102
+ var value = state.builderPrograms.get(proj);
124808
125103
  if (value)
124809
125104
  return value;
124810
- return ts.readBuilderProgram(parsed.options, compilerHost);
125105
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
125106
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
125107
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
125108
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
125109
+ return program;
124811
125110
  }
124812
125111
  function afterProgramDone(state, program, config) {
124813
125112
  if (program) {
@@ -124824,7 +125123,7 @@ var ts;
124824
125123
  state.projectCompilerOptions = state.baseCompilerOptions;
124825
125124
  }
124826
125125
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
124827
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125126
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
124828
125127
  reportAndStoreErrors(state, resolvedPath, diagnostics);
124829
125128
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
124830
125129
  if (canEmitBuildInfo)
@@ -124832,9 +125131,101 @@ var ts;
124832
125131
  afterProgramDone(state, program, config);
124833
125132
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
124834
125133
  }
125134
+ function isFileWatcherWithModifiedTime(value) {
125135
+ return !!value.watcher;
125136
+ }
125137
+ function getModifiedTime(state, fileName) {
125138
+ var path = toPath(state, fileName);
125139
+ var existing = state.filesWatched.get(path);
125140
+ if (state.watch && !!existing) {
125141
+ if (!isFileWatcherWithModifiedTime(existing))
125142
+ return existing;
125143
+ if (existing.modifiedTime)
125144
+ return existing.modifiedTime;
125145
+ }
125146
+ var result = ts.getModifiedTime(state.host, fileName);
125147
+ if (state.watch) {
125148
+ if (existing)
125149
+ existing.modifiedTime = result;
125150
+ else
125151
+ state.filesWatched.set(path, result);
125152
+ }
125153
+ return result;
125154
+ }
125155
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125156
+ var path = toPath(state, file);
125157
+ var existing = state.filesWatched.get(path);
125158
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125159
+ existing.callbacks.push(callback);
125160
+ }
125161
+ else {
125162
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125163
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125164
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125165
+ existing.modifiedTime = modifiedTime;
125166
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125167
+ }, pollingInterval, options, watchType, project);
125168
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125169
+ }
125170
+ return {
125171
+ close: function () {
125172
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125173
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125174
+ if (existing.callbacks.length === 1) {
125175
+ state.filesWatched.delete(path);
125176
+ ts.closeFileWatcherOf(existing);
125177
+ }
125178
+ else {
125179
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125180
+ }
125181
+ }
125182
+ };
125183
+ }
125184
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125185
+ if (!state.watch)
125186
+ return undefined;
125187
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125188
+ if (!result)
125189
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125190
+ return result;
125191
+ }
125192
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125193
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125194
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125195
+ if (existing) {
125196
+ existing.buildInfo = buildInfo;
125197
+ existing.modifiedTime = getCurrentTime(state.host);
125198
+ }
125199
+ else {
125200
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125201
+ }
125202
+ }
125203
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125204
+ var path = toPath(state, buildInfoPath);
125205
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125206
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125207
+ }
125208
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125209
+ var path = toPath(state, buildInfoPath);
125210
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125211
+ if (existing !== undefined && existing.path === path) {
125212
+ return existing.buildInfo || undefined;
125213
+ }
125214
+ ts.solutionPerformance.mark("beforeGetBuildInfo");
125215
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125216
+ var value = state.readFileWithCache(buildInfoPath);
125217
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125218
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125219
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125220
+ ts.Debug.assert(modifiedTime || !buildInfo);
125221
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125222
+ ts.solutionPerformance.mark("afterGetBuildInfo");
125223
+ ts.solutionPerformance.measure("GetBuildInfo", "beforeGetBuildInfo", "afterGetBuildInfo");
125224
+ return buildInfo;
125225
+ }
124835
125226
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
124836
125227
  // Check tsconfig time
124837
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125228
+ var tsconfigTime = getModifiedTime(state, configFile);
124838
125229
  if (oldestOutputFileTime < tsconfigTime) {
124839
125230
  return {
124840
125231
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -124844,88 +125235,24 @@ var ts;
124844
125235
  }
124845
125236
  }
124846
125237
  function getUpToDateStatusWorker(state, project, resolvedPath) {
124847
- var force = !!state.options.force;
124848
- var newestInputFileName = undefined;
124849
- var newestInputFileTime = minimumDate;
124850
- var host = state.host;
124851
- // Get timestamps of input files
124852
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
124853
- var inputFile = _a[_i];
124854
- if (!host.fileExists(inputFile)) {
124855
- return {
124856
- type: ts.UpToDateStatusType.Unbuildable,
124857
- reason: inputFile + " does not exist"
124858
- };
124859
- }
124860
- if (!force) {
124861
- var inputTime = ts.getModifiedTime(host, inputFile);
124862
- if (inputTime > newestInputFileTime) {
124863
- newestInputFileName = inputFile;
124864
- newestInputFileTime = inputTime;
124865
- }
124866
- }
124867
- }
125238
+ var _a, _b, _c;
124868
125239
  // Container if no files are specified in the project
124869
125240
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
124870
125241
  return {
124871
125242
  type: ts.UpToDateStatusType.ContainerOnly
124872
125243
  };
124873
125244
  }
124874
- // Collect the expected outputs of this project
124875
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
124876
- // Now see if all outputs are newer than the newest input
124877
- var oldestOutputFileName = "(none)";
124878
- var oldestOutputFileTime = maximumDate;
124879
- var newestOutputFileName = "(none)";
124880
- var newestOutputFileTime = minimumDate;
124881
- var missingOutputFileName;
124882
- var newestDeclarationFileContentChangedTime = minimumDate;
124883
- var isOutOfDateWithInputs = false;
124884
- if (!force) {
124885
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
124886
- var output = outputs_1[_b];
124887
- // Output is missing; can stop checking
124888
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
124889
- if (!host.fileExists(output)) {
124890
- missingOutputFileName = output;
124891
- break;
124892
- }
124893
- var outputTime = ts.getModifiedTime(host, output);
124894
- if (outputTime < oldestOutputFileTime) {
124895
- oldestOutputFileTime = outputTime;
124896
- oldestOutputFileName = output;
124897
- }
124898
- // If an output is older than the newest input, we can stop checking
124899
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
124900
- if (outputTime < newestInputFileTime) {
124901
- isOutOfDateWithInputs = true;
124902
- break;
124903
- }
124904
- if (outputTime > newestOutputFileTime) {
124905
- newestOutputFileTime = outputTime;
124906
- newestOutputFileName = output;
124907
- }
124908
- // Keep track of when the most recent time a .d.ts file was changed.
124909
- // In addition to file timestamps, we also keep track of when a .d.ts file
124910
- // had its file touched but not had its contents changed - this allows us
124911
- // to skip a downstream typecheck
124912
- if (ts.isDeclarationFileName(output)) {
124913
- var outputModifiedTime = ts.getModifiedTime(host, output);
124914
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124915
- }
124916
- }
124917
- }
124918
- var pseudoUpToDate = false;
124919
- var usesPrepend = false;
124920
- var upstreamChangedProject;
125245
+ // Fast check to see if reference projects are buildable
125246
+ var referenceStatuses;
125247
+ var force = !!state.options.force;
124921
125248
  if (project.projectReferences) {
124922
125249
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
124923
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
124924
- var ref = _d[_c];
124925
- usesPrepend = usesPrepend || !!(ref.prepend);
125250
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125251
+ var ref = _d[_i];
124926
125252
  var resolvedRef = ts.resolveProjectReferencePath(ref);
124927
125253
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
124928
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125254
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125255
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
124929
125256
  // Its a circular reference ignore the status of this project
124930
125257
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
124931
125258
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -124947,75 +125274,188 @@ var ts;
124947
125274
  upstreamProjectName: ref.path
124948
125275
  };
124949
125276
  }
124950
- // Check oldest output file name only if there is no missing output file name
124951
- // (a check we will have skipped if this is a forced build)
124952
- if (!force && !missingOutputFileName) {
124953
- // If the upstream project's newest file is older than our oldest output, we
124954
- // can't be out of date because of it
124955
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
124956
- continue;
124957
- }
124958
- // If the upstream project has only change .d.ts files, and we've built
124959
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
124960
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
124961
- pseudoUpToDate = true;
124962
- upstreamChangedProject = ref.path;
124963
- continue;
124964
- }
124965
- // We have an output older than an upstream output - we are out of date
124966
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125277
+ if (!force)
125278
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125279
+ }
125280
+ }
125281
+ if (force)
125282
+ return { type: ts.UpToDateStatusType.ForceBuild };
125283
+ // Check buildinfo first
125284
+ var host = state.host;
125285
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125286
+ var oldestOutputFileName = "(none)";
125287
+ var oldestOutputFileTime = maximumDate;
125288
+ var buildInfoTime;
125289
+ var buildInfoProgram;
125290
+ var buildInfoVersionMap;
125291
+ var newestDeclarationFileContentChangedTime;
125292
+ if (buildInfoPath) {
125293
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125294
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125295
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125296
+ if (!buildInfoCacheEntry_1) {
125297
+ state.buildInfoCache.set(resolvedPath, {
125298
+ path: toPath(state, buildInfoPath),
125299
+ buildInfo: false,
125300
+ modifiedTime: buildInfoTime
125301
+ });
125302
+ }
125303
+ return {
125304
+ type: ts.UpToDateStatusType.OutputMissing,
125305
+ missingOutputFileName: buildInfoPath
125306
+ };
125307
+ }
125308
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125309
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125310
+ return {
125311
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125312
+ version: buildInfo.version
125313
+ };
125314
+ }
125315
+ if (buildInfo.program) {
125316
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125317
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
124967
125318
  return {
124968
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
124969
- outOfDateOutputFileName: oldestOutputFileName,
124970
- newerProjectName: ref.path
125319
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125320
+ buildInfoFile: buildInfoPath
124971
125321
  };
124972
125322
  }
125323
+ buildInfoProgram = buildInfo.program;
124973
125324
  }
125325
+ oldestOutputFileTime = buildInfoTime;
125326
+ oldestOutputFileName = buildInfoPath;
125327
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
124974
125328
  }
124975
- if (missingOutputFileName !== undefined) {
124976
- return {
124977
- type: ts.UpToDateStatusType.OutputMissing,
124978
- missingOutputFileName: missingOutputFileName
124979
- };
125329
+ // Check input files
125330
+ var newestInputFileName = undefined;
125331
+ var newestInputFileTime = minimumDate;
125332
+ var pseudoInputUptodate = false;
125333
+ // Get timestamps of input files
125334
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125335
+ var inputFile = _f[_e];
125336
+ var inputTime = getModifiedTime(state, inputFile);
125337
+ if (inputTime === ts.missingFileModifiedTime) {
125338
+ return {
125339
+ type: ts.UpToDateStatusType.Unbuildable,
125340
+ reason: inputFile + " does not exist"
125341
+ };
125342
+ }
125343
+ // If an buildInfo is older than the newest input, we can stop checking
125344
+ if (buildInfoTime && buildInfoTime < inputTime) {
125345
+ var version_3 = void 0;
125346
+ var currentVersion = void 0;
125347
+ if (buildInfoProgram) {
125348
+ // Read files and see if they are same, read is anyways cached
125349
+ if (!buildInfoVersionMap)
125350
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125351
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125352
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125353
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125354
+ if (version_3 && version_3 === currentVersion)
125355
+ pseudoInputUptodate = true;
125356
+ }
125357
+ if (!version_3 || version_3 !== currentVersion) {
125358
+ return {
125359
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125360
+ outOfDateOutputFileName: buildInfoPath,
125361
+ newerInputFileName: inputFile
125362
+ };
125363
+ }
125364
+ }
125365
+ if (inputTime > newestInputFileTime) {
125366
+ newestInputFileName = inputFile;
125367
+ newestInputFileTime = inputTime;
125368
+ }
124980
125369
  }
124981
- if (isOutOfDateWithInputs) {
124982
- return {
124983
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
124984
- outOfDateOutputFileName: oldestOutputFileName,
124985
- newerInputFileName: newestInputFileName
124986
- };
125370
+ // Now see if all outputs are newer than the newest input
125371
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125372
+ if (!buildInfoPath) {
125373
+ // Collect the expected outputs of this project
125374
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125375
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125376
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125377
+ var output = outputs_1[_g];
125378
+ var path = toPath(state, output);
125379
+ // Output is missing; can stop checking
125380
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125381
+ if (!outputTime) {
125382
+ outputTime = ts.getModifiedTime(state.host, output);
125383
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125384
+ }
125385
+ if (outputTime === ts.missingFileModifiedTime) {
125386
+ return {
125387
+ type: ts.UpToDateStatusType.OutputMissing,
125388
+ missingOutputFileName: output
125389
+ };
125390
+ }
125391
+ if (outputTime < oldestOutputFileTime) {
125392
+ oldestOutputFileTime = outputTime;
125393
+ oldestOutputFileName = output;
125394
+ }
125395
+ // If an output is older than the newest input, we can stop checking
125396
+ if (outputTime < newestInputFileTime) {
125397
+ return {
125398
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125399
+ outOfDateOutputFileName: oldestOutputFileName,
125400
+ newerInputFileName: newestInputFileName
125401
+ };
125402
+ }
125403
+ }
124987
125404
  }
124988
- else {
124989
- // Check tsconfig time
124990
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
124991
- if (configStatus)
124992
- return configStatus;
124993
- // Check extended config time
124994
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
124995
- if (extendedConfigStatus)
124996
- return extendedConfigStatus;
124997
- // Check package file time
124998
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
124999
- var path = _a[0];
125000
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125001
- });
125002
- if (dependentPackageFileStatus)
125003
- return dependentPackageFileStatus;
125004
- }
125005
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125006
- state.buildInfoChecked.set(resolvedPath, true);
125007
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125008
- if (buildInfoPath) {
125009
- var value = state.readFileWithCache(buildInfoPath);
125010
- var buildInfo = value && ts.getBuildInfo(value);
125011
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125405
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125406
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125407
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125408
+ var pseudoUpToDate = false;
125409
+ var usesPrepend = false;
125410
+ var upstreamChangedProject;
125411
+ if (referenceStatuses) {
125412
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125413
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125414
+ usesPrepend = usesPrepend || !!(ref.prepend);
125415
+ // If the upstream project's newest file is older than our oldest output, we
125416
+ // can't be out of date because of it
125417
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125418
+ continue;
125419
+ }
125420
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125421
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125012
125422
  return {
125013
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125014
- version: buildInfo.version
125423
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125424
+ outOfDateOutputFileName: buildInfoPath,
125425
+ newerProjectName: ref.path
125015
125426
  };
125016
125427
  }
125428
+ // If the upstream project has only change .d.ts files, and we've built
125429
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125430
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125431
+ pseudoUpToDate = true;
125432
+ upstreamChangedProject = ref.path;
125433
+ continue;
125434
+ }
125435
+ // We have an output older than an upstream output - we are out of date
125436
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125437
+ return {
125438
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125439
+ outOfDateOutputFileName: oldestOutputFileName,
125440
+ newerProjectName: ref.path
125441
+ };
125017
125442
  }
125018
125443
  }
125444
+ // Check tsconfig time
125445
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125446
+ if (configStatus)
125447
+ return configStatus;
125448
+ // Check extended config time
125449
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125450
+ if (extendedConfigStatus)
125451
+ return extendedConfigStatus;
125452
+ // Check package file time
125453
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125454
+ var path = _a[0];
125455
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125456
+ });
125457
+ if (dependentPackageFileStatus)
125458
+ return dependentPackageFileStatus;
125019
125459
  if (usesPrepend && pseudoUpToDate) {
125020
125460
  return {
125021
125461
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125025,15 +125465,37 @@ var ts;
125025
125465
  }
125026
125466
  // Up to date
125027
125467
  return {
125028
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
125468
+ type: pseudoUpToDate ?
125469
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
125470
+ pseudoInputUptodate ?
125471
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
125472
+ ts.UpToDateStatusType.UpToDate,
125029
125473
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125030
125474
  newestInputFileTime: newestInputFileTime,
125031
- newestOutputFileTime: newestOutputFileTime,
125032
125475
  newestInputFileName: newestInputFileName,
125033
- newestOutputFileName: newestOutputFileName,
125034
125476
  oldestOutputFileName: oldestOutputFileName
125035
125477
  };
125036
125478
  }
125479
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
125480
+ if (seenRefs.has(resolvedRefPath))
125481
+ return false;
125482
+ seenRefs.add(resolvedRefPath);
125483
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
125484
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
125485
+ return true;
125486
+ if (resolvedConfig.projectReferences) {
125487
+ // Check references
125488
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
125489
+ var ref = _a[_i];
125490
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
125491
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
125492
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
125493
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
125494
+ return true;
125495
+ }
125496
+ }
125497
+ return false;
125498
+ }
125037
125499
  function getUpToDateStatus(state, project, resolvedPath) {
125038
125500
  if (project === undefined) {
125039
125501
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125042,43 +125504,76 @@ var ts;
125042
125504
  if (prior !== undefined) {
125043
125505
  return prior;
125044
125506
  }
125507
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125045
125508
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125509
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125510
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125046
125511
  state.projectStatus.set(resolvedPath, actual);
125047
125512
  return actual;
125048
125513
  }
125049
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125514
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125050
125515
  if (proj.options.noEmit)
125051
- return priorNewestUpdateTime;
125052
- var host = state.host;
125053
- var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125054
- if (!skipOutputs || outputs.length !== skipOutputs.size) {
125055
- var reportVerbose = !!state.options.verbose;
125056
- var now = host.now ? host.now() : new Date();
125057
- for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125058
- var file = outputs_2[_i];
125059
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
125060
- continue;
125061
- }
125062
- if (reportVerbose) {
125063
- reportVerbose = false;
125516
+ return;
125517
+ var now;
125518
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125519
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
125520
+ if (buildInfoPath) {
125521
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
125522
+ if (!!state.options.verbose)
125064
125523
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125524
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
125525
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
125526
+ }
125527
+ state.outputTimeStamps.delete(projectPath);
125528
+ }
125529
+ else {
125530
+ var host = state.host;
125531
+ var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125532
+ var outputTimeStampMap_1 = getOutputTimeStampMap(state, projectPath);
125533
+ var modifiedOutputs_1 = outputTimeStampMap_1 ? new ts.Set() : undefined;
125534
+ if (!skipOutputs || outputs.length !== skipOutputs.size) {
125535
+ var reportVerbose = !!state.options.verbose;
125536
+ for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125537
+ var file = outputs_2[_i];
125538
+ var path = toPath(state, file);
125539
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125540
+ continue;
125541
+ if (reportVerbose) {
125542
+ reportVerbose = false;
125543
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
125544
+ }
125545
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
125546
+ if (outputTimeStampMap_1) {
125547
+ outputTimeStampMap_1.set(path, now);
125548
+ modifiedOutputs_1.add(path);
125549
+ }
125065
125550
  }
125066
- if (ts.isDeclarationFileName(file)) {
125067
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
125068
- }
125069
- host.setModifiedTime(file, now);
125070
125551
  }
125552
+ // Clear out timestamps not in output list any more
125553
+ outputTimeStampMap_1 === null || outputTimeStampMap_1 === void 0 ? void 0 : outputTimeStampMap_1.forEach(function (_value, key) {
125554
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs_1.has(key))
125555
+ outputTimeStampMap_1.delete(key);
125556
+ });
125071
125557
  }
125072
- return priorNewestUpdateTime;
125558
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125559
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125560
+ }
125561
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
125562
+ var _a;
125563
+ if (!options.composite)
125564
+ return undefined;
125565
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125566
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
125567
+ return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125073
125568
  }
125074
125569
  function updateOutputTimestamps(state, proj, resolvedPath) {
125075
125570
  if (state.options.dry) {
125076
125571
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125077
125572
  }
125078
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125573
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125079
125574
  state.projectStatus.set(resolvedPath, {
125080
125575
  type: ts.UpToDateStatusType.UpToDate,
125081
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
125576
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125082
125577
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125083
125578
  });
125084
125579
  }
@@ -125124,6 +125619,7 @@ var ts;
125124
125619
  break;
125125
125620
  }
125126
125621
  // falls through
125622
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125127
125623
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125128
125624
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125129
125625
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125147,6 +125643,13 @@ var ts;
125147
125643
  }
125148
125644
  }
125149
125645
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125646
+ ts.solutionPerformance.mark("beforeBuild");
125647
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125648
+ ts.solutionPerformance.mark("afterBuild");
125649
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125650
+ return result;
125651
+ }
125652
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125150
125653
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125151
125654
  if (!buildOrder)
125152
125655
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125158,7 +125661,10 @@ var ts;
125158
125661
  if (!invalidatedProject)
125159
125662
  break;
125160
125663
  reportQueue = false;
125664
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125161
125665
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125666
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125667
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125162
125668
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125163
125669
  successfulProjects++;
125164
125670
  }
@@ -125247,6 +125753,14 @@ var ts;
125247
125753
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125248
125754
  }
125249
125755
  function buildNextInvalidatedProject(state, changeDetected) {
125756
+ ts.solutionPerformance.mark("beforeBuild");
125757
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125758
+ ts.solutionPerformance.mark("afterBuild");
125759
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125760
+ if (buildOrder)
125761
+ reportErrorSummary(state, buildOrder);
125762
+ }
125763
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125250
125764
  state.timerToBuildInvalidatedProject = undefined;
125251
125765
  if (state.reportFileChangeDetected) {
125252
125766
  state.reportFileChangeDetected = false;
@@ -125257,7 +125771,10 @@ var ts;
125257
125771
  var buildOrder = getBuildOrder(state);
125258
125772
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125259
125773
  if (invalidatedProject) {
125774
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125260
125775
  invalidatedProject.done();
125776
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125777
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125261
125778
  projectsBuilt++;
125262
125779
  while (state.projectPendingBuild.size) {
125263
125780
  // If already scheduled, skip
@@ -125273,23 +125790,24 @@ var ts;
125273
125790
  return;
125274
125791
  }
125275
125792
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125793
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125276
125794
  project.done();
125795
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125796
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125277
125797
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125278
125798
  projectsBuilt++;
125279
125799
  }
125280
125800
  }
125281
125801
  disableCache(state);
125282
- reportErrorSummary(state, buildOrder);
125802
+ return buildOrder;
125283
125803
  }
125284
125804
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125285
125805
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125286
125806
  return;
125287
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125288
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125289
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
125807
+ state.allWatchedConfigFiles.set(resolvedPath, watchFile(state, resolved, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
125290
125808
  }
125291
125809
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125292
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
125810
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125293
125811
  var _a;
125294
125812
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125295
125813
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125321,7 +125839,7 @@ var ts;
125321
125839
  if (!state.watch)
125322
125840
  return;
125323
125841
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125324
- createNewValue: function (_path, input) { return state.watchFile(input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.SourceFile, resolved); },
125842
+ createNewValue: function (_path, input) { return watchFile(state, input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.SourceFile, resolved); },
125325
125843
  onDeleteValue: ts.closeFileWatcher,
125326
125844
  });
125327
125845
  }
@@ -125329,13 +125847,14 @@ var ts;
125329
125847
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125330
125848
  return;
125331
125849
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125332
- createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
125850
+ createNewValue: function (path, _input) { return watchFile(state, path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
125333
125851
  onDeleteValue: ts.closeFileWatcher,
125334
125852
  });
125335
125853
  }
125336
125854
  function startWatching(state, buildOrder) {
125337
125855
  if (!state.watchAllProjectsPending)
125338
125856
  return;
125857
+ ts.solutionPerformance.mark("beforeStartWatching");
125339
125858
  state.watchAllProjectsPending = false;
125340
125859
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125341
125860
  var resolved = _a[_i];
@@ -125353,6 +125872,8 @@ var ts;
125353
125872
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125354
125873
  }
125355
125874
  }
125875
+ ts.solutionPerformance.mark("afterStartWatching");
125876
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125356
125877
  }
125357
125878
  function stopWatching(state) {
125358
125879
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -125459,19 +125980,18 @@ var ts;
125459
125980
  }
125460
125981
  }
125461
125982
  function reportUpToDateStatus(state, configFileName, status) {
125462
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
125463
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125464
- }
125465
125983
  switch (status.type) {
125466
125984
  case ts.UpToDateStatusType.OutOfDateWithSelf:
125467
- return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
125985
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_1_is_older_than_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
125468
125986
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
125469
- return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
125987
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_1_is_older_than_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
125470
125988
  case ts.UpToDateStatusType.OutputMissing:
125471
125989
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(state, configFileName), relName(state, status.missingOutputFileName));
125990
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
125991
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted, relName(state, configFileName), relName(state, status.buildInfoFile));
125472
125992
  case ts.UpToDateStatusType.UpToDate:
125473
125993
  if (status.newestInputFileTime !== undefined) {
125474
- return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(state, configFileName), relName(state, status.newestInputFileName || ""), relName(state, status.oldestOutputFileName || ""));
125994
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2, relName(state, configFileName), relName(state, status.newestInputFileName || ""), relName(state, status.oldestOutputFileName || ""));
125475
125995
  }
125476
125996
  // Don't report anything for "up to date because it was already built" -- too verbose
125477
125997
  break;
@@ -125479,6 +125999,8 @@ var ts;
125479
125999
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(state, configFileName), relName(state, status.newerProjectName));
125480
126000
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125481
126001
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126002
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126003
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_files, relName(state, configFileName));
125482
126004
  case ts.UpToDateStatusType.UpstreamOutOfDate:
125483
126005
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName));
125484
126006
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -125489,6 +126011,8 @@ var ts;
125489
126011
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
125490
126012
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
125491
126013
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version);
126014
+ case ts.UpToDateStatusType.ForceBuild:
126015
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125492
126016
  case ts.UpToDateStatusType.ContainerOnly:
125493
126017
  // Don't report status on "solution" projects
125494
126018
  // falls through
@@ -136331,7 +136855,7 @@ var ts;
136331
136855
  ts.Debug.assert(parent.name === node);
136332
136856
  return true;
136333
136857
  case 203 /* BindingElement */:
136334
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136858
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136335
136859
  default:
136336
136860
  return false;
136337
136861
  }
@@ -137797,7 +138321,7 @@ var ts;
137797
138321
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137798
138322
  if (ts.isInJSFile(referenceLocation)
137799
138323
  && referenceLocation.parent.kind === 203 /* BindingElement */
137800
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138324
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137801
138325
  referenceSymbol = referenceLocation.parent.symbol;
137802
138326
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137803
138327
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -143969,6 +144493,10 @@ var ts;
143969
144493
  }
143970
144494
  var typeDisplayString = printTypeInSingleLine(declarationType);
143971
144495
  if (typeDisplayString) {
144496
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
144497
+ if (isVariableNameMatchesType) {
144498
+ return;
144499
+ }
143972
144500
  addTypeHints(typeDisplayString, decl.name.end);
143973
144501
  }
143974
144502
  }
@@ -147169,11 +147697,9 @@ var ts;
147169
147697
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147170
147698
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147171
147699
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147172
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147173
- if (startLine !== commaTokenLine) {
147174
- formattingScanner.advance();
147175
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147176
- }
147700
+ // consume the comma
147701
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147702
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147177
147703
  }
147178
147704
  // consume the list end token only if it is still belong to the parent
147179
147705
  // there might be the case when current token matches end token but does not considered as one
@@ -174879,6 +175405,7 @@ var ts;
174879
175405
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174880
175406
  }
174881
175407
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
175408
+ var _a;
174882
175409
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174883
175410
  /*isForRename*/ false, function (project, position) {
174884
175411
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -174898,7 +175425,7 @@ var ts;
174898
175425
  // have started the other project searches from related symbols. Propagate the
174899
175426
  // correct results to all other projects.
174900
175427
  var defaultProjectResults = perProjectResults.get(defaultProject);
174901
- if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175428
+ if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
174902
175429
  // Clear all isDefinition properties
174903
175430
  perProjectResults.forEach(function (projectResults) {
174904
175431
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -174915,8 +175442,8 @@ var ts;
174915
175442
  var knownSymbolSpans_1 = createDocumentSpanSet();
174916
175443
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
174917
175444
  var referencedSymbol = defaultProjectResults_1[_i];
174918
- for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174919
- var ref = _b[_a];
175445
+ for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
175446
+ var ref = _c[_b];
174920
175447
  if (ref.isDefinition) {
174921
175448
  knownSymbolSpans_1.add(ref);
174922
175449
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -175076,11 +175603,9 @@ var ts;
175076
175603
  // it easier for the caller to skip post-processing.
175077
175604
  if (searchedProjects.size === 1) {
175078
175605
  var it = resultsMap.values().next();
175079
- ts.Debug.assert(!it.done);
175080
- return it.value;
175606
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175081
175607
  }
175082
175608
  return resultsMap;
175083
- // May enqueue to otherPositionQueue
175084
175609
  function searchPosition(project, location) {
175085
175610
  var projectResults = getResultsForPosition(project, location);
175086
175611
  if (!projectResults)