typescript 4.8.0-dev.20220608 → 4.8.0-dev.20220609

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220608";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220609";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -6187,7 +6187,7 @@ var ts;
6187
6187
  };
6188
6188
  }
6189
6189
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6190
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6190
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6191
6191
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6192
6192
  if (!ts.isString(relativeFileName))
6193
6193
  return;
@@ -6197,7 +6197,7 @@ var ts;
6197
6197
  if (callbacks) {
6198
6198
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6199
6199
  var fileCallback = callbacks_1[_i];
6200
- fileCallback(fileName, FileWatcherEventKind.Changed);
6200
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6201
6201
  }
6202
6202
  }
6203
6203
  },
@@ -6251,7 +6251,7 @@ var ts;
6251
6251
  }
6252
6252
  else {
6253
6253
  cache.set(path, {
6254
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6254
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6255
6255
  refCount: 1
6256
6256
  });
6257
6257
  }
@@ -6279,7 +6279,8 @@ var ts;
6279
6279
  var newTime = modifiedTime.getTime();
6280
6280
  if (oldTime !== newTime) {
6281
6281
  watchedFile.mtime = modifiedTime;
6282
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6282
+ // Pass modified times so tsc --build can use it
6283
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6283
6284
  return true;
6284
6285
  }
6285
6286
  return false;
@@ -6314,7 +6315,7 @@ var ts;
6314
6315
  */
6315
6316
  /*@internal*/
6316
6317
  function createDirectoryWatcherSupportingRecursive(_a) {
6317
- var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, directoryExists = _a.directoryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6318
+ var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, fileSystemEntryExists = _a.fileSystemEntryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6318
6319
  var cache = new ts.Map();
6319
6320
  var callbackCache = ts.createMultiMap();
6320
6321
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6414,7 +6415,7 @@ var ts;
6414
6415
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6415
6416
  // Iterate through existing children and update the watches if needed
6416
6417
  var parentWatcher = cache.get(dirPath);
6417
- if (parentWatcher && directoryExists(dirName)) {
6418
+ if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6418
6419
  // Schedule the update and postpone invoke for callbacks
6419
6420
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6420
6421
  return;
@@ -6487,7 +6488,7 @@ var ts;
6487
6488
  if (!parentWatcher)
6488
6489
  return false;
6489
6490
  var newChildWatches;
6490
- var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6491
+ var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6491
6492
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6492
6493
  // Filter our the symbolic link directories since those arent included in recursive watch
6493
6494
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6530,17 +6531,19 @@ var ts;
6530
6531
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6531
6532
  /*@internal*/
6532
6533
  function createFileWatcherCallback(callback) {
6533
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6534
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6534
6535
  }
6535
6536
  ts.createFileWatcherCallback = createFileWatcherCallback;
6536
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6537
- return function (eventName) {
6537
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6538
+ return function (eventName, _relativeFileName, modifiedTime) {
6538
6539
  if (eventName === "rename") {
6539
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6540
+ // Check time stamps rather than file system entry checks
6541
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6542
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6540
6543
  }
6541
6544
  else {
6542
6545
  // Change
6543
- callback(fileName, FileWatcherEventKind.Changed);
6546
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6544
6547
  }
6545
6548
  };
6546
6549
  }
@@ -6564,11 +6567,12 @@ var ts;
6564
6567
  }
6565
6568
  /*@internal*/
6566
6569
  function createSystemWatchFunctions(_a) {
6567
- 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;
6570
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6568
6571
  var dynamicPollingWatchFile;
6569
6572
  var fixedChunkSizePollingWatchFile;
6570
6573
  var nonPollingWatchFile;
6571
6574
  var hostRecursiveDirectoryWatcher;
6575
+ var hitSystemWatcherLimit = false;
6572
6576
  return {
6573
6577
  watchFile: watchFile,
6574
6578
  watchDirectory: watchDirectory
@@ -6586,7 +6590,7 @@ var ts;
6586
6590
  case ts.WatchFileKind.FixedChunkSizePolling:
6587
6591
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6588
6592
  case ts.WatchFileKind.UseFsEvents:
6589
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6593
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6590
6594
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6591
6595
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6592
6596
  if (!nonPollingWatchFile) {
@@ -6647,7 +6651,7 @@ var ts;
6647
6651
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6648
6652
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6649
6653
  getCurrentDirectory: getCurrentDirectory,
6650
- directoryExists: directoryExists,
6654
+ fileSystemEntryExists: fileSystemEntryExists,
6651
6655
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6652
6656
  watchDirectory: nonRecursiveWatchDirectory,
6653
6657
  realpath: realpath,
@@ -6698,6 +6702,122 @@ var ts;
6698
6702
  };
6699
6703
  }
6700
6704
  }
6705
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6706
+ var lastDirectoryPartWithDirectorySeparator;
6707
+ var lastDirectoryPart;
6708
+ if (inodeWatching) {
6709
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6710
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6711
+ }
6712
+ /** Watcher for the file system entry depending on whether it is missing or present */
6713
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6714
+ watchMissingFileSystemEntry() :
6715
+ watchPresentFileSystemEntry();
6716
+ return {
6717
+ close: function () {
6718
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6719
+ watcher.close();
6720
+ watcher = undefined;
6721
+ }
6722
+ };
6723
+ function updateWatcher(createWatcher) {
6724
+ // If watcher is not closed, update it
6725
+ if (watcher) {
6726
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6727
+ watcher.close();
6728
+ watcher = createWatcher();
6729
+ }
6730
+ }
6731
+ /**
6732
+ * Watch the file or directory that is currently present
6733
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
6734
+ */
6735
+ function watchPresentFileSystemEntry() {
6736
+ if (hitSystemWatcherLimit) {
6737
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6738
+ return watchPresentFileSystemEntryWithFsWatchFile();
6739
+ }
6740
+ try {
6741
+ var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6742
+ callbackChangingToMissingFileSystemEntry :
6743
+ callback);
6744
+ // Watch the missing file or directory or error
6745
+ presentWatcher.on("error", function () {
6746
+ callback("rename", "");
6747
+ updateWatcher(watchMissingFileSystemEntry);
6748
+ });
6749
+ return presentWatcher;
6750
+ }
6751
+ catch (e) {
6752
+ // Catch the exception and use polling instead
6753
+ // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6754
+ // so instead of throwing error, use fs.watchFile
6755
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6756
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6757
+ return watchPresentFileSystemEntryWithFsWatchFile();
6758
+ }
6759
+ }
6760
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6761
+ // In some scenarios, file save operation fires event with fileName.ext~ instead of fileName.ext
6762
+ // To ensure we see the file going missing and coming back up (file delete and then recreated)
6763
+ // and watches being updated correctly we are calling back with fileName.ext as well as fileName.ext~
6764
+ // The worst is we have fired event that was not needed but we wont miss any changes
6765
+ // especially in cases where file goes missing and watches wrong inode
6766
+ var originalRelativeName;
6767
+ if (relativeName && ts.endsWith(relativeName, "~")) {
6768
+ originalRelativeName = relativeName;
6769
+ relativeName = relativeName.slice(0, relativeName.length - 1);
6770
+ }
6771
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6772
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6773
+ if (event === "rename" &&
6774
+ (!relativeName ||
6775
+ relativeName === lastDirectoryPart ||
6776
+ ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6777
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
6778
+ if (originalRelativeName)
6779
+ callback(event, originalRelativeName, modifiedTime);
6780
+ callback(event, relativeName, modifiedTime);
6781
+ if (inodeWatching) {
6782
+ // If this was rename event, inode has changed means we need to update watcher
6783
+ updateWatcher(modifiedTime === ts.missingFileModifiedTime ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6784
+ }
6785
+ else if (modifiedTime === ts.missingFileModifiedTime) {
6786
+ updateWatcher(watchMissingFileSystemEntry);
6787
+ }
6788
+ }
6789
+ else {
6790
+ if (originalRelativeName)
6791
+ callback(event, originalRelativeName);
6792
+ callback(event, relativeName);
6793
+ }
6794
+ }
6795
+ /**
6796
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
6797
+ * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6798
+ */
6799
+ function watchPresentFileSystemEntryWithFsWatchFile() {
6800
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
6801
+ }
6802
+ /**
6803
+ * Watch the file or directory that is missing
6804
+ * and switch to existing file or directory when the missing filesystem entry is created
6805
+ */
6806
+ function watchMissingFileSystemEntry() {
6807
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
6808
+ if (eventKind === FileWatcherEventKind.Created) {
6809
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
6810
+ if (modifiedTime !== ts.missingFileModifiedTime) {
6811
+ callback("rename", "", modifiedTime);
6812
+ // Call the callback for current file or directory
6813
+ // For now it could be callback for the inner directory creation,
6814
+ // but just return current directory, better than current no-op
6815
+ updateWatcher(watchPresentFileSystemEntry);
6816
+ }
6817
+ }
6818
+ }, fallbackPollingInterval, fallbackOptions);
6819
+ }
6820
+ }
6701
6821
  }
6702
6822
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6703
6823
  /**
@@ -6750,7 +6870,6 @@ var ts;
6750
6870
  }
6751
6871
  var activeSession;
6752
6872
  var profilePath = "./profile.cpuprofile";
6753
- var hitSystemWatcherLimit = false;
6754
6873
  var Buffer = require("buffer").Buffer;
6755
6874
  var nodeVersion = getNodeMajorVersion();
6756
6875
  var isNode4OrLater = nodeVersion >= 4;
@@ -6765,20 +6884,21 @@ var ts;
6765
6884
  getModifiedTime: getModifiedTime,
6766
6885
  setTimeout: setTimeout,
6767
6886
  clearTimeout: clearTimeout,
6768
- fsWatch: fsWatch,
6887
+ fsWatchWorker: fsWatchWorker,
6769
6888
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6770
6889
  getCurrentDirectory: getCurrentDirectory,
6771
- fileExists: fileExists,
6890
+ fileSystemEntryExists: fileSystemEntryExists,
6772
6891
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6773
6892
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6774
6893
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6775
- directoryExists: directoryExists,
6776
6894
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6777
6895
  realpath: realpath,
6778
6896
  tscWatchFile: process.env.TSC_WATCHFILE,
6779
6897
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6780
6898
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6781
6899
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
6900
+ inodeWatching: isLinuxOrMacOs,
6901
+ sysLog: sysLog,
6782
6902
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6783
6903
  var nodeSystem = {
6784
6904
  args: process.argv.slice(2),
@@ -7028,110 +7148,14 @@ var ts;
7028
7148
  // File changed
7029
7149
  eventKind = FileWatcherEventKind.Changed;
7030
7150
  }
7031
- callback(fileName, eventKind);
7151
+ callback(fileName, eventKind, curr.mtime);
7032
7152
  }
7033
7153
  }
7034
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7035
- var options;
7036
- var lastDirectoryPartWithDirectorySeparator;
7037
- var lastDirectoryPart;
7038
- if (isLinuxOrMacOs) {
7039
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7040
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7041
- }
7042
- /** Watcher for the file system entry depending on whether it is missing or present */
7043
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7044
- watchMissingFileSystemEntry() :
7045
- watchPresentFileSystemEntry();
7046
- return {
7047
- close: function () {
7048
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7049
- watcher.close();
7050
- watcher = undefined;
7051
- }
7052
- };
7053
- /**
7054
- * Invoke the callback with rename and update the watcher if not closed
7055
- * @param createWatcher
7056
- */
7057
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7058
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7059
- // Call the callback for current directory
7060
- callback("rename", "");
7061
- // If watcher is not closed, update it
7062
- if (watcher) {
7063
- watcher.close();
7064
- watcher = createWatcher();
7065
- }
7066
- }
7067
- /**
7068
- * Watch the file or directory that is currently present
7069
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
7070
- */
7071
- function watchPresentFileSystemEntry() {
7072
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7073
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7074
- if (options === undefined) {
7075
- if (fsSupportsRecursiveFsWatch) {
7076
- options = { persistent: true, recursive: !!recursive };
7077
- }
7078
- else {
7079
- options = { persistent: true };
7080
- }
7081
- }
7082
- if (hitSystemWatcherLimit) {
7083
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7084
- return watchPresentFileSystemEntryWithFsWatchFile();
7085
- }
7086
- try {
7087
- var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7088
- callbackChangingToMissingFileSystemEntry :
7089
- callback);
7090
- // Watch the missing file or directory or error
7091
- presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7092
- return presentWatcher;
7093
- }
7094
- catch (e) {
7095
- // Catch the exception and use polling instead
7096
- // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7097
- // so instead of throwing error, use fs.watchFile
7098
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7099
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7100
- return watchPresentFileSystemEntryWithFsWatchFile();
7101
- }
7102
- }
7103
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7104
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7105
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7106
- return event === "rename" &&
7107
- (!relativeName ||
7108
- relativeName === lastDirectoryPart ||
7109
- (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7110
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7111
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7112
- callback(event, relativeName);
7113
- }
7114
- /**
7115
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
7116
- * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7117
- */
7118
- function watchPresentFileSystemEntryWithFsWatchFile() {
7119
- return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7120
- }
7121
- /**
7122
- * Watch the file or directory that is missing
7123
- * and switch to existing file or directory when the missing filesystem entry is created
7124
- */
7125
- function watchMissingFileSystemEntry() {
7126
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7127
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7128
- // Call the callback for current file or directory
7129
- // For now it could be callback for the inner directory creation,
7130
- // but just return current directory, better than current no-op
7131
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7132
- }
7133
- }, fallbackPollingInterval, fallbackOptions);
7134
- }
7154
+ function fsWatchWorker(fileOrDirectory, recursive, callback) {
7155
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7156
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7157
+ return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7158
+ { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7135
7159
  }
7136
7160
  function readFileWorker(fileName, _encoding) {
7137
7161
  var buffer;
@@ -7278,12 +7302,19 @@ var ts;
7278
7302
  }
7279
7303
  function getModifiedTime(path) {
7280
7304
  var _a;
7305
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7306
+ // the CPU time performance.
7307
+ var originalStackTraceLimit = Error.stackTraceLimit;
7308
+ Error.stackTraceLimit = 0;
7281
7309
  try {
7282
7310
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7283
7311
  }
7284
7312
  catch (e) {
7285
7313
  return undefined;
7286
7314
  }
7315
+ finally {
7316
+ Error.stackTraceLimit = originalStackTraceLimit;
7317
+ }
7287
7318
  }
7288
7319
  function setModifiedTime(path, time) {
7289
7320
  try {
@@ -9308,8 +9339,8 @@ var ts;
9308
9339
  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"),
9309
9340
  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"),
9310
9341
  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."),
9311
- 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}'"),
9312
- 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}'"),
9342
+ 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}'"),
9343
+ 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}'"),
9313
9344
  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"),
9314
9345
  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"),
9315
9346
  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"),
@@ -9353,6 +9384,8 @@ var ts;
9353
9384
  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}'."),
9354
9385
  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}'."),
9355
9386
  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."),
9387
+ Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
9388
+ Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
9356
9389
  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}'"),
9357
9390
  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."),
9358
9391
  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."),
@@ -20190,6 +20223,10 @@ var ts;
20190
20223
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20191
20224
  }
20192
20225
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20226
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20227
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20228
+ }
20229
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20193
20230
  function getCompilerOptionValue(options, option) {
20194
20231
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20195
20232
  }
@@ -39247,6 +39284,7 @@ var ts;
39247
39284
  type: "boolean",
39248
39285
  affectsSemanticDiagnostics: true,
39249
39286
  affectsEmit: true,
39287
+ affectsMultiFileEmitBuildInfo: true,
39250
39288
  category: ts.Diagnostics.Watch_and_Build_Modes,
39251
39289
  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,
39252
39290
  defaultValueDescription: false,
@@ -39281,12 +39319,40 @@ var ts;
39281
39319
  affectsSourceFile: true,
39282
39320
  affectsModuleResolution: true,
39283
39321
  affectsEmit: true,
39322
+ affectsMultiFileEmitBuildInfo: true,
39284
39323
  paramType: ts.Diagnostics.VERSION,
39285
39324
  showInSimplifiedHelpView: true,
39286
39325
  category: ts.Diagnostics.Language_and_Environment,
39287
39326
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39288
39327
  defaultValueDescription: 0 /* ES3 */,
39289
39328
  };
