@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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220527";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -3704,16 +3704,34 @@ var ts;
3704
3704
  /** Performance measurements for the compiler. */
3705
3705
  var ts;
3706
3706
  (function (ts) {
3707
- var performance;
3708
- (function (performance) {
3707
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3708
+ ts.performance = createPerformanceTracker();
3709
+ ts.solutionPerformance = createPerformanceTracker();
3710
+ function createPerformanceTracker() {
3709
3711
  var perfHooks;
3710
3712
  // when set, indicates the implementation of `Performance` to use for user timing.
3711
3713
  // when unset, indicates user timing is unavailable or disabled.
3712
3714
  var performanceImpl;
3715
+ var enabled = false;
3716
+ var timeorigin = ts.timestamp();
3717
+ var marks = new ts.Map();
3718
+ var counts = new ts.Map();
3719
+ var durations = new ts.Map();
3720
+ return {
3721
+ createTimerIf: createTimerIf,
3722
+ createTimer: createTimer,
3723
+ mark: mark,
3724
+ measure: measure,
3725
+ getCount: getCount,
3726
+ getDuration: getDuration,
3727
+ forEachMeasure: forEachMeasure,
3728
+ isEnabled: isEnabled,
3729
+ enable: enable,
3730
+ disable: disable,
3731
+ };
3713
3732
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3714
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3733
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3715
3734
  }
3716
- performance.createTimerIf = createTimerIf;
3717
3735
  function createTimer(measureName, startMarkName, endMarkName) {
3718
3736
  var enterCount = 0;
3719
3737
  return {
@@ -3735,13 +3753,6 @@ var ts;
3735
3753
  }
3736
3754
  }
3737
3755
  }
3738
- performance.createTimer = createTimer;
3739
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3740
- var enabled = false;
3741
- var timeorigin = ts.timestamp();
3742
- var marks = new ts.Map();
3743
- var counts = new ts.Map();
3744
- var durations = new ts.Map();
3745
3756
  /**
3746
3757
  * Marks a performance event.
3747
3758
  *
@@ -3756,7 +3767,6 @@ var ts;
3756
3767
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3757
3768
  }
3758
3769
  }
3759
- performance.mark = mark;
3760
3770
  /**
3761
3771
  * Adds a performance measurement with the specified name.
3762
3772
  *
@@ -3769,14 +3779,13 @@ var ts;
3769
3779
  function measure(measureName, startMarkName, endMarkName) {
3770
3780
  var _a, _b;
3771
3781
  if (enabled) {
3772
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3773
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3782
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3783
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3774
3784
  var previousDuration = durations.get(measureName) || 0;
3775
3785
  durations.set(measureName, previousDuration + (end - start));
3776
3786
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3777
3787
  }
3778
3788
  }
3779
- performance.measure = measure;
3780
3789
  /**
3781
3790
  * Gets the number of times a marker was encountered.
3782
3791
  *
@@ -3785,7 +3794,6 @@ var ts;
3785
3794
  function getCount(markName) {
3786
3795
  return counts.get(markName) || 0;
3787
3796
  }
3788
- performance.getCount = getCount;
3789
3797
  /**
3790
3798
  * Gets the total duration of all measurements with the supplied name.
3791
3799
  *
@@ -3794,7 +3802,6 @@ var ts;
3794
3802
  function getDuration(measureName) {
3795
3803
  return durations.get(measureName) || 0;
3796
3804
  }
3797
- performance.getDuration = getDuration;
3798
3805
  /**
3799
3806
  * Iterate over each measure, performing some action
3800
3807
  *
@@ -3803,14 +3810,12 @@ var ts;
3803
3810
  function forEachMeasure(cb) {
3804
3811
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3805
3812
  }
3806
- performance.forEachMeasure = forEachMeasure;
3807
3813
  /**
3808
3814
  * Indicates whether the performance API is enabled.
3809
3815
  */
3810
3816
  function isEnabled() {
3811
3817
  return enabled;
3812
3818
  }
3813
- performance.isEnabled = isEnabled;
3814
3819
  /** Enables (and resets) performance measurements for the compiler. */
3815
3820
  function enable(system) {
3816
3821
  var _a;
@@ -3831,7 +3836,6 @@ var ts;
3831
3836
  }
3832
3837
  return true;
3833
3838
  }
3834
- performance.enable = enable;
3835
3839
  /** Disables performance measurements for the compiler. */
3836
3840
  function disable() {
3837
3841
  if (enabled) {
@@ -3842,8 +3846,7 @@ var ts;
3842
3846
  enabled = false;
3843
3847
  }
3844
3848
  }
3845
- performance.disable = disable;
3846
- })(performance = ts.performance || (ts.performance = {}));
3849
+ }
3847
3850
  })(ts || (ts = {}));
3848
3851
  /* @internal */
3849
3852
  var ts;
@@ -6386,7 +6389,7 @@ var ts;
6386
6389
  };
6387
6390
  }
6388
6391
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6389
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6392
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6390
6393
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6391
6394
  if (!ts.isString(relativeFileName))
6392
6395
  return;
@@ -6396,7 +6399,7 @@ var ts;
6396
6399
  if (callbacks) {
6397
6400
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6398
6401
  var fileCallback = callbacks_1[_i];
6399
- fileCallback(fileName, FileWatcherEventKind.Changed);
6402
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6400
6403
  }
6401
6404
  }
6402
6405
  },
@@ -6450,7 +6453,7 @@ var ts;
6450
6453
  }
6451
6454
  else {
6452
6455
  cache.set(path, {
6453
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6456
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6454
6457
  refCount: 1
6455
6458
  });
6456
6459
  }
@@ -6478,7 +6481,7 @@ var ts;
6478
6481
  var newTime = modifiedTime.getTime();
6479
6482
  if (oldTime !== newTime) {
6480
6483
  watchedFile.mtime = modifiedTime;
6481
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6484
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6482
6485
  return true;
6483
6486
  }
6484
6487
  return false;
@@ -6729,17 +6732,18 @@ var ts;
6729
6732
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6730
6733
  /*@internal*/
6731
6734
  function createFileWatcherCallback(callback) {
6732
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6735
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6733
6736
  }
6734
6737
  ts.createFileWatcherCallback = createFileWatcherCallback;
6735
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6736
- return function (eventName) {
6738
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6739
+ return function (eventName, _relativeFileName, modifiedTime) {
6737
6740
  if (eventName === "rename") {
6738
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6741
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6742
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6739
6743
  }
6740
6744
  else {
6741
6745
  // Change
6742
- callback(fileName, FileWatcherEventKind.Changed);
6746
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6743
6747
  }
6744
6748
  };
6745
6749
  }
@@ -6763,7 +6767,7 @@ var ts;
6763
6767
  }
6764
6768
  /*@internal*/
6765
6769
  function createSystemWatchFunctions(_a) {
6766
- 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;
6770
+ 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;
6767
6771
  var dynamicPollingWatchFile;
6768
6772
  var fixedChunkSizePollingWatchFile;
6769
6773
  var nonPollingWatchFile;
@@ -6785,7 +6789,7 @@ var ts;
6785
6789
  case ts.WatchFileKind.FixedChunkSizePolling:
6786
6790
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6787
6791
  case ts.WatchFileKind.UseFsEvents:
6788
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6792
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6789
6793
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6790
6794
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6791
6795
  if (!nonPollingWatchFile) {
@@ -6967,7 +6971,6 @@ var ts;
6967
6971
  fsWatch: fsWatch,
6968
6972
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6969
6973
  getCurrentDirectory: getCurrentDirectory,
6970
- fileExists: fileExists,
6971
6974
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6972
6975
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6973
6976
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
@@ -7227,7 +7230,7 @@ var ts;
7227
7230
  // File changed
7228
7231
  eventKind = FileWatcherEventKind.Changed;
7229
7232
  }
7230
- callback(fileName, eventKind);
7233
+ callback(fileName, eventKind, curr.mtime);
7231
7234
  }
7232
7235
  }
7233
7236
  function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
@@ -7253,10 +7256,10 @@ var ts;
7253
7256
  * Invoke the callback with rename and update the watcher if not closed
7254
7257
  * @param createWatcher
7255
7258
  */
7256
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7259
+ function invokeCallbackAndUpdateWatcher(createWatcher, modifiedTime) {
7257
7260
  sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7258
7261
  // Call the callback for current directory
7259
- callback("rename", "");
7262
+ callback("rename", "", modifiedTime);
7260
7263
  // If watcher is not closed, update it
7261
7264
  if (watcher) {
7262
7265
  watcher.close();
@@ -7302,13 +7305,14 @@ var ts;
7302
7305
  function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7303
7306
  // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7304
7307
  // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7308
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
7305
7309
  return event === "rename" &&
7306
7310
  (!relativeName ||
7307
7311
  relativeName === lastDirectoryPart ||
7308
7312
  (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7309
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7310
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7311
- callback(event, relativeName);
7313
+ modifiedTime === ts.missingFileModifiedTime ?
7314
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry, modifiedTime) :
7315
+ callback(event, relativeName, modifiedTime);
7312
7316
  }
7313
7317
  /**
7314
7318
  * Watch the file or directory using fs.watchFile since fs.watch threw exception
@@ -7322,12 +7326,15 @@ var ts;
7322
7326
  * and switch to existing file or directory when the missing filesystem entry is created
7323
7327
  */
7324
7328
  function watchMissingFileSystemEntry() {
7325
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7326
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7327
- // Call the callback for current file or directory
7328
- // For now it could be callback for the inner directory creation,
7329
- // but just return current directory, better than current no-op
7330
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7329
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7330
+ if (eventKind === FileWatcherEventKind.Created) {
7331
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7332
+ if (modifiedTime !== ts.missingFileModifiedTime) {
7333
+ // Call the callback for current file or directory
7334
+ // For now it could be callback for the inner directory creation,
7335
+ // but just return current directory, better than current no-op
7336
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry, modifiedTime);
7337
+ }
7331
7338
  }
7332
7339
  }, fallbackPollingInterval, fallbackOptions);
7333
7340
  }
@@ -7477,12 +7484,19 @@ var ts;
7477
7484
  }
7478
7485
  function getModifiedTime(path) {
7479
7486
  var _a;
7487
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7488
+ // the CPU time performance.
7489
+ var originalStackTraceLimit = Error.stackTraceLimit;
7490
+ Error.stackTraceLimit = 0;
7480
7491
  try {
7481
7492
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7482
7493
  }
7483
7494
  catch (e) {
7484
7495
  return undefined;
7485
7496
  }
7497
+ finally {
7498
+ Error.stackTraceLimit = originalStackTraceLimit;
7499
+ }
7486
7500
  }
7487
7501
  function setModifiedTime(path, time) {
7488
7502
  try {
@@ -9503,8 +9517,8 @@ var ts;
9503
9517
  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"),
9504
9518
  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"),
9505
9519
  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."),
9506
- 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}'"),
9507
- 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}'"),
9520
+ 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}'"),
9521
+ 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}'"),
9508
9522
  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"),
9509
9523
  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"),
9510
9524
  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"),
@@ -9548,6 +9562,8 @@ var ts;
9548
9562
  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}'."),
9549
9563
  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}'."),
9550
9564
  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."),
9565
+ 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"),
9566
+ 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"),
9551
9567
  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}'"),
9552
9568
  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."),
9553
9569
  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."),
@@ -16412,9 +16428,6 @@ var ts;
16412
16428
  }
16413
16429
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16430
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16431
  return ts.isVariableDeclaration(node) &&
16419
16432
  !!node.initializer &&
16420
16433
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20239,9 @@ var ts;
20226
20239
  */
20227
20240
  function isFileForcedToBeModuleByFormat(file) {
20228
20241
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20242
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20243
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20244
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20245
  }
20232
20246
  function getSetExternalModuleIndicator(options) {
20233
20247
  // TODO: Should this callback be cached?
@@ -20235,7 +20249,7 @@ var ts;
20235
20249
  case ts.ModuleDetectionKind.Force:
20236
20250
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20251
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20252
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20253
  };
20240
20254
  case ts.ModuleDetectionKind.Legacy:
20241
20255
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20309,8 @@ var ts;
20295
20309
  }
20296
20310
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20311
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20312
+ return options.moduleDetection ||
20313
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20314
  }
20300
20315
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20316
  function hasJsonModuleEmitEnabled(options) {
@@ -20378,6 +20393,10 @@ var ts;
20378
20393
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20379
20394
  }
20380
20395
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20396
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20397
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20398
+ }
20399
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20381
20400
  function getCompilerOptionValue(options, option) {
20382
20401
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20383
20402
  }
@@ -39418,6 +39437,7 @@ var ts;
39418
39437
  type: "boolean",
39419
39438
  affectsSemanticDiagnostics: true,
39420
39439
  affectsEmit: true,
39440
+ affectsMultiFileEmitBuildInfo: true,
39421
39441
  category: ts.Diagnostics.Watch_and_Build_Modes,
39422
39442
  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,
39423
39443
  defaultValueDescription: false,
@@ -39452,12 +39472,40 @@ var ts;
39452
39472
  affectsSourceFile: true,
39453
39473
  affectsModuleResolution: true,
39454
39474
  affectsEmit: true,
39475
+ affectsMultiFileEmitBuildInfo: true,
39455
39476
  paramType: ts.Diagnostics.VERSION,
39456
39477
  showInSimplifiedHelpView: true,
39457
39478
  category: ts.Diagnostics.Language_and_Environment,
39458
39479
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39459
39480
  defaultValueDescription: 0 /* ES3 */,
39460
39481
  };
39482
+ /*@internal*/
39483
+ ts.moduleOptionDeclaration = {
39484
+ name: "module",
39485
+ shortName: "m",
39486
+ type: new ts.Map(ts.getEntries({
39487
+ none: ts.ModuleKind.None,
39488
+ commonjs: ts.ModuleKind.CommonJS,
39489
+ amd: ts.ModuleKind.AMD,
39490
+ system: ts.ModuleKind.System,
39491
+ umd: ts.ModuleKind.UMD,
39492
+ es6: ts.ModuleKind.ES2015,
39493
+ es2015: ts.ModuleKind.ES2015,
39494
+ es2020: ts.ModuleKind.ES2020,
39495
+ es2022: ts.ModuleKind.ES2022,
39496
+ esnext: ts.ModuleKind.ESNext,
39497
+ node16: ts.ModuleKind.Node16,
39498
+ nodenext: ts.ModuleKind.NodeNext,
39499
+ })),
39500
+ affectsModuleResolution: true,
39501
+ affectsEmit: true,
39502
+ affectsMultiFileEmitBuildInfo: true,
39503
+ paramType: ts.Diagnostics.KIND,
39504
+ showInSimplifiedHelpView: true,
39505
+ category: ts.Diagnostics.Modules,
39506
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39507
+ defaultValueDescription: undefined,
39508
+ };
39461
39509
  var commandOptionsWithoutBuild = [
39462
39510
  // CommandLine only options
39463
39511
  {
@@ -39519,37 +39567,14 @@ var ts;
39519
39567
  category: ts.Diagnostics.Command_line_Options,
39520
39568
  affectsSemanticDiagnostics: true,
39521
39569
  affectsEmit: true,
39570
+ affectsMultiFileEmitBuildInfo: true,
39522
39571
  isCommandLineOnly: true,
39523
39572
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39524
39573
  defaultValueDescription: false,
39525
39574
  },
39526
39575
  // Basic
39527
39576
  ts.targetOptionDeclaration,
39528
- {
39529
- name: "module",
39530
- shortName: "m",
39531
- type: new ts.Map(ts.getEntries({
39532
- none: ts.ModuleKind.None,
39533
- commonjs: ts.ModuleKind.CommonJS,
39534
- amd: ts.ModuleKind.AMD,
39535
- system: ts.ModuleKind.System,
39536
- umd: ts.ModuleKind.UMD,
39537
- es6: ts.ModuleKind.ES2015,
39538
- es2015: ts.ModuleKind.ES2015,
39539
- es2020: ts.ModuleKind.ES2020,
39540
- es2022: ts.ModuleKind.ES2022,
39541
- esnext: ts.ModuleKind.ESNext,
39542
- node16: ts.ModuleKind.Node16,
39543
- nodenext: ts.ModuleKind.NodeNext,
39544
- })),
39545
- affectsModuleResolution: true,
39546
- affectsEmit: true,
39547
- paramType: ts.Diagnostics.KIND,
39548
- showInSimplifiedHelpView: true,
39549
- category: ts.Diagnostics.Modules,
39550
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39551
- defaultValueDescription: undefined,
39552
- },
39577
+ ts.moduleOptionDeclaration,
39553
39578
  {
39554
39579
  name: "lib",
39555
39580
  type: "list",
@@ -39586,6 +39611,7 @@ var ts;
39586
39611
  type: jsxOptionMap,
39587
39612
  affectsSourceFile: true,
39588
39613
  affectsEmit: true,
39614
+ affectsMultiFileEmitBuildInfo: true,
39589
39615
  affectsModuleResolution: true,
39590
39616
  paramType: ts.Diagnostics.KIND,
39591
39617
  showInSimplifiedHelpView: true,
@@ -39598,6 +39624,7 @@ var ts;
39598
39624
  shortName: "d",
39599
39625
  type: "boolean",
39600
39626
  affectsEmit: true,
39627
+ affectsMultiFileEmitBuildInfo: true,
39601
39628
  showInSimplifiedHelpView: true,
39602
39629
  category: ts.Diagnostics.Emit,
39603
39630
  transpileOptionValue: undefined,
@@ -39608,6 +39635,7 @@ var ts;
39608
39635
  name: "declarationMap",
39609
39636
  type: "boolean",
39610
39637
  affectsEmit: true,
39638
+ affectsMultiFileEmitBuildInfo: true,
39611
39639
  showInSimplifiedHelpView: true,
39612
39640
  category: ts.Diagnostics.Emit,
39613
39641
  transpileOptionValue: undefined,
@@ -39618,6 +39646,7 @@ var ts;
39618
39646
  name: "emitDeclarationOnly",
39619
39647
  type: "boolean",
39620
39648
  affectsEmit: true,
39649
+ affectsMultiFileEmitBuildInfo: true,
39621
39650
  showInSimplifiedHelpView: true,
39622
39651
  category: ts.Diagnostics.Emit,
39623
39652
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39628,6 +39657,7 @@ var ts;
39628
39657
  name: "sourceMap",
39629
39658
  type: "boolean",
39630
39659
  affectsEmit: true,
39660
+ affectsMultiFileEmitBuildInfo: true,
39631
39661
  showInSimplifiedHelpView: true,
39632
39662
  category: ts.Diagnostics.Emit,
39633
39663
  defaultValueDescription: false,
@@ -39637,6 +39667,9 @@ var ts;
39637
39667
  name: "outFile",
39638
39668
  type: "string",
39639
39669
  affectsEmit: true,
39670
+ affectsMultiFileEmitBuildInfo: true,
39671
+ affectsDeclarationPath: true,
39672
+ affectsBundleEmitBuildInfo: true,
39640
39673
  isFilePath: true,
39641
39674
  paramType: ts.Diagnostics.FILE,
39642
39675
  showInSimplifiedHelpView: true,
@@ -39648,6 +39681,8 @@ var ts;
39648
39681
  name: "outDir",
39649
39682
  type: "string",
39650
39683
  affectsEmit: true,
39684
+ affectsMultiFileEmitBuildInfo: true,
39685
+ affectsDeclarationPath: true,
39651
39686
  isFilePath: true,
39652
39687
  paramType: ts.Diagnostics.DIRECTORY,
39653
39688
  showInSimplifiedHelpView: true,
@@ -39658,6 +39693,8 @@ var ts;
39658
39693
  name: "rootDir",
39659
39694
  type: "string",
39660
39695
  affectsEmit: true,
39696
+ affectsMultiFileEmitBuildInfo: true,
39697
+ affectsDeclarationPath: true,
39661
39698
  isFilePath: true,
39662
39699
  paramType: ts.Diagnostics.LOCATION,
39663
39700
  category: ts.Diagnostics.Modules,
@@ -39668,6 +39705,8 @@ var ts;
39668
39705
  name: "composite",
39669
39706
  type: "boolean",
39670
39707
  affectsEmit: true,
39708
+ affectsMultiFileEmitBuildInfo: true,
39709
+ affectsBundleEmitBuildInfo: true,
39671
39710
  isTSConfigOnly: true,
39672
39711
  category: ts.Diagnostics.Projects,
39673
39712
  transpileOptionValue: undefined,
@@ -39678,6 +39717,8 @@ var ts;
39678
39717
  name: "tsBuildInfoFile",
39679
39718
  type: "string",
39680
39719
  affectsEmit: true,
39720
+ affectsMultiFileEmitBuildInfo: true,
39721
+ affectsBundleEmitBuildInfo: true,
39681
39722
  isFilePath: true,
39682
39723
  paramType: ts.Diagnostics.FILE,
39683
39724
  category: ts.Diagnostics.Projects,
@@ -39689,6 +39730,7 @@ var ts;
39689
39730
  name: "removeComments",
39690
39731
  type: "boolean",
39691
39732
  affectsEmit: true,
39733
+ affectsMultiFileEmitBuildInfo: true,
39692
39734
  showInSimplifiedHelpView: true,
39693
39735
  category: ts.Diagnostics.Emit,
39694
39736
  defaultValueDescription: false,
@@ -39707,6 +39749,7 @@ var ts;
39707
39749
  name: "importHelpers",
39708
39750
  type: "boolean",
39709
39751
  affectsEmit: true,
39752
+ affectsMultiFileEmitBuildInfo: true,
39710
39753
  category: ts.Diagnostics.Emit,
39711
39754
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39712
39755
  defaultValueDescription: false,
@@ -39720,6 +39763,7 @@ var ts;
39720
39763
  })),
39721
39764
  affectsEmit: true,
39722
39765
  affectsSemanticDiagnostics: true,
39766
+ affectsMultiFileEmitBuildInfo: true,
39723
39767
  category: ts.Diagnostics.Emit,
39724
39768
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39725
39769
  defaultValueDescription: 0 /* Remove */,
@@ -39728,6 +39772,7 @@ var ts;
39728
39772
  name: "downlevelIteration",
39729
39773
  type: "boolean",
39730
39774
  affectsEmit: true,
39775
+ affectsMultiFileEmitBuildInfo: true,
39731
39776
  category: ts.Diagnostics.Emit,
39732
39777
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39733
39778
  defaultValueDescription: false,
@@ -39746,6 +39791,9 @@ var ts;
39746
39791
  type: "boolean",
39747
39792
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39748
39793
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39794
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39795
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39796
+ affectsMultiFileEmitBuildInfo: true,
39749
39797
  showInSimplifiedHelpView: true,
39750
39798
  category: ts.Diagnostics.Type_Checking,
39751
39799
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39755,6 +39803,7 @@ var ts;
39755
39803
  name: "noImplicitAny",
39756
39804
  type: "boolean",
39757
39805
  affectsSemanticDiagnostics: true,
39806
+ affectsMultiFileEmitBuildInfo: true,
39758
39807
  strictFlag: true,
39759
39808
  category: ts.Diagnostics.Type_Checking,
39760
39809
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39764,6 +39813,7 @@ var ts;
39764
39813
  name: "strictNullChecks",
39765
39814
  type: "boolean",
39766
39815
  affectsSemanticDiagnostics: true,
39816
+ affectsMultiFileEmitBuildInfo: true,
39767
39817
  strictFlag: true,
39768
39818
  category: ts.Diagnostics.Type_Checking,
39769
39819
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39772,6 +39822,8 @@ var ts;
39772
39822
  {
39773
39823
  name: "strictFunctionTypes",
39774
39824
  type: "boolean",
39825
+ affectsSemanticDiagnostics: true,
39826
+ affectsMultiFileEmitBuildInfo: true,
39775
39827
  strictFlag: true,
39776
39828
  category: ts.Diagnostics.Type_Checking,
39777
39829
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39780,6 +39832,8 @@ var ts;
39780
39832
  {
39781
39833
  name: "strictBindCallApply",
39782
39834
  type: "boolean",
39835
+ affectsSemanticDiagnostics: true,
39836
+ affectsMultiFileEmitBuildInfo: true,
39783
39837
  strictFlag: true,
39784
39838
  category: ts.Diagnostics.Type_Checking,
39785
39839
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39789,6 +39843,7 @@ var ts;
39789
39843
  name: "strictPropertyInitialization",
39790
39844
  type: "boolean",
39791
39845
  affectsSemanticDiagnostics: true,
39846
+ affectsMultiFileEmitBuildInfo: true,
39792
39847
  strictFlag: true,
39793
39848
  category: ts.Diagnostics.Type_Checking,
39794
39849
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39798,6 +39853,7 @@ var ts;
39798
39853
  name: "noImplicitThis",
39799
39854
  type: "boolean",
39800
39855
  affectsSemanticDiagnostics: true,
39856
+ affectsMultiFileEmitBuildInfo: true,
39801
39857
  strictFlag: true,
39802
39858
  category: ts.Diagnostics.Type_Checking,
39803
39859
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39807,6 +39863,7 @@ var ts;
39807
39863
  name: "useUnknownInCatchVariables",
39808
39864
  type: "boolean",
39809
39865
  affectsSemanticDiagnostics: true,
39866
+ affectsMultiFileEmitBuildInfo: true,
39810
39867
  strictFlag: true,
39811
39868
  category: ts.Diagnostics.Type_Checking,
39812
39869
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39816,6 +39873,8 @@ var ts;
39816
39873
  name: "alwaysStrict",
39817
39874
  type: "boolean",
39818
39875
  affectsSourceFile: true,
39876
+ affectsEmit: true,
39877
+ affectsMultiFileEmitBuildInfo: true,
39819
39878
  strictFlag: true,
39820
39879
  category: ts.Diagnostics.Type_Checking,
39821
39880
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39826,6 +39885,7 @@ var ts;
39826
39885
  name: "noUnusedLocals",
39827
39886
  type: "boolean",
39828
39887
  affectsSemanticDiagnostics: true,
39888
+ affectsMultiFileEmitBuildInfo: true,
39829
39889
  category: ts.Diagnostics.Type_Checking,
39830
39890
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39831
39891
  defaultValueDescription: false,
@@ -39834,6 +39894,7 @@ var ts;
39834
39894
  name: "noUnusedParameters",
39835
39895
  type: "boolean",
39836
39896
  affectsSemanticDiagnostics: true,
39897
+ affectsMultiFileEmitBuildInfo: true,
39837
39898
  category: ts.Diagnostics.Type_Checking,
39838
39899
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39839
39900
  defaultValueDescription: false,
@@ -39842,6 +39903,7 @@ var ts;
39842
39903
  name: "exactOptionalPropertyTypes",
39843
39904
  type: "boolean",
39844
39905
  affectsSemanticDiagnostics: true,
39906
+ affectsMultiFileEmitBuildInfo: true,
39845
39907
  category: ts.Diagnostics.Type_Checking,
39846
39908
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39847
39909
  defaultValueDescription: false,
@@ -39850,6 +39912,7 @@ var ts;
39850
39912
  name: "noImplicitReturns",
39851
39913
  type: "boolean",
39852
39914
  affectsSemanticDiagnostics: true,
39915
+ affectsMultiFileEmitBuildInfo: true,
39853
39916
  category: ts.Diagnostics.Type_Checking,
39854
39917
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39855
39918
  defaultValueDescription: false,
@@ -39859,6 +39922,7 @@ var ts;
39859
39922
  type: "boolean",
39860
39923
  affectsBindDiagnostics: true,
39861
39924
  affectsSemanticDiagnostics: true,
39925
+ affectsMultiFileEmitBuildInfo: true,
39862
39926
  category: ts.Diagnostics.Type_Checking,
39863
39927
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39864
39928
  defaultValueDescription: false,
@@ -39867,6 +39931,7 @@ var ts;
39867
39931
  name: "noUncheckedIndexedAccess",
39868
39932
  type: "boolean",
39869
39933
  affectsSemanticDiagnostics: true,
39934
+ affectsMultiFileEmitBuildInfo: true,
39870
39935
  category: ts.Diagnostics.Type_Checking,
39871
39936
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39872
39937
  defaultValueDescription: false,
@@ -39875,6 +39940,7 @@ var ts;
39875
39940
  name: "noImplicitOverride",
39876
39941
  type: "boolean",
39877
39942
  affectsSemanticDiagnostics: true,
39943
+ affectsMultiFileEmitBuildInfo: true,
39878
39944
  category: ts.Diagnostics.Type_Checking,
39879
39945
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39880
39946
  defaultValueDescription: false,
@@ -39882,6 +39948,8 @@ var ts;
39882
39948
  {
39883
39949
  name: "noPropertyAccessFromIndexSignature",
39884
39950
  type: "boolean",
39951
+ affectsSemanticDiagnostics: true,
39952
+ affectsMultiFileEmitBuildInfo: true,
39885
39953
  showInSimplifiedHelpView: false,
39886
39954
  category: ts.Diagnostics.Type_Checking,
39887
39955
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39967,6 +40035,7 @@ var ts;
39967
40035
  name: "allowSyntheticDefaultImports",
39968
40036
  type: "boolean",
39969
40037
  affectsSemanticDiagnostics: true,
40038
+ affectsMultiFileEmitBuildInfo: true,
39970
40039
  category: ts.Diagnostics.Interop_Constraints,
39971
40040
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39972
40041
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39976,6 +40045,7 @@ var ts;
39976
40045
  type: "boolean",
39977
40046
  affectsSemanticDiagnostics: true,
39978
40047
  affectsEmit: true,
40048
+ affectsMultiFileEmitBuildInfo: true,
39979
40049
  showInSimplifiedHelpView: true,
39980
40050
  category: ts.Diagnostics.Interop_Constraints,
39981
40051
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39992,6 +40062,7 @@ var ts;
39992
40062
  name: "allowUmdGlobalAccess",
39993
40063
  type: "boolean",
39994
40064
  affectsSemanticDiagnostics: true,
40065
+ affectsMultiFileEmitBuildInfo: true,
39995
40066
  category: ts.Diagnostics.Modules,
39996
40067
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39997
40068
  defaultValueDescription: false,
@@ -40013,6 +40084,7 @@ var ts;
40013
40084
  name: "sourceRoot",
40014
40085
  type: "string",
40015
40086
  affectsEmit: true,
40087
+ affectsMultiFileEmitBuildInfo: true,
40016
40088
  paramType: ts.Diagnostics.LOCATION,
40017
40089
  category: ts.Diagnostics.Emit,
40018
40090
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -40021,6 +40093,7 @@ var ts;
40021
40093
  name: "mapRoot",
40022
40094
  type: "string",
40023
40095
  affectsEmit: true,
40096
+ affectsMultiFileEmitBuildInfo: true,
40024
40097
  paramType: ts.Diagnostics.LOCATION,
40025
40098
  category: ts.Diagnostics.Emit,
40026
40099
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -40029,6 +40102,7 @@ var ts;
40029
40102
  name: "inlineSourceMap",
40030
40103
  type: "boolean",
40031
40104
  affectsEmit: true,
40105
+ affectsMultiFileEmitBuildInfo: true,
40032
40106
  category: ts.Diagnostics.Emit,
40033
40107
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
40034
40108
  defaultValueDescription: false,
@@ -40037,6 +40111,7 @@ var ts;
40037
40111
  name: "inlineSources",
40038
40112
  type: "boolean",
40039
40113
  affectsEmit: true,
40114
+ affectsMultiFileEmitBuildInfo: true,
40040
40115
  category: ts.Diagnostics.Emit,
40041
40116
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
40042
40117
  defaultValueDescription: false,
@@ -40046,6 +40121,7 @@ var ts;
40046
40121
  name: "experimentalDecorators",
40047
40122
  type: "boolean",
40048
40123
  affectsSemanticDiagnostics: true,
40124
+ affectsMultiFileEmitBuildInfo: true,
40049
40125
  category: ts.Diagnostics.Language_and_Environment,
40050
40126
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
40051
40127
  defaultValueDescription: false,
@@ -40055,6 +40131,7 @@ var ts;
40055
40131
  type: "boolean",
40056
40132
  affectsSemanticDiagnostics: true,
40057
40133
  affectsEmit: true,
40134
+ affectsMultiFileEmitBuildInfo: true,
40058
40135
  category: ts.Diagnostics.Language_and_Environment,
40059
40136
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
40060
40137
  defaultValueDescription: false,
@@ -40079,6 +40156,7 @@ var ts;
40079
40156
  type: "string",
40080
40157
  affectsSemanticDiagnostics: true,
40081
40158
  affectsEmit: true,
40159
+ affectsMultiFileEmitBuildInfo: true,
40082
40160
  affectsModuleResolution: true,
40083
40161
  category: ts.Diagnostics.Language_and_Environment,
40084
40162
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -40096,6 +40174,9 @@ var ts;
40096
40174
  name: "out",
40097
40175
  type: "string",
40098
40176
  affectsEmit: true,
40177
+ affectsMultiFileEmitBuildInfo: true,
40178
+ affectsDeclarationPath: true,
40179
+ affectsBundleEmitBuildInfo: true,
40099
40180
  isFilePath: false,
40100
40181
  // for correct behaviour, please use outFile
40101
40182
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -40107,6 +40188,7 @@ var ts;
40107
40188
  name: "reactNamespace",
40108
40189
  type: "string",
40109
40190
  affectsEmit: true,
40191
+ affectsMultiFileEmitBuildInfo: true,
40110
40192
  category: ts.Diagnostics.Language_and_Environment,
40111
40193
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
40112
40194
  defaultValueDescription: "`React`",
@@ -40114,6 +40196,8 @@ var ts;
40114
40196
  {
40115
40197
  name: "skipDefaultLibCheck",
40116
40198
  type: "boolean",
40199
+ // We need to store these to determine whether `lib` files need to be rechecked
40200
+ affectsMultiFileEmitBuildInfo: true,
40117
40201
  category: ts.Diagnostics.Completeness,
40118
40202
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
40119
40203
  defaultValueDescription: false,
@@ -40129,6 +40213,7 @@ var ts;
40129
40213
  name: "emitBOM",
40130
40214
  type: "boolean",
40131
40215
  affectsEmit: true,
40216
+ affectsMultiFileEmitBuildInfo: true,
40132
40217
  category: ts.Diagnostics.Emit,
40133
40218
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
40134
40219
  defaultValueDescription: false,
@@ -40140,6 +40225,7 @@ var ts;
40140
40225
  lf: 1 /* LineFeed */
40141
40226
  })),
40142
40227
  affectsEmit: true,
40228
+ affectsMultiFileEmitBuildInfo: true,
40143
40229
  paramType: ts.Diagnostics.NEWLINE,
40144
40230
  category: ts.Diagnostics.Emit,
40145
40231
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -40149,6 +40235,7 @@ var ts;
40149
40235
  name: "noErrorTruncation",
40150
40236
  type: "boolean",
40151
40237
  affectsSemanticDiagnostics: true,
40238
+ affectsMultiFileEmitBuildInfo: true,
40152
40239
  category: ts.Diagnostics.Output_Formatting,
40153
40240
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
40154
40241
  defaultValueDescription: false,
@@ -40179,6 +40266,7 @@ var ts;
40179
40266
  name: "stripInternal",
40180
40267
  type: "boolean",
40181
40268
  affectsEmit: true,
40269
+ affectsMultiFileEmitBuildInfo: true,
40182
40270
  category: ts.Diagnostics.Emit,
40183
40271
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40184
40272
  defaultValueDescription: false,
@@ -40219,6 +40307,7 @@ var ts;
40219
40307
  name: "noImplicitUseStrict",
40220
40308
  type: "boolean",
40221
40309
  affectsSemanticDiagnostics: true,
40310
+ affectsMultiFileEmitBuildInfo: true,
40222
40311
  category: ts.Diagnostics.Backwards_Compatibility,
40223
40312
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40224
40313
  defaultValueDescription: false,
@@ -40227,6 +40316,7 @@ var ts;
40227
40316
  name: "noEmitHelpers",
40228
40317
  type: "boolean",
40229
40318
  affectsEmit: true,
40319
+ affectsMultiFileEmitBuildInfo: true,
40230
40320
  category: ts.Diagnostics.Emit,
40231
40321
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40232
40322
  defaultValueDescription: false,
@@ -40235,6 +40325,7 @@ var ts;
40235
40325
  name: "noEmitOnError",
40236
40326
  type: "boolean",
40237
40327
  affectsEmit: true,
40328
+ affectsMultiFileEmitBuildInfo: true,
40238
40329
  category: ts.Diagnostics.Emit,
40239
40330
  transpileOptionValue: undefined,
40240
40331
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40244,6 +40335,7 @@ var ts;
40244
40335
  name: "preserveConstEnums",
40245
40336
  type: "boolean",
40246
40337
  affectsEmit: true,
40338
+ affectsMultiFileEmitBuildInfo: true,
40247
40339
  category: ts.Diagnostics.Emit,
40248
40340
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40249
40341
  defaultValueDescription: false,
@@ -40252,6 +40344,8 @@ var ts;
40252
40344
  name: "declarationDir",
40253
40345
  type: "string",
40254
40346
  affectsEmit: true,
40347
+ affectsMultiFileEmitBuildInfo: true,
40348
+ affectsDeclarationPath: true,
40255
40349
  isFilePath: true,
40256
40350
  paramType: ts.Diagnostics.DIRECTORY,
40257
40351
  category: ts.Diagnostics.Emit,
@@ -40261,6 +40355,8 @@ var ts;
40261
40355
  {
40262
40356
  name: "skipLibCheck",
40263
40357
  type: "boolean",
40358
+ // We need to store these to determine whether `lib` files need to be rechecked
40359
+ affectsMultiFileEmitBuildInfo: true,
40264
40360
  category: ts.Diagnostics.Completeness,
40265
40361
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40266
40362
  defaultValueDescription: false,
@@ -40270,6 +40366,7 @@ var ts;
40270
40366
  type: "boolean",
40271
40367
  affectsBindDiagnostics: true,
40272
40368
  affectsSemanticDiagnostics: true,
40369
+ affectsMultiFileEmitBuildInfo: true,
40273
40370
  category: ts.Diagnostics.Type_Checking,
40274
40371
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40275
40372
  defaultValueDescription: undefined,
@@ -40279,6 +40376,7 @@ var ts;
40279
40376
  type: "boolean",
40280
40377
  affectsBindDiagnostics: true,
40281
40378
  affectsSemanticDiagnostics: true,
40379
+ affectsMultiFileEmitBuildInfo: true,
40282
40380
  category: ts.Diagnostics.Type_Checking,
40283
40381
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40284
40382
  defaultValueDescription: undefined,
@@ -40287,6 +40385,7 @@ var ts;
40287
40385
  name: "suppressExcessPropertyErrors",
40288
40386
  type: "boolean",
40289
40387
  affectsSemanticDiagnostics: true,
40388
+ affectsMultiFileEmitBuildInfo: true,
40290
40389
  category: ts.Diagnostics.Backwards_Compatibility,
40291
40390
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40292
40391
  defaultValueDescription: false,
@@ -40295,6 +40394,7 @@ var ts;
40295
40394
  name: "suppressImplicitAnyIndexErrors",
40296
40395
  type: "boolean",
40297
40396
  affectsSemanticDiagnostics: true,
40397
+ affectsMultiFileEmitBuildInfo: true,
40298
40398
  category: ts.Diagnostics.Backwards_Compatibility,
40299
40399
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40300
40400
  defaultValueDescription: false,
@@ -40319,6 +40419,7 @@ var ts;
40319
40419
  name: "noStrictGenericChecks",
40320
40420
  type: "boolean",
40321
40421
  affectsSemanticDiagnostics: true,
40422
+ affectsMultiFileEmitBuildInfo: true,
40322
40423
  category: ts.Diagnostics.Backwards_Compatibility,
40323
40424
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40324
40425
  defaultValueDescription: false,
@@ -40328,6 +40429,7 @@ var ts;
40328
40429
  type: "boolean",
40329
40430
  affectsSemanticDiagnostics: true,
40330
40431
  affectsEmit: true,
40432
+ affectsMultiFileEmitBuildInfo: true,
40331
40433
  category: ts.Diagnostics.Language_and_Environment,
40332
40434
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40333
40435
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40336,6 +40438,7 @@ var ts;
40336
40438
  name: "preserveValueImports",
40337
40439
  type: "boolean",
40338
40440
  affectsEmit: true,
40441
+ affectsMultiFileEmitBuildInfo: true,
40339
40442
  category: ts.Diagnostics.Emit,
40340
40443
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40341
40444
  defaultValueDescription: false,
@@ -40379,6 +40482,8 @@ var ts;
40379
40482
  /* @internal */
40380
40483
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40381
40484
  /* @internal */
40485
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40486
+ /* @internal */
40382
40487
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40383
40488
  /* @internal */
40384
40489
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41234,6 +41339,7 @@ var ts;
41234
41339
  return optionDefinition.type;
41235
41340
  }
41236
41341
  }