39329
+ /*@internal*/
39330
+ ts.moduleOptionDeclaration = {
39331
+ name: "module",
39332
+ shortName: "m",
39333
+ type: new ts.Map(ts.getEntries({
39334
+ none: ts.ModuleKind.None,
39335
+ commonjs: ts.ModuleKind.CommonJS,
39336
+ amd: ts.ModuleKind.AMD,
39337
+ system: ts.ModuleKind.System,
39338
+ umd: ts.ModuleKind.UMD,
39339
+ es6: ts.ModuleKind.ES2015,
39340
+ es2015: ts.ModuleKind.ES2015,
39341
+ es2020: ts.ModuleKind.ES2020,
39342
+ es2022: ts.ModuleKind.ES2022,
39343
+ esnext: ts.ModuleKind.ESNext,
39344
+ node16: ts.ModuleKind.Node16,
39345
+ nodenext: ts.ModuleKind.NodeNext,
39346
+ })),
39347
+ affectsModuleResolution: true,
39348
+ affectsEmit: true,
39349
+ affectsMultiFileEmitBuildInfo: true,
39350
+ paramType: ts.Diagnostics.KIND,
39351
+ showInSimplifiedHelpView: true,
39352
+ category: ts.Diagnostics.Modules,
39353
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39354
+ defaultValueDescription: undefined,
39355
+ };
39290
39356
  var commandOptionsWithoutBuild = [
39291
39357
  // CommandLine only options
39292
39358
  {
@@ -39348,37 +39414,14 @@ var ts;
39348
39414
  category: ts.Diagnostics.Command_line_Options,
39349
39415
  affectsSemanticDiagnostics: true,
39350
39416
  affectsEmit: true,
39417
+ affectsMultiFileEmitBuildInfo: true,
39351
39418
  isCommandLineOnly: true,
39352
39419
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39353
39420
  defaultValueDescription: false,
39354
39421
  },
39355
39422
  // Basic
39356
39423
  ts.targetOptionDeclaration,
39357
- {
39358
- name: "module",
39359
- shortName: "m",
39360
- type: new ts.Map(ts.getEntries({
39361
- none: ts.ModuleKind.None,
39362
- commonjs: ts.ModuleKind.CommonJS,
39363
- amd: ts.ModuleKind.AMD,
39364
- system: ts.ModuleKind.System,
39365
- umd: ts.ModuleKind.UMD,
39366
- es6: ts.ModuleKind.ES2015,
39367
- es2015: ts.ModuleKind.ES2015,
39368
- es2020: ts.ModuleKind.ES2020,
39369
- es2022: ts.ModuleKind.ES2022,
39370
- esnext: ts.ModuleKind.ESNext,
39371
- node16: ts.ModuleKind.Node16,
39372
- nodenext: ts.ModuleKind.NodeNext,
39373
- })),
39374
- affectsModuleResolution: true,
39375
- affectsEmit: true,
39376
- paramType: ts.Diagnostics.KIND,
39377
- showInSimplifiedHelpView: true,
39378
- category: ts.Diagnostics.Modules,
39379
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39380
- defaultValueDescription: undefined,
39381
- },
39424
+ ts.moduleOptionDeclaration,
39382
39425
  {
39383
39426
  name: "lib",
39384
39427
  type: "list",
@@ -39415,6 +39458,7 @@ var ts;
39415
39458
  type: jsxOptionMap,
39416
39459
  affectsSourceFile: true,
39417
39460
  affectsEmit: true,
39461
+ affectsMultiFileEmitBuildInfo: true,
39418
39462
  affectsModuleResolution: true,
39419
39463
  paramType: ts.Diagnostics.KIND,
39420
39464
  showInSimplifiedHelpView: true,
@@ -39427,6 +39471,7 @@ var ts;
39427
39471
  shortName: "d",
39428
39472
  type: "boolean",
39429
39473
  affectsEmit: true,
39474
+ affectsMultiFileEmitBuildInfo: true,
39430
39475
  showInSimplifiedHelpView: true,
39431
39476
  category: ts.Diagnostics.Emit,
39432
39477
  transpileOptionValue: undefined,
@@ -39437,6 +39482,7 @@ var ts;
39437
39482
  name: "declarationMap",
39438
39483
  type: "boolean",
39439
39484
  affectsEmit: true,
39485
+ affectsMultiFileEmitBuildInfo: true,
39440
39486
  showInSimplifiedHelpView: true,
39441
39487
  category: ts.Diagnostics.Emit,
39442
39488
  transpileOptionValue: undefined,
@@ -39447,6 +39493,7 @@ var ts;
39447
39493
  name: "emitDeclarationOnly",
39448
39494
  type: "boolean",
39449
39495
  affectsEmit: true,
39496
+ affectsMultiFileEmitBuildInfo: true,
39450
39497
  showInSimplifiedHelpView: true,
39451
39498
  category: ts.Diagnostics.Emit,
39452
39499
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39457,6 +39504,7 @@ var ts;
39457
39504
  name: "sourceMap",
39458
39505
  type: "boolean",
39459
39506
  affectsEmit: true,
39507
+ affectsMultiFileEmitBuildInfo: true,
39460
39508
  showInSimplifiedHelpView: true,
39461
39509
  category: ts.Diagnostics.Emit,
39462
39510
  defaultValueDescription: false,
@@ -39466,6 +39514,9 @@ var ts;
39466
39514
  name: "outFile",
39467
39515
  type: "string",
39468
39516
  affectsEmit: true,
39517
+ affectsMultiFileEmitBuildInfo: true,
39518
+ affectsDeclarationPath: true,
39519
+ affectsBundleEmitBuildInfo: true,
39469
39520
  isFilePath: true,
39470
39521
  paramType: ts.Diagnostics.FILE,
39471
39522
  showInSimplifiedHelpView: true,
@@ -39477,6 +39528,8 @@ var ts;
39477
39528
  name: "outDir",
39478
39529
  type: "string",
39479
39530
  affectsEmit: true,
39531
+ affectsMultiFileEmitBuildInfo: true,
39532
+ affectsDeclarationPath: true,
39480
39533
  isFilePath: true,
39481
39534
  paramType: ts.Diagnostics.DIRECTORY,
39482
39535
  showInSimplifiedHelpView: true,
@@ -39487,6 +39540,8 @@ var ts;
39487
39540
  name: "rootDir",
39488
39541
  type: "string",
39489
39542
  affectsEmit: true,
39543
+ affectsMultiFileEmitBuildInfo: true,
39544
+ affectsDeclarationPath: true,
39490
39545
  isFilePath: true,
39491
39546
  paramType: ts.Diagnostics.LOCATION,
39492
39547
  category: ts.Diagnostics.Modules,
@@ -39497,6 +39552,8 @@ var ts;
39497
39552
  name: "composite",
39498
39553
  type: "boolean",
39499
39554
  affectsEmit: true,
39555
+ affectsMultiFileEmitBuildInfo: true,
39556
+ affectsBundleEmitBuildInfo: true,
39500
39557
  isTSConfigOnly: true,
39501
39558
  category: ts.Diagnostics.Projects,
39502
39559
  transpileOptionValue: undefined,
@@ -39507,6 +39564,8 @@ var ts;
39507
39564
  name: "tsBuildInfoFile",
39508
39565
  type: "string",
39509
39566
  affectsEmit: true,
39567
+ affectsMultiFileEmitBuildInfo: true,
39568
+ affectsBundleEmitBuildInfo: true,
39510
39569
  isFilePath: true,
39511
39570
  paramType: ts.Diagnostics.FILE,
39512
39571
  category: ts.Diagnostics.Projects,
@@ -39518,6 +39577,7 @@ var ts;
39518
39577
  name: "removeComments",
39519
39578
  type: "boolean",
39520
39579
  affectsEmit: true,
39580
+ affectsMultiFileEmitBuildInfo: true,
39521
39581
  showInSimplifiedHelpView: true,
39522
39582
  category: ts.Diagnostics.Emit,
39523
39583
  defaultValueDescription: false,
@@ -39536,6 +39596,7 @@ var ts;
39536
39596
  name: "importHelpers",
39537
39597
  type: "boolean",
39538
39598
  affectsEmit: true,
39599
+ affectsMultiFileEmitBuildInfo: true,
39539
39600
  category: ts.Diagnostics.Emit,
39540
39601
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39541
39602
  defaultValueDescription: false,
@@ -39549,6 +39610,7 @@ var ts;
39549
39610
  })),
39550
39611
  affectsEmit: true,
39551
39612
  affectsSemanticDiagnostics: true,
39613
+ affectsMultiFileEmitBuildInfo: true,
39552
39614
  category: ts.Diagnostics.Emit,
39553
39615
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39554
39616
  defaultValueDescription: 0 /* Remove */,
@@ -39557,6 +39619,7 @@ var ts;
39557
39619
  name: "downlevelIteration",
39558
39620
  type: "boolean",
39559
39621
  affectsEmit: true,
39622
+ affectsMultiFileEmitBuildInfo: true,
39560
39623
  category: ts.Diagnostics.Emit,
39561
39624
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39562
39625
  defaultValueDescription: false,
@@ -39575,6 +39638,9 @@ var ts;
39575
39638
  type: "boolean",
39576
39639
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39577
39640
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39641
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39642
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39643
+ affectsMultiFileEmitBuildInfo: true,
39578
39644
  showInSimplifiedHelpView: true,
39579
39645
  category: ts.Diagnostics.Type_Checking,
39580
39646
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39584,6 +39650,7 @@ var ts;
39584
39650
  name: "noImplicitAny",
39585
39651
  type: "boolean",
39586
39652
  affectsSemanticDiagnostics: true,
39653
+ affectsMultiFileEmitBuildInfo: true,
39587
39654
  strictFlag: true,
39588
39655
  category: ts.Diagnostics.Type_Checking,
39589
39656
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39593,6 +39660,7 @@ var ts;
39593
39660
  name: "strictNullChecks",
39594
39661
  type: "boolean",
39595
39662
  affectsSemanticDiagnostics: true,
39663
+ affectsMultiFileEmitBuildInfo: true,
39596
39664
  strictFlag: true,
39597
39665
  category: ts.Diagnostics.Type_Checking,
39598
39666
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39601,6 +39669,8 @@ var ts;
39601
39669
  {
39602
39670
  name: "strictFunctionTypes",
39603
39671
  type: "boolean",
39672
+ affectsSemanticDiagnostics: true,
39673
+ affectsMultiFileEmitBuildInfo: true,
39604
39674
  strictFlag: true,
39605
39675
  category: ts.Diagnostics.Type_Checking,
39606
39676
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39609,6 +39679,8 @@ var ts;
39609
39679
  {
39610
39680
  name: "strictBindCallApply",
39611
39681
  type: "boolean",
39682
+ affectsSemanticDiagnostics: true,
39683
+ affectsMultiFileEmitBuildInfo: true,
39612
39684
  strictFlag: true,
39613
39685
  category: ts.Diagnostics.Type_Checking,
39614
39686
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39618,6 +39690,7 @@ var ts;
39618
39690
  name: "strictPropertyInitialization",
39619
39691
  type: "boolean",
39620
39692
  affectsSemanticDiagnostics: true,
39693
+ affectsMultiFileEmitBuildInfo: true,
39621
39694
  strictFlag: true,
39622
39695
  category: ts.Diagnostics.Type_Checking,
39623
39696
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39627,6 +39700,7 @@ var ts;
39627
39700
  name: "noImplicitThis",
39628
39701
  type: "boolean",
39629
39702
  affectsSemanticDiagnostics: true,
39703
+ affectsMultiFileEmitBuildInfo: true,
39630
39704
  strictFlag: true,
39631
39705
  category: ts.Diagnostics.Type_Checking,
39632
39706
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39636,6 +39710,7 @@ var ts;
39636
39710
  name: "useUnknownInCatchVariables",
39637
39711
  type: "boolean",
39638
39712
  affectsSemanticDiagnostics: true,
39713
+ affectsMultiFileEmitBuildInfo: true,
39639
39714
  strictFlag: true,
39640
39715
  category: ts.Diagnostics.Type_Checking,
39641
39716
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39645,6 +39720,8 @@ var ts;
39645
39720
  name: "alwaysStrict",
39646
39721
  type: "boolean",
39647
39722
  affectsSourceFile: true,
39723
+ affectsEmit: true,
39724
+ affectsMultiFileEmitBuildInfo: true,
39648
39725
  strictFlag: true,
39649
39726
  category: ts.Diagnostics.Type_Checking,
39650
39727
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39655,6 +39732,7 @@ var ts;
39655
39732
  name: "noUnusedLocals",
39656
39733
  type: "boolean",
39657
39734
  affectsSemanticDiagnostics: true,
39735
+ affectsMultiFileEmitBuildInfo: true,
39658
39736
  category: ts.Diagnostics.Type_Checking,
39659
39737
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39660
39738
  defaultValueDescription: false,
@@ -39663,6 +39741,7 @@ var ts;
39663
39741
  name: "noUnusedParameters",
39664
39742
  type: "boolean",
39665
39743
  affectsSemanticDiagnostics: true,
39744
+ affectsMultiFileEmitBuildInfo: true,
39666
39745
  category: ts.Diagnostics.Type_Checking,
39667
39746
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39668
39747
  defaultValueDescription: false,
@@ -39671,6 +39750,7 @@ var ts;
39671
39750
  name: "exactOptionalPropertyTypes",
39672
39751
  type: "boolean",
39673
39752
  affectsSemanticDiagnostics: true,
39753
+ affectsMultiFileEmitBuildInfo: true,
39674
39754
  category: ts.Diagnostics.Type_Checking,
39675
39755
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39676
39756
  defaultValueDescription: false,
@@ -39679,6 +39759,7 @@ var ts;
39679
39759
  name: "noImplicitReturns",
39680
39760
  type: "boolean",
39681
39761
  affectsSemanticDiagnostics: true,
39762
+ affectsMultiFileEmitBuildInfo: true,
39682
39763
  category: ts.Diagnostics.Type_Checking,
39683
39764
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39684
39765
  defaultValueDescription: false,
@@ -39688,6 +39769,7 @@ var ts;
39688
39769
  type: "boolean",
39689
39770
  affectsBindDiagnostics: true,
39690
39771
  affectsSemanticDiagnostics: true,
39772
+ affectsMultiFileEmitBuildInfo: true,
39691
39773
  category: ts.Diagnostics.Type_Checking,
39692
39774
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39693
39775
  defaultValueDescription: false,
@@ -39696,6 +39778,7 @@ var ts;
39696
39778
  name: "noUncheckedIndexedAccess",
39697
39779
  type: "boolean",
39698
39780
  affectsSemanticDiagnostics: true,
39781
+ affectsMultiFileEmitBuildInfo: true,
39699
39782
  category: ts.Diagnostics.Type_Checking,
39700
39783
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39701
39784
  defaultValueDescription: false,
@@ -39704,6 +39787,7 @@ var ts;
39704
39787
  name: "noImplicitOverride",
39705
39788
  type: "boolean",
39706
39789
  affectsSemanticDiagnostics: true,
39790
+ affectsMultiFileEmitBuildInfo: true,
39707
39791
  category: ts.Diagnostics.Type_Checking,
39708
39792
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39709
39793
  defaultValueDescription: false,
@@ -39711,6 +39795,8 @@ var ts;
39711
39795
  {
39712
39796
  name: "noPropertyAccessFromIndexSignature",
39713
39797
  type: "boolean",
39798
+ affectsSemanticDiagnostics: true,
39799
+ affectsMultiFileEmitBuildInfo: true,
39714
39800
  showInSimplifiedHelpView: false,
39715
39801
  category: ts.Diagnostics.Type_Checking,
39716
39802
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39796,6 +39882,7 @@ var ts;
39796
39882
  name: "allowSyntheticDefaultImports",
39797
39883
  type: "boolean",
39798
39884
  affectsSemanticDiagnostics: true,
39885
+ affectsMultiFileEmitBuildInfo: true,
39799
39886
  category: ts.Diagnostics.Interop_Constraints,
39800
39887
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39801
39888
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39805,6 +39892,7 @@ var ts;
39805
39892
  type: "boolean",
39806
39893
  affectsSemanticDiagnostics: true,
39807
39894
  affectsEmit: true,
39895
+ affectsMultiFileEmitBuildInfo: true,
39808
39896
  showInSimplifiedHelpView: true,
39809
39897
  category: ts.Diagnostics.Interop_Constraints,
39810
39898
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39821,6 +39909,7 @@ var ts;
39821
39909
  name: "allowUmdGlobalAccess",
39822
39910
  type: "boolean",
39823
39911
  affectsSemanticDiagnostics: true,
39912
+ affectsMultiFileEmitBuildInfo: true,
39824
39913
  category: ts.Diagnostics.Modules,
39825
39914
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39826
39915
  defaultValueDescription: false,
@@ -39842,6 +39931,7 @@ var ts;
39842
39931
  name: "sourceRoot",
39843
39932
  type: "string",
39844
39933
  affectsEmit: true,
39934
+ affectsMultiFileEmitBuildInfo: true,
39845
39935
  paramType: ts.Diagnostics.LOCATION,
39846
39936
  category: ts.Diagnostics.Emit,
39847
39937
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39850,6 +39940,7 @@ var ts;
39850
39940
  name: "mapRoot",
39851
39941
  type: "string",
39852
39942
  affectsEmit: true,
39943
+ affectsMultiFileEmitBuildInfo: true,
39853
39944
  paramType: ts.Diagnostics.LOCATION,
39854
39945
  category: ts.Diagnostics.Emit,
39855
39946
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39858,6 +39949,7 @@ var ts;
39858
39949
  name: "inlineSourceMap",
39859
39950
  type: "boolean",
39860
39951
  affectsEmit: true,
39952
+ affectsMultiFileEmitBuildInfo: true,
39861
39953
  category: ts.Diagnostics.Emit,
39862
39954
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39863
39955
  defaultValueDescription: false,
@@ -39866,6 +39958,7 @@ var ts;
39866
39958
  name: "inlineSources",
39867
39959
  type: "boolean",
39868
39960
  affectsEmit: true,
39961
+ affectsMultiFileEmitBuildInfo: true,
39869
39962
  category: ts.Diagnostics.Emit,
39870
39963
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39871
39964
  defaultValueDescription: false,
@@ -39875,6 +39968,7 @@ var ts;
39875
39968
  name: "experimentalDecorators",
39876
39969
  type: "boolean",
39877
39970
  affectsSemanticDiagnostics: true,
39971
+ affectsMultiFileEmitBuildInfo: true,
39878
39972
  category: ts.Diagnostics.Language_and_Environment,
39879
39973
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39880
39974
  defaultValueDescription: false,
@@ -39884,6 +39978,7 @@ var ts;
39884
39978
  type: "boolean",
39885
39979
  affectsSemanticDiagnostics: true,
39886
39980
  affectsEmit: true,
39981
+ affectsMultiFileEmitBuildInfo: true,
39887
39982
  category: ts.Diagnostics.Language_and_Environment,
39888
39983
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39889
39984
  defaultValueDescription: false,
@@ -39908,6 +40003,7 @@ var ts;
39908
40003
  type: "string",
39909
40004
  affectsSemanticDiagnostics: true,
39910
40005
  affectsEmit: true,
40006
+ affectsMultiFileEmitBuildInfo: true,
39911
40007
  affectsModuleResolution: true,
39912
40008
  category: ts.Diagnostics.Language_and_Environment,
39913
40009
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39925,6 +40021,9 @@ var ts;
39925
40021
  name: "out",
39926
40022
  type: "string",
39927
40023
  affectsEmit: true,
40024
+ affectsMultiFileEmitBuildInfo: true,
40025
+ affectsDeclarationPath: true,
40026
+ affectsBundleEmitBuildInfo: true,
39928
40027
  isFilePath: false,
39929
40028
  // for correct behaviour, please use outFile
39930
40029
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39936,6 +40035,7 @@ var ts;
39936
40035
  name: "reactNamespace",
39937
40036
  type: "string",
39938
40037
  affectsEmit: true,
40038
+ affectsMultiFileEmitBuildInfo: true,
39939
40039
  category: ts.Diagnostics.Language_and_Environment,
39940
40040
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39941
40041
  defaultValueDescription: "`React`",
@@ -39943,6 +40043,8 @@ var ts;
39943
40043
  {
39944
40044
  name: "skipDefaultLibCheck",
39945
40045
  type: "boolean",
40046
+ // We need to store these to determine whether `lib` files need to be rechecked
40047
+ affectsMultiFileEmitBuildInfo: true,
39946
40048
  category: ts.Diagnostics.Completeness,
39947
40049
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39948
40050
  defaultValueDescription: false,
@@ -39958,6 +40060,7 @@ var ts;
39958
40060
  name: "emitBOM",
39959
40061
  type: "boolean",
39960
40062
  affectsEmit: true,
40063
+ affectsMultiFileEmitBuildInfo: true,
39961
40064
  category: ts.Diagnostics.Emit,
39962
40065
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39963
40066
  defaultValueDescription: false,
@@ -39969,6 +40072,7 @@ var ts;
39969
40072
  lf: 1 /* LineFeed */
39970
40073
  })),
39971
40074
  affectsEmit: true,
40075
+ affectsMultiFileEmitBuildInfo: true,
39972
40076
  paramType: ts.Diagnostics.NEWLINE,
39973
40077
  category: ts.Diagnostics.Emit,
39974
40078
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39978,6 +40082,7 @@ var ts;
39978
40082
  name: "noErrorTruncation",
39979
40083
  type: "boolean",
39980
40084
  affectsSemanticDiagnostics: true,
40085
+ affectsMultiFileEmitBuildInfo: true,
39981
40086
  category: ts.Diagnostics.Output_Formatting,
39982
40087
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39983
40088
  defaultValueDescription: false,
@@ -40008,6 +40113,7 @@ var ts;
40008
40113
  name: "stripInternal",
40009
40114
  type: "boolean",
40010
40115
  affectsEmit: true,
40116
+ affectsMultiFileEmitBuildInfo: true,
40011
40117
  category: ts.Diagnostics.Emit,
40012
40118
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40013
40119
  defaultValueDescription: false,
@@ -40048,6 +40154,7 @@ var ts;
40048
40154
  name: "noImplicitUseStrict",
40049
40155
  type: "boolean",
40050
40156
  affectsSemanticDiagnostics: true,
40157
+ affectsMultiFileEmitBuildInfo: true,
40051
40158
  category: ts.Diagnostics.Backwards_Compatibility,
40052
40159
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40053
40160
  defaultValueDescription: false,
@@ -40056,6 +40163,7 @@ var ts;
40056
40163
  name: "noEmitHelpers",
40057
40164
  type: "boolean",
40058
40165
  affectsEmit: true,
40166
+ affectsMultiFileEmitBuildInfo: true,
40059
40167
  category: ts.Diagnostics.Emit,
40060
40168
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40061
40169
  defaultValueDescription: false,
@@ -40064,6 +40172,7 @@ var ts;
40064
40172
  name: "noEmitOnError",
40065
40173
  type: "boolean",
40066
40174
  affectsEmit: true,
40175
+ affectsMultiFileEmitBuildInfo: true,
40067
40176
  category: ts.Diagnostics.Emit,
40068
40177
  transpileOptionValue: undefined,
40069
40178
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40073,6 +40182,7 @@ var ts;
40073
40182
  name: "preserveConstEnums",
40074
40183
  type: "boolean",
40075
40184
  affectsEmit: true,
40185
+ affectsMultiFileEmitBuildInfo: true,
40076
40186
  category: ts.Diagnostics.Emit,
40077
40187
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40078
40188
  defaultValueDescription: false,
@@ -40081,6 +40191,8 @@ var ts;
40081
40191
  name: "declarationDir",
40082
40192
  type: "string",
40083
40193
  affectsEmit: true,
40194
+ affectsMultiFileEmitBuildInfo: true,
40195
+ affectsDeclarationPath: true,
40084
40196
  isFilePath: true,
40085
40197
  paramType: ts.Diagnostics.DIRECTORY,
40086
40198
  category: ts.Diagnostics.Emit,
@@ -40090,6 +40202,8 @@ var ts;
40090
40202
  {
40091
40203
  name: "skipLibCheck",
40092
40204
  type: "boolean",
40205
+ // We need to store these to determine whether `lib` files need to be rechecked
40206
+ affectsMultiFileEmitBuildInfo: true,
40093
40207
  category: ts.Diagnostics.Completeness,
40094
40208
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40095
40209
  defaultValueDescription: false,
@@ -40099,6 +40213,7 @@ var ts;
40099
40213
  type: "boolean",
40100
40214
  affectsBindDiagnostics: true,
40101
40215
  affectsSemanticDiagnostics: true,
40216
+ affectsMultiFileEmitBuildInfo: true,
40102
40217
  category: ts.Diagnostics.Type_Checking,
40103
40218
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40104
40219
  defaultValueDescription: undefined,
@@ -40108,6 +40223,7 @@ var ts;
40108
40223
  type: "boolean",
40109
40224
  affectsBindDiagnostics: true,
40110
40225
  affectsSemanticDiagnostics: true,
40226
+ affectsMultiFileEmitBuildInfo: true,
40111
40227
  category: ts.Diagnostics.Type_Checking,
40112
40228
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40113
40229
  defaultValueDescription: undefined,
@@ -40116,6 +40232,7 @@ var ts;
40116
40232
  name: "suppressExcessPropertyErrors",
40117
40233
  type: "boolean",
40118
40234
  affectsSemanticDiagnostics: true,
40235
+ affectsMultiFileEmitBuildInfo: true,
40119
40236
  category: ts.Diagnostics.Backwards_Compatibility,
40120
40237
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40121
40238
  defaultValueDescription: false,
@@ -40124,6 +40241,7 @@ var ts;
40124
40241
  name: "suppressImplicitAnyIndexErrors",
40125
40242
  type: "boolean",
40126
40243
  affectsSemanticDiagnostics: true,
40244
+ affectsMultiFileEmitBuildInfo: true,
40127
40245
  category: ts.Diagnostics.Backwards_Compatibility,
40128
40246
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40129
40247
  defaultValueDescription: false,
@@ -40148,6 +40266,7 @@ var ts;
40148
40266
  name: "noStrictGenericChecks",
40149
40267
  type: "boolean",
40150
40268
  affectsSemanticDiagnostics: true,
40269
+ affectsMultiFileEmitBuildInfo: true,
40151
40270
  category: ts.Diagnostics.Backwards_Compatibility,
40152
40271
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40153
40272
  defaultValueDescription: false,
@@ -40157,6 +40276,7 @@ var ts;
40157
40276
  type: "boolean",
40158
40277
  affectsSemanticDiagnostics: true,
40159
40278
  affectsEmit: true,
40279
+ affectsMultiFileEmitBuildInfo: true,
40160
40280
  category: ts.Diagnostics.Language_and_Environment,
40161
40281
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40162
40282
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40165,6 +40285,7 @@ var ts;
40165
40285
  name: "preserveValueImports",
40166
40286
  type: "boolean",
40167
40287
  affectsEmit: true,
40288
+ affectsMultiFileEmitBuildInfo: true,
40168
40289
  category: ts.Diagnostics.Emit,
40169
40290
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40170
40291
  defaultValueDescription: false,
@@ -40208,6 +40329,8 @@ var ts;
40208
40329
  /* @internal */
40209
40330
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40210
40331
  /* @internal */
40332
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40333
+ /* @internal */
40211
40334
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40212
40335
  /* @internal */
40213
40336
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41063,6 +41186,7 @@ var ts;
41063
41186
  return optionDefinition.type;
41064
41187
  }
41065
41188
  }