41342
+ /* @internal */
41237
41343
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41238
41344
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41239
41345
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41242,6 +41348,7 @@ var ts;
41242
41348
  }
41243
41349
  });
41244
41350
  }
41351
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41245
41352
  function serializeCompilerOptions(options, pathOptions) {
41246
41353
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41247
41354
  }
@@ -42237,7 +42344,7 @@ var ts;
42237
42344
  }
42238
42345
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42239
42346
  return {
42240
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42347
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42241
42348
  flags: 1 /* Recursive */
42242
42349
  };
42243
42350
  }
@@ -47140,12 +47247,14 @@ var ts;
47140
47247
  }
47141
47248
  }
47142
47249
  function setCommonJsModuleIndicator(node) {
47143
- if (file.externalModuleIndicator) {
47250
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47144
47251
  return false;
47145
47252
  }
47146
47253
  if (!file.commonJsModuleIndicator) {
47147
47254
  file.commonJsModuleIndicator = node;
47148
- bindSourceFileAsExternalModule();
47255
+ if (!file.externalModuleIndicator) {
47256
+ bindSourceFileAsExternalModule();
47257
+ }
47149
47258
  }
47150
47259
  return true;
47151
47260
  }
@@ -47559,7 +47668,11 @@ var ts;
47559
47668
  checkStrictModeEvalOrArguments(node, node.name);
47560
47669
  }
47561
47670
  if (!ts.isBindingPattern(node.name)) {
47562
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47671
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47672
+ if (ts.isInJSFile(node) &&
47673
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47674
+ !ts.getJSDocTypeTag(node) &&
47675
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
47676
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47564
47677
  }
47565
47678
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50386,7 +50499,8 @@ var ts;
50386
50499
  && isAliasableOrJsExpression(node.parent.right)
50387
50500
  || node.kind === 297 /* ShorthandPropertyAssignment */
50388
50501
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50389
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50502
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50503
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50390
50504
  }
50391
50505
  function isAliasableOrJsExpression(e) {
50392
50506
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50479,7 +50593,7 @@ var ts;
50479
50593
  return hasExportAssignmentSymbol(moduleSymbol);
50480
50594
  }
50481
50595
  // 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
50482
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50596
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50483
50597
  }
50484
50598
  function getTargetOfImportClause(node, dontResolveAlias) {
50485
50599
  var _a;
@@ -68343,13 +68457,40 @@ var ts;
68343
68457
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68344
68458
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68345
68459
  }
68346
- function isValidBigIntString(s) {
68460
+ /**
68461
+ * Tests whether the provided string can be parsed as a number.
68462
+ * @param s The string to test.
68463
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68464
+ */
68465
+ function isValidNumberString(s, roundTripOnly) {
68466
+ if (s === "")
68467
+ return false;
68468
+ var n = +s;
68469
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68470
+ }
68471
+ /**
68472
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68473
+ */
68474
+ function parseBigIntLiteralType(text) {
68475
+ var negative = text.startsWith("-");
68476
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68477
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68478
+ }
68479
+ /**
68480
+ * Tests whether the provided string can be parsed as a bigint.
68481
+ * @param s The string to test.
68482
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68483
+ */
68484
+ function isValidBigIntString(s, roundTripOnly) {
68485
+ if (s === "")
68486
+ return false;
68347
68487
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68348
68488
  var success = true;
68349
68489
  scanner.setOnError(function () { return success = false; });
68350
68490
  scanner.setText(s + "n");
68351
68491
  var result = scanner.scan();
68352
- if (result === 40 /* MinusToken */) {
68492
+ var negative = result === 40 /* MinusToken */;
68493
+ if (negative) {
68353
68494
  result = scanner.scan();
68354
68495
  }
68355
68496
  var flags = scanner.getTokenFlags();
@@ -68358,7 +68499,8 @@ var ts;
68358
68499
  // * a bigint can be scanned, and that when it is scanned, it is
68359
68500
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68360
68501
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68361
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68502
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68503
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68362
68504
  }
68363
68505
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68364
68506
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68366,8 +68508,8 @@ var ts;
68366
68508
  }
68367
68509
  if (source.flags & 128 /* StringLiteral */) {
68368
68510
  var value = source.value;
68369
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68370
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68511
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68512
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68371
68513
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68372
68514
  }
68373
68515
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68940,8 +69082,57 @@ var ts;
68940
69082
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68941
69083
  // succeed. That would be a pointless and confusing outcome.
68942
69084
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69085
+ var _loop_23 = function (i) {
69086
+ var source_1 = matches ? matches[i] : neverType;
69087
+ var target_3 = types[i];
69088
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
69089
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
69090
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
69091
+ var inferenceContext = getInferenceInfoForType(target_3);
69092
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
69093
+ if (constraint && !isTypeAny(constraint)) {
69094
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
69095
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
69096
+ // If the constraint contains `string`, we don't need to look for a more preferred type
69097
+ if (!(allTypeFlags_1 & 4 /* String */)) {
69098
+ var str_1 = source_1.value;
69099
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
69100
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
69101
+ allTypeFlags_1 &= ~296 /* NumberLike */;
69102
+ }
69103
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
69104
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
69105
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
69106
+ }
69107
+ // for each type in the constraint, find the highest priority matching type
69108
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
69109
+ return !(right.flags & allTypeFlags_1) ? left :
69110
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
69111
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
69112
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
69113
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
69114
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
69115
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
69116
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
69117
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
69118
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
69119
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
69120
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
69121
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
69122
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
69123
+ left;
69124
+ }, neverType);
69125
+ if (!(matchingType.flags & 131072 /* Never */)) {
69126
+ inferFromTypes(matchingType, target_3);
69127
+ return "continue";
69128
+ }
69129
+ }
69130
+ }
69131
+ }
69132
+ inferFromTypes(source_1, target_3);
69133
+ };
68943
69134
  for (var i = 0; i < types.length; i++) {
68944
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
69135
+ _loop_23(i);
68945
69136
  }
68946
69137
  }
68947
69138
  }
@@ -69459,7 +69650,7 @@ var ts;
69459
69650
  function mapTypesByKeyProperty(types, name) {
69460
69651
  var map = new ts.Map();
69461
69652
  var count = 0;
69462
- var _loop_23 = function (type) {
69653
+ var _loop_24 = function (type) {
69463
69654
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69464
69655
  var discriminant = getTypeOfPropertyOfType(type, name);
69465
69656
  if (discriminant) {
@@ -69485,7 +69676,7 @@ var ts;
69485
69676
  };
69486
69677
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69487
69678
  var type = types_16[_i];
69488
- var state_9 = _loop_23(type);
69679
+ var state_9 = _loop_24(type);
69489
69680
  if (typeof state_9 === "object")
69490
69681
  return state_9.value;
69491
69682
  }
@@ -75873,7 +76064,7 @@ var ts;
75873
76064
  if (spreadIndex >= 0) {
75874
76065
  // Create synthetic arguments from spreads of tuple types.
75875
76066
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75876
- var _loop_24 = function (i) {
76067
+ var _loop_25 = function (i) {
75877
76068
  var arg = args[i];
75878
76069
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75879
76070
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75890,7 +76081,7 @@ var ts;
75890
76081
  }
75891
76082
  };
75892
76083
  for (var i = spreadIndex; i < args.length; i++) {
75893
- _loop_24(i);
76084
+ _loop_25(i);
75894
76085
  }
75895
76086
  return effectiveArgs_1;
75896
76087
  }
@@ -76210,7 +76401,7 @@ var ts;
76210
76401
  var min_3 = Number.MAX_VALUE;
76211
76402
  var minIndex = 0;
76212
76403
  var i_1 = 0;
76213
- var _loop_25 = function (c) {
76404
+ var _loop_26 = function (c) {
76214
76405
  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)); };
76215
76406
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76216
76407
  if (diags_2) {
@@ -76228,7 +76419,7 @@ var ts;
76228
76419
  };
76229
76420
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76230
76421
  var c = candidatesForArgumentError_1[_a];
76231
- _loop_25(c);
76422
+ _loop_26(c);
76232
76423
  }
76233
76424
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76234
76425
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76386,7 +76577,7 @@ var ts;
76386
76577
  }
76387
76578
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76388
76579
  var parameters = [];
76389
- var _loop_26 = function (i) {
76580
+ var _loop_27 = function (i) {
76390
76581
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76391
76582
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76392
76583
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76394,7 +76585,7 @@ var ts;
76394
76585
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76395
76586
  };
76396
76587
  for (var i = 0; i < maxNonRestParam; i++) {
76397
- _loop_26(i);
76588
+ _loop_27(i);
76398
76589
  }
76399
76590
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76400
76591
  var flags = 0 /* None */;
@@ -80451,7 +80642,7 @@ var ts;
80451
80642
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80452
80643
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80453
80644
  var indexSignatureMap_1 = new ts.Map();
80454
- var _loop_27 = function (declaration) {
80645
+ var _loop_28 = function (declaration) {
80455
80646
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80456
80647
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80457
80648
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80466,7 +80657,7 @@ var ts;
80466
80657
  };
80467
80658
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80468
80659
  var declaration = _a[_i];
80469
- _loop_27(declaration);
80660
+ _loop_28(declaration);
80470
80661
  }
80471
80662
  indexSignatureMap_1.forEach(function (entry) {
80472
80663
  if (entry.declarations.length > 1) {
@@ -82662,7 +82853,7 @@ var ts;
82662
82853
  }
82663
82854
  // For a commonjs `const x = require`, validate the alias and exit
82664
82855
  var symbol = getSymbolOfNode(node);
82665
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82856
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82666
82857
  checkAliasSymbol(node);
82667
82858
  return;
82668
82859
  }
@@ -83927,7 +84118,7 @@ var ts;
83927
84118
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83928
84119
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83929
84120
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83930
- var _loop_28 = function (info) {
84121
+ var _loop_29 = function (info) {
83931
84122
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83932
84123
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83933
84124
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83940,7 +84131,7 @@ var ts;
83940
84131
  };
83941
84132
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83942
84133
  var info = indexInfos_9[_i];
83943
- _loop_28(info);
84134
+ _loop_29(info);
83944
84135
  }
83945
84136
  }
83946
84137
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83948,7 +84139,7 @@ var ts;
83948
84139
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83949
84140
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83950
84141
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83951
- var _loop_29 = function (info) {
84142
+ var _loop_30 = function (info) {
83952
84143
  if (info === checkInfo)
83953
84144
  return "continue";
83954
84145
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83963,7 +84154,7 @@ var ts;
83963
84154
  };
83964
84155
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83965
84156
  var info = indexInfos_10[_i];
83966
- _loop_29(info);
84157
+ _loop_30(info);
83967
84158
  }
83968
84159
  }