41189
+ /* @internal */
41066
41190
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41067
41191
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41068
41192
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41071,6 +41195,7 @@ var ts;
41071
41195
  }
41072
41196
  });
41073
41197
  }
41198
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41074
41199
  function serializeCompilerOptions(options, pathOptions) {
41075
41200
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41076
41201
  }
@@ -42236,16 +42361,18 @@ var ts;
42236
42361
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42237
42362
  return { fileName: resolved.path, packageId: resolved.packageId };
42238
42363
  }
42239
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42240
- var _a;
42364
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42365
+ var _a, _b;
42241
42366
  if (resultFromCache) {
42242
42367
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42368
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42243
42369
  return resultFromCache;
42244
42370
  }
42245
42371
  return {
42246
42372
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42247
42373
  failedLookupLocations: failedLookupLocations,
42248
- resolutionDiagnostics: diagnostics
42374
+ affectingLocations: affectingLocations,
42375
+ resolutionDiagnostics: diagnostics,
42249
42376
  };
42250
42377
  }
42251
42378
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42434,6 +42561,7 @@ var ts;
42434
42561
  }
42435
42562
  }
42436
42563
  var failedLookupLocations = [];
42564
+ var affectingLocations = [];
42437
42565
  var features = getDefaultNodeResolutionFeatures(options);
42438
42566
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42439
42567
  // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
@@ -42452,6 +42580,7 @@ var ts;
42452
42580
  host: host,
42453
42581
  traceEnabled: traceEnabled,
42454
42582
  failedLookupLocations: failedLookupLocations,
42583
+ affectingLocations: affectingLocations,
42455
42584
  packageJsonInfoCache: cache,
42456
42585
  features: features,
42457
42586
  conditions: conditions,
@@ -42476,7 +42605,7 @@ var ts;
42476
42605
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42477
42606
  };
42478
42607
  }
42479
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42608
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42480
42609
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42481
42610
  if (traceEnabled)
42482
42611
  traceResult(result);
@@ -42556,6 +42685,7 @@ var ts;
42556
42685
  host: host,
42557
42686
  traceEnabled: isTraceEnabled(options, host),
42558
42687
  failedLookupLocations: [],
42688
+ affectingLocations: [],
42559
42689
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42560
42690
  conditions: ts.emptyArray,
42561
42691
  features: NodeResolutionFeatures.None,
@@ -43210,6 +43340,7 @@ var ts;
43210
43340
  var _a, _b;
43211
43341
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43212
43342
  var failedLookupLocations = [];
43343
+ var affectingLocations = [];
43213
43344
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43214
43345
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43215
43346
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43222,6 +43353,7 @@ var ts;
43222
43353
  host: host,
43223
43354
  traceEnabled: traceEnabled,
43224
43355
  failedLookupLocations: failedLookupLocations,
43356
+ affectingLocations: affectingLocations,
43225
43357
  packageJsonInfoCache: cache,
43226
43358
  features: features,
43227
43359
  conditions: conditions,
@@ -43229,7 +43361,7 @@ var ts;
43229
43361
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43230
43362
  };
43231
43363
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43232
- return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
43364
+ return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
43233
43365
  function tryResolve(extensions) {
43234
43366
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43235
43367
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43524,6 +43656,7 @@ var ts;
43524
43656
  host: host,
43525
43657
  traceEnabled: isTraceEnabled(options, host),
43526
43658
  failedLookupLocations: [],
43659
+ affectingLocations: [],
43527
43660
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43528
43661
  conditions: ["node", "require", "types"],
43529
43662
  features: features,
@@ -43612,6 +43745,7 @@ var ts;
43612
43745
  compilerOptions: options,
43613
43746
  traceEnabled: isTraceEnabled(options, host),
43614
43747
  failedLookupLocations: [],
43748
+ affectingLocations: [],
43615
43749
  packageJsonInfoCache: packageJsonInfoCache,
43616
43750
  features: 0,
43617
43751
  conditions: [],
@@ -43644,6 +43778,7 @@ var ts;
43644
43778
  if (typeof existing !== "boolean") {
43645
43779
  if (traceEnabled)
43646
43780
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43781
+ state.affectingLocations.push(packageJsonPath);
43647
43782
  return existing;
43648
43783
  }
43649
43784
  else {
@@ -43662,6 +43797,7 @@ var ts;
43662
43797
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43663
43798
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43664
43799
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
43800
+ state.affectingLocations.push(packageJsonPath);
43665
43801
  return result;
43666
43802
  }
43667
43803
  else {
@@ -44325,12 +44461,25 @@ var ts;
44325
44461
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44326
44462
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44327
44463
  var failedLookupLocations = [];
44464
+ var affectingLocations = [];
44328
44465
  var containingDirectory = ts.getDirectoryPath(containingFile);
44329
44466
  var diagnostics = [];
44330
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44467
+ var state = {
44468
+ compilerOptions: compilerOptions,
44469
+ host: host,
44470
+ traceEnabled: traceEnabled,
44471
+ failedLookupLocations: failedLookupLocations,
44472
+ affectingLocations: affectingLocations,
44473
+ packageJsonInfoCache: cache,
44474
+ features: NodeResolutionFeatures.None,
44475
+ conditions: [],
44476
+ requestContainingDirectory: containingDirectory,
44477
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44478
+ };
44331
44479
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44332
44480
  // No originalPath because classic resolution doesn't resolve realPath
44333
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44481
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
44482
+ /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44334
44483
  function tryResolve(extensions) {
44335
44484
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44336
44485
  if (resolvedUsingSettings) {
@@ -44373,10 +44522,23 @@ var ts;
44373
44522
  trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
44374
44523
  }
44375
44524
  var failedLookupLocations = [];
44525
+ var affectingLocations = [];
44376
44526
  var diagnostics = [];
44377
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44527
+ var state = {
44528
+ compilerOptions: compilerOptions,
44529
+ host: host,
44530
+ traceEnabled: traceEnabled,
44531
+ failedLookupLocations: failedLookupLocations,
44532
+ affectingLocations: affectingLocations,
44533
+ packageJsonInfoCache: packageJsonInfoCache,
44534
+ features: NodeResolutionFeatures.None,
44535
+ conditions: [],
44536
+ requestContainingDirectory: undefined,
44537
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44538
+ };
44378
44539
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44379
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44540
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44541
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44380
44542
  }
44381
44543
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44382
44544
  /**
@@ -47937,16 +48099,6 @@ var ts;
47937
48099
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47938
48100
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47939
48101
  })(TypeFacts || (TypeFacts = {}));
47940
- var typeofEQFacts = new ts.Map(ts.getEntries({
47941
- string: 1 /* TypeofEQString */,
47942
- number: 2 /* TypeofEQNumber */,
47943
- bigint: 4 /* TypeofEQBigInt */,
47944
- boolean: 8 /* TypeofEQBoolean */,
47945
- symbol: 16 /* TypeofEQSymbol */,
47946
- undefined: 65536 /* EQUndefined */,
47947
- object: 32 /* TypeofEQObject */,
47948
- function: 64 /* TypeofEQFunction */
47949
- }));
47950
48102
  var typeofNEFacts = new ts.Map(ts.getEntries({
47951
48103
  string: 256 /* TypeofNEString */,
47952
48104
  number: 512 /* TypeofNENumber */,
@@ -48745,14 +48897,6 @@ var ts;
48745
48897
  var awaitedTypeStack = [];
48746
48898
  var diagnostics = ts.createDiagnosticCollection();
48747
48899
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48748
- var typeofTypesByName = new ts.Map(ts.getEntries({
48749
- string: stringType,
48750
- number: numberType,
48751
- bigint: bigintType,
48752
- boolean: booleanType,
48753
- symbol: esSymbolType,
48754
- undefined: undefinedType
48755
- }));
48756
48900
  var typeofType = createTypeofType();
48757
48901
  var _jsxNamespace;
48758
48902
  var _jsxFactoryEntity;
@@ -51628,7 +51772,7 @@ var ts;
51628
51772
  return type;
51629
51773
  }
51630
51774
  function createTypeofType() {
51631
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51775
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51632
51776
  }
51633
51777
  function createTypeParameter(symbol) {
51634
51778
  var type = createType(262144 /* TypeParameter */);
@@ -52414,6 +52558,9 @@ var ts;
52414
52558
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52415
52559
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52416
52560
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
52561
+ if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
52562
+ return ts.factory.createArrayTypeNode(typeArgumentNodes[0]);
52563
+ }
52417
52564
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52418
52565
  }
52419
52566
  var objectFlags = ts.getObjectFlags(type);
@@ -52604,7 +52751,7 @@ var ts;
52604
52751
  // Always use 'typeof T' for type of class, enum, and module objects
52605
52752
  else if (symbol.flags & 32 /* Class */
52606
52753
  && !getBaseTypeVariableOfClass(symbol)
52607
- && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) ||
52754
+ && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) ||
52608
52755
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52609
52756
  shouldWriteTypeOfFunctionSymbol()) {
52610
52757
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56234,6 +56381,17 @@ var ts;
56234
56381
  });
56235
56382
  var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type
56236
56383
  members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
56384
+ if (initialSize === members_4.size) {
56385
+ if (type.aliasSymbol) {
56386
+ result.aliasSymbol = type.aliasSymbol;
56387
+ result.aliasTypeArguments = type.aliasTypeArguments;
56388
+ }
56389
+ if (ts.getObjectFlags(type) & 4 /* Reference */) {
56390
+ result.aliasSymbol = type.symbol;
56391
+ var args = getTypeArguments(type);
56392
+ result.aliasTypeArguments = ts.length(args) ? args : undefined;
56393
+ }
56394
+ }
56237
56395
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56238
56396
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56239
56397
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -69842,19 +70000,17 @@ var ts;
69842
70000
  }
69843
70001
  return links.switchTypes;
69844
70002
  }
69845
- function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
70003
+ // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are
70004
+ // represented as undefined. Return undefined if one or more case clause expressions are not string literals.
70005
+ function getSwitchClauseTypeOfWitnesses(switchStatement) {
70006
+ if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) {
70007
+ return undefined;
70008
+ }
69846
70009
  var witnesses = [];
69847
70010
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
69848
70011
  var clause = _a[_i];
69849
- if (clause.kind === 289 /* CaseClause */) {
69850
- if (ts.isStringLiteralLike(clause.expression)) {
69851
- witnesses.push(clause.expression.text);
69852
- continue;
69853
- }
69854
- return ts.emptyArray;
69855
- }
69856
- if (retainDefault)
69857
- witnesses.push(/*explicitDefaultStatement*/ undefined);
70012
+ var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined;
70013
+ witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined);
69858
70014
  }
69859
70015
  return witnesses;
69860
70016
  }