83969
84160
  function checkTypeNameIsReserved(name, message) {
@@ -84282,7 +84473,7 @@ var ts;
84282
84473
  var baseTypes = baseTypeNode && getBaseTypes(type);
84283
84474
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84284
84475
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84285
- var _loop_30 = function (member) {
84476
+ var _loop_31 = function (member) {
84286
84477
  if (ts.hasAmbientModifier(member)) {
84287
84478
  return "continue";
84288
84479
  }
@@ -84299,7 +84490,7 @@ var ts;
84299
84490
  };
84300
84491
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84301
84492
  var member = _a[_i];
84302
- _loop_30(member);
84493
+ _loop_31(member);
84303
84494
  }
84304
84495
  }
84305
84496
  /**
@@ -84387,7 +84578,7 @@ var ts;
84387
84578
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84388
84579
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84389
84580
  var issuedMemberError = false;
84390
- var _loop_31 = function (member) {
84581
+ var _loop_32 = function (member) {
84391
84582
  if (ts.isStatic(member)) {
84392
84583
  return "continue";
84393
84584
  }
@@ -84406,7 +84597,7 @@ var ts;
84406
84597
  };
84407
84598
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84408
84599
  var member = _a[_i];
84409
- _loop_31(member);
84600
+ _loop_32(member);
84410
84601
  }
84411
84602
  if (!issuedMemberError) {
84412
84603
  // check again with diagnostics to generate a less-specific error
@@ -90066,9 +90257,7 @@ var ts;
90066
90257
  var ts;
90067
90258
  (function (ts) {
90068
90259
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
90069
- var _a = generatorOptions.extendedDiagnostics
90070
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
90071
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90260
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
90072
90261
  // Current source map file and its index in the sources list
90073
90262
  var rawSources = [];
90074
90263
  var sources = [];
@@ -110385,7 +110574,8 @@ var ts;
110385
110574
  return;
110386
110575
  }
110387
110576
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110388
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110577
+ var buildInfo = { bundle: bundle, program: program, version: version };
110578
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110389
110579
  }
110390
110580
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110391
110581
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110539,13 +110729,18 @@ var ts;
110539
110729
  if (sourceMapFilePath) {
110540
110730
  var sourceMap = sourceMapGenerator.toString();
110541
110731
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
110732
+ if (printer.bundleFileInfo)
110733
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110542
110734
  }
110543
110735
  }
110544
110736
  else {
110545
110737
  writer.writeLine();
110546
110738
  }
110547
110739
  // Write the output file
110548
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110740
+ var text = writer.getText();
110741
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110742
+ if (printer.bundleFileInfo)
110743
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110549
110744
  // Reset state
110550
110745
  writer.clear();
110551
110746
  }
@@ -110688,34 +110883,54 @@ var ts;
110688
110883
  }
110689
110884
  /*@internal*/
110690
110885
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
110886
+ var createHash = ts.maybeBind(host, host.createHash);
110691
110887
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
110692
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
110693
- if (!buildInfoText)
110888
+ var buildInfo;
110889
+ if (host.getBuildInfo) {
110890
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
110891
+ if (!hostBuildInfo)
110892
+ return buildInfoPath;
110893
+ buildInfo = hostBuildInfo;
110894
+ }
110895
+ else {
110896
+ var buildInfoText = host.readFile(buildInfoPath);
110897
+ if (!buildInfoText)
110898
+ return buildInfoPath;
110899
+ buildInfo = getBuildInfo(buildInfoText);
110900
+ }
110901
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
110694
110902
  return buildInfoPath;
110695
110903
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
110696
110904
  if (!jsFileText)
110697
110905
  return jsFilePath;
110906
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
110907
+ return jsFilePath;
110698
110908
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
110699
110909
  // error if no source map or for now if inline sourcemap
110700
110910
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
110701
110911
  return sourceMapFilePath || "inline sourcemap decoding";
110912
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
110913
+ return sourceMapFilePath;
110702
110914
  // read declaration text
110703
110915
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
110704
110916
  if (declarationFilePath && !declarationText)
110705
110917
  return declarationFilePath;
110918
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
110919
+ return declarationFilePath;
110706
110920
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
110707
110921
  // error if no source map or for now if inline sourcemap
110708
110922
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
110709
110923
  return declarationMapPath || "inline sourcemap decoding";
110710
- var buildInfo = getBuildInfo(buildInfoText);
110711
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
110712
- return buildInfoPath;
110924
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
110925
+ return declarationMapPath;
110713
110926
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110714
110927
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
110715
110928
  /*onlyOwnText*/ true);
110716
110929
  var outputFiles = [];
110717
110930
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
110718
110931
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
110932
+ var changedDtsText;
110933
+ var changedDtsData;
110719
110934
  var emitHost = {
110720
110935
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
110721
110936
  getCanonicalFileName: host.getCanonicalFileName,
@@ -110731,7 +110946,7 @@ var ts;
110731
110946
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
110732
110947
  getProjectReferenceRedirect: ts.returnUndefined,
110733
110948
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
110734
- writeFile: function (name, text, writeByteOrderMark) {
110949
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
110735
110950
  switch (name) {
110736
110951
  case jsFilePath:
110737
110952
  if (jsFileText === text)
@@ -110742,8 +110957,13 @@ var ts;
110742
110957
  return;
110743
110958
  break;
110744
110959
  case buildInfoPath:
110745
- var newBuildInfo = getBuildInfo(text);
110960
+ var newBuildInfo = data.buildInfo;
110746
110961
  newBuildInfo.program = buildInfo.program;
110962
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
110963
+ // Update the output signature
110964
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
110965
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
110966
+ }
110747
110967
  // Update sourceFileInfo
110748
110968
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
110749
110969
  newBuildInfo.bundle.js.sources = js.sources;
@@ -110751,11 +110971,13 @@ var ts;
110751
110971
  newBuildInfo.bundle.dts.sources = dts.sources;
110752
110972
  }
110753
110973
  newBuildInfo.bundle.sourceFiles = sourceFiles;
110754
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
110974
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
110755
110975
  return;
110756
110976
  case declarationFilePath:
110757
110977
  if (declarationText === text)
110758
110978
  return;
110979
+ changedDtsText = text;
110980
+ changedDtsData = data;
110759
110981
  break;
110760
110982
  case declarationMapPath:
110761
110983
  if (declarationMapText === text)
@@ -110774,6 +110996,7 @@ var ts;
110774
110996
  getSourceFileFromReference: ts.returnUndefined,
110775
110997
  redirectTargetsMap: ts.createMultiMap(),
110776
110998
  getFileIncludeReasons: ts.notImplemented,
110999
+ createHash: createHash,
110777
111000
  };
110778
111001
  emitFiles(ts.notImplementedResolver, emitHost,
110779
111002
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -115858,12 +116081,10 @@ var ts;
115858
116081
  }
115859
116082
  ts.createCompilerHost = createCompilerHost;
115860
116083
  /*@internal*/
115861
- // TODO(shkamat): update this after reworking ts build API
115862
116084
  function createCompilerHostWorker(options, setParentNodes, system) {
115863
116085
  if (system === void 0) { system = ts.sys; }
115864
116086
  var existingDirectories = new ts.Map();
115865
116087
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
115866
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
115867
116088
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
115868
116089
  var text;
115869
116090
  try {
@@ -115896,7 +116117,7 @@ var ts;
115896
116117
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
115897
116118
  // the system.writeFile will do its own directory creation and
115898
116119
  // the ensureDirectoriesExist call will always be redundant.
115899
- 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); });
116120
+ 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); });
115900
116121
  ts.performance.mark("afterIOWrite");
115901
116122
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
115902
116123
  }
@@ -115906,35 +116127,6 @@ var ts;
115906
116127
  }
115907
116128
  }
115908
116129
  }
115909
- var outputFingerprints;
115910
- function writeFileWorker(fileName, data, writeByteOrderMark) {
115911
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
115912
- system.writeFile(fileName, data, writeByteOrderMark);
115913
- return;
115914
- }
115915
- if (!outputFingerprints) {
115916
- outputFingerprints = new ts.Map();
115917
- }
115918
- var hash = computeHash(data);
115919
- var mtimeBefore = system.getModifiedTime(fileName);
115920
- if (mtimeBefore) {
115921
- var fingerprint = outputFingerprints.get(fileName);
115922
- // If output has not been changed, and the file has no external modification
115923
- if (fingerprint &&
115924
- fingerprint.byteOrderMark === writeByteOrderMark &&
115925
- fingerprint.hash === hash &&
115926
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
115927
- return;
115928
- }
115929
- }
115930
- system.writeFile(fileName, data, writeByteOrderMark);
115931
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
115932
- outputFingerprints.set(fileName, {
115933
- hash: hash,
115934
- byteOrderMark: writeByteOrderMark,
115935
- mtime: mtimeAfter
115936
- });
115937
- }
115938
116130
  function getDefaultLibLocation() {
115939
116131
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
115940
116132
  }
@@ -117524,6 +117716,7 @@ var ts;
117524
117716
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117525
117717
  redirectTargetsMap: redirectTargetsMap,
117526
117718
  getFileIncludeReasons: program.getFileIncludeReasons,
117719
+ createHash: ts.maybeBind(host, host.createHash),
117527
117720
  };
117528
117721
  }
117529
117722
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -119637,13 +119830,9 @@ var ts;
119637
119830
  function createManyToManyPathMap() {
119638
119831
  function create(forward, reverse, deleted) {
119639
119832
  var map = {
119640
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
119641
- forEach: function (fn) { return forward.forEach(fn); },
119642
119833
  getKeys: function (v) { return reverse.get(v); },
119643
119834
  getValues: function (k) { return forward.get(k); },
119644
- hasKey: function (k) { return forward.has(k); },
119645
119835
  keys: function () { return forward.keys(); },
119646
- deletedKeys: function () { return deleted; },
119647
119836
  deleteKey: function (k) {
119648
119837
  (deleted || (deleted = new ts.Set())).add(k);
119649
119838
  var set = forward.get(k);
@@ -119670,11 +119859,6 @@ var ts;
119670
119859
  });
119671
119860
  return map;
119672
119861
  },
119673
- clear: function () {
119674
- forward.clear();
119675
- reverse.clear();
119676
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119677
- }
119678
119862
  };
119679
119863
  return map;
119680
119864
  }
@@ -119802,18 +119986,21 @@ var ts;
119802
119986
  * Creates the state of file references and signature for the new program from oldState if it is safe
119803
119987
  */
119804
119988
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
119989
+ var _a, _b, _c;
119805
119990
  var fileInfos = new ts.Map();
119806
119991
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
119807
119992
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
119808
- var hasCalledUpdateShapeSignature = new ts.Set();
119809
119993
  var useOldState = canReuseOldState(referencedMap, oldState);
119810
119994
  // Ensure source files have parent pointers set
119811
119995
  newProgram.getTypeChecker();
119812
119996
  // Create the reference map, and set the file infos
119813
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
119814
- var sourceFile = _a[_i];
119997
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
119998
+ var sourceFile = _d[_i];
119815
119999
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
119816
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120000
+ var oldUncommitedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120001
+ var signature = oldUncommitedSignature === undefined ?
120002
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120003
+ oldUncommitedSignature || undefined;
119817
120004
  if (referencedMap) {
119818
120005
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
119819
120006
  if (newReferences) {
@@ -119821,19 +120008,26 @@ var ts;
119821
120008
  }
119822
120009
  // Copy old visible to outside files map
119823
120010
  if (useOldState) {
119824
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120011
+ var oldUncommitedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120012
+ var exportedModules = oldUncommitedExportedModules === undefined ?
120013
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120014
+ oldUncommitedExportedModules || undefined;
119825
120015
  if (exportedModules) {
119826
120016
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119827
120017
  }
119828
120018
  }
119829
120019
  }
119830
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120020
+ fileInfos.set(sourceFile.resolvedPath, {
120021
+ version: version_2,
120022
+ signature: signature,
120023
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120024
+ impliedFormat: sourceFile.impliedNodeFormat
120025
+ });
119831
120026
  }
119832
120027
  return {
119833
120028
  fileInfos: fileInfos,
119834
120029
  referencedMap: referencedMap,
119835
120030
  exportedModulesMap: exportedModulesMap,
119836
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
119837
120031
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
119838
120032
  };
119839
120033
  }
@@ -119847,71 +120041,42 @@ var ts;
119847
120041
  }
119848
120042
  BuilderState.releaseCache = releaseCache;
119849
120043
  /**
119850
- * Creates a clone of the state
120044
+ * Gets the files affected by the path from the program
119851
120045
  */
119852
- function clone(state) {
120046
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
119853
120047
  var _a, _b;
119854
- // Dont need to backup allFiles info since its cache anyway
119855
- return {
119856
- fileInfos: new ts.Map(state.fileInfos),
119857
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
119858
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
119859
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
119860
- useFileVersionAsSignature: state.useFileVersionAsSignature,
119861
- };
120048
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120049
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120050
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120051
+ return result;
119862
120052
  }
119863
- BuilderState.clone = clone;
119864
- /**
119865
- * Gets the files affected by the path from the program
119866
- */
119867
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
119868
- // Since the operation could be cancelled, the signatures are always stored in the cache
119869
- // They will be committed once it is safe to use them
119870
- // eg when calling this api from tsserver, if there is no cancellation of the operation
119871
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
119872
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120053
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120054
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
119873
120055
  var sourceFile = programOfThisState.getSourceFileByPath(path);
119874
120056
  if (!sourceFile) {
119875
120057
  return ts.emptyArray;
119876
120058
  }
119877
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120059
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
119878
120060
  return [sourceFile];
119879
120061
  }
119880
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
119881
- if (!cacheToUpdateSignature) {
119882
- // Commit all the signatures in the signature cache
119883
- updateSignaturesFromCache(state, signatureCache);
119884
- }
119885
- return result;
120062
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
119886
120063
  }
119887
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119888
- /**
119889
- * Updates the signatures from the cache into state's fileinfo signatures
119890
- * This should be called whenever it is safe to commit the state of the builder
119891
- */
119892
- function updateSignaturesFromCache(state, signatureCache) {
119893
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
119894
- }
119895
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120064
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
119896
120065
  function updateSignatureOfFile(state, signature, path) {
119897
120066
  state.fileInfos.get(path).signature = signature;
119898
- state.hasCalledUpdateShapeSignature.add(path);
120067
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
119899
120068
  }
119900
120069
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
119901
120070
  /**
119902
120071
  * Returns if the shape of the signature has changed since last emit
119903
120072
  */
119904
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120073
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120074
+ var _a;
119905
120075
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
119906
- ts.Debug.assert(!!sourceFile);
119907
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
119908
120076
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
119909
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120077
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
119910
120078
  return false;
119911
- }
119912
120079
  var info = state.fileInfos.get(sourceFile.resolvedPath);
119913
- if (!info)
119914
- return ts.Debug.fail();
119915
120080
  var prevSignature = info.signature;
119916
120081
  var latestSignature;
119917
120082
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -119922,45 +120087,55 @@ var ts;
119922
120087
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119923
120088
  if (firstDts_1) {
119924
120089
  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; })); });
119925
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119926
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
119927
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120090
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120091
+ if (latestSignature !== prevSignature) {
120092
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
119928
120093
  }
119929
120094
  }
119930
120095
  }
119931
120096
  // Default is to use file version as signature
119932
120097
  if (latestSignature === undefined) {
119933
120098
  latestSignature = sourceFile.version;
119934
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120099
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
120100
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119935
120101
  // All the references in this file are exported
119936
120102
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
119937
120103
  if (references) {
119938
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120104
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
119939
120105
  }
119940
120106
  else {
119941
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120107
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119942
120108
  }
119943
120109
  }
119944
120110
  }
119945
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120111
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120112
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120113
+ info.signature = latestSignature;
119946
120114
  return latestSignature !== prevSignature;
119947
120115
  }
119948
120116
  BuilderState.updateShapeSignature = updateShapeSignature;
120117
+ function computeSignature(text, computeHash) {
120118
+ return (computeHash || ts.generateDjb2Hash)(text);
120119
+ }
120120
+ BuilderState.computeSignature = computeSignature;
119949
120121
  /**
119950
120122
  * Coverts the declaration emit result into exported modules map
119951
120123
  */
119952
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120124
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120125
+ if (!state.exportedModulesMap)
120126
+ return;
120127
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119953
120128
  if (!exportedModulesFromDeclarationEmit) {
119954
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120129
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119955
120130
  return;
119956
120131
  }
119957
120132
  var exportedModules;
119958
120133
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
119959
120134
  if (exportedModules) {
119960
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120135
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119961
120136
  }
119962
120137
  else {
119963
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120138
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119964
120139
  }
119965
120140
  function addExportedModule(exportedModulePaths) {
119966
120141
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -119972,19 +120147,6 @@ var ts;
119972
120147
  }
119973
120148
  }
119974
120149
  BuilderState.updateExportedModules = updateExportedModules;
119975
- /**
119976
- * Updates the exported modules from cache into state's exported modules map
119977
- * This should be called whenever it is safe to commit the state of the builder
119978
- */
119979
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
119980
- var _a;
119981
- if (exportedModulesMapCache) {
119982
- ts.Debug.assert(!!state.exportedModulesMap);
119983
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119984
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119985
- }
119986
- }
119987
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
119988
120150
  /**
119989
120151
  * Get all the dependencies of the sourceFile
119990
120152
  */
@@ -120105,7 +120267,7 @@ var ts;
120105
120267
  /**
120106
120268
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120107
120269
  */
120108
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120270
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120109
120271
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120110
120272
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120111
120273
  }
@@ -120125,7 +120287,7 @@ var ts;
120125
120287
  if (!seenFileNamesMap.has(currentPath)) {
120126
120288
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120127
120289
  seenFileNamesMap.set(currentPath, currentSourceFile);
120128
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120290
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120129
120291
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120130
120292
  }
120131
120293
  }
@@ -120151,32 +120313,33 @@ var ts;
120151
120313
  * Create the state so that we can iterate on changedFiles/affected files
120152
120314
  */
120153
120315
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120316
+ var _a, _b;
120154
120317
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120155
120318
  state.program = newProgram;
120156
120319
  var compilerOptions = newProgram.getCompilerOptions();
120157
120320
  state.compilerOptions = compilerOptions;
120321
+ var outFilePath = ts.outFile(compilerOptions);
120158
120322
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120159
- if (!ts.outFile(compilerOptions)) {
120323
+ if (!outFilePath) {
120160
120324
  state.semanticDiagnosticsPerFile = new ts.Map();
120161
120325
  }
120326
+ 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)) {
120327
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120328
+ }
120162
120329
  state.changedFilesSet = new ts.Set();
120330
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120163
120331
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120164
120332
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120165
120333
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120166
120334
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120335
+ var canCopyEmitSignatures = compilerOptions.composite &&
120336
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120337
+ !outFilePath &&
120338
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120167
120339
  if (useOldState) {
120168
- // Verify the sanity of old state
120169
- if (!oldState.currentChangedFilePath) {
120170
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120171
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120172
- }
120173
- var changedFilesSet = oldState.changedFilesSet;
120174
- if (canCopySemanticDiagnostics) {
120175
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120176
- }
120177
120340
  // Copy old state's changed files set
120178
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120179
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120341
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120342
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
120180
120343
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120181
120344
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120182
120345
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120197,6 +120360,8 @@ var ts;
120197
120360
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120198
120361
  // versions dont match
120199
120362
  oldInfo.version !== info.version ||
120363
+ // Implied formats dont match
120364
+ oldInfo.impliedFormat !== info.impliedFormat ||
120200
120365
  // Referenced files changed
120201
120366
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120202
120367
  // Referenced file was deleted in the new program
@@ -120220,27 +120385,25 @@ var ts;
120220
120385
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120221
120386
  }
120222
120387
  }
120388
+ if (canCopyEmitSignatures) {
120389
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120390
+ if (oldEmitSignature)
120391
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120392
+ }
120223
120393
  });
120224
120394
  // If the global file is removed, add all files as changed
120225
120395
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120226
120396
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120227
120397
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120228
120398
  }
120229
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120399
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120230
120400
  // Add all files to affectedFilesPendingEmit since emit changed
120231
120401
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120232
120402
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120233
120403
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120234
120404
  }
120235
- if (useOldState) {
120236
- // Any time the interpretation of a source file changes, mark it as changed
120237
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120238
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120239
- state.changedFilesSet.add(sourceFilePath);
120240
- }
120241
- });
120242
- }
120243
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120405
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120406
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120244
120407
  return state;
120245
120408
  }
120246
120409
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120276,30 +120439,35 @@ var ts;
120276
120439
  ts.BuilderState.releaseCache(state);
120277
120440
  state.program = undefined;
120278
120441
  }
120279
- /**
120280
- * Creates a clone of the state
120281
- */
120282
- function cloneBuilderProgramState(state) {
120283
- var _a;
120284
- var newState = ts.BuilderState.clone(state);
120285
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120286
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120287
- newState.affectedFiles = state.affectedFiles;
120288
- newState.affectedFilesIndex = state.affectedFilesIndex;
120289
- newState.currentChangedFilePath = state.currentChangedFilePath;
120290
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120291
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120292
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120293
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120294
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120295
- newState.program = state.program;
120296
- newState.compilerOptions = state.compilerOptions;
120297
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120298
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120299
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120300
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120301
- newState.programEmitComplete = state.programEmitComplete;
120302
- return newState;
120442
+ function backupEmitBuilderProgramState(state) {
120443
+ var outFilePath = ts.outFile(state.compilerOptions);
120444
+ // Only in --out changeFileSet is kept around till emit
120445
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120446
+ return {
120447
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120448
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120449
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120450
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120451
+ programEmitComplete: state.programEmitComplete,
120452
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120453
+ outSignature: state.outSignature,
120454
+ dtsChangeTime: state.dtsChangeTime,
120455
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120456
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120457
+ };
120458
+ }
120459
+ function restoreEmitBuilderProgramState(state, backupEmitState) {
120460
+ state.affectedFilesPendingEmit = backupEmitState.affectedFilesPendingEmit;
120461
+ state.affectedFilesPendingEmitKind = backupEmitState.affectedFilesPendingEmitKind;
120462
+ state.affectedFilesPendingEmitIndex = backupEmitState.affectedFilesPendingEmitIndex;
120463
+ state.seenEmittedFiles = backupEmitState.seenEmittedFiles;
120464
+ state.programEmitComplete = backupEmitState.programEmitComplete;
120465
+ state.emitSignatures = backupEmitState.emitSignatures;
120466
+ state.outSignature = backupEmitState.outSignature;
120467
+ state.dtsChangeTime = backupEmitState.dtsChangeTime;
120468
+ state.hasChangedEmitSignature = backupEmitState.hasChangedEmitSignature;
120469
+ if (backupEmitState.changedFilesSet)
120470
+ state.changedFilesSet = backupEmitState.changedFilesSet;
120303
120471
  }
120304
120472
  /**
120305
120473
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120314,7 +120482,7 @@ var ts;
120314
120482
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120315
120483
  */
120316
120484
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120317
- var _a;
120485
+ var _a, _b;
120318
120486
  while (true) {
120319
120487
  var affectedFiles = state.affectedFiles;
120320
120488
  if (affectedFiles) {
@@ -120334,10 +120502,8 @@ var ts;
120334
120502
  state.changedFilesSet.delete(state.currentChangedFilePath);
120335
120503
  state.currentChangedFilePath = undefined;
120336
120504
  // Commit the changes in file signature
120337
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120338
- state.currentAffectedFilesSignatures.clear();
120339
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120340
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120505
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120506
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120341
120507
  state.affectedFiles = undefined;
120342
120508
  }
120343
120509
  // Get next changed file
@@ -120355,12 +120521,7 @@ var ts;
120355
120521
  return program;
120356
120522
  }
120357
120523
  // Get next batch of affected files
120358
- if (!state.currentAffectedFilesSignatures)
120359
- state.currentAffectedFilesSignatures = new ts.Map();
120360
- if (state.exportedModulesMap) {
120361
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120362
- }
120363
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120524
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120364
120525
  state.currentChangedFilePath = nextKey.value;
120365
120526
  state.affectedFilesIndex = 0;
120366
120527
  if (!state.seenAffectedFiles)
@@ -120412,7 +120573,6 @@ var ts;
120412
120573
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120413
120574
  */
120414
120575
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120415
- var _a;
120416
120576
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120417
120577
  // If affected files is everything except default library, then nothing more to do
120418
120578
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120420,10 +120580,9 @@ var ts;
120420
120580
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120421
120581
  // That means when affected file is handled, its signature can be out of date
120422
120582
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120423
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120583
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120424
120584
  return;
120425
120585
  }
120426
- 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);
120427
120586
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120428
120587
  return;
120429
120588
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120443,7 +120602,7 @@ var ts;
120443
120602
  // This ensures that we dont later during incremental builds considering wrong signature.
120444
120603
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120445
120604
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120446
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120605
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120447
120606
  // If not dts emit, nothing more to do
120448
120607
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120449
120608
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120464,27 +120623,10 @@ var ts;
120464
120623
  return !state.semanticDiagnosticsFromOldState.size;
120465
120624
  }
120466
120625
  function isChangedSignature(state, path) {
120467
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120468
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120626
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120627
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120469
120628
  return newSignature !== oldSignature;
120470
120629
  }
120471
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120472
- // Go through exported modules from cache first
120473
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120474
- var result = keys && ts.forEachKey(keys, fn);
120475
- if (result)
120476
- return result;
120477
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120478
- keys = state.exportedModulesMap.getKeys(filePath);
120479
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120480
- var _a;
120481
- // If the cache had an updated value, skip
120482
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120483
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120484
- fn(exportedFromPath) :
120485
- undefined;
120486
- });
120487
- }
120488
120630
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120489
120631
  var _a;
120490
120632
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120499,6 +120641,7 @@ var ts;
120499
120641
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120500
120642
  */
120501
120643
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120644
+ var _a;
120502
120645
  // If there was change in signature (dts output) for the changed file,
120503
120646
  // then only we need to handle pending file emit
120504
120647
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120525,11 +120668,10 @@ var ts;
120525
120668
  }
120526
120669
  }
120527
120670
  }
120528
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120529
120671
  var seenFileAndExportsOfFile = new ts.Set();
120530
120672
  // Go through exported modules from cache first
120531
120673
  // If exported modules has path, all files referencing file exported from are affected
120532
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120674
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120533
120675
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120534
120676
  return true;
120535
120677
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120543,19 +120685,18 @@ var ts;
120543
120685
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120544
120686
  */
120545
120687
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120546
- var _a;
120688
+ var _a, _b;
120547
120689
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120548
120690
  return undefined;
120549
120691
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120550
120692
  return true;
120551
120693
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120552
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120553
120694
  // If exported modules has path, all files referencing file exported from are affected
120554
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120695
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120555
120696
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120556
120697
  });
120557
120698
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120558
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120699
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120559
120700
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120560
120701
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120561
120702
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120576,12 +120717,13 @@ var ts;
120576
120717
  }
120577
120718
  else {
120578
120719
  state.seenAffectedFiles.add(affected.resolvedPath);
120720
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
120721
+ state.buildInfoEmitPending = true;
120579
120722
  if (emitKind !== undefined) {
120580
120723
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120581
120724
  }
120582
120725
  if (isPendingEmit) {
120583
120726
  state.affectedFilesPendingEmitIndex++;
120584
- state.buildInfoEmitPending = true;
120585
120727
  }
120586
120728
  else {
120587
120729
  state.affectedFilesIndex++;
@@ -120629,25 +120771,61 @@ var ts;
120629
120771
  }
120630
120772
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
120631
120773
  }
120774
+ function isProgramBundleEmitBuildInfo(info) {
120775
+ return !!ts.outFile(info.options || {});
120776
+ }
120777
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
120632
120778
  /**
120633
120779
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
120634
120780
  */
120635
- function getProgramBuildInfo(state, getCanonicalFileName) {
120636
- if (ts.outFile(state.compilerOptions))
120637
- return undefined;
120781
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
120782
+ var outFilePath = ts.outFile(state.compilerOptions);
120783
+ if (outFilePath && !state.compilerOptions.composite)
120784
+ return;
120638
120785
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
120639
120786
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
120787
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
120788
+ if (outFilePath) {
120789
+ var fileNames_1 = [];
120790
+ var fileInfos_1 = [];
120791
+ state.program.getRootFileNames().forEach(function (f) {
120792
+ var sourceFile = state.program.getSourceFile(f);
120793
+ if (!sourceFile)
120794
+ return;
120795
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
120796
+ fileInfos_1.push(sourceFile.version);
120797
+ });
120798
+ var result_15 = {
120799
+ fileNames: fileNames_1,
120800
+ fileInfos: fileInfos_1,
120801
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
120802
+ outSignature: state.outSignature,
120803
+ dtsChangeTime: state.dtsChangeTime,
120804
+ };
120805
+ return result_15;
120806
+ }
120640
120807
  var fileNames = [];
120641
120808
  var fileNameToFileId = new ts.Map();
120642
120809
  var fileIdsList;
120643
120810
  var fileNamesToFileIdListId;
120811
+ var emitSignatures;
120644
120812
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
120813
+ var _b, _c;
120645
120814
  var key = _a[0], value = _a[1];
120646
120815
  // Ensure fileId
120647
120816
  var fileId = toFileId(key);
120648
120817
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
120649
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120650
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120818
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
120819
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
120820
+ if (state.compilerOptions.composite) {
120821
+ var file = state.program.getSourceFileByPath(key);
120822
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
120823
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
120824
+ if (emitSignature !== actualSignature) {
120825
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
120826
+ }
120827
+ }
120828
+ }
120651
120829
  return value.version === actualSignature ?
120652
120830
  value.affectsGlobalScope || value.impliedFormat ?
120653
120831
  // If file version is same as signature, dont serialize signature
@@ -120655,11 +120833,11 @@ var ts;
120655
120833
  // If file info only contains version and signature and both are same we can just write string
120656
120834
  value.version :
120657
120835
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120658
- signature === undefined ?
120836
+ oldSignature === undefined ?
120659
120837
  // If we havent computed signature, use fileInfo as is
120660
120838
  value :
120661
120839
  // Serialize fileInfo with new updated signature
120662
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120840
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120663
120841
  // Signature of the FileInfo is undefined, serialize it as false
120664
120842
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120665
120843
  });
@@ -120674,17 +120852,13 @@ var ts;
120674
120852
  if (state.exportedModulesMap) {
120675
120853
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
120676
120854
  var _a;
120677
- if (state.currentAffectedFilesExportedModulesMap) {
120678
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
120679
- return undefined;
120680
- }
120681
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
120682
- if (newValue) {
120683
- return [toFileId(key), toFileIdListId(newValue)];
120684
- }
120685
- }
120855
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
120686
120856
  // Not in temporary cache, use existing value
120687
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120857
+ if (oldValue === undefined)
120858
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120859
+ if (oldValue)
120860
+ return [toFileId(key), toFileIdListId(oldValue)];
120861
+ return undefined;
120688
120862
  });
120689
120863
  }
120690
120864
  var semanticDiagnosticsPerFile;
@@ -120695,9 +120869,7 @@ var ts;
120695
120869
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
120696
120870
  [
120697
120871
  toFileId(key),
120698
- state.hasReusableDiagnostic ?
120699
- value :
120700
- convertToReusableDiagnostics(value, relativeToBuildInfo)
120872
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
120701
120873
  ] :
120702
120874
  toFileId(key));
120703
120875
  }
@@ -120712,16 +120884,27 @@ var ts;
120712
120884
  }
120713
120885
  }
120714
120886
  }
120715
- return {
120887
+ var changeFileSet;
120888
+ if (state.changedFilesSet.size) {
120889
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
120890
+ var path = _e[_d];
120891
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
120892
+ }
120893
+ }
120894
+ var result = {
120716
120895
  fileNames: fileNames,
120717
120896
  fileInfos: fileInfos,
120718
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
120897
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
120719
120898
  fileIdsList: fileIdsList,
120720
120899
  referencedMap: referencedMap,
120721
120900
  exportedModulesMap: exportedModulesMap,
120722
120901
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
120723
120902
  affectedFilesPendingEmit: affectedFilesPendingEmit,
120903
+ changeFileSet: changeFileSet,
120904
+ emitSignatures: emitSignatures,
120905
+ dtsChangeTime: state.dtsChangeTime,
120724
120906
  };
120907
+ return result;
120725
120908
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
120726
120909
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
120727
120910
  }
@@ -120746,24 +120929,18 @@ var ts;
120746
120929
  }