@@ -71044,14 +71200,9 @@ var ts;
71044
71200
  }
71045
71201
  return type;
71046
71202
  }
71047
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71048
- return type;
71049
- }
71050
- var facts = assumeTrue ?
71051
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71052
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71053
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71054
- return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71203
+ return assumeTrue ?
71204
+ narrowTypeByTypeName(type, literal.text) :
71205
+ getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
71055
71206
  }
71056
71207
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71057
71208
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71098,102 +71249,52 @@ var ts;
71098
71249
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71099
71250
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71100
71251
  }
71101
- function getImpliedTypeFromTypeofGuard(type, text) {
71102
- switch (text) {
71103
- case "object":
71104
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71105
- case "function":
71106
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71107
- default:
71108
- return typeofTypesByName.get(text);
71252
+ function narrowTypeByTypeName(type, typeName) {
71253
+ switch (typeName) {
71254
+ case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */);
71255
+ case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */);
71256
+ case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */);
71257
+ case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */);
71258
+ case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */);
71259
+ case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]);
71260
+ case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */);
71261
+ case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */);
71109
71262
  }
71263
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71110
71264
  }
71111
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71112
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71113
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71114
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71115
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71116
- // filtering by type-facts.
71117
- function narrowTypeByImpliedType(type, candidate) {
71118
- if (type.flags & 3 /* AnyOrUnknown */) {
71119
- return candidate;
71120
- }
71265
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71121
71266
  return mapType(type, function (t) {
71122
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71123
- return t;
71124
- }
71125
- return mapType(candidate, function (c) {
71126
- if (!areTypesComparable(t, c)) {
71127
- return neverType;
71128
- }
71129
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71130
- return isTypeSubtypeOf(c, t) ? c : neverType;
71131
- }
71132
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71133
- return c;
71134
- }
71135
- return getIntersectionType([t, c]);
71136
- });
71267
+ // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
71268
+ // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
71269
+ // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
71270
+ // but are classified as "function" according to `typeof`.
71271
+ return isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType :
71272
+ // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
71273
+ // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
71274
+ isTypeSubtypeOf(impliedType, t) ? impliedType :
71275
+ // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
71276
+ // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
71277
+ // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
71278
+ getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) :
71279
+ neverType;
71137
71280
  });
71138
71281
  }
71139
71282
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71140
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71141
- if (!switchWitnesses.length) {
71283
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71284
+ if (!witnesses) {
71142
71285
  return type;
71143
71286
  }
71144
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71145
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71146
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71147
- var clauseWitnesses;
71148
- var switchFacts;
71149
- if (defaultCaseLocation > -1) {
71150
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71151
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71152
- // witness array.
71153
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71154
- // The adjusted clause start and end after removing the `default` statement.
71155
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71156
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71157
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71158
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71159
- }
71160
- else {
71161
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71162
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71163
- }
71287
+ // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause.
71288
+ var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; });
71289
+ var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd);
71164
71290
  if (hasDefaultClause) {
71165
- return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
71291
+ // In the default clause we filter constituents down to those that are not-equal to all handled cases.
71292
+ var notEqualFacts_1 = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
71293
+ return filterType(type, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; });
71166
71294
  }
71167
- /*
71168
- The implied type is the raw type suggested by a
71169
- value being caught in this clause.
71170
-
71171
- When the clause contains a default case we ignore
71172
- the implied type and try to narrow using any facts
71173
- we can learn: see `switchFacts`.
71174
-
71175
- Example:
71176
- switch (typeof x) {
71177
- case 'number':
71178
- case 'string': break;
71179
- default: break;
71180
- case 'number':
71181
- case 'boolean': break
71182
- }
71183
-
71184
- In the first clause (case `number` and `string`) the
71185
- implied type is number | string.
71186
-
71187
- In the default clause we de not compute an implied type.
71188
-
71189
- In the third clause (case `number` and `boolean`)
71190
- the naive implied type is number | boolean, however
71191
- we use the type facts to narrow the implied type to
71192
- boolean. We know that number cannot be selected
71193
- because it is caught in the first clause.
71194
- */
71195
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71196
- return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71295
+ // In the non-default cause we create a union of the type narrowed by each of the listed cases.
71296
+ var clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71297
+ return getUnionType(ts.map(clauseWitnesses, function (text) { return text ? narrowTypeByTypeName(type, text) : neverType; }));
71197
71298
  }
71198
71299
  function isMatchingConstructorReference(expr) {
71199
71300
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -78005,45 +78106,12 @@ var ts;
78005
78106
  ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
78006
78107
  : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
78007
78108
  }
78008
- /**
78009
- * Collect the TypeFacts learned from a typeof switch with
78010
- * total clauses `witnesses`, and the active clause ranging
78011
- * from `start` to `end`. Parameter `hasDefault` denotes
78012
- * whether the active clause contains a default clause.
78013
- */
78014
- function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
78109
+ // Return the combined not-equal type facts for all cases except those between the start and end indices.
78110
+ function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) {
78015
78111
  var facts = 0 /* None */;
78016
- // When in the default we only collect inequality facts
78017
- // because default is 'in theory' a set of infinite
78018
- // equalities.
78019
- if (hasDefault) {
78020
- // Value is not equal to any types after the active clause.
78021
- for (var i = end; i < witnesses.length; i++) {
78022
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78023
- }
78024
- // Remove inequalities for types that appear in the
78025
- // active clause because they appear before other
78026
- // types collected so far.
78027
- for (var i = start; i < end; i++) {
78028
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78029
- }
78030
- // Add inequalities for types before the active clause unconditionally.
78031
- for (var i = 0; i < start; i++) {
78032
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78033
- }
78034
- }
78035
- // When in an active clause without default the set of
78036
- // equalities is finite.
78037
- else {
78038
- // Add equalities for all types in the active clause.
78039
- for (var i = start; i < end; i++) {
78040
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78041
- }
78042
- // Remove equalities for types that appear before the
78043
- // active clause.
78044
- for (var i = 0; i < start; i++) {
78045
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78046
- }
78112
+ for (var i = 0; i < witnesses.length; i++) {
78113
+ var witness = i < start || i >= end ? witnesses[i] : undefined;
78114
+ facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0;
78047
78115
  }
78048
78116
  return facts;
78049
78117
  }
@@ -78053,16 +78121,19 @@ var ts;
78053
78121
  }
78054
78122
  function computeExhaustiveSwitchStatement(node) {
78055
78123
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78056
- var operandType = getTypeOfExpression(node.expression.expression);
78057
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78058
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78059
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78060
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78061
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78062
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78063
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
78124
+ var witnesses = getSwitchClauseTypeOfWitnesses(node);
78125
+ if (!witnesses) {
78126
+ return false;
78127
+ }
78128
+ var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
78129
+ // Get the not-equal flags for all handled cases.
78130
+ var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
78131
+ if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
78132
+ // We special case the top types to be exhaustive when all cases are handled.
78133
+ return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */;
78064
78134
  }
78065
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
78135
+ // A missing not-equal flag indicates that the type wasn't handled by some case.
78136
+ return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
78066
78137
  }
78067
78138
  var type = getTypeOfExpression(node.expression);
78068
78139
  if (!isLiteralType(type)) {
@@ -110797,7 +110868,9 @@ var ts;
110797
110868
  return;
110798
110869
  }
110799
110870
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110800
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110871
+ var buildInfo = { bundle: bundle, program: program, version: version };
110872
+ // Pass buildinfo as additional data to avoid having to reparse
110873
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110801
110874
  }
110802
110875
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110803
110876
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110951,13 +111024,20 @@ var ts;
110951
111024
  if (sourceMapFilePath) {
110952
111025
  var sourceMap = sourceMapGenerator.toString();
110953
111026
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111027
+ if (printer.bundleFileInfo)
111028
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110954
111029
  }
110955
111030
  }
110956
111031
  else {
110957
111032
  writer.writeLine();
110958
111033
  }
110959
111034
  // Write the output file
110960
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111035
+ var text = writer.getText();
111036
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111037
+ // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
111038
+ // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
111039
+ if (printer.bundleFileInfo)
111040
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110961
111041
  // Reset state
110962
111042
  writer.clear();
110963
111043
  }
@@ -111100,34 +111180,56 @@ var ts;
111100
111180
  }
111101
111181
  /*@internal*/
111102
111182
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111183
+ var createHash = ts.maybeBind(host, host.createHash);
111103
111184
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111104
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111105
- if (!buildInfoText)
111185
+ var buildInfo;
111186
+ if (host.getBuildInfo) {
111187
+ // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111188
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111189
+ if (!hostBuildInfo)
111190
+ return buildInfoPath;
111191
+ buildInfo = hostBuildInfo;
111192
+ }
111193
+ else {
111194
+ var buildInfoText = host.readFile(buildInfoPath);
111195
+ if (!buildInfoText)
111196
+ return buildInfoPath;
111197
+ buildInfo = getBuildInfo(buildInfoText);
111198
+ }
111199
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111106
111200
  return buildInfoPath;
111107
111201
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111108
111202
  if (!jsFileText)
111109
111203
  return jsFilePath;
111204
+ // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111205
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111206
+ return jsFilePath;
111110
111207
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111111
111208
  // error if no source map or for now if inline sourcemap
111112
111209
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111113
111210
  return sourceMapFilePath || "inline sourcemap decoding";
111211
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111212
+ return sourceMapFilePath;
111114
111213
  // read declaration text
111115
111214
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111116
111215
  if (declarationFilePath && !declarationText)
111117
111216
  return declarationFilePath;
111217
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111218
+ return declarationFilePath;
111118
111219
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111119
111220
  // error if no source map or for now if inline sourcemap
111120
111221
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111121
111222
  return declarationMapPath || "inline sourcemap decoding";
111122
- var buildInfo = getBuildInfo(buildInfoText);
111123
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111124
- return buildInfoPath;
111223
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111224
+ return declarationMapPath;
111125
111225
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111126
111226
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111127
111227
  /*onlyOwnText*/ true);
111128
111228
  var outputFiles = [];
111129
111229
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111130
111230
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111231
+ var changedDtsText;
111232
+ var changedDtsData;
111131
111233
  var emitHost = {
111132
111234
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111133
111235
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111143,7 +111245,7 @@ var ts;
111143
111245
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111144
111246
  getProjectReferenceRedirect: ts.returnUndefined,
111145
111247
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111146
- writeFile: function (name, text, writeByteOrderMark) {
111248
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111147
111249
  switch (name) {
111148
111250
  case jsFilePath:
111149
111251
  if (jsFileText === text)
@@ -111154,8 +111256,13 @@ var ts;
111154
111256
  return;
111155
111257
  break;
111156
111258
  case buildInfoPath:
111157
- var newBuildInfo = getBuildInfo(text);
111259
+ var newBuildInfo = data.buildInfo;
111158
111260
  newBuildInfo.program = buildInfo.program;
111261
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111262
+ // Update the output signature
111263
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111264
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111265
+ }
111159
111266
  // Update sourceFileInfo
111160
111267
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111161
111268
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111163,11 +111270,13 @@ var ts;
111163
111270
  newBuildInfo.bundle.dts.sources = dts.sources;
111164
111271
  }
111165
111272
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111166
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111273
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111167
111274
  return;
111168
111275
  case declarationFilePath:
111169
111276
  if (declarationText === text)
111170
111277
  return;
111278
+ changedDtsText = text;
111279
+ changedDtsData = data;
111171
111280
  break;
111172
111281
  case declarationMapPath:
111173
111282
  if (declarationMapText === text)
@@ -111186,6 +111295,7 @@ var ts;
111186
111295
  getSourceFileFromReference: ts.returnUndefined,
111187
111296
  redirectTargetsMap: ts.createMultiMap(),
111188
111297
  getFileIncludeReasons: ts.notImplemented,
111298
+ createHash: createHash,
111189
111299
  };
111190
111300
  emitFiles(ts.notImplementedResolver, emitHost,
111191
111301
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116270,12 +116380,10 @@ var ts;
116270
116380
  }
116271
116381
  ts.createCompilerHost = createCompilerHost;
116272
116382
  /*@internal*/
116273
- // TODO(shkamat): update this after reworking ts build API
116274
116383
  function createCompilerHostWorker(options, setParentNodes, system) {
116275
116384
  if (system === void 0) { system = ts.sys; }
116276
116385
  var existingDirectories = new ts.Map();
116277
116386
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116278
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116279
116387
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116280
116388
  var text;
116281
116389
  try {
@@ -116308,7 +116416,7 @@ var ts;
116308
116416
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116309
116417
  // the system.writeFile will do its own directory creation and
116310
116418
  // the ensureDirectoriesExist call will always be redundant.
116311
- 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); });
116419
+ 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); });
116312
116420
  ts.performance.mark("afterIOWrite");
116313
116421
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116314
116422
  }
@@ -116318,35 +116426,6 @@ var ts;
116318
116426
  }
116319
116427
  }
116320
116428
  }
116321
- var outputFingerprints;
116322
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116323
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116324
- system.writeFile(fileName, data, writeByteOrderMark);
116325
- return;
116326
- }
116327
- if (!outputFingerprints) {
116328
- outputFingerprints = new ts.Map();
116329
- }
116330
- var hash = computeHash(data);
116331
- var mtimeBefore = system.getModifiedTime(fileName);
116332
- if (mtimeBefore) {
116333
- var fingerprint = outputFingerprints.get(fileName);
116334
- // If output has not been changed, and the file has no external modification
116335
- if (fingerprint &&
116336
- fingerprint.byteOrderMark === writeByteOrderMark &&
116337
- fingerprint.hash === hash &&
116338
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116339
- return;
116340
- }
116341
- }
116342
- system.writeFile(fileName, data, writeByteOrderMark);
116343
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116344
- outputFingerprints.set(fileName, {
116345
- hash: hash,
116346
- byteOrderMark: writeByteOrderMark,
116347
- mtime: mtimeAfter
116348
- });
116349
- }
116350
116429
  function getDefaultLibLocation() {
116351
116430
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116352
116431
  }
@@ -117946,6 +118025,7 @@ var ts;
117946
118025
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117947
118026
  redirectTargetsMap: redirectTargetsMap,
117948
118027
  getFileIncludeReasons: program.getFileIncludeReasons,
118028
+ createHash: ts.maybeBind(host, host.createHash),
117949
118029
  };
117950
118030
  }
117951
118031
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120059,13 +120139,9 @@ var ts;
120059
120139
  function createManyToManyPathMap() {
120060
120140
  function create(forward, reverse, deleted) {
120061
120141
  var map = {
120062
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120063
- forEach: function (fn) { return forward.forEach(fn); },
120064
120142
  getKeys: function (v) { return reverse.get(v); },
120065
120143
  getValues: function (k) { return forward.get(k); },
120066
- hasKey: function (k) { return forward.has(k); },
120067
120144
  keys: function () { return forward.keys(); },
120068
- deletedKeys: function () { return deleted; },
120069
120145
  deleteKey: function (k) {
120070
120146
  (deleted || (deleted = new ts.Set())).add(k);
120071
120147
  var set = forward.get(k);
@@ -120092,11 +120168,6 @@ var ts;
120092
120168
  });
120093
120169
  return map;
120094
120170
  },
120095
- clear: function () {
120096
- forward.clear();
120097
- reverse.clear();
120098
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120099
- }
120100
120171
  };
120101
120172
  return map;
120102
120173
  }
@@ -120224,18 +120295,21 @@ var ts;
120224
120295
  * Creates the state of file references and signature for the new program from oldState if it is safe
120225
120296
  */
120226
120297
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120298
+ var _a, _b, _c;
120227
120299
  var fileInfos = new ts.Map();
120228
120300
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120229
120301
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120230
- var hasCalledUpdateShapeSignature = new ts.Set();
120231
120302
  var useOldState = canReuseOldState(referencedMap, oldState);
120232
120303
  // Ensure source files have parent pointers set
120233
120304
  newProgram.getTypeChecker();
120234
120305
  // Create the reference map, and set the file infos
120235
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120236
- var sourceFile = _a[_i];
120306
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120307
+ var sourceFile = _d[_i];
120237
120308
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120238
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120309
+ var oldUncommittedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120310
+ var signature = oldUncommittedSignature === undefined ?
120311
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120312
+ oldUncommittedSignature || undefined;
120239
120313
  if (referencedMap) {
120240
120314
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120241
120315
  if (newReferences) {
@@ -120243,19 +120317,26 @@ var ts;
120243
120317
  }
120244
120318
  // Copy old visible to outside files map
120245
120319
  if (useOldState) {
120246
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120320
+ var oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120321
+ var exportedModules = oldUncommittedExportedModules === undefined ?
120322
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120323
+ oldUncommittedExportedModules || undefined;
120247
120324
  if (exportedModules) {
120248
120325
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120249
120326
  }
120250
120327
  }
120251
120328
  }
120252
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120329
+ fileInfos.set(sourceFile.resolvedPath, {
120330
+ version: version_2,
120331
+ signature: signature,
120332
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120333
+ impliedFormat: sourceFile.impliedNodeFormat
120334
+ });
120253
120335
  }
120254
120336
  return {
120255
120337
  fileInfos: fileInfos,
120256
120338
  referencedMap: referencedMap,
120257
120339
  exportedModulesMap: exportedModulesMap,
120258
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120259
120340
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120260
120341
  };
120261
120342
  }
@@ -120269,71 +120350,42 @@ var ts;
120269
120350
  }
120270
120351
  BuilderState.releaseCache = releaseCache;
120271
120352
  /**
120272
- * Creates a clone of the state
120353
+ * Gets the files affected by the path from the program
120273
120354
  */
120274
- function clone(state) {
120355
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120275
120356
  var _a, _b;
120276
- // Dont need to backup allFiles info since its cache anyway
120277
- return {
120278
- fileInfos: new ts.Map(state.fileInfos),
120279
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120280
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120281
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120282
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120283
- };
120357
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120358
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120359
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120360
+ return result;
120284
120361
  }
120285
- BuilderState.clone = clone;
120286
- /**
120287
- * Gets the files affected by the path from the program
120288
- */
120289
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120290
- // Since the operation could be cancelled, the signatures are always stored in the cache
120291
- // They will be committed once it is safe to use them
120292
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120293
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120294
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120362
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120363
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120295
120364
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120296
120365
  if (!sourceFile) {
120297
120366
  return ts.emptyArray;
120298
120367
  }