120747
120930
  return fileIdListId;
120748
120931
  }
120749
- }
120750
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
120751
- var result;
120752
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120753
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120754
- var name = _a[_i];
120755
- var optionKey = name.toLowerCase();
120756
- var optionInfo = optionsNameMap.get(optionKey);
120757
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
120758
- // We need to store `strict`, even though it won't be examined directly, so that the
120759
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
120760
- optionKey === "strict" ||
120761
- // We need to store these to determine whether `lib` files need to be rechecked.
120762
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
120763
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
120932
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
120933
+ var result;
120934
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120935
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120936
+ var name = _a[_i];
120937
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
120938
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
120939
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
120940
+ }
120764
120941
  }
120942
+ return result;
120765
120943
  }
120766
- return result;
120767
120944
  }
120768
120945
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
120769
120946
  if (option) {
@@ -120837,6 +121014,10 @@ var ts;
120837
121014
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
120838
121015
  }
120839
121016
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121017
+ function computeSignature(text, data, computeHash) {
121018
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121019
+ }
121020
+ ts.computeSignature = computeSignature;
120840
121021
  function createBuilderProgram(kind, _a) {
120841
121022
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
120842
121023
  // Return same program if underlying program doesnt change
@@ -120855,8 +121036,8 @@ var ts;
120855
121036
  */
120856
121037
  var computeHash = ts.maybeBind(host, host.createHash);
120857
121038
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
120858
- var backupState;
120859
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121039
+ var backupEmitState;
121040
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
120860
121041
  // To ensure that we arent storing any references to old program or new program without state
120861
121042
  newProgram = undefined; // TODO: GH#18217
120862
121043
  oldProgram = undefined;
@@ -120864,20 +121045,20 @@ var ts;
120864
121045
  var getState = function () { return state; };
120865
121046
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
120866
121047
  builderProgram.getState = getState;
120867
- builderProgram.backupState = function () {
120868
- ts.Debug.assert(backupState === undefined);
120869
- backupState = cloneBuilderProgramState(state);
121048
+ builderProgram.backupEmitState = function () {
121049
+ ts.Debug.assert(backupEmitState === undefined);
121050
+ backupEmitState = backupEmitBuilderProgramState(state);
120870
121051
  };
120871
- builderProgram.restoreState = function () {
120872
- state = ts.Debug.checkDefined(backupState);
120873
- backupState = undefined;
121052
+ builderProgram.restoreEmitState = function () {
121053
+ restoreEmitBuilderProgramState(state, ts.Debug.checkDefined(backupEmitState));
121054
+ backupEmitState = undefined;
120874
121055
  };
120875
121056
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
120876
121057
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
120877
121058
  builderProgram.emit = emit;
120878
121059
  builderProgram.releaseProgram = function () {
120879
121060
  releaseCache(state);
120880
- backupState = undefined;
121061
+ backupEmitState = undefined;
120881
121062
  };
120882
121063
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
120883
121064
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
@@ -120936,35 +121117,59 @@ var ts;
120936
121117
  return toAffectedFileEmitResult(state,
120937
121118
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120938
121119
  // Otherwise just affected file
120939
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120940
- getWriteFileUpdatingSignatureCallback(writeFile) :
121120
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121121
+ getWriteFileCallback(writeFile, customTransformers) :
120941
121122
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120942
121123
  }
120943
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121124
+ function getWriteFileCallback(writeFile, customTransformers) {
120944
121125
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120945
- var _a;
121126
+ var _a, _b, _c;
120946
121127
  if (ts.isDeclarationFileName(fileName)) {
120947
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120948
- var file = sourceFiles[0];
120949
- var info = state.fileInfos.get(file.resolvedPath);
120950
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120951
- if (signature === file.version) {
120952
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120953
- if (newSignature !== file.version) { // Update it
120954
- if (host.storeFilesChangingSignatureDuringEmit)
120955
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120956
- if (state.exportedModulesMap)
120957
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120958
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120959
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121128
+ if (!ts.outFile(state.compilerOptions)) {
121129
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121130
+ var newSignature = void 0;
121131
+ if (!customTransformers) {
121132
+ var file = sourceFiles[0];
121133
+ var info = state.fileInfos.get(file.resolvedPath);
121134
+ if (info.signature === file.version) {
121135
+ newSignature = computeSignature(text, data, computeHash);
121136
+ if (newSignature !== file.version) { // Update it
121137
+ if (host.storeFilesChangingSignatureDuringEmit)
121138
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121139
+ if (state.exportedModulesMap)
121140
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121141
+ if (state.affectedFiles) {
121142
+ // Keep old signature so we know what to undo if cancellation happens
121143
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121144
+ if (existing === undefined)
121145
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121146
+ info.signature = newSignature;
121147
+ }
121148
+ else {
121149
+ // These are directly commited
121150
+ info.signature = newSignature;
121151
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121152
+ }
121153
+ }
120960
121154
  }
120961
- else {
120962
- info.signature = newSignature;
120963
- if (state.exportedModulesMap)
120964
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121155
+ }
121156
+ if (state.compilerOptions.composite) {
121157
+ var filePath = sourceFiles[0].resolvedPath;
121158
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121159
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
121160
+ if (newSignature !== oldSignature) {
121161
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121162
+ state.hasChangedEmitSignature = true;
120965
121163
  }
120966
121164
  }
120967
121165
  }
121166
+ else if (state.compilerOptions.composite) {
121167
+ var newSignature = computeSignature(text, data, computeHash);
121168
+ if (newSignature !== state.outSignature) {
121169
+ state.outSignature = newSignature;
121170
+ state.hasChangedEmitSignature = true;
121171
+ }
121172
+ }
120968
121173
  }
120969
121174
  if (writeFile)
120970
121175
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121029,8 +121234,8 @@ var ts;
121029
121234
  }
121030
121235
  }
121031
121236
  }
121032
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121033
- getWriteFileUpdatingSignatureCallback(writeFile) :
121237
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121238
+ getWriteFileCallback(writeFile, customTransformers) :
121034
121239
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121035
121240
  }
121036
121241
  /**
@@ -121119,29 +121324,58 @@ var ts;
121119
121324
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121120
121325
  }
121121
121326
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121122
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121123
- var _a;
121327
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121328
+ var _a, _b, _c, _d;
121124
121329
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121125
121330
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121126
- var filePaths = program.fileNames.map(toPath);
121127
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121128
- var fileInfos = new ts.Map();
121129
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121130
- var state = {
121131
- fileInfos: fileInfos,
121132
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121133
- referencedMap: toManyToManyPathMap(program.referencedMap),
121134
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121135
- 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]; }),
121136
- hasReusableDiagnostic: true,
121137
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121138
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121139
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121140
- };
121331
+ var state;
121332
+ var filePaths;
121333
+ var filePathsSetList;
121334
+ if (isProgramBundleEmitBuildInfo(program)) {
121335
+ state = {
121336
+ fileInfos: new ts.Map(),
121337
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121338
+ dtsChangeTime: program.dtsChangeTime,
121339
+ outSignature: program.outSignature,
121340
+ };
121341
+ }
121342
+ else {
121343
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121344
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121345
+ var fileInfos_2 = new ts.Map();
121346
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121347
+ program.fileInfos.forEach(function (fileInfo, index) {
121348
+ var path = toFilePath(index + 1);
121349
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121350
+ fileInfos_2.set(path, stateFileInfo);
121351
+ if (emitSignatures_1 && stateFileInfo.signature)
121352
+ emitSignatures_1.set(path, stateFileInfo.signature);
121353
+ });
121354
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121355
+ if (ts.isNumber(value))
121356
+ emitSignatures_1.delete(toFilePath(value));
121357
+ else
121358
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121359
+ });
121360
+ state = {
121361
+ fileInfos: fileInfos_2,
121362
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121363
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121364
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121365
+ 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]; }),
121366
+ hasReusableDiagnostic: true,
121367
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121368
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121369
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121370
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121371
+ dtsChangeTime: program.dtsChangeTime,
121372
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121373
+ };
121374
+ }
121141
121375
  return {
121142
121376
  getState: function () { return state; },
121143
- backupState: ts.noop,
121144
- restoreState: ts.noop,
121377
+ backupEmitState: ts.noop,
121378
+ restoreEmitState: ts.noop,
121145
121379
  getProgram: ts.notImplemented,
121146
121380
  getProgramOrUndefined: ts.returnUndefined,
121147
121381
  releaseProgram: ts.noop,
@@ -121186,12 +121420,24 @@ var ts;
121186
121420
  return map;
121187
121421
  }
121188
121422
  }
121189
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121423
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121424
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121425
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121426
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121427
+ var fileInfos = new ts.Map();
121428
+ program.fileInfos.forEach(function (fileInfo, index) {
121429
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121430
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121431
+ fileInfos.set(path, version);
121432
+ });
121433
+ return fileInfos;
121434
+ }
121435
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121190
121436
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121191
121437
  return {
121192
121438
  getState: ts.notImplemented,
121193
- backupState: ts.noop,
121194
- restoreState: ts.noop,
121439
+ backupEmitState: ts.noop,
121440
+ restoreEmitState: ts.noop,
121195
121441
  getProgram: getProgram,
121196
121442
  getProgramOrUndefined: function () { return getState().program; },
121197
121443
  releaseProgram: function () { return getState().program = undefined; },
@@ -122307,9 +122553,9 @@ var ts;
122307
122553
  if (!preferSymlinks) {
122308
122554
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122309
122555
  // so we only need to remove them from the realpath filenames.
122310
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122311
- if (result_15)
122312
- return result_15;
122556
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122557
+ if (result_16)
122558
+ return result_16;
122313
122559
  }
122314
122560
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122315
122561
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122329,10 +122575,10 @@ var ts;
122329
122575
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122330
122576
  var symlinkDirectory = symlinkDirectories_1[_i];
122331
122577
  var option = ts.resolvePath(symlinkDirectory, relative);
122332
- var result_16 = cb(option, target === referenceRedirect);
122578
+ var result_17 = cb(option, target === referenceRedirect);
122333
122579
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122334
- if (result_16)
122335
- return result_16;
122580
+ if (result_17)
122581
+ return result_17;
122336
122582
  }
122337
122583
  });
122338
122584
  });
@@ -122374,7 +122620,7 @@ var ts;
122374
122620
  });
122375
122621
  // Sort by paths closest to importing file Name directory
122376
122622
  var sortedPaths = [];
122377
- var _loop_32 = function (directory) {
122623
+ var _loop_33 = function (directory) {
122378
122624
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122379
122625
  var pathsInDirectory;
122380
122626
  allFileNames.forEach(function (_a, fileName) {
@@ -122398,7 +122644,7 @@ var ts;
122398
122644
  };
122399
122645
  var out_directory_1;
122400
122646
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122401
- var state_10 = _loop_32(directory);
122647
+ var state_10 = _loop_33(directory);
122402
122648
  directory = out_directory_1;
122403
122649
  if (state_10 === "break")
122404
122650
  break;
@@ -123242,6 +123488,7 @@ var ts;
123242
123488
  readDirectory: ts.maybeBind(host, host.readDirectory),
123243
123489
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123244
123490
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123491
+ now: ts.maybeBind(host, host.now),
123245
123492
  };
123246
123493
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123247
123494
  try {
@@ -123302,6 +123549,7 @@ var ts;
123302
123549
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123303
123550
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123304
123551
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123552
+ now: ts.maybeBind(system, system.now),
123305
123553
  };
123306
123554
  }
123307
123555
  ts.createProgramHost = createProgramHost;
@@ -123369,20 +123617,26 @@ var ts;
123369
123617
  var ts;
123370
123618
  (function (ts) {
123371
123619
  function readBuilderProgram(compilerOptions, host) {
123372
- if (ts.outFile(compilerOptions))
123373
- return undefined;
123374
123620
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123375
123621
  if (!buildInfoPath)
123376
123622
  return undefined;
123377
- var content = host.readFile(buildInfoPath);
123378
- if (!content)
123379
- return undefined;
123380
- var buildInfo = ts.getBuildInfo(content);
123623
+ var buildInfo;
123624
+ if (host.getBuildInfo) {
123625
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
123626
+ if (!buildInfo)
123627
+ return undefined;
123628
+ }
123629
+ else {
123630
+ var content = host.readFile(buildInfoPath);
123631
+ if (!content)
123632
+ return undefined;
123633
+ buildInfo = ts.getBuildInfo(content);
123634
+ }
123381
123635
  if (buildInfo.version !== ts.version)
123382
123636
  return undefined;
123383
123637
  if (!buildInfo.program)
123384
123638
  return undefined;
123385
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123639
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123386
123640
  }
123387
123641
  ts.readBuilderProgram = readBuilderProgram;
123388
123642
  function createIncrementalCompilerHost(options, system) {
@@ -123391,6 +123645,7 @@ var ts;
123391
123645
  host.createHash = ts.maybeBind(system, system.createHash);
123392
123646
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123393
123647
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
123648
+ host.now = ts.maybeBind(system, system.now);
123394
123649
  ts.setGetSourceFileAsHashVersioned(host, system);
123395
123650
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123396
123651
  return host;
@@ -123845,6 +124100,7 @@ var ts;
123845
124100
  }
123846
124101
  function reloadFileNamesFromConfigFile() {
123847
124102
  writeLog("Reloading new file names and options");
124103
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123848
124104
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123849
124105
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123850
124106
  hasChangedConfigFileParsingErrors = true;
@@ -124125,14 +124381,17 @@ var ts;
124125
124381
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124126
124382
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124127
124383
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124128
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124129
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124130
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124131
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124384
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124385
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124386
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124387
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124388
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124389
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124132
124390
  /**
124133
124391
  * Projects with no outputs (i.e. "solution" files)
124134
124392
  */
124135
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124393
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124394
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124136
124395
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124137
124396
  function resolveConfigFileProjectName(project) {
124138
124397
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124177,9 +124436,11 @@ var ts;
124177
124436
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124178
124437
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124179
124438
  }
124180
- function newer(date1, date2) {
124181
- return date2 > date1 ? date2 : date1;
124439
+ /*@internal*/
124440
+ function getCurrentTime(host) {
124441
+ return host.now ? host.now() : new Date();
124182
124442
  }
124443
+ ts.getCurrentTime = getCurrentTime;
124183
124444
  /*@internal*/
124184
124445
  function isCircularBuildOrder(buildOrder) {
124185
124446
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124269,6 +124530,7 @@ var ts;
124269
124530
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124270
124531
  };
124271
124532
  }
124533
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124272
124534
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124273
124535
  var state = {
124274
124536
  host: host,
@@ -124285,8 +124547,9 @@ var ts;
124285
124547
  resolvedConfigFilePaths: new ts.Map(),
124286
124548
  configFileCache: new ts.Map(),
124287
124549
  projectStatus: new ts.Map(),
124288
- buildInfoChecked: new ts.Map(),
124289
124550
  extendedConfigCache: new ts.Map(),
124551
+ buildInfoCache: new ts.Map(),
124552
+ outputTimeStamps: new ts.Map(),
124290
124553
  builderPrograms: new ts.Map(),
124291
124554
  diagnostics: new ts.Map(),
124292
124555
  projectPendingBuild: new ts.Map(),
@@ -124309,6 +124572,7 @@ var ts;
124309
124572
  allWatchedConfigFiles: new ts.Map(),
124310
124573
  allWatchedExtendedConfigFiles: new ts.Map(),
124311
124574
  allWatchedPackageJsonFiles: new ts.Map(),
124575
+ filesWatched: new ts.Map(),
124312
124576
  lastCachedPackageJsonLookups: new ts.Map(),
124313
124577
  timerToBuildInvalidatedProject: undefined,
124314
124578
  reportFileChangeDetected: false,
@@ -124343,6 +124607,7 @@ var ts;
124343
124607
  if (value) {
124344
124608
  return isParsedCommandLine(value) ? value : undefined;
124345
124609
  }
124610
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124346
124611
  var diagnostic;
124347
124612
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124348
124613
  var parsed;
@@ -124357,6 +124622,8 @@ var ts;
124357
124622
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124358
124623
  }
124359
124624
  configFileCache.set(configFilePath, parsed || diagnostic);
124625
+ ts.solutionPerformance.mark("afterParseConfigFile");
124626
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124360
124627
  return parsed;
124361
124628
  }
124362
124629
  function resolveProjectName(state, name) {
@@ -124406,6 +124673,7 @@ var ts;
124406
124673
  return state.buildOrder || createStateBuildOrder(state);
124407
124674
  }
124408
124675
  function createStateBuildOrder(state) {
124676
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124409
124677
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124410
124678
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124411
124679
  state.resolvedConfigFilePaths.clear();
@@ -124415,11 +124683,12 @@ var ts;
124415
124683
  // Config file cache
124416
124684
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124417
124685
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124418
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124419
124686
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124420
124687
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124421
124688
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124422
124689
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124690
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124691
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124423
124692
  // Remove watches for the program no longer in the solution
124424
124693
  if (state.watch) {
124425
124694
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -124435,6 +124704,8 @@ var ts;
124435
124704
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124436
124705
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124437
124706
  }
124707
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124708
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124438
124709
  return state.buildOrder = buildOrder;
124439
124710
  }
124440
124711
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124555,6 +124826,7 @@ var ts;
124555
124826
  if (updateOutputFileStampsPending) {
124556
124827
  updateOutputTimestamps(state, config, projectPath);
124557
124828
  }
124829
+ ts.solutionPerformance.mark("timestampUpdated");
124558
124830
  return doneInvalidatedProject(state, projectPath);
124559
124831
  }
124560
124832
  };