120299
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120368
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120300
120369
  return [sourceFile];
120301
120370
  }
120302
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120303
- if (!cacheToUpdateSignature) {
120304
- // Commit all the signatures in the signature cache
120305
- updateSignaturesFromCache(state, signatureCache);
120306
- }
120307
- return result;
120371
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120308
120372
  }
120309
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120310
- /**
120311
- * Updates the signatures from the cache into state's fileinfo signatures
120312
- * This should be called whenever it is safe to commit the state of the builder
120313
- */
120314
- function updateSignaturesFromCache(state, signatureCache) {
120315
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120316
- }
120317
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120373
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120318
120374
  function updateSignatureOfFile(state, signature, path) {
120319
120375
  state.fileInfos.get(path).signature = signature;
120320
- state.hasCalledUpdateShapeSignature.add(path);
120376
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120321
120377
  }
120322
120378
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120323
120379
  /**
120324
120380
  * Returns if the shape of the signature has changed since last emit
120325
120381
  */
120326
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120382
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120383
+ var _a;
120327
120384
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120328
- ts.Debug.assert(!!sourceFile);
120329
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120330
120385
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120331
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120386
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
120332
120387
  return false;
120333
- }
120334
120388
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120335
- if (!info)
120336
- return ts.Debug.fail();
120337
120389
  var prevSignature = info.signature;
120338
120390
  var latestSignature;
120339
120391
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120344,45 +120396,55 @@ var ts;
120344
120396
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120345
120397
  if (firstDts_1) {
120346
120398
  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; })); });
120347
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120348
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120349
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120399
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120400
+ if (latestSignature !== prevSignature) {
120401
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120350
120402
  }
120351
120403
  }
120352
120404
  }
120353
120405
  // Default is to use file version as signature
120354
120406
  if (latestSignature === undefined) {
120355
120407
  latestSignature = sourceFile.version;
120356
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120408
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
120409
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120357
120410
  // All the references in this file are exported
120358
120411
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120359
120412
  if (references) {
120360
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120413
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120361
120414
  }
120362
120415
  else {
120363
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120416
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120364
120417
  }
120365
120418
  }
120366
120419
  }
120367
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120420
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120421
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120422
+ info.signature = latestSignature;
120368
120423
  return latestSignature !== prevSignature;
120369
120424
  }
120370
120425
  BuilderState.updateShapeSignature = updateShapeSignature;
120426
+ function computeSignature(text, computeHash) {
120427
+ return (computeHash || ts.generateDjb2Hash)(text);
120428
+ }
120429
+ BuilderState.computeSignature = computeSignature;
120371
120430
  /**
120372
120431
  * Coverts the declaration emit result into exported modules map
120373
120432
  */
120374
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120433
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120434
+ if (!state.exportedModulesMap)
120435
+ return;
120436
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120375
120437
  if (!exportedModulesFromDeclarationEmit) {
120376
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120438
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120377
120439
  return;
120378
120440
  }
120379
120441
  var exportedModules;
120380
120442
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120381
120443
  if (exportedModules) {
120382
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120444
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120383
120445
  }
120384
120446
  else {
120385
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120447
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120386
120448
  }
120387
120449
  function addExportedModule(exportedModulePaths) {
120388
120450
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120394,19 +120456,6 @@ var ts;
120394
120456
  }
120395
120457
  }
120396
120458
  BuilderState.updateExportedModules = updateExportedModules;
120397
- /**
120398
- * Updates the exported modules from cache into state's exported modules map
120399
- * This should be called whenever it is safe to commit the state of the builder
120400
- */
120401
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120402
- var _a;
120403
- if (exportedModulesMapCache) {
120404
- ts.Debug.assert(!!state.exportedModulesMap);
120405
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120406
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120407
- }
120408
- }
120409
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120410
120459
  /**
120411
120460
  * Get all the dependencies of the sourceFile
120412
120461
  */
@@ -120527,7 +120576,7 @@ var ts;
120527
120576
  /**
120528
120577
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120529
120578
  */
120530
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120579
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120531
120580
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120532
120581
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120533
120582
  }
@@ -120547,7 +120596,7 @@ var ts;
120547
120596
  if (!seenFileNamesMap.has(currentPath)) {
120548
120597
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120549
120598
  seenFileNamesMap.set(currentPath, currentSourceFile);
120550
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120599
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120551
120600
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120552
120601
  }
120553
120602
  }
@@ -120573,32 +120622,33 @@ var ts;
120573
120622
  * Create the state so that we can iterate on changedFiles/affected files
120574
120623
  */
120575
120624
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120625
+ var _a, _b;
120576
120626
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120577
120627
  state.program = newProgram;
120578
120628
  var compilerOptions = newProgram.getCompilerOptions();
120579
120629
  state.compilerOptions = compilerOptions;
120630
+ var outFilePath = ts.outFile(compilerOptions);
120580
120631
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120581
- if (!ts.outFile(compilerOptions)) {
120632
+ if (!outFilePath) {
120582
120633
  state.semanticDiagnosticsPerFile = new ts.Map();
120583
120634
  }
120635
+ 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)) {
120636
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120637
+ }
120584
120638
  state.changedFilesSet = new ts.Set();
120639
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120585
120640
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120586
120641
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120587
120642
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120588
120643
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120644
+ var canCopyEmitSignatures = compilerOptions.composite &&
120645
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120646
+ !outFilePath &&
120647
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120589
120648
  if (useOldState) {
120590
- // Verify the sanity of old state
120591
- if (!oldState.currentChangedFilePath) {
120592
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120593
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120594
- }
120595
- var changedFilesSet = oldState.changedFilesSet;
120596
- if (canCopySemanticDiagnostics) {
120597
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120598
- }
120599
120649
  // Copy old state's changed files set
120600
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120601
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120650
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120651
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
120602
120652
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120603
120653
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120604
120654
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120619,6 +120669,8 @@ var ts;
120619
120669
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120620
120670
  // versions dont match
120621
120671
  oldInfo.version !== info.version ||
120672
+ // Implied formats dont match
120673
+ oldInfo.impliedFormat !== info.impliedFormat ||
120622
120674
  // Referenced files changed
120623
120675
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120624
120676
  // Referenced file was deleted in the new program
@@ -120642,27 +120694,25 @@ var ts;
120642
120694
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120643
120695
  }
120644
120696
  }
120697
+ if (canCopyEmitSignatures) {
120698
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120699
+ if (oldEmitSignature)
120700
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120701
+ }
120645
120702
  });
120646
120703
  // If the global file is removed, add all files as changed
120647
120704
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120648
120705
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120649
120706
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120650
120707
  }
120651
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120708
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120652
120709
  // Add all files to affectedFilesPendingEmit since emit changed
120653
120710
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120654
120711
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120655
120712
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120656
120713
  }
120657
- if (useOldState) {
120658
- // Any time the interpretation of a source file changes, mark it as changed
120659
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120660
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120661
- state.changedFilesSet.add(sourceFilePath);
120662
- }
120663
- });
120664
- }
120665
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120714
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120715
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120666
120716
  return state;
120667
120717
  }
120668
120718
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120698,30 +120748,35 @@ var ts;
120698
120748
  ts.BuilderState.releaseCache(state);
120699
120749
  state.program = undefined;
120700
120750
  }
120701
- /**
120702
- * Creates a clone of the state
120703
- */
120704
- function cloneBuilderProgramState(state) {
120705
- var _a;
120706
- var newState = ts.BuilderState.clone(state);
120707
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120708
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120709
- newState.affectedFiles = state.affectedFiles;
120710
- newState.affectedFilesIndex = state.affectedFilesIndex;
120711
- newState.currentChangedFilePath = state.currentChangedFilePath;
120712
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120713
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120714
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120715
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120716
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120717
- newState.program = state.program;
120718
- newState.compilerOptions = state.compilerOptions;
120719
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120720
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120721
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120722
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120723
- newState.programEmitComplete = state.programEmitComplete;
120724
- return newState;
120751
+ function backupBuilderProgramEmitState(state) {
120752
+ var outFilePath = ts.outFile(state.compilerOptions);
120753
+ // Only in --out changeFileSet is kept around till emit
120754
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120755
+ return {
120756
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120757
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120758
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120759
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120760
+ programEmitComplete: state.programEmitComplete,
120761
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120762
+ outSignature: state.outSignature,
120763
+ dtsChangeTime: state.dtsChangeTime,
120764
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120765
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120766
+ };
120767
+ }
120768
+ function restoreBuilderProgramEmitState(state, savedEmitState) {
120769
+ state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
120770
+ state.affectedFilesPendingEmitKind = savedEmitState.affectedFilesPendingEmitKind;
120771
+ state.affectedFilesPendingEmitIndex = savedEmitState.affectedFilesPendingEmitIndex;
120772
+ state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
120773
+ state.programEmitComplete = savedEmitState.programEmitComplete;
120774
+ state.emitSignatures = savedEmitState.emitSignatures;
120775
+ state.outSignature = savedEmitState.outSignature;
120776
+ state.dtsChangeTime = savedEmitState.dtsChangeTime;
120777
+ state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
120778
+ if (savedEmitState.changedFilesSet)
120779
+ state.changedFilesSet = savedEmitState.changedFilesSet;
120725
120780
  }
120726
120781
  /**
120727
120782
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120736,7 +120791,7 @@ var ts;
120736
120791
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120737
120792
  */
120738
120793
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120739
- var _a;
120794
+ var _a, _b;
120740
120795
  while (true) {
120741
120796
  var affectedFiles = state.affectedFiles;
120742
120797
  if (affectedFiles) {
@@ -120756,10 +120811,8 @@ var ts;
120756
120811
  state.changedFilesSet.delete(state.currentChangedFilePath);
120757
120812
  state.currentChangedFilePath = undefined;
120758
120813
  // Commit the changes in file signature
120759
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120760
- state.currentAffectedFilesSignatures.clear();
120761
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120762
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120814
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120815
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120763
120816
  state.affectedFiles = undefined;
120764
120817
  }
120765
120818
  // Get next changed file
@@ -120777,12 +120830,7 @@ var ts;
120777
120830
  return program;
120778
120831
  }
120779
120832
  // Get next batch of affected files
120780
- if (!state.currentAffectedFilesSignatures)
120781
- state.currentAffectedFilesSignatures = new ts.Map();
120782
- if (state.exportedModulesMap) {
120783
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120784
- }
120785
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120833
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120786
120834
  state.currentChangedFilePath = nextKey.value;
120787
120835
  state.affectedFilesIndex = 0;
120788
120836
  if (!state.seenAffectedFiles)
@@ -120834,7 +120882,6 @@ var ts;
120834
120882
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120835
120883
  */
120836
120884
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120837
- var _a;
120838
120885
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120839
120886
  // If affected files is everything except default library, then nothing more to do
120840
120887
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120842,10 +120889,9 @@ var ts;
120842
120889
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120843
120890
  // That means when affected file is handled, its signature can be out of date
120844
120891
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120845
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120892
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120846
120893
  return;
120847
120894
  }
120848
- 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);
120849
120895
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120850
120896
  return;
120851
120897
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120865,7 +120911,7 @@ var ts;
120865
120911
  // This ensures that we dont later during incremental builds considering wrong signature.
120866
120912
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120867
120913
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120868
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120914
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120869
120915
  // If not dts emit, nothing more to do
120870
120916
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120871
120917
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120886,27 +120932,10 @@ var ts;
120886
120932
  return !state.semanticDiagnosticsFromOldState.size;
120887
120933
  }
120888
120934
  function isChangedSignature(state, path) {
120889
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120890
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120935
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120936
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120891
120937
  return newSignature !== oldSignature;
120892
120938
  }
120893
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120894
- // Go through exported modules from cache first
120895
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120896
- var result = keys && ts.forEachKey(keys, fn);
120897
- if (result)
120898
- return result;
120899
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120900
- keys = state.exportedModulesMap.getKeys(filePath);
120901
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120902
- var _a;
120903
- // If the cache had an updated value, skip
120904
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120905
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120906
- fn(exportedFromPath) :
120907
- undefined;
120908
- });
120909
- }
120910
120939
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120911
120940
  var _a;
120912
120941
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120921,6 +120950,7 @@ var ts;
120921
120950
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120922
120951
  */
120923
120952
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120953
+ var _a;
120924
120954
  // If there was change in signature (dts output) for the changed file,
120925
120955
  // then only we need to handle pending file emit
120926
120956
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120947,11 +120977,10 @@ var ts;
120947
120977
  }
120948
120978
  }
120949
120979
  }
120950
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120951
120980
  var seenFileAndExportsOfFile = new ts.Set();
120952
120981
  // Go through exported modules from cache first
120953
120982
  // If exported modules has path, all files referencing file exported from are affected
120954
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120983
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120955
120984
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120956
120985
  return true;
120957
120986
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120965,19 +120994,18 @@ var ts;
120965
120994
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120966
120995
  */
120967
120996
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120968
- var _a;
120997
+ var _a, _b;
120969
120998
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120970
120999
  return undefined;
120971
121000
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120972
121001
  return true;
120973
121002
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120974
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120975
121003
  // If exported modules has path, all files referencing file exported from are affected
120976
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121004
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120977
121005
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120978
121006
  });
120979
121007
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120980
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
121008
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120981
121009
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120982
121010
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120983
121011
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120998,12 +121026,13 @@ var ts;
120998
121026
  }
120999
121027
  else {
121000
121028
  state.seenAffectedFiles.add(affected.resolvedPath);
121029
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121030
+ state.buildInfoEmitPending = true;
121001
121031
  if (emitKind !== undefined) {
121002
121032
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
121003
121033
  }
121004
121034
  if (isPendingEmit) {
121005
121035
  state.affectedFilesPendingEmitIndex++;
121006
- state.buildInfoEmitPending = true;
121007
121036
  }
121008
121037
  else {
121009
121038
  state.affectedFilesIndex++;
@@ -121051,25 +121080,62 @@ var ts;
121051
121080
  }
121052
121081
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121053
121082
  }
121083
+ function isProgramBundleEmitBuildInfo(info) {
121084
+ return !!ts.outFile(info.options || {});
121085
+ }
121086
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121054
121087
  /**
121055
121088
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121056
121089
  */
121057
- function getProgramBuildInfo(state, getCanonicalFileName) {
121058
- if (ts.outFile(state.compilerOptions))
121059
- return undefined;
121090
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121091
+ var outFilePath = ts.outFile(state.compilerOptions);
121092
+ if (outFilePath && !state.compilerOptions.composite)
121093
+ return;
121060
121094
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121061
121095
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121096
+ // Update the dtsChange time in buildInfo
121097
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121098
+ if (outFilePath) {
121099
+ var fileNames_1 = [];
121100
+ var fileInfos_1 = [];
121101
+ state.program.getRootFileNames().forEach(function (f) {
121102
+ var sourceFile = state.program.getSourceFile(f);
121103
+ if (!sourceFile)
121104
+ return;
121105
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121106
+ fileInfos_1.push(sourceFile.version);
121107
+ });
121108
+ var result_15 = {
121109
+ fileNames: fileNames_1,
121110
+ fileInfos: fileInfos_1,
121111
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121112
+ outSignature: state.outSignature,
121113
+ dtsChangeTime: state.dtsChangeTime,
121114
+ };
121115
+ return result_15;
121116
+ }
121062
121117
  var fileNames = [];
121063
121118
  var fileNameToFileId = new ts.Map();
121064
121119
  var fileIdsList;
121065
121120
  var fileNamesToFileIdListId;
121121
+ var emitSignatures;
121066
121122
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121123
+ var _b, _c;
121067
121124
  var key = _a[0], value = _a[1];
121068
121125
  // Ensure fileId
121069
121126
  var fileId = toFileId(key);
121070
121127
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121071
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121072
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
121128
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
121129
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
121130
+ if (state.compilerOptions.composite) {
121131
+ var file = state.program.getSourceFileByPath(key);
121132
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
121133
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
121134
+ if (emitSignature !== actualSignature) {
121135
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
121136
+ }
121137
+ }
121138
+ }
121073
121139
  return value.version === actualSignature ?
121074
121140
  value.affectsGlobalScope || value.impliedFormat ?
121075
121141
  // If file version is same as signature, dont serialize signature
@@ -121077,11 +121143,11 @@ var ts;
121077
121143
  // If file info only contains version and signature and both are same we can just write string
121078
121144
  value.version :
121079
121145
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121080
- signature === undefined ?
121146
+ oldSignature === undefined ?
121081
121147
  // If we havent computed signature, use fileInfo as is
121082
121148
  value :
121083
121149
  // Serialize fileInfo with new updated signature
121084
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121150
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121085
121151
  // Signature of the FileInfo is undefined, serialize it as false
121086
121152
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121087
121153
  });
@@ -121096,17 +121162,13 @@ var ts;
121096
121162
  if (state.exportedModulesMap) {
121097
121163
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121098
121164
  var _a;
121099
- if (state.currentAffectedFilesExportedModulesMap) {
121100
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121101
- return undefined;
121102
- }
121103
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121104
- if (newValue) {
121105
- return [toFileId(key), toFileIdListId(newValue)];
121106
- }
121107
- }
121165
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121108
121166
  // Not in temporary cache, use existing value
121109
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121167
+ if (oldValue === undefined)
121168
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121169
+ if (oldValue)
121170
+ return [toFileId(key), toFileIdListId(oldValue)];
121171
+ return undefined;
121110
121172
  });
121111
121173
  }
121112
121174
  var semanticDiagnosticsPerFile;
@@ -121117,9 +121179,7 @@ var ts;
121117
121179
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121118
121180
  [
121119
121181
  toFileId(key),
121120
- state.hasReusableDiagnostic ?
121121
- value :
121122
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121182
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121123
121183
  ] :
121124
121184
  toFileId(key));
121125
121185
  }
@@ -121134,16 +121194,27 @@ var ts;
121134
121194
  }
121135
121195
  }
121136
121196
  }
121137
- return {
121197
+ var changeFileSet;
121198
+ if (state.changedFilesSet.size) {
121199
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
121200
+ var path = _e[_d];
121201
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
121202
+ }
121203
+ }
121204
+ var result = {
121138
121205
  fileNames: fileNames,
121139
121206
  fileInfos: fileInfos,
121140
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121207
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121141
121208
  fileIdsList: fileIdsList,
121142
121209
  referencedMap: referencedMap,
121143
121210
  exportedModulesMap: exportedModulesMap,
121144
121211
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121145
121212
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121213
+ changeFileSet: changeFileSet,
121214
+ emitSignatures: emitSignatures,
121215
+ dtsChangeTime: state.dtsChangeTime,
121146
121216
  };
121217
+ return result;
121147
121218
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121148
121219
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121149
121220
  }
@@ -121168,24 +121239,21 @@ var ts;
121168
121239
  }
121169
121240
  return fileIdListId;
121170
121241
  }
121171
- }
121172
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121173
- var result;
121174
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121175
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121176
- var name = _a[_i];
121177
- var optionKey = name.toLowerCase();
121178
- var optionInfo = optionsNameMap.get(optionKey);
121179
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121180
- // We need to store `strict`, even though it won't be examined directly, so that the
121181
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121182
- optionKey === "strict" ||
121183
- // We need to store these to determine whether `lib` files need to be rechecked.
121184
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121185
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
121242
+ /**
121243
+ * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
121244
+ */
121245
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
121246
+ var result;
121247
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121248
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121249
+ var name = _a[_i];
121250
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
121251
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
121252
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
121253
+ }
121186
121254
  }
121255
+ return result;
121187
121256
  }
121188
- return result;
121189
121257
  }
121190
121258
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121191
121259
  if (option) {
@@ -121259,6 +121327,10 @@ var ts;
121259
121327
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121260
121328
  }
121261
121329
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121330
+ function computeSignature(text, data, computeHash) {
121331
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121332
+ }
121333
+ ts.computeSignature = computeSignature;
121262
121334
  function createBuilderProgram(kind, _a) {
121263
121335
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121264
121336
  // Return same program if underlying program doesnt change
@@ -121277,8 +121349,7 @@ var ts;
121277
121349
  */
121278
121350
  var computeHash = ts.maybeBind(host, host.createHash);
121279
121351
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121280
- var backupState;
121281
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121352
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121282
121353
  // To ensure that we arent storing any references to old program or new program without state
121283
121354
  newProgram = undefined; // TODO: GH#18217
121284
121355
  oldProgram = undefined;
@@ -121286,21 +121357,12 @@ var ts;
121286
121357
  var getState = function () { return state; };
121287
121358
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121288
121359
  builderProgram.getState = getState;
121289
- builderProgram.backupState = function () {
121290
- ts.Debug.assert(backupState === undefined);
121291
- backupState = cloneBuilderProgramState(state);
121292
- };
121293
- builderProgram.restoreState = function () {
121294
- state = ts.Debug.checkDefined(backupState);
121295
- backupState = undefined;
121296
- };
121360
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121361
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121297
121362
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121298
121363
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121299
121364
  builderProgram.emit = emit;
121300
- builderProgram.releaseProgram = function () {
121301
- releaseCache(state);
121302
- backupState = undefined;
121303
- };
121365
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121304
121366
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121305
121367
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121306
121368
  }
@@ -121358,35 +121420,62 @@ var ts;
121358
121420
  return toAffectedFileEmitResult(state,
121359
121421
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121360
121422
  // Otherwise just affected file
121361
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121362
- getWriteFileUpdatingSignatureCallback(writeFile) :
121423
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121424
+ getWriteFileCallback(writeFile, customTransformers) :
121363
121425
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121364
121426
  }
121365
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121427
+ function getWriteFileCallback(writeFile, customTransformers) {
121366
121428
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121367
- var _a;
121429
+ var _a, _b, _c;
121368
121430
  if (ts.isDeclarationFileName(fileName)) {
121369
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121370
- var file = sourceFiles[0];
121371
- var info = state.fileInfos.get(file.resolvedPath);
121372
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121373
- if (signature === file.version) {
121374
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121375
- if (newSignature !== file.version) { // Update it
121376
- if (host.storeFilesChangingSignatureDuringEmit)
121377
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121378
- if (state.exportedModulesMap)
121379
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121380
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121381
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121431
+ if (!ts.outFile(state.compilerOptions)) {
121432
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121433
+ var newSignature = void 0;
121434
+ if (!customTransformers) {
121435
+ var file = sourceFiles[0];
121436
+ var info = state.fileInfos.get(file.resolvedPath);
121437
+ if (info.signature === file.version) {
121438
+ newSignature = computeSignature(text, data, computeHash);
121439
+ if (newSignature !== file.version) { // Update it
121440
+ if (host.storeFilesChangingSignatureDuringEmit)
121441
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121442
+ if (state.exportedModulesMap)
121443
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121444
+ if (state.affectedFiles) {
121445
+ // Keep old signature so we know what to undo if cancellation happens
121446
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121447
+ if (existing === undefined)
121448
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121449
+ info.signature = newSignature;
121450
+ }
121451
+ else {
121452
+ // These are directly commited
121453
+ info.signature = newSignature;
121454
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121455
+ }
121456
+ }
121382
121457
  }
121383
- else {
121384
- info.signature = newSignature;
121385
- if (state.exportedModulesMap)
121386
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121458
+ }
121459
+ // Store d.ts emit hash so later can be compared to check if d.ts has changed.
121460
+ // Currently we do this only for composite projects since these are the only projects that can be referenced by other projects
121461
+ // and would need their d.ts change time in --build mode
121462
+ if (state.compilerOptions.composite) {
121463
+ var filePath = sourceFiles[0].resolvedPath;
121464
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121465
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
121466
+ if (newSignature !== oldSignature) {
121467
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121468
+ state.hasChangedEmitSignature = true;
121387
121469
  }
121388
121470
  }
121389
121471
  }
121472
+ else if (state.compilerOptions.composite) {
121473
+ var newSignature = computeSignature(text, data, computeHash);
121474
+ if (newSignature !== state.outSignature) {
121475
+ state.outSignature = newSignature;
121476
+ state.hasChangedEmitSignature = true;
121477
+ }
121478
+ }
121390
121479
  }
121391
121480
  if (writeFile)
121392
121481
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121451,8 +121540,8 @@ var ts;
121451
121540
  }
121452
121541
  }
121453
121542
  }
121454
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121455
- getWriteFileUpdatingSignatureCallback(writeFile) :
121543
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121544
+ getWriteFileCallback(writeFile, customTransformers) :
121456
121545
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121457
121546
  }
121458
121547
  /**
@@ -121541,29 +121630,58 @@ var ts;
121541
121630
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121542
121631
  }
121543
121632
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121544
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121545
- var _a;
121633
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121634
+ var _a, _b, _c, _d;
121546
121635
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121547
121636
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121548
- var filePaths = program.fileNames.map(toPath);
121549
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121550
- var fileInfos = new ts.Map();
121551
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121552
- var state = {
121553
- fileInfos: fileInfos,
121554
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121555
- referencedMap: toManyToManyPathMap(program.referencedMap),
121556
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121557
- 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]; }),
121558
- hasReusableDiagnostic: true,
121559
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121560
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121561
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121562
- };
121637
+ var state;
121638
+ var filePaths;
121639
+ var filePathsSetList;
121640
+ if (isProgramBundleEmitBuildInfo(program)) {
121641
+ state = {
121642
+ fileInfos: new ts.Map(),
121643
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121644
+ dtsChangeTime: program.dtsChangeTime,
121645
+ outSignature: program.outSignature,
121646
+ };
121647
+ }
121648
+ else {
121649
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121650
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121651
+ var fileInfos_2 = new ts.Map();
121652
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121653
+ program.fileInfos.forEach(function (fileInfo, index) {
121654
+ var path = toFilePath(index + 1);
121655
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121656
+ fileInfos_2.set(path, stateFileInfo);
121657
+ if (emitSignatures_1 && stateFileInfo.signature)
121658
+ emitSignatures_1.set(path, stateFileInfo.signature);
121659
+ });
121660
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121661
+ if (ts.isNumber(value))
121662
+ emitSignatures_1.delete(toFilePath(value));
121663
+ else
121664
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121665
+ });
121666
+ state = {
121667
+ fileInfos: fileInfos_2,
121668
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121669
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121670
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121671
+ 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]; }),
121672
+ hasReusableDiagnostic: true,
121673
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121674
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121675
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121676
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121677
+ dtsChangeTime: program.dtsChangeTime,
121678
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121679
+ };
121680
+ }
121563
121681
  return {
121564
121682
  getState: function () { return state; },
121565
- backupState: ts.noop,
121566
- restoreState: ts.noop,
121683
+ saveEmitState: ts.noop,
121684
+ restoreEmitState: ts.noop,
121567
121685
  getProgram: ts.notImplemented,
121568
121686
  getProgramOrUndefined: ts.returnUndefined,
121569
121687
  releaseProgram: ts.noop,
@@ -121608,12 +121726,24 @@ var ts;
121608
121726
  return map;
121609
121727
  }
121610
121728
  }
121611
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121729
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121730
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121731
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121732
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121733
+ var fileInfos = new ts.Map();
121734
+ program.fileInfos.forEach(function (fileInfo, index) {
121735
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121736
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121737
+ fileInfos.set(path, version);
121738
+ });
121739
+ return fileInfos;
121740
+ }
121741
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121612
121742
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121613
121743
  return {
121614
121744
  getState: ts.notImplemented,
121615
- backupState: ts.noop,
121616
- restoreState: ts.noop,
121745
+ saveEmitState: ts.noop,
121746
+ restoreEmitState: ts.noop,
121617
121747
  getProgram: getProgram,
121618
121748
  getProgramOrUndefined: function () { return getState().program; },
121619
121749
  releaseProgram: function () { return getState().program = undefined; },
@@ -121717,8 +121847,10 @@ var ts;
121717
121847
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121718
121848
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121719
121849
  var resolutionsWithFailedLookups = [];
121850
+ var resolutionsWithOnlyAffectingLocations = [];
121720
121851
  var resolvedFileToResolution = ts.createMultiMap();
121721
121852
  var hasChangedAutomaticTypeDirectiveNames = false;
121853
+ var affectingPathChecks;
121722
121854
  var failedLookupChecks;
121723
121855
  var startsWithPathChecks;
121724
121856
  var isInDirectoryChecks;
@@ -121745,6 +121877,7 @@ var ts;
121745
121877
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121746
121878
  var customFailedLookupPaths = new ts.Map();
121747
121879
  var directoryWatchesOfFailedLookups = new ts.Map();
121880
+ var fileWatchesOfAffectingLocations = new ts.Map();
121748
121881
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121749
121882
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121750
121883
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121787,6 +121920,7 @@ var ts;
121787
121920
  }
121788
121921
  function clear() {
121789
121922
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
121923
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121790
121924
  customFailedLookupPaths.clear();
121791
121925
  nonRelativeExternalModuleResolutions.clear();
121792
121926
  closeTypeRootsWatch();
@@ -121794,9 +121928,11 @@ var ts;
121794
121928
  resolvedTypeReferenceDirectives.clear();
121795
121929
  resolvedFileToResolution.clear();
121796
121930
  resolutionsWithFailedLookups.length = 0;
121931
+ resolutionsWithOnlyAffectingLocations.length = 0;
121797
121932
  failedLookupChecks = undefined;
121798
121933
  startsWithPathChecks = undefined;
121799
121934
  isInDirectoryChecks = undefined;
121935
+ affectingPathChecks = undefined;
121800
121936
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
121801
121937
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
121802
121938
  clearPerDirectoryResolutions();
@@ -121846,10 +121982,18 @@ var ts;
121846
121982
  watcher.watcher.close();
121847
121983
  }
121848
121984
  });
121985
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
121986
+ if (watcher.refCount === 0) {
121987
+ fileWatchesOfAffectingLocations.delete(path);
121988
+ watcher.watcher.close();
121989
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
121990
+ watcher.watcher = ts.noopFileWatcher;
121991
+ }
121992
+ });
121849
121993
  hasChangedAutomaticTypeDirectiveNames = false;
121850
121994
  }
121851
121995
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
121852
- var _a;
121996
+ var _a, _b;
121853
121997
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
121854
121998
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
121855
121999
  if (!resolutionHost.getGlobalCache) {
@@ -121860,11 +122004,12 @@ var ts;
121860
122004
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
121861
122005
  // create different collection of failed lookup locations for second pass
121862
122006
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
121863
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
122007
+ var _c = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _c.resolvedModule, failedLookupLocations = _c.failedLookupLocations, affectingLocations = _c.affectingLocations;
121864
122008
  if (resolvedModule) {
121865
122009
  // Modify existing resolution so its saved in the directory cache as well
121866
122010
  primaryResult.resolvedModule = resolvedModule;
121867
122011
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122012
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
121868
122013
  return primaryResult;
121869
122014
  }
121870
122015
  }
@@ -122115,10 +122260,11 @@ var ts;
122115
122260
  }
122116
122261
  function watchFailedLookupLocationOfResolution(resolution) {
122117
122262
  ts.Debug.assert(!!resolution.refCount);
122118
- var failedLookupLocations = resolution.failedLookupLocations;
122119
- if (!failedLookupLocations.length)
122263
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122264
+ if (!failedLookupLocations.length && !affectingLocations.length)
122120
122265
  return;
122121
- resolutionsWithFailedLookups.push(resolution);
122266
+ if (failedLookupLocations.length)
122267
+ resolutionsWithFailedLookups.push(resolution);
122122
122268
  var setAtRoot = false;
122123
122269
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122124
122270
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122145,12 +122291,66 @@ var ts;
122145
122291
  // This is always non recursive
122146
122292
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122147
122293
  }
122294
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
122295
+ }
122296
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
122297
+ ts.Debug.assert(!!resolution.refCount);
122298
+ if (addToResolutionsWithOnlyAffectingLocations)
122299
+ resolutionsWithOnlyAffectingLocations.push(resolution);
122300
+ var affectingLocations = resolution.affectingLocations;
122301
+ // Watch package json
122302
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122303
+ var affectingLocation = affectingLocations_1[_i];
122304
+ createFileWatcherOfAffectingLocation(affectingLocation);
122305
+ }
122306
+ }
122307
+ function createFileWatcherOfAffectingLocation(affectingLocation) {
122308
+ var path = resolutionHost.toPath(affectingLocation);
122309
+ var fileWatcher = fileWatchesOfAffectingLocations.get(path);
122310
+ if (fileWatcher) {
122311
+ fileWatcher.refCount++;
122312
+ return;
122313
+ }
122314
+ var locationToWatch = affectingLocation;
122315
+ var locationToWatchPath = path;
122316
+ if (resolutionHost.realpath) {
122317
+ locationToWatch = resolutionHost.realpath(affectingLocation);
122318
+ locationToWatchPath = resolutionHost.toPath(locationToWatch);
122319
+ if (path !== locationToWatchPath) {
122320
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
122321
+ if (fileWatcher_1) {
122322
+ fileWatcher_1.refCount++;
122323
+ fileWatcher_1.paths.add(path);
122324
+ fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
122325
+ return;
122326
+ }
122327
+ }
122328
+ }
122329
+ var paths = new ts.Set();
122330
+ paths.add(locationToWatchPath);
122331
+ var watcher = {
122332
+ watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
122333
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
122334
+ paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
122335
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122336
+ }),
122337
+ refCount: 1,
122338
+ paths: paths,
122339
+ };
122340
+ fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
122341
+ if (path !== locationToWatchPath) {
122342
+ fileWatchesOfAffectingLocations.set(path, watcher);
122343
+ paths.add(path);
122344
+ }
122148
122345
  }
122149
122346
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122150
122347
  var program = resolutionHost.getCurrentProgram();
122151
122348
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122152
122349
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122153
122350
  }
122351
+ else {
122352
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122353
+ }
122154
122354
  }
122155
122355
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122156
122356
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122172,38 +122372,44 @@ var ts;
122172
122372
  if (resolved && resolved.resolvedFileName) {
122173
122373
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122174
122374
  }
122175
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122176
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122177
- return;
122178
- }
122179
- var failedLookupLocations = resolution.failedLookupLocations;
122180
- var removeAtRoot = false;
122181
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122182
- var failedLookupLocation = failedLookupLocations_2[_i];
122183
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122184
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122185
- if (toWatch) {
122186
- var dirPath = toWatch.dirPath;
122187
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122188
- if (refCount) {
122189
- if (refCount === 1) {
122190
- customFailedLookupPaths.delete(failedLookupLocationPath);
122375
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122376
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122377
+ var removeAtRoot = false;
122378
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122379
+ var failedLookupLocation = failedLookupLocations_2[_i];
122380
+ var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122381
+ var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122382
+ if (toWatch) {
122383
+ var dirPath = toWatch.dirPath;
122384
+ var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122385
+ if (refCount) {
122386
+ if (refCount === 1) {
122387
+ customFailedLookupPaths.delete(failedLookupLocationPath);
122388
+ }
122389
+ else {
122390
+ ts.Debug.assert(refCount > 1);
122391
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122392
+ }
122393
+ }
122394
+ if (dirPath === rootPath) {
122395
+ removeAtRoot = true;
122191
122396
  }
122192
122397
  else {
122193
- ts.Debug.assert(refCount > 1);
122194
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122398
+ removeDirectoryWatcher(dirPath);
122195
122399
  }
122196
122400
  }
122197
- if (dirPath === rootPath) {
122198
- removeAtRoot = true;
122199
- }
122200
- else {
122201
- removeDirectoryWatcher(dirPath);
122202
- }
122203
122401
  }
122402
+ if (removeAtRoot) {
122403
+ removeDirectoryWatcher(rootPath);
122404
+ }
122405
+ }
122406
+ else if (affectingLocations.length) {
122407
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
122204
122408
  }
122205
- if (removeAtRoot) {
122206
- removeDirectoryWatcher(rootPath);
122409
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
122410
+ var affectingLocation = affectingLocations_2[_a];
122411
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
122412
+ watcher.refCount--;
122207
122413
  }
122208
122414
  }
122209
122415
  function removeDirectoryWatcher(dirPath) {
@@ -122282,7 +122488,7 @@ var ts;
122282
122488
  if (isCreatingWatchedDirectory) {
122283
122489
  // Watching directory is created
122284
122490
  // Invalidate any resolution has failed lookup in this directory
122285
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122491
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122286
122492
  }
122287
122493
  else {
122288
122494
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122300,7 +122506,7 @@ var ts;
122300
122506
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122301
122507
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122302
122508
  // Invalidate any resolution from this directory
122303
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122509
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122304
122510
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122305
122511
  }
122306
122512
  else {
@@ -122312,7 +122518,7 @@ var ts;
122312
122518
  return false;
122313
122519
  }
122314
122520
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122315
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122521
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122316
122522
  // If the invalidated file is from a node_modules package, invalidate everything else
122317
122523
  // in the package since we might not get notifications for other files in the package.
122318
122524
  // This hardens our logic against unreliable file watchers.
@@ -122324,21 +122530,32 @@ var ts;
122324
122530
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122325
122531
  }
122326
122532
  function invalidateResolutionsOfFailedLookupLocations() {
122327
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122533
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122328
122534
  return false;
122329
122535
  }
122330
122536
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122331
122537
  failedLookupChecks = undefined;
122332
122538
  startsWithPathChecks = undefined;
122333
122539
  isInDirectoryChecks = undefined;
122540
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122541
+ affectingPathChecks = undefined;
122334
122542
  return invalidated;
122335
122543
  }
122336
122544
  function canInvalidateFailedLookupResolution(resolution) {
122545
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122546
+ return true;
122547
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122548
+ return false;
122337
122549
  return resolution.failedLookupLocations.some(function (location) {
122338
122550
  var locationPath = resolutionHost.toPath(location);
122339
- return ts.contains(failedLookupChecks, locationPath) ||
122551
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122340
122552
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122341
- (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }));
122553
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
122554
+ });
122555
+ }
122556
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
122557
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
122558
+ return affectingPathChecks.has(resolutionHost.toPath(location));
122342
122559
  });
122343
122560
  }
122344
122561
  function closeTypeRootsWatch() {
@@ -122729,9 +122946,9 @@ var ts;
122729
122946
  if (!preferSymlinks) {
122730
122947
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122731
122948
  // so we only need to remove them from the realpath filenames.
122732
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122733
- if (result_15)
122734
- return result_15;
122949
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122950
+ if (result_16)
122951
+ return result_16;
122735
122952
  }
122736
122953
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122737
122954
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122751,10 +122968,10 @@ var ts;
122751
122968
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122752
122969
  var symlinkDirectory = symlinkDirectories_1[_i];
122753
122970
  var option = ts.resolvePath(symlinkDirectory, relative);
122754
- var result_16 = cb(option, target === referenceRedirect);
122971
+ var result_17 = cb(option, target === referenceRedirect);
122755
122972
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122756
- if (result_16)
122757
- return result_16;
122973
+ if (result_17)
122974
+ return result_17;
122758
122975
  }
122759
122976
  });
122760
122977
  });
@@ -123664,6 +123881,7 @@ var ts;
123664
123881
  readDirectory: ts.maybeBind(host, host.readDirectory),
123665
123882
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123666
123883
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123884
+ now: ts.maybeBind(host, host.now),
123667
123885
  };
123668
123886
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123669
123887
  try {
@@ -123724,6 +123942,7 @@ var ts;
123724
123942
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123725
123943
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123726
123944
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123945
+ now: ts.maybeBind(system, system.now),
123727
123946
  };
123728
123947
  }
123729
123948
  ts.createProgramHost = createProgramHost;
@@ -123791,20 +124010,27 @@ var ts;
123791
124010
  var ts;
123792
124011
  (function (ts) {
123793
124012
  function readBuilderProgram(compilerOptions, host) {
123794
- if (ts.outFile(compilerOptions))
123795
- return undefined;
123796
124013
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123797
124014
  if (!buildInfoPath)
123798
124015
  return undefined;
123799
- var content = host.readFile(buildInfoPath);
123800
- if (!content)
123801
- return undefined;
123802
- var buildInfo = ts.getBuildInfo(content);
124016
+ var buildInfo;
124017
+ if (host.getBuildInfo) {
124018
+ // host provides buildinfo, get it from there. This allows host to cache it
124019
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
124020
+ if (!buildInfo)
124021
+ return undefined;
124022
+ }
124023
+ else {
124024
+ var content = host.readFile(buildInfoPath);
124025
+ if (!content)
124026
+ return undefined;
124027
+ buildInfo = ts.getBuildInfo(content);
124028
+ }
123803
124029
  if (buildInfo.version !== ts.version)
123804
124030
  return undefined;
123805
124031
  if (!buildInfo.program)
123806
124032
  return undefined;
123807
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124033
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123808
124034
  }
123809
124035
  ts.readBuilderProgram = readBuilderProgram;
123810
124036
  function createIncrementalCompilerHost(options, system) {
@@ -123813,6 +124039,7 @@ var ts;
123813
124039
  host.createHash = ts.maybeBind(system, system.createHash);
123814
124040
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123815
124041
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124042
+ host.now = ts.maybeBind(system, system.now);
123816
124043
  ts.setGetSourceFileAsHashVersioned(host, system);
123817
124044
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123818
124045
  return host;
@@ -123857,7 +124084,6 @@ var ts;
123857
124084
  var builderProgram;
123858
124085
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
123859
124086
  var missingFilesMap; // Map of file watchers for the missing files
123860
- var packageJsonMap; // map of watchers for package json files used in module resolution
123861
124087
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
123862
124088
  var timerToUpdateProgram; // timer callback to recompile the program
123863
124089
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -123921,6 +124147,7 @@ var ts;
123921
124147
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
123922
124148
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
123923
124149
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124150
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
123924
124151
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
123925
124152
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
123926
124153
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -124003,10 +124230,6 @@ var ts;
124003
124230
  });
124004
124231
  parsedConfigs = undefined;
124005
124232
  }
124006
- if (packageJsonMap) {
124007
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
124008
- packageJsonMap = undefined;
124009
- }
124010
124233
  }
124011
124234
  function getCurrentBuilderProgram() {
124012
124235
  return builderProgram;
@@ -124062,15 +124285,9 @@ var ts;
124062
124285
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124063
124286
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124064
124287
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124065
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124066
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124067
- var path = _a[0], data = _a[1];
124068
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124069
- });
124070
124288
  resolutionCache.finishCachingPerDirectoryResolution();
124071
124289
  // Update watches
124072
124290
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124073
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124074
124291
  if (needsUpdateInTypeRootWatch) {
124075
124292
  resolutionCache.updateTypeRootsWatch();
124076
124293
  }
@@ -124376,21 +124593,6 @@ var ts;
124376
124593
  ts.noopFileWatcher :
124377
124594
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124378
124595
  }
124379
- function watchPackageJsonLookupPath(packageJsonPath) {
124380
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124381
- return sourceFilesCache.has(packageJsonPath) ?
124382
- ts.noopFileWatcher :
124383
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124384
- }
124385
- function onPackageJsonChange(fileName, eventKind, path) {
124386
- updateCachedSystemWithFile(fileName, path, eventKind);
124387
- // package.json changes invalidate module resolution and can change the set of loaded files
124388
- // so if we witness a change to one, we have to do a full reload
124389
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124390
- changesAffectResolution = true;
124391
- // Update the program
124392
- scheduleProgramUpdate();
124393
- }
124394
124596
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124395
124597
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124396
124598
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124548,14 +124750,17 @@ var ts;
124548
124750
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124549
124751
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124550
124752
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124551
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124552
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124553
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124554
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124753
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124754
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124755
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124756
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124757
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124758
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124555
124759
  /**
124556
124760
  * Projects with no outputs (i.e. "solution" files)
124557
124761
  */