@@ -124648,6 +124920,10 @@ var ts;
124648
124920
  };
124649
124921
  function done(cancellationToken, writeFile, customTransformers) {
124650
124922
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124923
+ if (kind === InvalidatedProjectKind.Build)
124924
+ ts.solutionPerformance.mark("projectsBuilt");
124925
+ else
124926
+ ts.solutionPerformance.mark("bundlesUpdated");
124651
124927
  return doneInvalidatedProject(state, projectPath);
124652
124928
  }
124653
124929
  function withProgramOrUndefined(action) {
@@ -124709,21 +124985,21 @@ var ts;
124709
124985
  }
124710
124986
  function emit(writeFileCallback, cancellationToken, customTransformers) {
124711
124987
  var _a;
124712
- var _b, _c;
124988
+ var _b, _c, _d;
124713
124989
  ts.Debug.assertIsDefined(program);
124714
124990
  ts.Debug.assert(step === BuildStep.Emit);
124715
124991
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
124716
- program.backupState();
124992
+ program.backupEmitState();
124717
124993
  var declDiagnostics;
124718
124994
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
124719
124995
  var outputFiles = [];
124720
124996
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
124721
124997
  /*write*/ undefined,
124722
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
124998
+ /*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,
124723
124999
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
124724
125000
  // Don't emit .d.ts if there are decl file errors
124725
125001
  if (declDiagnostics) {
124726
- program.restoreState();
125002
+ program.restoreEmitState();
124727
125003
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
124728
125004
  return {
124729
125005
  emitSkipped: true,
@@ -124733,37 +125009,46 @@ var ts;
124733
125009
  // Actual Emit
124734
125010
  var host = state.host, compilerHost = state.compilerHost;
124735
125011
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124736
- var newestDeclarationFileContentChangedTime = minimumDate;
124737
- var anyDtsChanged = false;
125012
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
124738
125013
  var emitterDiagnostics = ts.createDiagnosticCollection();
124739
125014
  var emittedOutputs = new ts.Map();
125015
+ var options = program.getCompilerOptions();
125016
+ var isIncremental = ts.isIncrementalCompilation(options);
125017
+ var outputTimeStampMap;
125018
+ var now;
125019
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124740
125020
  outputFiles.forEach(function (_a) {
124741
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124742
- var priorChangeTime;
124743
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124744
- // Check for unchanged .d.ts files
124745
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124746
- priorChangeTime = host.getModifiedTime(name);
124747
- }
124748
- else {
125021
+ var _b, _c;
125022
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125023
+ var path = toPath(state, name);
125024
+ emittedOutputs.set(toPath(state, name), name);
125025
+ if (buildInfo) {
125026
+ setBuildInfo(state, buildInfo, projectPath, options);
125027
+ 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)) {
124749
125028
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124750
- anyDtsChanged = true;
124751
125029
  }
124752
125030
  }
124753
- emittedOutputs.set(toPath(state, name), name);
124754
125031
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124755
- if (priorChangeTime !== undefined) {
124756
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125032
+ if (!isIncremental && state.watch) {
125033
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
124757
125034
  }
124758
125035
  });
124759
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124760
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125036
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
125037
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
125038
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124761
125039
  return emitResult;
124762
125040
  }
124763
125041
  function emitBuildInfo(writeFileCallback, cancellationToken) {
124764
125042
  ts.Debug.assertIsDefined(program);
124765
125043
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
124766
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125044
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125045
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
125046
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125047
+ if (writeFileCallback)
125048
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125049
+ else
125050
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125051
+ }, cancellationToken);
124767
125052
  if (emitResult.diagnostics.length) {
124768
125053
  reportErrors(state, emitResult.diagnostics);
124769
125054
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -124776,7 +125061,7 @@ var ts;
124776
125061
  step = BuildStep.QueueReferencingProjects;
124777
125062
  return emitResult;
124778
125063
  }
124779
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125064
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
124780
125065
  var _a;
124781
125066
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
124782
125067
  if (emitDiagnostics.length) {
@@ -124787,13 +125072,11 @@ var ts;
124787
125072
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
124788
125073
  }
124789
125074
  // Update time stamps for rest of the outputs
124790
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125075
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124791
125076
  state.diagnostics.delete(projectPath);
124792
125077
  state.projectStatus.set(projectPath, {
124793
125078
  type: ts.UpToDateStatusType.UpToDate,
124794
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
124795
- maximumDate :
124796
- newestDeclarationFileContentChangedTime,
125079
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
124797
125080
  oldestOutputFileName: oldestOutputFileName
124798
125081
  });
124799
125082
  afterProgramDone(state, program, config);
@@ -124828,13 +125111,21 @@ var ts;
124828
125111
  ts.Debug.assert(!!outputFiles.length);
124829
125112
  var emitterDiagnostics = ts.createDiagnosticCollection();
124830
125113
  var emittedOutputs = new ts.Map();
125114
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125115
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
124831
125116
  outputFiles.forEach(function (_a) {
124832
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125117
+ var _b, _c;
125118
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124833
125119
  emittedOutputs.set(toPath(state, name), name);
125120
+ if (buildInfo) {
125121
+ setBuildInfo(state, buildInfo, projectPath, config.options);
125122
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125123
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125124
+ }
125125
+ }
124834
125126
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124835
125127
  });
124836
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
124837
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125128
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
124838
125129
  return { emitSkipped: false, diagnostics: emitDiagnostics };
124839
125130
  }
124840
125131
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -124885,6 +125176,13 @@ var ts;
124885
125176
  !ts.isIncrementalCompilation(config.options);
124886
125177
  }
124887
125178
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
125179
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
125180
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
125181
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
125182
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
125183
+ return result;
125184
+ }
125185
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124888
125186
  if (!state.projectPendingBuild.size)
124889
125187
  return undefined;
124890
125188
  if (isCircularBuildOrder(buildOrder))
@@ -124933,7 +125231,7 @@ var ts;
124933
125231
  }
124934
125232
  continue;
124935
125233
  }
124936
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125234
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
124937
125235
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124938
125236
  return {
124939
125237
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -124984,9 +125282,7 @@ var ts;
124984
125282
  }
124985
125283
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124986
125284
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124987
- if (!info)
124988
- return info;
124989
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
125285
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124990
125286
  }
124991
125287
  function listEmittedFile(_a, proj, file) {
124992
125288
  var write = _a.write;
@@ -124994,14 +125290,17 @@ var ts;
124994
125290
  write("TSFILE: " + file);
124995
125291
  }
124996
125292
  }
124997
- function getOldProgram(_a, proj, parsed) {
124998
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
124999
- if (options.force)
125293
+ function getOldProgram(state, proj, parsed) {
125294
+ if (state.options.force)
125000
125295
  return undefined;
125001
- var value = builderPrograms.get(proj);
125296
+ var value = state.builderPrograms.get(proj);
125002
125297
  if (value)
125003
125298
  return value;
125004
- return ts.readBuilderProgram(parsed.options, compilerHost);
125299
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
125300
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
125301
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
125302
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
125303
+ return program;
125005
125304
  }
125006
125305
  function afterProgramDone(state, program, config) {
125007
125306
  if (program) {
@@ -125018,7 +125317,7 @@ var ts;
125018
125317
  state.projectCompilerOptions = state.baseCompilerOptions;
125019
125318
  }
125020
125319
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125021
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125320
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125022
125321
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125023
125322
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125024
125323
  if (canEmitBuildInfo)
@@ -125026,9 +125325,101 @@ var ts;
125026
125325
  afterProgramDone(state, program, config);
125027
125326
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125028
125327
  }
125328
+ function isFileWatcherWithModifiedTime(value) {
125329
+ return !!value.watcher;
125330
+ }
125331
+ function getModifiedTime(state, fileName) {
125332
+ var path = toPath(state, fileName);
125333
+ var existing = state.filesWatched.get(path);
125334
+ if (state.watch && !!existing) {
125335
+ if (!isFileWatcherWithModifiedTime(existing))
125336
+ return existing;
125337
+ if (existing.modifiedTime)
125338
+ return existing.modifiedTime;
125339
+ }
125340
+ var result = ts.getModifiedTime(state.host, fileName);
125341
+ if (state.watch) {
125342
+ if (existing)
125343
+ existing.modifiedTime = result;
125344
+ else
125345
+ state.filesWatched.set(path, result);
125346
+ }
125347
+ return result;
125348
+ }
125349
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125350
+ var path = toPath(state, file);
125351
+ var existing = state.filesWatched.get(path);
125352
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125353
+ existing.callbacks.push(callback);
125354
+ }
125355
+ else {
125356
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125357
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125358
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125359
+ existing.modifiedTime = modifiedTime;
125360
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125361
+ }, pollingInterval, options, watchType, project);
125362
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125363
+ }
125364
+ return {
125365
+ close: function () {
125366
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125367
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125368
+ if (existing.callbacks.length === 1) {
125369
+ state.filesWatched.delete(path);
125370
+ ts.closeFileWatcherOf(existing);
125371
+ }
125372
+ else {
125373
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125374
+ }
125375
+ }
125376
+ };
125377
+ }
125378
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125379
+ if (!state.watch)
125380
+ return undefined;
125381
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125382
+ if (!result)
125383
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125384
+ return result;
125385
+ }
125386
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125387
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125388
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125389
+ if (existing) {
125390
+ existing.buildInfo = buildInfo;
125391
+ existing.modifiedTime = getCurrentTime(state.host);
125392
+ }
125393
+ else {
125394
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125395
+ }
125396
+ }
125397
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125398
+ var path = toPath(state, buildInfoPath);
125399
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125400
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125401
+ }
125402
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125403
+ var path = toPath(state, buildInfoPath);
125404
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125405
+ if (existing !== undefined && existing.path === path) {
125406
+ return existing.buildInfo || undefined;
125407
+ }
125408
+ ts.solutionPerformance.mark("beforeGetBuildInfo");
125409
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125410
+ var value = state.readFileWithCache(buildInfoPath);
125411
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125412
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125413
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125414
+ ts.Debug.assert(modifiedTime || !buildInfo);
125415
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125416
+ ts.solutionPerformance.mark("afterGetBuildInfo");
125417
+ ts.solutionPerformance.measure("GetBuildInfo", "beforeGetBuildInfo", "afterGetBuildInfo");
125418
+ return buildInfo;
125419
+ }
125029
125420
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125030
125421
  // Check tsconfig time
125031
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125422
+ var tsconfigTime = getModifiedTime(state, configFile);
125032
125423
  if (oldestOutputFileTime < tsconfigTime) {
125033
125424
  return {
125034
125425
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125038,88 +125429,24 @@ var ts;
125038
125429
  }
125039
125430
  }
125040
125431
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125041
- var force = !!state.options.force;
125042
- var newestInputFileName = undefined;
125043
- var newestInputFileTime = minimumDate;
125044
- var host = state.host;
125045
- // Get timestamps of input files
125046
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125047
- var inputFile = _a[_i];
125048
- if (!host.fileExists(inputFile)) {
125049
- return {
125050
- type: ts.UpToDateStatusType.Unbuildable,
125051
- reason: inputFile + " does not exist"
125052
- };
125053
- }
125054
- if (!force) {
125055
- var inputTime = ts.getModifiedTime(host, inputFile);
125056
- if (inputTime > newestInputFileTime) {
125057
- newestInputFileName = inputFile;
125058
- newestInputFileTime = inputTime;
125059
- }
125060
- }
125061
- }
125432
+ var _a, _b, _c;
125062
125433
  // Container if no files are specified in the project
125063
125434
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125064
125435
  return {
125065
125436
  type: ts.UpToDateStatusType.ContainerOnly
125066
125437
  };
125067
125438
  }
125068
- // Collect the expected outputs of this project
125069
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125070
- // Now see if all outputs are newer than the newest input
125071
- var oldestOutputFileName = "(none)";
125072
- var oldestOutputFileTime = maximumDate;
125073
- var newestOutputFileName = "(none)";
125074
- var newestOutputFileTime = minimumDate;
125075
- var missingOutputFileName;
125076
- var newestDeclarationFileContentChangedTime = minimumDate;
125077
- var isOutOfDateWithInputs = false;
125078
- if (!force) {
125079
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125080
- var output = outputs_1[_b];
125081
- // Output is missing; can stop checking
125082
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125083
- if (!host.fileExists(output)) {
125084
- missingOutputFileName = output;
125085
- break;
125086
- }
125087
- var outputTime = ts.getModifiedTime(host, output);
125088
- if (outputTime < oldestOutputFileTime) {
125089
- oldestOutputFileTime = outputTime;
125090
- oldestOutputFileName = output;
125091
- }
125092
- // If an output is older than the newest input, we can stop checking
125093
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125094
- if (outputTime < newestInputFileTime) {
125095
- isOutOfDateWithInputs = true;
125096
- break;
125097
- }
125098
- if (outputTime > newestOutputFileTime) {
125099
- newestOutputFileTime = outputTime;
125100
- newestOutputFileName = output;
125101
- }
125102
- // Keep track of when the most recent time a .d.ts file was changed.
125103
- // In addition to file timestamps, we also keep track of when a .d.ts file
125104
- // had its file touched but not had its contents changed - this allows us
125105
- // to skip a downstream typecheck
125106
- if (ts.isDeclarationFileName(output)) {
125107
- var outputModifiedTime = ts.getModifiedTime(host, output);
125108
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125109
- }
125110
- }
125111
- }
125112
- var pseudoUpToDate = false;
125113
- var usesPrepend = false;
125114
- var upstreamChangedProject;
125439
+ // Fast check to see if reference projects are buildable
125440
+ var referenceStatuses;
125441
+ var force = !!state.options.force;
125115
125442
  if (project.projectReferences) {
125116
125443
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125117
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125118
- var ref = _d[_c];
125119
- usesPrepend = usesPrepend || !!(ref.prepend);
125444
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125445
+ var ref = _d[_i];
125120
125446
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125121
125447
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125122
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125448
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125449
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125123
125450
  // Its a circular reference ignore the status of this project
125124
125451
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125125
125452
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125141,75 +125468,188 @@ var ts;
125141
125468
  upstreamProjectName: ref.path
125142
125469
  };
125143
125470
  }
125144
- // Check oldest output file name only if there is no missing output file name
125145
- // (a check we will have skipped if this is a forced build)
125146
- if (!force && !missingOutputFileName) {
125147
- // If the upstream project's newest file is older than our oldest output, we
125148
- // can't be out of date because of it
125149
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125150
- continue;
125151
- }
125152
- // If the upstream project has only change .d.ts files, and we've built
125153
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125154
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125155
- pseudoUpToDate = true;
125156
- upstreamChangedProject = ref.path;
125157
- continue;
125158
- }
125159
- // We have an output older than an upstream output - we are out of date
125160
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125471
+ if (!force)
125472
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125473
+ }
125474
+ }
125475
+ if (force)
125476
+ return { type: ts.UpToDateStatusType.ForceBuild };
125477
+ // Check buildinfo first
125478
+ var host = state.host;
125479
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125480
+ var oldestOutputFileName = "(none)";
125481
+ var oldestOutputFileTime = maximumDate;
125482
+ var buildInfoTime;
125483
+ var buildInfoProgram;
125484
+ var buildInfoVersionMap;
125485
+ var newestDeclarationFileContentChangedTime;
125486
+ if (buildInfoPath) {
125487
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125488
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125489
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125490
+ if (!buildInfoCacheEntry_1) {
125491
+ state.buildInfoCache.set(resolvedPath, {
125492
+ path: toPath(state, buildInfoPath),
125493
+ buildInfo: false,
125494
+ modifiedTime: buildInfoTime
125495
+ });
125496
+ }
125497
+ return {
125498
+ type: ts.UpToDateStatusType.OutputMissing,
125499
+ missingOutputFileName: buildInfoPath
125500
+ };
125501
+ }
125502
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125503
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125504
+ return {
125505
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125506
+ version: buildInfo.version
125507
+ };
125508
+ }
125509
+ if (buildInfo.program) {
125510
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125511
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125161
125512
  return {
125162
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125163
- outOfDateOutputFileName: oldestOutputFileName,
125164
- newerProjectName: ref.path
125513
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125514
+ buildInfoFile: buildInfoPath
125165
125515
  };
125166
125516
  }
125517
+ buildInfoProgram = buildInfo.program;
125167
125518
  }
125519
+ oldestOutputFileTime = buildInfoTime;
125520
+ oldestOutputFileName = buildInfoPath;
125521
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125168
125522
  }
125169
- if (missingOutputFileName !== undefined) {
125170
- return {
125171
- type: ts.UpToDateStatusType.OutputMissing,
125172
- missingOutputFileName: missingOutputFileName
125173
- };
125523
+ // Check input files
125524
+ var newestInputFileName = undefined;
125525
+ var newestInputFileTime = minimumDate;
125526
+ var pseudoInputUptodate = false;
125527
+ // Get timestamps of input files
125528
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125529
+ var inputFile = _f[_e];
125530
+ var inputTime = getModifiedTime(state, inputFile);
125531
+ if (inputTime === ts.missingFileModifiedTime) {
125532
+ return {
125533
+ type: ts.UpToDateStatusType.Unbuildable,
125534
+ reason: inputFile + " does not exist"
125535
+ };
125536
+ }
125537
+ // If an buildInfo is older than the newest input, we can stop checking
125538
+ if (buildInfoTime && buildInfoTime < inputTime) {
125539
+ var version_3 = void 0;
125540
+ var currentVersion = void 0;
125541
+ if (buildInfoProgram) {
125542
+ // Read files and see if they are same, read is anyways cached
125543
+ if (!buildInfoVersionMap)
125544
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125545
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125546
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125547
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125548
+ if (version_3 && version_3 === currentVersion)
125549
+ pseudoInputUptodate = true;
125550
+ }
125551
+ if (!version_3 || version_3 !== currentVersion) {
125552
+ return {
125553
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125554
+ outOfDateOutputFileName: buildInfoPath,
125555
+ newerInputFileName: inputFile
125556
+ };
125557
+ }
125558
+ }
125559
+ if (inputTime > newestInputFileTime) {
125560
+ newestInputFileName = inputFile;
125561
+ newestInputFileTime = inputTime;
125562
+ }
125174
125563
  }
125175
- if (isOutOfDateWithInputs) {
125176
- return {
125177
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125178
- outOfDateOutputFileName: oldestOutputFileName,
125179
- newerInputFileName: newestInputFileName
125180
- };
125564
+ // Now see if all outputs are newer than the newest input
125565
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125566
+ if (!buildInfoPath) {
125567
+ // Collect the expected outputs of this project
125568
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125569
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125570
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125571
+ var output = outputs_1[_g];
125572
+ var path = toPath(state, output);
125573
+ // Output is missing; can stop checking
125574
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125575
+ if (!outputTime) {
125576
+ outputTime = ts.getModifiedTime(state.host, output);
125577
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125578
+ }
125579
+ if (outputTime === ts.missingFileModifiedTime) {
125580
+ return {
125581
+ type: ts.UpToDateStatusType.OutputMissing,
125582
+ missingOutputFileName: output
125583
+ };
125584
+ }
125585
+ if (outputTime < oldestOutputFileTime) {
125586
+ oldestOutputFileTime = outputTime;
125587
+ oldestOutputFileName = output;
125588
+ }
125589
+ // If an output is older than the newest input, we can stop checking
125590
+ if (outputTime < newestInputFileTime) {
125591
+ return {
125592
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125593
+ outOfDateOutputFileName: oldestOutputFileName,
125594
+ newerInputFileName: newestInputFileName
125595
+ };
125596
+ }
125597
+ }
125181
125598
  }
125182
- else {
125183
- // Check tsconfig time
125184
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125185
- if (configStatus)
125186
- return configStatus;
125187
- // Check extended config time
125188
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125189
- if (extendedConfigStatus)
125190
- return extendedConfigStatus;
125191
- // Check package file time
125192
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125193
- var path = _a[0];
125194
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125195
- });
125196
- if (dependentPackageFileStatus)
125197
- return dependentPackageFileStatus;
125198
- }
125199
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125200
- state.buildInfoChecked.set(resolvedPath, true);
125201
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125202
- if (buildInfoPath) {
125203
- var value = state.readFileWithCache(buildInfoPath);
125204
- var buildInfo = value && ts.getBuildInfo(value);
125205
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125599
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125600
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125601
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125602
+ var pseudoUpToDate = false;
125603
+ var usesPrepend = false;
125604
+ var upstreamChangedProject;
125605
+ if (referenceStatuses) {
125606
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125607
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125608
+ usesPrepend = usesPrepend || !!(ref.prepend);
125609
+ // If the upstream project's newest file is older than our oldest output, we
125610
+ // can't be out of date because of it
125611
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125612
+ continue;
125613
+ }
125614
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125615
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125206
125616
  return {
125207
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125208
- version: buildInfo.version
125617
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125618
+ outOfDateOutputFileName: buildInfoPath,
125619
+ newerProjectName: ref.path
125209
125620
  };
125210
125621
  }
125622
+ // If the upstream project has only change .d.ts files, and we've built
125623
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125624
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125625
+ pseudoUpToDate = true;
125626
+ upstreamChangedProject = ref.path;
125627
+ continue;
125628
+ }
125629
+ // We have an output older than an upstream output - we are out of date
125630
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125631
+ return {
125632
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125633
+ outOfDateOutputFileName: oldestOutputFileName,
125634
+ newerProjectName: ref.path
125635
+ };
125211
125636
  }
125212
125637
  }
125638
+ // Check tsconfig time
125639
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125640
+ if (configStatus)
125641
+ return configStatus;
125642
+ // Check extended config time
125643
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125644
+ if (extendedConfigStatus)
125645
+ return extendedConfigStatus;
125646
+ // Check package file time
125647
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125648
+ var path = _a[0];
125649
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125650
+ });
125651
+ if (dependentPackageFileStatus)
125652
+ return dependentPackageFileStatus;
125213
125653
  if (usesPrepend && pseudoUpToDate) {
125214
125654
  return {
125215
125655
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125219,15 +125659,37 @@ var ts;
125219
125659
  }
125220
125660
  // Up to date
125221
125661
  return {
125222
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
125662
+ type: pseudoUpToDate ?
125663
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
125664
+ pseudoInputUptodate ?
125665
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
125666
+ ts.UpToDateStatusType.UpToDate,
125223
125667
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125224
125668
  newestInputFileTime: newestInputFileTime,
125225
- newestOutputFileTime: newestOutputFileTime,
125226
125669
  newestInputFileName: newestInputFileName,
125227
- newestOutputFileName: newestOutputFileName,
125228
125670
  oldestOutputFileName: oldestOutputFileName
125229
125671
  };
125230
125672
  }
125673
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
125674
+ if (seenRefs.has(resolvedRefPath))
125675
+ return false;
125676
+ seenRefs.add(resolvedRefPath);
125677
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
125678
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
125679
+ return true;
125680
+ if (resolvedConfig.projectReferences) {
125681
+ // Check references
125682
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
125683
+ var ref = _a[_i];
125684
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
125685
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
125686
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
125687
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
125688
+ return true;
125689
+ }
125690
+ }
125691
+ return false;
125692
+ }
125231
125693
  function getUpToDateStatus(state, project, resolvedPath) {
125232
125694
  if (project === undefined) {
125233
125695
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125236,43 +125698,76 @@ var ts;
125236
125698
  if (prior !== undefined) {
125237
125699
  return prior;
125238
125700
  }
125701
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125239
125702
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125703
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125704
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125240
125705
  state.projectStatus.set(resolvedPath, actual);
125241
125706
  return actual;
125242
125707
  }
125243
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125708
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125244
125709
  if (proj.options.noEmit)
125245
- return priorNewestUpdateTime;
125246
- var host = state.host;
125247
- var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125248
- if (!skipOutputs || outputs.length !== skipOutputs.size) {
125249
- var reportVerbose = !!state.options.verbose;
125250
- var now = host.now ? host.now() : new Date();
125251
- for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125252
- var file = outputs_2[_i];
125253
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
125254
- continue;
125255
- }
125256
- if (reportVerbose) {
125257
- reportVerbose = false;
125710
+ return;
125711
+ var now;
125712
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125713
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
125714
+ if (buildInfoPath) {
125715
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
125716
+ if (!!state.options.verbose)
125258
125717
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125718
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
125719
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
125720
+ }
125721
+ state.outputTimeStamps.delete(projectPath);
125722
+ }
125723
+ else {
125724
+ var host = state.host;
125725
+ var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125726
+ var outputTimeStampMap_1 = getOutputTimeStampMap(state, projectPath);
125727
+ var modifiedOutputs_1 = outputTimeStampMap_1 ? new ts.Set() : undefined;
125728
+ if (!skipOutputs || outputs.length !== skipOutputs.size) {
125729
+ var reportVerbose = !!state.options.verbose;
125730
+ for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125731
+ var file = outputs_2[_i];
125732
+ var path = toPath(state, file);
125733
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125734
+ continue;
125735
+ if (reportVerbose) {
125736
+ reportVerbose = false;
125737
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
125738
+ }
125739
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
125740
+ if (outputTimeStampMap_1) {
125741
+ outputTimeStampMap_1.set(path, now);
125742
+ modifiedOutputs_1.add(path);
125743
+ }
125259
125744
  }
125260
- if (ts.isDeclarationFileName(file)) {
125261
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
125262
- }
125263
- host.setModifiedTime(file, now);
125264
125745
  }
125746
+ // Clear out timestamps not in output list any more
125747
+ outputTimeStampMap_1 === null || outputTimeStampMap_1 === void 0 ? void 0 : outputTimeStampMap_1.forEach(function (_value, key) {
125748
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs_1.has(key))
125749
+ outputTimeStampMap_1.delete(key);
125750
+ });
125265
125751
  }
125266
- return priorNewestUpdateTime;
125752
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125753
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125754
+ }
125755
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
125756
+ var _a;
125757
+ if (!options.composite)
125758
+ return undefined;
125759
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125760
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
125761
+ 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;
125267
125762
  }
125268
125763
  function updateOutputTimestamps(state, proj, resolvedPath) {
125269
125764
  if (state.options.dry) {
125270
125765
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125271
125766
  }
125272
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125767
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125273
125768
  state.projectStatus.set(resolvedPath, {
125274
125769
  type: ts.UpToDateStatusType.UpToDate,
125275
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
125770
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125276
125771
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125277
125772
  });
125278
125773
  }
@@ -125318,6 +125813,7 @@ var ts;
125318
125813
  break;
125319
125814
  }
125320
125815
  // falls through
125816
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125321
125817
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125322
125818
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125323
125819
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125341,6 +125837,13 @@ var ts;
125341
125837
  }
125342
125838
  }
125343
125839
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125840
+ ts.solutionPerformance.mark("beforeBuild");
125841
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125842
+ ts.solutionPerformance.mark("afterBuild");
125843
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125844
+ return result;
125845
+ }
125846
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125344
125847
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125345
125848
  if (!buildOrder)
125346
125849
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125352,7 +125855,10 @@ var ts;
125352
125855
  if (!invalidatedProject)
125353
125856
  break;
125354
125857
  reportQueue = false;
125858
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125355
125859
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125860
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125861
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125356
125862
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125357
125863
  successfulProjects++;
125358
125864
  }
@@ -125441,6 +125947,14 @@ var ts;
125441
125947
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125442
125948
  }
125443
125949
  function buildNextInvalidatedProject(state, changeDetected) {
125950
+ ts.solutionPerformance.mark("beforeBuild");
125951
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125952
+ ts.solutionPerformance.mark("afterBuild");
125953
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125954
+ if (buildOrder)
125955
+ reportErrorSummary(state, buildOrder);
125956
+ }
125957
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125444
125958
  state.timerToBuildInvalidatedProject = undefined;
125445
125959
  if (state.reportFileChangeDetected) {
125446
125960
  state.reportFileChangeDetected = false;
@@ -125451,7 +125965,10 @@ var ts;
125451
125965
  var buildOrder = getBuildOrder(state);
125452
125966
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125453
125967
  if (invalidatedProject) {
125968
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125454
125969
  invalidatedProject.done();
125970
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125971
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125455
125972
  projectsBuilt++;
125456
125973
  while (state.projectPendingBuild.size) {
125457
125974
  // If already scheduled, skip
@@ -125467,23 +125984,24 @@ var ts;
125467
125984
  return;
125468
125985
  }
125469
125986
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125987
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125470
125988
  project.done();
125989
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125990
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125471
125991
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125472
125992
  projectsBuilt++;
125473
125993
  }
125474
125994
  }
125475
125995
  disableCache(state);
125476
- reportErrorSummary(state, buildOrder);
125996
+ return buildOrder;
125477
125997
  }
125478
125998
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125479
125999
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125480
126000
  return;
125481
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125482
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125483
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126001
+ 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));
125484
126002
  }
125485
126003
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125486
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126004
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125487
126005
  var _a;
125488
126006
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125489
126007
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125515,7 +126033,7 @@ var ts;
125515
126033
  if (!state.watch)
125516
126034
  return;
125517
126035
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125518
- 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); },
126036
+ 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); },
125519
126037
  onDeleteValue: ts.closeFileWatcher,
125520
126038
  });
125521
126039
  }
@@ -125523,13 +126041,14 @@ var ts;
125523
126041
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125524
126042
  return;
125525
126043
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125526
- 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); },
126044
+ 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); },
125527
126045
  onDeleteValue: ts.closeFileWatcher,
125528
126046
  });
125529
126047
  }
125530
126048
  function startWatching(state, buildOrder) {
125531
126049
  if (!state.watchAllProjectsPending)
125532
126050
  return;
126051
+ ts.solutionPerformance.mark("beforeStartWatching");
125533
126052
  state.watchAllProjectsPending = false;
125534
126053
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125535
126054
  var resolved = _a[_i];
@@ -125547,6 +126066,8 @@ var ts;
125547
126066
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125548
126067
  }
125549
126068
  }
126069
+ ts.solutionPerformance.mark("afterStartWatching");
126070
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125550
126071
  }
125551
126072
  function stopWatching(state) {
125552
126073
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -125653,19 +126174,18 @@ var ts;
125653
126174
  }
125654
126175
  }
125655
126176
  function reportUpToDateStatus(state, configFileName, status) {
125656
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
125657
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125658
- }
125659
126177
  switch (status.type) {
125660
126178
  case ts.UpToDateStatusType.OutOfDateWithSelf:
125661
- 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));
126179
+ 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));
125662
126180
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
125663
- 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));
126181
+ 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));
125664
126182
  case ts.UpToDateStatusType.OutputMissing:
125665
126183
  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));
126184
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
126185
+ 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));
125666
126186
  case ts.UpToDateStatusType.UpToDate:
125667
126187
  if (status.newestInputFileTime !== undefined) {
125668
- 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 || ""));
126188
+ 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 || ""));
125669
126189
  }
125670
126190
  // Don't report anything for "up to date because it was already built" -- too verbose
125671
126191
  break;
@@ -125673,6 +126193,8 @@ var ts;
125673
126193
  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));
125674
126194
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125675
126195
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126196
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126197
+ 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));
125676
126198
  case ts.UpToDateStatusType.UpstreamOutOfDate:
125677
126199
  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));
125678
126200
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -125683,6 +126205,8 @@ var ts;
125683
126205
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
125684
126206
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
125685
126207
  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);
126208
+ case ts.UpToDateStatusType.ForceBuild:
126209
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125686
126210
  case ts.UpToDateStatusType.ContainerOnly:
125687
126211
  // Don't report status on "solution" projects
125688
126212
  // falls through
@@ -136942,7 +137466,7 @@ var ts;
136942
137466
  ts.Debug.assert(parent.name === node);
136943
137467
  return true;
136944
137468
  case 203 /* BindingElement */:
136945
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
137469
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136946
137470
  default:
136947
137471
  return false;
136948
137472
  }
@@ -138408,7 +138932,7 @@ var ts;
138408
138932
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138409
138933
  if (ts.isInJSFile(referenceLocation)
138410
138934
  && referenceLocation.parent.kind === 203 /* BindingElement */
138411
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138935
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138412
138936
  referenceSymbol = referenceLocation.parent.symbol;
138413
138937
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138414
138938
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -144580,6 +145104,10 @@ var ts;
144580
145104
  }
144581
145105
  var typeDisplayString = printTypeInSingleLine(declarationType);
144582
145106
  if (typeDisplayString) {
145107
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
145108
+ if (isVariableNameMatchesType) {
145109
+ return;
145110
+ }
144583
145111
  addTypeHints(typeDisplayString, decl.name.end);
144584
145112
  }
144585
145113
  }
@@ -147780,11 +148308,9 @@ var ts;
147780
148308
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147781
148309
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147782
148310
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147783
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147784
- if (startLine !== commaTokenLine) {
147785
- formattingScanner.advance();
147786
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147787
- }
148311
+ // consume the comma
148312
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
148313
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147788
148314
  }
147789
148315
  // consume the list end token only if it is still belong to the parent
147790
148316
  // there might be the case when current token matches end token but does not considered as one