124558
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124762
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124763
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124559
124764
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124560
124765
  function resolveConfigFileProjectName(project) {
124561
124766
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124600,9 +124805,12 @@ var ts;
124600
124805
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124601
124806
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124602
124807
  }
124603
- function newer(date1, date2) {
124604
- return date2 > date1 ? date2 : date1;
124808
+ /*@internal*/
124809
+ /** Helper to use now method instead of current date for testing purposes to get consistent baselines */
124810
+ function getCurrentTime(host) {
124811
+ return host.now ? host.now() : new Date();
124605
124812
  }
124813
+ ts.getCurrentTime = getCurrentTime;
124606
124814
  /*@internal*/
124607
124815
  function isCircularBuildOrder(buildOrder) {
124608
124816
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124692,6 +124900,7 @@ var ts;
124692
124900
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124693
124901
  };
124694
124902
  }
124903
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124695
124904
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124696
124905
  var state = {
124697
124906
  host: host,
@@ -124708,8 +124917,9 @@ var ts;
124708
124917
  resolvedConfigFilePaths: new ts.Map(),
124709
124918
  configFileCache: new ts.Map(),
124710
124919
  projectStatus: new ts.Map(),
124711
- buildInfoChecked: new ts.Map(),
124712
124920
  extendedConfigCache: new ts.Map(),
124921
+ buildInfoCache: new ts.Map(),
124922
+ outputTimeStamps: new ts.Map(),
124713
124923
  builderPrograms: new ts.Map(),
124714
124924
  diagnostics: new ts.Map(),
124715
124925
  projectPendingBuild: new ts.Map(),
@@ -124732,6 +124942,7 @@ var ts;
124732
124942
  allWatchedConfigFiles: new ts.Map(),
124733
124943
  allWatchedExtendedConfigFiles: new ts.Map(),
124734
124944
  allWatchedPackageJsonFiles: new ts.Map(),
124945
+ filesWatched: new ts.Map(),
124735
124946
  lastCachedPackageJsonLookups: new ts.Map(),
124736
124947
  timerToBuildInvalidatedProject: undefined,
124737
124948
  reportFileChangeDetected: false,
@@ -124838,11 +125049,12 @@ var ts;
124838
125049
  // Config file cache
124839
125050
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124840
125051
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124841
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124842
125052
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124843
125053
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124844
125054
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124845
125055
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125056
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125057
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124846
125058
  // Remove watches for the program no longer in the solution
124847
125059
  if (state.watch) {
124848
125060
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125132,21 +125344,21 @@ var ts;
125132
125344
  }
125133
125345
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125134
125346
  var _a;
125135
- var _b, _c;
125347
+ var _b, _c, _d;
125136
125348
  ts.Debug.assertIsDefined(program);
125137
125349
  ts.Debug.assert(step === BuildStep.Emit);
125138
125350
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125139
- program.backupState();
125351
+ var saved = program.saveEmitState();
125140
125352
  var declDiagnostics;
125141
125353
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125142
125354
  var outputFiles = [];
125143
125355
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125144
125356
  /*write*/ undefined,
125145
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
125357
+ /*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,
125146
125358
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125147
125359
  // Don't emit .d.ts if there are decl file errors
125148
125360
  if (declDiagnostics) {
125149
- program.restoreState();
125361
+ program.restoreEmitState(saved);
125150
125362
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125151
125363
  return {
125152
125364
  emitSkipped: true,
@@ -125156,37 +125368,44 @@ var ts;
125156
125368
  // Actual Emit
125157
125369
  var host = state.host, compilerHost = state.compilerHost;
125158
125370
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125159
- var newestDeclarationFileContentChangedTime = minimumDate;
125160
- var anyDtsChanged = false;
125371
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125161
125372
  var emitterDiagnostics = ts.createDiagnosticCollection();
125162
125373
  var emittedOutputs = new ts.Map();
125374
+ var options = program.getCompilerOptions();
125375
+ var isIncremental = ts.isIncrementalCompilation(options);
125376
+ var outputTimeStampMap;
125377
+ var now;
125163
125378
  outputFiles.forEach(function (_a) {
125164
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125165
- var priorChangeTime;
125166
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125167
- // Check for unchanged .d.ts files
125168
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125169
- priorChangeTime = host.getModifiedTime(name);
125170
- }
125171
- else {
125379
+ var _b, _c;
125380
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125381
+ var path = toPath(state, name);
125382
+ emittedOutputs.set(toPath(state, name), name);
125383
+ if (buildInfo) {
125384
+ setBuildInfo(state, buildInfo, projectPath, options);
125385
+ // Buildinfo has information on when last dts change time
125386
+ 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)) {
125172
125387
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125173
- anyDtsChanged = true;
125174
125388
  }
125175
125389
  }
125176
- emittedOutputs.set(toPath(state, name), name);
125177
125390
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125178
- if (priorChangeTime !== undefined) {
125179
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125391
+ if (!isIncremental && state.watch) {
125392
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125180
125393
  }
125181
125394
  });
125182
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125183
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125395
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125184
125396
  return emitResult;
125185
125397
  }
125186
125398
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125187
125399
  ts.Debug.assertIsDefined(program);
125188
125400
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125189
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125401
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125402
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
125403
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125404
+ if (writeFileCallback)
125405
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125406
+ else
125407
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125408
+ }, cancellationToken);
125190
125409
  if (emitResult.diagnostics.length) {
125191
125410
  reportErrors(state, emitResult.diagnostics);
125192
125411
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125199,7 +125418,7 @@ var ts;
125199
125418
  step = BuildStep.QueueReferencingProjects;
125200
125419
  return emitResult;
125201
125420
  }
125202
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125421
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125203
125422
  var _a;
125204
125423
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125205
125424
  if (emitDiagnostics.length) {
@@ -125210,13 +125429,11 @@ var ts;
125210
125429
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125211
125430
  }
125212
125431
  // Update time stamps for rest of the outputs
125213
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125432
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125214
125433
  state.diagnostics.delete(projectPath);
125215
125434
  state.projectStatus.set(projectPath, {
125216
125435
  type: ts.UpToDateStatusType.UpToDate,
125217
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125218
- maximumDate :
125219
- newestDeclarationFileContentChangedTime,
125436
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125220
125437
  oldestOutputFileName: oldestOutputFileName
125221
125438
  });
125222
125439
  afterProgramDone(state, program, config);
@@ -125251,13 +125468,21 @@ var ts;
125251
125468
  ts.Debug.assert(!!outputFiles.length);
125252
125469
  var emitterDiagnostics = ts.createDiagnosticCollection();
125253
125470
  var emittedOutputs = new ts.Map();
125471
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125472
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125254
125473
  outputFiles.forEach(function (_a) {
125255
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125474
+ var _b, _c;
125475
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125256
125476
  emittedOutputs.set(toPath(state, name), name);
125477
+ if (buildInfo) {
125478
+ setBuildInfo(state, buildInfo, projectPath, config.options);
125479
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125480
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125481
+ }
125482
+ }
125257
125483
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125258
125484
  });
125259
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125260
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125485
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125261
125486
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125262
125487
  }
125263
125488
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125356,7 +125581,7 @@ var ts;
125356
125581
  }
125357
125582
  continue;
125358
125583
  }
125359
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125584
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125360
125585
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125361
125586
  return {
125362
125587
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125441,7 +125666,8 @@ var ts;
125441
125666
  state.projectCompilerOptions = state.baseCompilerOptions;
125442
125667
  }
125443
125668
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125444
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125669
+ // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors
125670
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125445
125671
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125446
125672
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125447
125673
  if (canEmitBuildInfo)
@@ -125449,9 +125675,99 @@ var ts;
125449
125675
  afterProgramDone(state, program, config);
125450
125676
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125451
125677
  }
125678
+ function isFileWatcherWithModifiedTime(value) {
125679
+ return !!value.watcher;
125680
+ }
125681
+ function getModifiedTime(state, fileName) {
125682
+ var path = toPath(state, fileName);
125683
+ var existing = state.filesWatched.get(path);
125684
+ if (state.watch && !!existing) {
125685
+ if (!isFileWatcherWithModifiedTime(existing))
125686
+ return existing;
125687
+ if (existing.modifiedTime)
125688
+ return existing.modifiedTime;
125689
+ }
125690
+ // In watch mode we store the modified times in the cache
125691
+ // This is either Date | FileWatcherWithModifiedTime because we query modified times first and
125692
+ // then after complete compilation of the project, watch the files so we dont want to loose these modified times.
125693
+ var result = ts.getModifiedTime(state.host, fileName);
125694
+ if (state.watch) {
125695
+ if (existing)
125696
+ existing.modifiedTime = result;
125697
+ else
125698
+ state.filesWatched.set(path, result);
125699
+ }
125700
+ return result;
125701
+ }
125702
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125703
+ var path = toPath(state, file);
125704
+ var existing = state.filesWatched.get(path);
125705
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125706
+ existing.callbacks.push(callback);
125707
+ }
125708
+ else {
125709
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125710
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125711
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125712
+ existing.modifiedTime = modifiedTime;
125713
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125714
+ }, pollingInterval, options, watchType, project);
125715
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125716
+ }
125717
+ return {
125718
+ close: function () {
125719
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125720
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125721
+ if (existing.callbacks.length === 1) {
125722
+ state.filesWatched.delete(path);
125723
+ ts.closeFileWatcherOf(existing);
125724
+ }
125725
+ else {
125726
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125727
+ }
125728
+ }
125729
+ };
125730
+ }
125731
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125732
+ // Output timestamps are stored only in watch mode
125733
+ if (!state.watch)
125734
+ return undefined;
125735
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125736
+ if (!result)
125737
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125738
+ return result;
125739
+ }
125740
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125741
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125742
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125743
+ if (existing) {
125744
+ existing.buildInfo = buildInfo;
125745
+ existing.modifiedTime = getCurrentTime(state.host);
125746
+ }
125747
+ else {
125748
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125749
+ }
125750
+ }
125751
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125752
+ var path = toPath(state, buildInfoPath);
125753
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125754
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125755
+ }
125756
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125757
+ var path = toPath(state, buildInfoPath);
125758
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125759
+ if (existing !== undefined && existing.path === path) {
125760
+ return existing.buildInfo || undefined;
125761
+ }
125762
+ var value = state.readFileWithCache(buildInfoPath);
125763
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125764
+ ts.Debug.assert(modifiedTime || !buildInfo);
125765
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125766
+ return buildInfo;
125767
+ }
125452
125768
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125453
125769
  // Check tsconfig time
125454
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125770
+ var tsconfigTime = getModifiedTime(state, configFile);
125455
125771
  if (oldestOutputFileTime < tsconfigTime) {
125456
125772
  return {
125457
125773
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125461,88 +125777,24 @@ var ts;
125461
125777
  }
125462
125778
  }
125463
125779
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125464
- var force = !!state.options.force;
125465
- var newestInputFileName = undefined;
125466
- var newestInputFileTime = minimumDate;
125467
- var host = state.host;
125468
- // Get timestamps of input files
125469
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125470
- var inputFile = _a[_i];
125471
- if (!host.fileExists(inputFile)) {
125472
- return {
125473
- type: ts.UpToDateStatusType.Unbuildable,
125474
- reason: inputFile + " does not exist"
125475
- };
125476
- }
125477
- if (!force) {
125478
- var inputTime = ts.getModifiedTime(host, inputFile);
125479
- if (inputTime > newestInputFileTime) {
125480
- newestInputFileName = inputFile;
125481
- newestInputFileTime = inputTime;
125482
- }
125483
- }
125484
- }
125780
+ var _a, _b, _c;
125485
125781
  // Container if no files are specified in the project
125486
125782
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125487
125783
  return {
125488
125784
  type: ts.UpToDateStatusType.ContainerOnly
125489
125785
  };
125490
125786
  }
125491
- // Collect the expected outputs of this project
125492
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125493
- // Now see if all outputs are newer than the newest input
125494
- var oldestOutputFileName = "(none)";
125495
- var oldestOutputFileTime = maximumDate;
125496
- var newestOutputFileName = "(none)";
125497
- var newestOutputFileTime = minimumDate;
125498
- var missingOutputFileName;
125499
- var newestDeclarationFileContentChangedTime = minimumDate;
125500
- var isOutOfDateWithInputs = false;
125501
- if (!force) {
125502
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125503
- var output = outputs_1[_b];
125504
- // Output is missing; can stop checking
125505
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125506
- if (!host.fileExists(output)) {
125507
- missingOutputFileName = output;
125508
- break;
125509
- }
125510
- var outputTime = ts.getModifiedTime(host, output);
125511
- if (outputTime < oldestOutputFileTime) {
125512
- oldestOutputFileTime = outputTime;
125513
- oldestOutputFileName = output;
125514
- }
125515
- // If an output is older than the newest input, we can stop checking
125516
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125517
- if (outputTime < newestInputFileTime) {
125518
- isOutOfDateWithInputs = true;
125519
- break;
125520
- }
125521
- if (outputTime > newestOutputFileTime) {
125522
- newestOutputFileTime = outputTime;
125523
- newestOutputFileName = output;
125524
- }
125525
- // Keep track of when the most recent time a .d.ts file was changed.
125526
- // In addition to file timestamps, we also keep track of when a .d.ts file
125527
- // had its file touched but not had its contents changed - this allows us
125528
- // to skip a downstream typecheck
125529
- if (ts.isDeclarationFileName(output)) {
125530
- var outputModifiedTime = ts.getModifiedTime(host, output);
125531
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125532
- }
125533
- }
125534
- }
125535
- var pseudoUpToDate = false;
125536
- var usesPrepend = false;
125537
- var upstreamChangedProject;
125787
+ // Fast check to see if reference projects are upto date and error free
125788
+ var referenceStatuses;
125789
+ var force = !!state.options.force;
125538
125790
  if (project.projectReferences) {
125539
125791
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125540
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125541
- var ref = _d[_c];
125542
- usesPrepend = usesPrepend || !!(ref.prepend);
125792
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125793
+ var ref = _d[_i];
125543
125794
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125544
125795
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125545
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125796
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125797
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125546
125798
  // Its a circular reference ignore the status of this project
125547
125799
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125548
125800
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125564,75 +125816,194 @@ var ts;
125564
125816
  upstreamProjectName: ref.path
125565
125817
  };
125566
125818
  }
125567
- // Check oldest output file name only if there is no missing output file name
125568
- // (a check we will have skipped if this is a forced build)
125569
- if (!force && !missingOutputFileName) {
125570
- // If the upstream project's newest file is older than our oldest output, we
125571
- // can't be out of date because of it
125572
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125573
- continue;
125574
- }
125575
- // If the upstream project has only change .d.ts files, and we've built
125576
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125577
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125578
- pseudoUpToDate = true;
125579
- upstreamChangedProject = ref.path;
125580
- continue;
125581
- }
125582
- // We have an output older than an upstream output - we are out of date
125583
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125819
+ if (!force)
125820
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125821
+ }
125822
+ }
125823
+ if (force)
125824
+ return { type: ts.UpToDateStatusType.ForceBuild };
125825
+ // Check buildinfo first
125826
+ var host = state.host;
125827
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125828
+ var oldestOutputFileName;
125829
+ var oldestOutputFileTime = maximumDate;
125830
+ var buildInfoTime;
125831
+ var buildInfoProgram;
125832
+ var buildInfoVersionMap;
125833
+ var newestDeclarationFileContentChangedTime;
125834
+ if (buildInfoPath) {
125835
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125836
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125837
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125838
+ if (!buildInfoCacheEntry_1) {
125839
+ state.buildInfoCache.set(resolvedPath, {
125840
+ path: toPath(state, buildInfoPath),
125841
+ buildInfo: false,
125842
+ modifiedTime: buildInfoTime
125843
+ });
125844
+ }
125845
+ return {
125846
+ type: ts.UpToDateStatusType.OutputMissing,
125847
+ missingOutputFileName: buildInfoPath
125848
+ };
125849
+ }
125850
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125851
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125852
+ return {
125853
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125854
+ version: buildInfo.version
125855
+ };
125856
+ }
125857
+ if (buildInfo.program) {
125858
+ // If there are pending changes that are not emitted, project is out of date
125859
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125860
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125584
125861
  return {
125585
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125586
- outOfDateOutputFileName: oldestOutputFileName,
125587
- newerProjectName: ref.path
125862
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125863
+ buildInfoFile: buildInfoPath
125588
125864
  };
125589
125865
  }
125866
+ buildInfoProgram = buildInfo.program;
125590
125867
  }
125868
+ oldestOutputFileTime = buildInfoTime;
125869
+ oldestOutputFileName = buildInfoPath;
125870
+ // Get the last dtsChange time from build info
125871
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125591
125872
  }
125592
- if (missingOutputFileName !== undefined) {
125593
- return {
125594
- type: ts.UpToDateStatusType.OutputMissing,
125595
- missingOutputFileName: missingOutputFileName
125596
- };
125873
+ // Check input files
125874
+ var newestInputFileName = undefined;
125875
+ var newestInputFileTime = minimumDate;
125876
+ /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */
125877
+ var pseudoInputUpToDate = false;
125878
+ // Get timestamps of input files
125879
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125880
+ var inputFile = _f[_e];
125881
+ var inputTime = getModifiedTime(state, inputFile);
125882
+ if (inputTime === ts.missingFileModifiedTime) {
125883
+ return {
125884
+ type: ts.UpToDateStatusType.Unbuildable,
125885
+ reason: inputFile + " does not exist"
125886
+ };
125887
+ }
125888
+ // If an buildInfo is older than the newest input, we can stop checking
125889
+ if (buildInfoTime && buildInfoTime < inputTime) {
125890
+ var version_3 = void 0;
125891
+ var currentVersion = void 0;
125892
+ if (buildInfoProgram) {
125893
+ // Read files and see if they are same, read is anyways cached
125894
+ if (!buildInfoVersionMap)
125895
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125896
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125897
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125898
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125899
+ if (version_3 && version_3 === currentVersion)
125900
+ pseudoInputUpToDate = true;
125901
+ }
125902
+ if (!version_3 || version_3 !== currentVersion) {
125903
+ return {
125904
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125905
+ outOfDateOutputFileName: buildInfoPath,
125906
+ newerInputFileName: inputFile
125907
+ };
125908
+ }
125909
+ }
125910
+ if (inputTime > newestInputFileTime) {
125911
+ newestInputFileName = inputFile;
125912
+ newestInputFileTime = inputTime;
125913
+ }
125597
125914
  }
125598
- if (isOutOfDateWithInputs) {
125599
- return {
125600
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125601
- outOfDateOutputFileName: oldestOutputFileName,
125602
- newerInputFileName: newestInputFileName
125603
- };
125915
+ // Now see if all outputs are newer than the newest input
125916
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125917
+ if (!buildInfoPath) {
125918
+ // Collect the expected outputs of this project
125919
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125920
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125921
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125922
+ var output = outputs_1[_g];
125923
+ var path = toPath(state, output);
125924
+ // Output is missing; can stop checking
125925
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125926
+ if (!outputTime) {
125927
+ outputTime = ts.getModifiedTime(state.host, output);
125928
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125929
+ }
125930
+ if (outputTime === ts.missingFileModifiedTime) {
125931
+ return {
125932
+ type: ts.UpToDateStatusType.OutputMissing,
125933
+ missingOutputFileName: output
125934
+ };
125935
+ }
125936
+ // If an output is older than the newest input, we can stop checking
125937
+ if (outputTime < newestInputFileTime) {
125938
+ return {
125939
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125940
+ outOfDateOutputFileName: output,
125941
+ newerInputFileName: newestInputFileName
125942
+ };
125943
+ }
125944
+ // No need to get newestDeclarationFileContentChangedTime since thats needed only for composite projects
125945
+ // And composite projects are the only ones that can be referenced
125946
+ if (outputTime < oldestOutputFileTime) {
125947
+ oldestOutputFileTime = outputTime;
125948
+ oldestOutputFileName = output;
125949
+ }
125950
+ }
125604
125951
  }
125605
- else {
125606
- // Check tsconfig time
125607
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125608
- if (configStatus)
125609
- return configStatus;
125610
- // Check extended config time
125611
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125612
- if (extendedConfigStatus)
125613
- return extendedConfigStatus;
125614
- // Check package file time
125615
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125616
- var path = _a[0];
125617
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125618
- });
125619
- if (dependentPackageFileStatus)
125620
- return dependentPackageFileStatus;
125621
- }
125622
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125623
- state.buildInfoChecked.set(resolvedPath, true);
125624
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125625
- if (buildInfoPath) {
125626
- var value = state.readFileWithCache(buildInfoPath);
125627
- var buildInfo = value && ts.getBuildInfo(value);
125628
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125952
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125953
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125954
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125955
+ /** Inputs are up-to-date, just need either timestamp update or bundle prepend manipulation to make it look up-to-date */
125956
+ var pseudoUpToDate = false;
125957
+ var usesPrepend = false;
125958
+ var upstreamChangedProject;
125959
+ if (referenceStatuses) {
125960
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125961
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125962
+ usesPrepend = usesPrepend || !!(ref.prepend);
125963
+ // If the upstream project's newest file is older than our oldest output, we
125964
+ // can't be out of date because of it
125965
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125966
+ continue;
125967
+ }
125968
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125969
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125629
125970
  return {
125630
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125631
- version: buildInfo.version
125971
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125972
+ outOfDateOutputFileName: buildInfoPath,
125973
+ newerProjectName: ref.path
125632
125974
  };
125633
125975
  }
125976
+ // If the upstream project has only change .d.ts files, and we've built
125977
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125978
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125979
+ pseudoUpToDate = true;
125980
+ upstreamChangedProject = ref.path;
125981
+ continue;
125982
+ }
125983
+ // We have an output older than an upstream output - we are out of date
125984
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125985
+ return {
125986
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125987
+ outOfDateOutputFileName: oldestOutputFileName,
125988
+ newerProjectName: ref.path
125989
+ };
125634
125990
  }
125635
125991
  }
125992
+ // Check tsconfig time
125993
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125994
+ if (configStatus)
125995
+ return configStatus;
125996
+ // Check extended config time
125997
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125998
+ if (extendedConfigStatus)
125999
+ return extendedConfigStatus;
126000
+ // Check package file time
126001
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
126002
+ var path = _a[0];
126003
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
126004
+ });
126005
+ if (dependentPackageFileStatus)
126006
+ return dependentPackageFileStatus;
125636
126007
  if (usesPrepend && pseudoUpToDate) {
125637
126008
  return {
125638
126009
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125642,15 +126013,37 @@ var ts;
125642
126013
  }
125643
126014
  // Up to date
125644
126015
  return {
125645
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
126016
+ type: pseudoUpToDate ?
126017
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
126018
+ pseudoInputUpToDate ?
126019
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
126020
+ ts.UpToDateStatusType.UpToDate,
125646
126021
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125647
126022
  newestInputFileTime: newestInputFileTime,
125648
- newestOutputFileTime: newestOutputFileTime,
125649
126023
  newestInputFileName: newestInputFileName,
125650
- newestOutputFileName: newestOutputFileName,
125651
126024
  oldestOutputFileName: oldestOutputFileName
125652
126025
  };
125653
126026
  }
126027
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
126028
+ if (seenRefs.has(resolvedRefPath))
126029
+ return false;
126030
+ seenRefs.add(resolvedRefPath);
126031
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
126032
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
126033
+ return true;
126034
+ if (resolvedConfig.projectReferences) {
126035
+ // Check references
126036
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
126037
+ var ref = _a[_i];
126038
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
126039
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
126040
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
126041
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
126042
+ return true;
126043
+ }
126044
+ }
126045
+ return false;
126046
+ }
125654
126047
  function getUpToDateStatus(state, project, resolvedPath) {
125655
126048
  if (project === undefined) {
125656
126049
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125663,39 +126056,68 @@ var ts;
125663
126056
  state.projectStatus.set(resolvedPath, actual);
125664
126057
  return actual;
125665
126058
  }
125666
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126059
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125667
126060
  if (proj.options.noEmit)
125668
- return priorNewestUpdateTime;
126061
+ return;
126062
+ var now;
126063
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
126064
+ if (buildInfoPath) {
126065
+ // For incremental projects, only buildinfo needs to be upto date with timestamp check
126066
+ // as we dont check output files for up-to-date ness
126067
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
126068
+ if (!!state.options.verbose)
126069
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
126070
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
126071
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
126072
+ }
126073
+ state.outputTimeStamps.delete(projectPath);
126074
+ return;
126075
+ }
125669
126076
  var host = state.host;
125670
126077
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126078
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126079
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125671
126080
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125672
126081
  var reportVerbose = !!state.options.verbose;
125673
- var now = host.now ? host.now() : new Date();
125674
126082
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125675
126083
  var file = outputs_2[_i];
125676
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
126084
+ var path = toPath(state, file);
126085
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125677
126086
  continue;
125678
- }
125679
126087
  if (reportVerbose) {
125680
126088
  reportVerbose = false;
125681
126089
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125682
126090
  }
125683
- if (ts.isDeclarationFileName(file)) {
125684
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
126091
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
126092
+ // Store output timestamps in a map because non incremental build will need to check them to determine up-to-dateness
126093
+ if (outputTimeStampMap) {
126094
+ outputTimeStampMap.set(path, now);
126095
+ modifiedOutputs.add(path);
125685
126096
  }
125686
- host.setModifiedTime(file, now);
125687
126097
  }
125688
126098
  }
125689
- return priorNewestUpdateTime;
126099
+ // Clear out timestamps not in output list any more
126100
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.forEach(function (_value, key) {
126101
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs.has(key))
126102
+ outputTimeStampMap.delete(key);
126103
+ });
126104
+ }
126105
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
126106
+ var _a;
126107
+ if (!options.composite)
126108
+ return undefined;
126109
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126110
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126111
+ 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;
125690
126112
  }
125691
126113
  function updateOutputTimestamps(state, proj, resolvedPath) {
125692
126114
  if (state.options.dry) {
125693
126115
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125694
126116
  }
125695
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126117
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125696
126118
  state.projectStatus.set(resolvedPath, {
125697
126119
  type: ts.UpToDateStatusType.UpToDate,
125698
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126120
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125699
126121
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125700
126122
  });
125701
126123
  }
@@ -125741,6 +126163,7 @@ var ts;
125741
126163
  break;
125742
126164
  }
125743
126165
  // falls through
126166
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125744
126167
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125745
126168
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125746
126169
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125901,12 +126324,10 @@ var ts;
125901
126324
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125902
126325
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125903
126326
  return;
125904
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125905
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125906
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126327
+ 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));
125907
126328
  }
125908
126329
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125909
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126330
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125910
126331
  var _a;
125911
126332
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125912
126333
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125938,7 +126359,7 @@ var ts;
125938
126359
  if (!state.watch)
125939
126360
  return;
125940
126361
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125941
- 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); },
126362
+ 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); },
125942
126363
  onDeleteValue: ts.closeFileWatcher,
125943
126364
  });
125944
126365
  }
@@ -125946,7 +126367,7 @@ var ts;
125946
126367
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125947
126368
  return;
125948
126369
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125949
- 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); },
126370
+ 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); },
125950
126371
  onDeleteValue: ts.closeFileWatcher,
125951
126372
  });
125952
126373
  }
@@ -126076,19 +126497,18 @@ var ts;
126076
126497
  }
126077
126498
  }
126078
126499
  function reportUpToDateStatus(state, configFileName, status) {
126079
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126080
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126081
- }
126082
126500
  switch (status.type) {
126083
126501
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126084
- 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));
126502
+ 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));
126085
126503
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126086
- 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));
126504
+ 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));
126087
126505
  case ts.UpToDateStatusType.OutputMissing:
126088
126506
  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));
126507
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
126508
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted, relName(state, configFileName), relName(state, status.buildInfoFile));
126089
126509
  case ts.UpToDateStatusType.UpToDate:
126090
126510
  if (status.newestInputFileTime !== undefined) {
126091
- 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 || ""));
126511
+ 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 || ""));
126092
126512
  }
126093
126513
  // Don't report anything for "up to date because it was already built" -- too verbose
126094
126514
  break;
@@ -126096,6 +126516,8 @@ var ts;
126096
126516
  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));
126097
126517
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126098
126518
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126519
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126520
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files, relName(state, configFileName));
126099
126521
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126100
126522
  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));
126101
126523
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126106,6 +126528,8 @@ var ts;
126106
126528
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126107
126529
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126108
126530
  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);
126531
+ case ts.UpToDateStatusType.ForceBuild:
126532
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126109
126533
  case ts.UpToDateStatusType.ContainerOnly:
126110
126534
  // Don't report status on "solution" projects
126111
126535
  // falls through