typescript 4.8.0-dev.20220605 → 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.20220605";
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
  }
@@ -39033,6 +39070,7 @@ var ts;
39033
39070
  ["es2022.error", "lib.es2022.error.d.ts"],
39034
39071
  ["es2022.intl", "lib.es2022.intl.d.ts"],
39035
39072
  ["es2022.object", "lib.es2022.object.d.ts"],
39073
+ ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
39036
39074
  ["es2022.string", "lib.es2022.string.d.ts"],
39037
39075
  ["esnext.array", "lib.es2022.array.d.ts"],
39038
39076
  ["esnext.symbol", "lib.es2019.symbol.d.ts"],
@@ -39246,6 +39284,7 @@ var ts;
39246
39284
  type: "boolean",
39247
39285
  affectsSemanticDiagnostics: true,
39248
39286
  affectsEmit: true,
39287
+ affectsMultiFileEmitBuildInfo: true,
39249
39288
  category: ts.Diagnostics.Watch_and_Build_Modes,
39250
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,
39251
39290
  defaultValueDescription: false,
@@ -39280,12 +39319,40 @@ var ts;
39280
39319
  affectsSourceFile: true,
39281
39320
  affectsModuleResolution: true,
39282
39321
  affectsEmit: true,
39322
+ affectsMultiFileEmitBuildInfo: true,
39283
39323
  paramType: ts.Diagnostics.VERSION,
39284
39324
  showInSimplifiedHelpView: true,
39285
39325
  category: ts.Diagnostics.Language_and_Environment,
39286
39326
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39287
39327
  defaultValueDescription: 0 /* ES3 */,
39288
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
+ };
39289
39356
  var commandOptionsWithoutBuild = [
39290
39357
  // CommandLine only options
39291
39358
  {
@@ -39347,37 +39414,14 @@ var ts;
39347
39414
  category: ts.Diagnostics.Command_line_Options,
39348
39415
  affectsSemanticDiagnostics: true,
39349
39416
  affectsEmit: true,
39417
+ affectsMultiFileEmitBuildInfo: true,
39350
39418
  isCommandLineOnly: true,
39351
39419
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39352
39420
  defaultValueDescription: false,
39353
39421
  },
39354
39422
  // Basic
39355
39423
  ts.targetOptionDeclaration,
39356
- {
39357
- name: "module",
39358
- shortName: "m",
39359
- type: new ts.Map(ts.getEntries({
39360
- none: ts.ModuleKind.None,
39361
- commonjs: ts.ModuleKind.CommonJS,
39362
- amd: ts.ModuleKind.AMD,
39363
- system: ts.ModuleKind.System,
39364
- umd: ts.ModuleKind.UMD,
39365
- es6: ts.ModuleKind.ES2015,
39366
- es2015: ts.ModuleKind.ES2015,
39367
- es2020: ts.ModuleKind.ES2020,
39368
- es2022: ts.ModuleKind.ES2022,
39369
- esnext: ts.ModuleKind.ESNext,
39370
- node16: ts.ModuleKind.Node16,
39371
- nodenext: ts.ModuleKind.NodeNext,
39372
- })),
39373
- affectsModuleResolution: true,
39374
- affectsEmit: true,
39375
- paramType: ts.Diagnostics.KIND,
39376
- showInSimplifiedHelpView: true,
39377
- category: ts.Diagnostics.Modules,
39378
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39379
- defaultValueDescription: undefined,
39380
- },
39424
+ ts.moduleOptionDeclaration,
39381
39425
  {
39382
39426
  name: "lib",
39383
39427
  type: "list",
@@ -39414,6 +39458,7 @@ var ts;
39414
39458
  type: jsxOptionMap,
39415
39459
  affectsSourceFile: true,
39416
39460
  affectsEmit: true,
39461
+ affectsMultiFileEmitBuildInfo: true,
39417
39462
  affectsModuleResolution: true,
39418
39463
  paramType: ts.Diagnostics.KIND,
39419
39464
  showInSimplifiedHelpView: true,
@@ -39426,6 +39471,7 @@ var ts;
39426
39471
  shortName: "d",
39427
39472
  type: "boolean",
39428
39473
  affectsEmit: true,
39474
+ affectsMultiFileEmitBuildInfo: true,
39429
39475
  showInSimplifiedHelpView: true,
39430
39476
  category: ts.Diagnostics.Emit,
39431
39477
  transpileOptionValue: undefined,
@@ -39436,6 +39482,7 @@ var ts;
39436
39482
  name: "declarationMap",
39437
39483
  type: "boolean",
39438
39484
  affectsEmit: true,
39485
+ affectsMultiFileEmitBuildInfo: true,
39439
39486
  showInSimplifiedHelpView: true,
39440
39487
  category: ts.Diagnostics.Emit,
39441
39488
  transpileOptionValue: undefined,
@@ -39446,6 +39493,7 @@ var ts;
39446
39493
  name: "emitDeclarationOnly",
39447
39494
  type: "boolean",
39448
39495
  affectsEmit: true,
39496
+ affectsMultiFileEmitBuildInfo: true,
39449
39497
  showInSimplifiedHelpView: true,
39450
39498
  category: ts.Diagnostics.Emit,
39451
39499
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39456,6 +39504,7 @@ var ts;
39456
39504
  name: "sourceMap",
39457
39505
  type: "boolean",
39458
39506
  affectsEmit: true,
39507
+ affectsMultiFileEmitBuildInfo: true,
39459
39508
  showInSimplifiedHelpView: true,
39460
39509
  category: ts.Diagnostics.Emit,
39461
39510
  defaultValueDescription: false,
@@ -39465,6 +39514,9 @@ var ts;
39465
39514
  name: "outFile",
39466
39515
  type: "string",
39467
39516
  affectsEmit: true,
39517
+ affectsMultiFileEmitBuildInfo: true,
39518
+ affectsDeclarationPath: true,
39519
+ affectsBundleEmitBuildInfo: true,
39468
39520
  isFilePath: true,
39469
39521
  paramType: ts.Diagnostics.FILE,
39470
39522
  showInSimplifiedHelpView: true,
@@ -39476,6 +39528,8 @@ var ts;
39476
39528
  name: "outDir",
39477
39529
  type: "string",
39478
39530
  affectsEmit: true,
39531
+ affectsMultiFileEmitBuildInfo: true,
39532
+ affectsDeclarationPath: true,
39479
39533
  isFilePath: true,
39480
39534
  paramType: ts.Diagnostics.DIRECTORY,
39481
39535
  showInSimplifiedHelpView: true,
@@ -39486,6 +39540,8 @@ var ts;
39486
39540
  name: "rootDir",
39487
39541
  type: "string",
39488
39542
  affectsEmit: true,
39543
+ affectsMultiFileEmitBuildInfo: true,
39544
+ affectsDeclarationPath: true,
39489
39545
  isFilePath: true,
39490
39546
  paramType: ts.Diagnostics.LOCATION,
39491
39547
  category: ts.Diagnostics.Modules,
@@ -39496,6 +39552,8 @@ var ts;
39496
39552
  name: "composite",
39497
39553
  type: "boolean",
39498
39554
  affectsEmit: true,
39555
+ affectsMultiFileEmitBuildInfo: true,
39556
+ affectsBundleEmitBuildInfo: true,
39499
39557
  isTSConfigOnly: true,
39500
39558
  category: ts.Diagnostics.Projects,
39501
39559
  transpileOptionValue: undefined,
@@ -39506,6 +39564,8 @@ var ts;
39506
39564
  name: "tsBuildInfoFile",
39507
39565
  type: "string",
39508
39566
  affectsEmit: true,
39567
+ affectsMultiFileEmitBuildInfo: true,
39568
+ affectsBundleEmitBuildInfo: true,
39509
39569
  isFilePath: true,
39510
39570
  paramType: ts.Diagnostics.FILE,
39511
39571
  category: ts.Diagnostics.Projects,
@@ -39517,6 +39577,7 @@ var ts;
39517
39577
  name: "removeComments",
39518
39578
  type: "boolean",
39519
39579
  affectsEmit: true,
39580
+ affectsMultiFileEmitBuildInfo: true,
39520
39581
  showInSimplifiedHelpView: true,
39521
39582
  category: ts.Diagnostics.Emit,
39522
39583
  defaultValueDescription: false,
@@ -39535,6 +39596,7 @@ var ts;
39535
39596
  name: "importHelpers",
39536
39597
  type: "boolean",
39537
39598
  affectsEmit: true,
39599
+ affectsMultiFileEmitBuildInfo: true,
39538
39600
  category: ts.Diagnostics.Emit,
39539
39601
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39540
39602
  defaultValueDescription: false,
@@ -39548,6 +39610,7 @@ var ts;
39548
39610
  })),
39549
39611
  affectsEmit: true,
39550
39612
  affectsSemanticDiagnostics: true,
39613
+ affectsMultiFileEmitBuildInfo: true,
39551
39614
  category: ts.Diagnostics.Emit,
39552
39615
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39553
39616
  defaultValueDescription: 0 /* Remove */,
@@ -39556,6 +39619,7 @@ var ts;
39556
39619
  name: "downlevelIteration",
39557
39620
  type: "boolean",
39558
39621
  affectsEmit: true,
39622
+ affectsMultiFileEmitBuildInfo: true,
39559
39623
  category: ts.Diagnostics.Emit,
39560
39624
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39561
39625
  defaultValueDescription: false,
@@ -39574,6 +39638,9 @@ var ts;
39574
39638
  type: "boolean",
39575
39639
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39576
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,
39577
39644
  showInSimplifiedHelpView: true,
39578
39645
  category: ts.Diagnostics.Type_Checking,
39579
39646
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39583,6 +39650,7 @@ var ts;
39583
39650
  name: "noImplicitAny",
39584
39651
  type: "boolean",
39585
39652
  affectsSemanticDiagnostics: true,
39653
+ affectsMultiFileEmitBuildInfo: true,
39586
39654
  strictFlag: true,
39587
39655
  category: ts.Diagnostics.Type_Checking,
39588
39656
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39592,6 +39660,7 @@ var ts;
39592
39660
  name: "strictNullChecks",
39593
39661
  type: "boolean",
39594
39662
  affectsSemanticDiagnostics: true,
39663
+ affectsMultiFileEmitBuildInfo: true,
39595
39664
  strictFlag: true,
39596
39665
  category: ts.Diagnostics.Type_Checking,
39597
39666
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39600,6 +39669,8 @@ var ts;
39600
39669
  {
39601
39670
  name: "strictFunctionTypes",
39602
39671
  type: "boolean",
39672
+ affectsSemanticDiagnostics: true,
39673
+ affectsMultiFileEmitBuildInfo: true,
39603
39674
  strictFlag: true,
39604
39675
  category: ts.Diagnostics.Type_Checking,
39605
39676
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39608,6 +39679,8 @@ var ts;
39608
39679
  {
39609
39680
  name: "strictBindCallApply",
39610
39681
  type: "boolean",
39682
+ affectsSemanticDiagnostics: true,
39683
+ affectsMultiFileEmitBuildInfo: true,
39611
39684
  strictFlag: true,
39612
39685
  category: ts.Diagnostics.Type_Checking,
39613
39686
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39617,6 +39690,7 @@ var ts;
39617
39690
  name: "strictPropertyInitialization",
39618
39691
  type: "boolean",
39619
39692
  affectsSemanticDiagnostics: true,
39693
+ affectsMultiFileEmitBuildInfo: true,
39620
39694
  strictFlag: true,
39621
39695
  category: ts.Diagnostics.Type_Checking,
39622
39696
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39626,6 +39700,7 @@ var ts;
39626
39700
  name: "noImplicitThis",
39627
39701
  type: "boolean",
39628
39702
  affectsSemanticDiagnostics: true,
39703
+ affectsMultiFileEmitBuildInfo: true,
39629
39704
  strictFlag: true,
39630
39705
  category: ts.Diagnostics.Type_Checking,
39631
39706
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39635,6 +39710,7 @@ var ts;
39635
39710
  name: "useUnknownInCatchVariables",
39636
39711
  type: "boolean",
39637
39712
  affectsSemanticDiagnostics: true,
39713
+ affectsMultiFileEmitBuildInfo: true,
39638
39714
  strictFlag: true,
39639
39715
  category: ts.Diagnostics.Type_Checking,
39640
39716
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39644,6 +39720,8 @@ var ts;
39644
39720
  name: "alwaysStrict",
39645
39721
  type: "boolean",
39646
39722
  affectsSourceFile: true,
39723
+ affectsEmit: true,
39724
+ affectsMultiFileEmitBuildInfo: true,
39647
39725
  strictFlag: true,
39648
39726
  category: ts.Diagnostics.Type_Checking,
39649
39727
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39654,6 +39732,7 @@ var ts;
39654
39732
  name: "noUnusedLocals",
39655
39733
  type: "boolean",
39656
39734
  affectsSemanticDiagnostics: true,
39735
+ affectsMultiFileEmitBuildInfo: true,
39657
39736
  category: ts.Diagnostics.Type_Checking,
39658
39737
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39659
39738
  defaultValueDescription: false,
@@ -39662,6 +39741,7 @@ var ts;
39662
39741
  name: "noUnusedParameters",
39663
39742
  type: "boolean",
39664
39743
  affectsSemanticDiagnostics: true,
39744
+ affectsMultiFileEmitBuildInfo: true,
39665
39745
  category: ts.Diagnostics.Type_Checking,
39666
39746
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39667
39747
  defaultValueDescription: false,
@@ -39670,6 +39750,7 @@ var ts;
39670
39750
  name: "exactOptionalPropertyTypes",
39671
39751
  type: "boolean",
39672
39752
  affectsSemanticDiagnostics: true,
39753
+ affectsMultiFileEmitBuildInfo: true,
39673
39754
  category: ts.Diagnostics.Type_Checking,
39674
39755
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39675
39756
  defaultValueDescription: false,
@@ -39678,6 +39759,7 @@ var ts;
39678
39759
  name: "noImplicitReturns",
39679
39760
  type: "boolean",
39680
39761
  affectsSemanticDiagnostics: true,
39762
+ affectsMultiFileEmitBuildInfo: true,
39681
39763
  category: ts.Diagnostics.Type_Checking,
39682
39764
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39683
39765
  defaultValueDescription: false,
@@ -39687,6 +39769,7 @@ var ts;
39687
39769
  type: "boolean",
39688
39770
  affectsBindDiagnostics: true,
39689
39771
  affectsSemanticDiagnostics: true,
39772
+ affectsMultiFileEmitBuildInfo: true,
39690
39773
  category: ts.Diagnostics.Type_Checking,
39691
39774
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39692
39775
  defaultValueDescription: false,
@@ -39695,6 +39778,7 @@ var ts;
39695
39778
  name: "noUncheckedIndexedAccess",
39696
39779
  type: "boolean",
39697
39780
  affectsSemanticDiagnostics: true,
39781
+ affectsMultiFileEmitBuildInfo: true,
39698
39782
  category: ts.Diagnostics.Type_Checking,
39699
39783
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39700
39784
  defaultValueDescription: false,
@@ -39703,6 +39787,7 @@ var ts;
39703
39787
  name: "noImplicitOverride",
39704
39788
  type: "boolean",
39705
39789
  affectsSemanticDiagnostics: true,
39790
+ affectsMultiFileEmitBuildInfo: true,
39706
39791
  category: ts.Diagnostics.Type_Checking,
39707
39792
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39708
39793
  defaultValueDescription: false,
@@ -39710,6 +39795,8 @@ var ts;
39710
39795
  {
39711
39796
  name: "noPropertyAccessFromIndexSignature",
39712
39797
  type: "boolean",
39798
+ affectsSemanticDiagnostics: true,
39799
+ affectsMultiFileEmitBuildInfo: true,
39713
39800
  showInSimplifiedHelpView: false,
39714
39801
  category: ts.Diagnostics.Type_Checking,
39715
39802
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39795,6 +39882,7 @@ var ts;
39795
39882
  name: "allowSyntheticDefaultImports",
39796
39883
  type: "boolean",
39797
39884
  affectsSemanticDiagnostics: true,
39885
+ affectsMultiFileEmitBuildInfo: true,
39798
39886
  category: ts.Diagnostics.Interop_Constraints,
39799
39887
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39800
39888
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39804,6 +39892,7 @@ var ts;
39804
39892
  type: "boolean",
39805
39893
  affectsSemanticDiagnostics: true,
39806
39894
  affectsEmit: true,
39895
+ affectsMultiFileEmitBuildInfo: true,
39807
39896
  showInSimplifiedHelpView: true,
39808
39897
  category: ts.Diagnostics.Interop_Constraints,
39809
39898
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39820,6 +39909,7 @@ var ts;
39820
39909
  name: "allowUmdGlobalAccess",
39821
39910
  type: "boolean",
39822
39911
  affectsSemanticDiagnostics: true,
39912
+ affectsMultiFileEmitBuildInfo: true,
39823
39913
  category: ts.Diagnostics.Modules,
39824
39914
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39825
39915
  defaultValueDescription: false,
@@ -39841,6 +39931,7 @@ var ts;
39841
39931
  name: "sourceRoot",
39842
39932
  type: "string",
39843
39933
  affectsEmit: true,
39934
+ affectsMultiFileEmitBuildInfo: true,
39844
39935
  paramType: ts.Diagnostics.LOCATION,
39845
39936
  category: ts.Diagnostics.Emit,
39846
39937
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39849,6 +39940,7 @@ var ts;
39849
39940
  name: "mapRoot",
39850
39941
  type: "string",
39851
39942
  affectsEmit: true,
39943
+ affectsMultiFileEmitBuildInfo: true,
39852
39944
  paramType: ts.Diagnostics.LOCATION,
39853
39945
  category: ts.Diagnostics.Emit,
39854
39946
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39857,6 +39949,7 @@ var ts;
39857
39949
  name: "inlineSourceMap",
39858
39950
  type: "boolean",
39859
39951
  affectsEmit: true,
39952
+ affectsMultiFileEmitBuildInfo: true,
39860
39953
  category: ts.Diagnostics.Emit,
39861
39954
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39862
39955
  defaultValueDescription: false,
@@ -39865,6 +39958,7 @@ var ts;
39865
39958
  name: "inlineSources",
39866
39959
  type: "boolean",
39867
39960
  affectsEmit: true,
39961
+ affectsMultiFileEmitBuildInfo: true,
39868
39962
  category: ts.Diagnostics.Emit,
39869
39963
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39870
39964
  defaultValueDescription: false,
@@ -39874,6 +39968,7 @@ var ts;
39874
39968
  name: "experimentalDecorators",
39875
39969
  type: "boolean",
39876
39970
  affectsSemanticDiagnostics: true,
39971
+ affectsMultiFileEmitBuildInfo: true,
39877
39972
  category: ts.Diagnostics.Language_and_Environment,
39878
39973
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39879
39974
  defaultValueDescription: false,
@@ -39883,6 +39978,7 @@ var ts;
39883
39978
  type: "boolean",
39884
39979
  affectsSemanticDiagnostics: true,
39885
39980
  affectsEmit: true,
39981
+ affectsMultiFileEmitBuildInfo: true,
39886
39982
  category: ts.Diagnostics.Language_and_Environment,
39887
39983
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39888
39984
  defaultValueDescription: false,
@@ -39907,6 +40003,7 @@ var ts;
39907
40003
  type: "string",
39908
40004
  affectsSemanticDiagnostics: true,
39909
40005
  affectsEmit: true,
40006
+ affectsMultiFileEmitBuildInfo: true,
39910
40007
  affectsModuleResolution: true,
39911
40008
  category: ts.Diagnostics.Language_and_Environment,
39912
40009
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39924,6 +40021,9 @@ var ts;
39924
40021
  name: "out",
39925
40022
  type: "string",
39926
40023
  affectsEmit: true,
40024
+ affectsMultiFileEmitBuildInfo: true,
40025
+ affectsDeclarationPath: true,
40026
+ affectsBundleEmitBuildInfo: true,
39927
40027
  isFilePath: false,
39928
40028
  // for correct behaviour, please use outFile
39929
40029
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39935,6 +40035,7 @@ var ts;
39935
40035
  name: "reactNamespace",
39936
40036
  type: "string",
39937
40037
  affectsEmit: true,
40038
+ affectsMultiFileEmitBuildInfo: true,
39938
40039
  category: ts.Diagnostics.Language_and_Environment,
39939
40040
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39940
40041
  defaultValueDescription: "`React`",
@@ -39942,6 +40043,8 @@ var ts;
39942
40043
  {
39943
40044
  name: "skipDefaultLibCheck",
39944
40045
  type: "boolean",
40046
+ // We need to store these to determine whether `lib` files need to be rechecked
40047
+ affectsMultiFileEmitBuildInfo: true,
39945
40048
  category: ts.Diagnostics.Completeness,
39946
40049
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39947
40050
  defaultValueDescription: false,
@@ -39957,6 +40060,7 @@ var ts;
39957
40060
  name: "emitBOM",
39958
40061
  type: "boolean",
39959
40062
  affectsEmit: true,
40063
+ affectsMultiFileEmitBuildInfo: true,
39960
40064
  category: ts.Diagnostics.Emit,
39961
40065
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39962
40066
  defaultValueDescription: false,
@@ -39968,6 +40072,7 @@ var ts;
39968
40072
  lf: 1 /* LineFeed */
39969
40073
  })),
39970
40074
  affectsEmit: true,
40075
+ affectsMultiFileEmitBuildInfo: true,
39971
40076
  paramType: ts.Diagnostics.NEWLINE,
39972
40077
  category: ts.Diagnostics.Emit,
39973
40078
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39977,6 +40082,7 @@ var ts;
39977
40082
  name: "noErrorTruncation",
39978
40083
  type: "boolean",
39979
40084
  affectsSemanticDiagnostics: true,
40085
+ affectsMultiFileEmitBuildInfo: true,
39980
40086
  category: ts.Diagnostics.Output_Formatting,
39981
40087
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39982
40088
  defaultValueDescription: false,
@@ -40007,6 +40113,7 @@ var ts;
40007
40113
  name: "stripInternal",
40008
40114
  type: "boolean",
40009
40115
  affectsEmit: true,
40116
+ affectsMultiFileEmitBuildInfo: true,
40010
40117
  category: ts.Diagnostics.Emit,
40011
40118
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40012
40119
  defaultValueDescription: false,
@@ -40047,6 +40154,7 @@ var ts;
40047
40154
  name: "noImplicitUseStrict",
40048
40155
  type: "boolean",
40049
40156
  affectsSemanticDiagnostics: true,
40157
+ affectsMultiFileEmitBuildInfo: true,
40050
40158
  category: ts.Diagnostics.Backwards_Compatibility,
40051
40159
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40052
40160
  defaultValueDescription: false,
@@ -40055,6 +40163,7 @@ var ts;
40055
40163
  name: "noEmitHelpers",
40056
40164
  type: "boolean",
40057
40165
  affectsEmit: true,
40166
+ affectsMultiFileEmitBuildInfo: true,
40058
40167
  category: ts.Diagnostics.Emit,
40059
40168
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40060
40169
  defaultValueDescription: false,
@@ -40063,6 +40172,7 @@ var ts;
40063
40172
  name: "noEmitOnError",
40064
40173
  type: "boolean",
40065
40174
  affectsEmit: true,
40175
+ affectsMultiFileEmitBuildInfo: true,
40066
40176
  category: ts.Diagnostics.Emit,
40067
40177
  transpileOptionValue: undefined,
40068
40178
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40072,6 +40182,7 @@ var ts;
40072
40182
  name: "preserveConstEnums",
40073
40183
  type: "boolean",
40074
40184
  affectsEmit: true,
40185
+ affectsMultiFileEmitBuildInfo: true,
40075
40186
  category: ts.Diagnostics.Emit,
40076
40187
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40077
40188
  defaultValueDescription: false,
@@ -40080,6 +40191,8 @@ var ts;
40080
40191
  name: "declarationDir",
40081
40192
  type: "string",
40082
40193
  affectsEmit: true,
40194
+ affectsMultiFileEmitBuildInfo: true,
40195
+ affectsDeclarationPath: true,
40083
40196
  isFilePath: true,
40084
40197
  paramType: ts.Diagnostics.DIRECTORY,
40085
40198
  category: ts.Diagnostics.Emit,
@@ -40089,6 +40202,8 @@ var ts;
40089
40202
  {
40090
40203
  name: "skipLibCheck",
40091
40204
  type: "boolean",
40205
+ // We need to store these to determine whether `lib` files need to be rechecked
40206
+ affectsMultiFileEmitBuildInfo: true,
40092
40207
  category: ts.Diagnostics.Completeness,
40093
40208
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40094
40209
  defaultValueDescription: false,
@@ -40098,6 +40213,7 @@ var ts;
40098
40213
  type: "boolean",
40099
40214
  affectsBindDiagnostics: true,
40100
40215
  affectsSemanticDiagnostics: true,
40216
+ affectsMultiFileEmitBuildInfo: true,
40101
40217
  category: ts.Diagnostics.Type_Checking,
40102
40218
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40103
40219
  defaultValueDescription: undefined,
@@ -40107,6 +40223,7 @@ var ts;
40107
40223
  type: "boolean",
40108
40224
  affectsBindDiagnostics: true,
40109
40225
  affectsSemanticDiagnostics: true,
40226
+ affectsMultiFileEmitBuildInfo: true,
40110
40227
  category: ts.Diagnostics.Type_Checking,
40111
40228
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40112
40229
  defaultValueDescription: undefined,
@@ -40115,6 +40232,7 @@ var ts;
40115
40232
  name: "suppressExcessPropertyErrors",
40116
40233
  type: "boolean",
40117
40234
  affectsSemanticDiagnostics: true,
40235
+ affectsMultiFileEmitBuildInfo: true,
40118
40236
  category: ts.Diagnostics.Backwards_Compatibility,
40119
40237
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40120
40238
  defaultValueDescription: false,
@@ -40123,6 +40241,7 @@ var ts;
40123
40241
  name: "suppressImplicitAnyIndexErrors",
40124
40242
  type: "boolean",
40125
40243
  affectsSemanticDiagnostics: true,
40244
+ affectsMultiFileEmitBuildInfo: true,
40126
40245
  category: ts.Diagnostics.Backwards_Compatibility,
40127
40246
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40128
40247
  defaultValueDescription: false,
@@ -40147,6 +40266,7 @@ var ts;
40147
40266
  name: "noStrictGenericChecks",
40148
40267
  type: "boolean",
40149
40268
  affectsSemanticDiagnostics: true,
40269
+ affectsMultiFileEmitBuildInfo: true,
40150
40270
  category: ts.Diagnostics.Backwards_Compatibility,
40151
40271
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40152
40272
  defaultValueDescription: false,
@@ -40156,6 +40276,7 @@ var ts;
40156
40276
  type: "boolean",
40157
40277
  affectsSemanticDiagnostics: true,
40158
40278
  affectsEmit: true,
40279
+ affectsMultiFileEmitBuildInfo: true,
40159
40280
  category: ts.Diagnostics.Language_and_Environment,
40160
40281
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40161
40282
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40164,6 +40285,7 @@ var ts;
40164
40285
  name: "preserveValueImports",
40165
40286
  type: "boolean",
40166
40287
  affectsEmit: true,
40288
+ affectsMultiFileEmitBuildInfo: true,
40167
40289
  category: ts.Diagnostics.Emit,
40168
40290
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40169
40291
  defaultValueDescription: false,
@@ -40207,6 +40329,8 @@ var ts;
40207
40329
  /* @internal */
40208
40330
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40209
40331
  /* @internal */
40332
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40333
+ /* @internal */
40210
40334
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40211
40335
  /* @internal */
40212
40336
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41062,6 +41186,7 @@ var ts;
41062
41186
  return optionDefinition.type;
41063
41187
  }
41064
41188
  }
41189
+ /* @internal */
41065
41190
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41066
41191
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41067
41192
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41070,6 +41195,7 @@ var ts;
41070
41195
  }
41071
41196
  });
41072
41197
  }
41198
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41073
41199
  function serializeCompilerOptions(options, pathOptions) {
41074
41200
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41075
41201
  }
@@ -42235,16 +42361,18 @@ var ts;
42235
42361
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42236
42362
  return { fileName: resolved.path, packageId: resolved.packageId };
42237
42363
  }
42238
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42239
- var _a;
42364
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42365
+ var _a, _b;
42240
42366
  if (resultFromCache) {
42241
42367
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42368
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42242
42369
  return resultFromCache;
42243
42370
  }
42244
42371
  return {
42245
42372
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42246
42373
  failedLookupLocations: failedLookupLocations,
42247
- resolutionDiagnostics: diagnostics
42374
+ affectingLocations: affectingLocations,
42375
+ resolutionDiagnostics: diagnostics,
42248
42376
  };
42249
42377
  }
42250
42378
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42433,6 +42561,7 @@ var ts;
42433
42561
  }
42434
42562
  }
42435
42563
  var failedLookupLocations = [];
42564
+ var affectingLocations = [];
42436
42565
  var features = getDefaultNodeResolutionFeatures(options);
42437
42566
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42438
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
@@ -42451,6 +42580,7 @@ var ts;
42451
42580
  host: host,
42452
42581
  traceEnabled: traceEnabled,
42453
42582
  failedLookupLocations: failedLookupLocations,
42583
+ affectingLocations: affectingLocations,
42454
42584
  packageJsonInfoCache: cache,
42455
42585
  features: features,
42456
42586
  conditions: conditions,
@@ -42475,7 +42605,7 @@ var ts;
42475
42605
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42476
42606
  };
42477
42607
  }
42478
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42608
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42479
42609
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42480
42610
  if (traceEnabled)
42481
42611
  traceResult(result);
@@ -42555,6 +42685,7 @@ var ts;
42555
42685
  host: host,
42556
42686
  traceEnabled: isTraceEnabled(options, host),
42557
42687
  failedLookupLocations: [],
42688
+ affectingLocations: [],
42558
42689
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42559
42690
  conditions: ts.emptyArray,
42560
42691
  features: NodeResolutionFeatures.None,
@@ -43209,6 +43340,7 @@ var ts;
43209
43340
  var _a, _b;
43210
43341
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43211
43342
  var failedLookupLocations = [];
43343
+ var affectingLocations = [];
43212
43344
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43213
43345
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43214
43346
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43221,6 +43353,7 @@ var ts;
43221
43353
  host: host,
43222
43354
  traceEnabled: traceEnabled,
43223
43355
  failedLookupLocations: failedLookupLocations,
43356
+ affectingLocations: affectingLocations,
43224
43357
  packageJsonInfoCache: cache,
43225
43358
  features: features,
43226
43359
  conditions: conditions,
@@ -43228,7 +43361,7 @@ var ts;
43228
43361
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43229
43362
  };
43230
43363
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43231
- 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);
43232
43365
  function tryResolve(extensions) {
43233
43366
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43234
43367
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43523,6 +43656,7 @@ var ts;
43523
43656
  host: host,
43524
43657
  traceEnabled: isTraceEnabled(options, host),
43525
43658
  failedLookupLocations: [],
43659
+ affectingLocations: [],
43526
43660
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43527
43661
  conditions: ["node", "require", "types"],
43528
43662
  features: features,
@@ -43611,6 +43745,7 @@ var ts;
43611
43745
  compilerOptions: options,
43612
43746
  traceEnabled: isTraceEnabled(options, host),
43613
43747
  failedLookupLocations: [],
43748
+ affectingLocations: [],
43614
43749
  packageJsonInfoCache: packageJsonInfoCache,
43615
43750
  features: 0,
43616
43751
  conditions: [],
@@ -43643,6 +43778,7 @@ var ts;
43643
43778
  if (typeof existing !== "boolean") {
43644
43779
  if (traceEnabled)
43645
43780
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43781
+ state.affectingLocations.push(packageJsonPath);
43646
43782
  return existing;
43647
43783
  }
43648
43784
  else {
@@ -43661,6 +43797,7 @@ var ts;
43661
43797
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43662
43798
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43663
43799
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
43800
+ state.affectingLocations.push(packageJsonPath);
43664
43801
  return result;
43665
43802
  }
43666
43803
  else {
@@ -44324,12 +44461,25 @@ var ts;
44324
44461
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44325
44462
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44326
44463
  var failedLookupLocations = [];
44464
+ var affectingLocations = [];
44327
44465
  var containingDirectory = ts.getDirectoryPath(containingFile);
44328
44466
  var diagnostics = [];
44329
- 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
+ };
44330
44479
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44331
44480
  // No originalPath because classic resolution doesn't resolve realPath
44332
- 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);
44333
44483
  function tryResolve(extensions) {
44334
44484
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44335
44485
  if (resolvedUsingSettings) {
@@ -44372,10 +44522,23 @@ var ts;
44372
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);
44373
44523
  }
44374
44524
  var failedLookupLocations = [];
44525
+ var affectingLocations = [];
44375
44526
  var diagnostics = [];
44376
- 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
+ };
44377
44539
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44378
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44540
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44541
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44379
44542
  }
44380
44543
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44381
44544
  /**
@@ -47936,16 +48099,6 @@ var ts;
47936
48099
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47937
48100
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47938
48101
  })(TypeFacts || (TypeFacts = {}));
47939
- var typeofEQFacts = new ts.Map(ts.getEntries({
47940
- string: 1 /* TypeofEQString */,
47941
- number: 2 /* TypeofEQNumber */,
47942
- bigint: 4 /* TypeofEQBigInt */,
47943
- boolean: 8 /* TypeofEQBoolean */,
47944
- symbol: 16 /* TypeofEQSymbol */,
47945
- undefined: 65536 /* EQUndefined */,
47946
- object: 32 /* TypeofEQObject */,
47947
- function: 64 /* TypeofEQFunction */
47948
- }));
47949
48102
  var typeofNEFacts = new ts.Map(ts.getEntries({
47950
48103
  string: 256 /* TypeofNEString */,
47951
48104
  number: 512 /* TypeofNENumber */,
@@ -48744,14 +48897,6 @@ var ts;
48744
48897
  var awaitedTypeStack = [];
48745
48898
  var diagnostics = ts.createDiagnosticCollection();
48746
48899
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48747
- var typeofTypesByName = new ts.Map(ts.getEntries({
48748
- string: stringType,
48749
- number: numberType,
48750
- bigint: bigintType,
48751
- boolean: booleanType,
48752
- symbol: esSymbolType,
48753
- undefined: undefinedType
48754
- }));
48755
48900
  var typeofType = createTypeofType();
48756
48901
  var _jsxNamespace;
48757
48902
  var _jsxFactoryEntity;
@@ -51627,7 +51772,7 @@ var ts;
51627
51772
  return type;
51628
51773
  }
51629
51774
  function createTypeofType() {
51630
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51775
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51631
51776
  }
51632
51777
  function createTypeParameter(symbol) {
51633
51778
  var type = createType(262144 /* TypeParameter */);
@@ -52413,6 +52558,9 @@ var ts;
52413
52558
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52414
52559
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52415
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
+ }
52416
52564
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52417
52565
  }
52418
52566
  var objectFlags = ts.getObjectFlags(type);
@@ -52603,7 +52751,7 @@ var ts;
52603
52751
  // Always use 'typeof T' for type of class, enum, and module objects
52604
52752
  else if (symbol.flags & 32 /* Class */
52605
52753
  && !getBaseTypeVariableOfClass(symbol)
52606
- && !(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 */)) ||
52607
52755
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52608
52756
  shouldWriteTypeOfFunctionSymbol()) {
52609
52757
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56233,6 +56381,17 @@ var ts;
56233
56381
  });
56234
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
56235
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
+ }
56236
56395
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56237
56396
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56238
56397
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -64416,6 +64575,9 @@ var ts;
64416
64575
  }
64417
64576
  return false;
64418
64577
  }
64578
+ function containsUndefinedType(type) {
64579
+ return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
64580
+ }
64419
64581
  function isStringIndexSignatureOnlyType(type) {
64420
64582
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64421
64583
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -69838,19 +70000,17 @@ var ts;
69838
70000
  }
69839
70001
  return links.switchTypes;
69840
70002
  }
69841
- 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
+ }
69842
70009
  var witnesses = [];
69843
70010
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
69844
70011
  var clause = _a[_i];
69845
- if (clause.kind === 289 /* CaseClause */) {
69846
- if (ts.isStringLiteralLike(clause.expression)) {
69847
- witnesses.push(clause.expression.text);
69848
- continue;
69849
- }
69850
- return ts.emptyArray;
69851
- }
69852
- if (retainDefault)
69853
- 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);
69854
70014
  }
69855
70015
  return witnesses;
69856
70016
  }
@@ -71040,14 +71200,9 @@ var ts;
71040
71200
  }
71041
71201
  return type;
71042
71202
  }
71043
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71044
- return type;
71045
- }
71046
- var facts = assumeTrue ?
71047
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71048
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71049
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71050
- 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 */);
71051
71206
  }
71052
71207
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71053
71208
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71094,102 +71249,52 @@ var ts;
71094
71249
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71095
71250
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71096
71251
  }
71097
- function getImpliedTypeFromTypeofGuard(type, text) {
71098
- switch (text) {
71099
- case "object":
71100
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71101
- case "function":
71102
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71103
- default:
71104
- 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 */);
71105
71262
  }
71263
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71106
71264
  }
71107
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71108
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71109
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71110
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71111
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71112
- // filtering by type-facts.
71113
- function narrowTypeByImpliedType(type, candidate) {
71114
- if (type.flags & 3 /* AnyOrUnknown */) {
71115
- return candidate;
71116
- }
71265
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71117
71266
  return mapType(type, function (t) {
71118
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71119
- return t;
71120
- }
71121
- return mapType(candidate, function (c) {
71122
- if (!areTypesComparable(t, c)) {
71123
- return neverType;
71124
- }
71125
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71126
- return isTypeSubtypeOf(c, t) ? c : neverType;
71127
- }
71128
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71129
- return c;
71130
- }
71131
- return getIntersectionType([t, c]);
71132
- });
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;
71133
71280
  });
71134
71281
  }
71135
71282
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71136
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71137
- if (!switchWitnesses.length) {
71283
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71284
+ if (!witnesses) {
71138
71285
  return type;
71139
71286
  }
71140
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71141
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71142
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71143
- var clauseWitnesses;
71144
- var switchFacts;
71145
- if (defaultCaseLocation > -1) {
71146
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71147
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71148
- // witness array.
71149
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71150
- // The adjusted clause start and end after removing the `default` statement.
71151
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71152
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71153
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71154
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71155
- }
71156
- else {
71157
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71158
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71159
- }
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);
71160
71290
  if (hasDefaultClause) {
71161
- 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; });
71162
71294
  }
71163
- /*
71164
- The implied type is the raw type suggested by a
71165
- value being caught in this clause.
71166
-
71167
- When the clause contains a default case we ignore
71168
- the implied type and try to narrow using any facts
71169
- we can learn: see `switchFacts`.
71170
-
71171
- Example:
71172
- switch (typeof x) {
71173
- case 'number':
71174
- case 'string': break;
71175
- default: break;
71176
- case 'number':
71177
- case 'boolean': break
71178
- }
71179
-
71180
- In the first clause (case `number` and `string`) the
71181
- implied type is number | string.
71182
-
71183
- In the default clause we de not compute an implied type.
71184
-
71185
- In the third clause (case `number` and `boolean`)
71186
- the naive implied type is number | boolean, however
71187
- we use the type facts to narrow the implied type to
71188
- boolean. We know that number cannot be selected
71189
- because it is caught in the first clause.
71190
- */
71191
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71192
- 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; }));
71193
71298
  }
71194
71299
  function isMatchingConstructorReference(expr) {
71195
71300
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71800,7 +71905,7 @@ var ts;
71800
71905
  return convertAutoToAny(flowType);
71801
71906
  }
71802
71907
  }
71803
- else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
71908
+ else if (!assumeInitialized && !containsUndefinedType(type) && containsUndefinedType(flowType)) {
71804
71909
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
71805
71910
  // Return the declared type to reduce follow-on errors
71806
71911
  return type;
@@ -74811,7 +74916,7 @@ var ts;
74811
74916
  assumeUninitialized = true;
74812
74917
  }
74813
74918
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
74814
- if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
74919
+ if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) {
74815
74920
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
74816
74921
  // Return the declared type to reduce follow-on errors
74817
74922
  return propType;
@@ -78001,45 +78106,12 @@ var ts;
78001
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
78002
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);
78003
78108
  }
78004
- /**
78005
- * Collect the TypeFacts learned from a typeof switch with
78006
- * total clauses `witnesses`, and the active clause ranging
78007
- * from `start` to `end`. Parameter `hasDefault` denotes
78008
- * whether the active clause contains a default clause.
78009
- */
78010
- 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) {
78011
78111
  var facts = 0 /* None */;
78012
- // When in the default we only collect inequality facts
78013
- // because default is 'in theory' a set of infinite
78014
- // equalities.
78015
- if (hasDefault) {
78016
- // Value is not equal to any types after the active clause.
78017
- for (var i = end; i < witnesses.length; i++) {
78018
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78019
- }
78020
- // Remove inequalities for types that appear in the
78021
- // active clause because they appear before other
78022
- // types collected so far.
78023
- for (var i = start; i < end; i++) {
78024
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78025
- }
78026
- // Add inequalities for types before the active clause unconditionally.
78027
- for (var i = 0; i < start; i++) {
78028
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78029
- }
78030
- }
78031
- // When in an active clause without default the set of
78032
- // equalities is finite.
78033
- else {
78034
- // Add equalities for all types in the active clause.
78035
- for (var i = start; i < end; i++) {
78036
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78037
- }
78038
- // Remove equalities for types that appear before the
78039
- // active clause.
78040
- for (var i = 0; i < start; i++) {
78041
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78042
- }
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;
78043
78115
  }
78044
78116
  return facts;
78045
78117
  }
@@ -78049,16 +78121,19 @@ var ts;
78049
78121
  }
78050
78122
  function computeExhaustiveSwitchStatement(node) {
78051
78123
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78052
- var operandType = getTypeOfExpression(node.expression.expression);
78053
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78054
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78055
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78056
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78057
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78058
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78059
- 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 */;
78060
78134
  }
78061
- 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; });
78062
78137
  }
78063
78138
  var type = getTypeOfExpression(node.expression);
78064
78139
  if (!isLiteralType(type)) {
@@ -81890,6 +81965,11 @@ var ts;
81890
81965
  function checkJSDocTypeTag(node) {
81891
81966
  checkSourceElement(node.typeExpression);
81892
81967
  }
81968
+ function checkJSDocLinkLikeTag(node) {
81969
+ if (node.name) {
81970
+ resolveJSDocMemberName(node.name, /*ignoreErrors*/ true);
81971
+ }
81972
+ }
81893
81973
  function checkJSDocParameterTag(node) {
81894
81974
  checkSourceElement(node.typeExpression);
81895
81975
  }
@@ -84661,7 +84741,7 @@ var ts;
84661
84741
  var propName = member.name;
84662
84742
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84663
84743
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84664
- if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84744
+ if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) {
84665
84745
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84666
84746
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84667
84747
  }
@@ -84686,7 +84766,7 @@ var ts;
84686
84766
  ts.setParent(reference, staticBlock);
84687
84767
  reference.flowNode = staticBlock.returnFlowNode;
84688
84768
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84689
- if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84769
+ if (!containsUndefinedType(flowType)) {
84690
84770
  return true;
84691
84771
  }
84692
84772
  }
@@ -84701,7 +84781,7 @@ var ts;
84701
84781
  ts.setParent(reference, constructor);
84702
84782
  reference.flowNode = constructor.returnFlowNode;
84703
84783
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84704
- return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84784
+ return !containsUndefinedType(flowType);
84705
84785
  }
84706
84786
  function checkInterfaceDeclaration(node) {
84707
84787
  // Grammar checking
@@ -85684,12 +85764,16 @@ var ts;
85684
85764
  }
85685
85765
  }
85686
85766
  function checkSourceElementWorker(node) {
85687
- if (ts.isInJSFile(node)) {
85688
- ts.forEach(node.jsDoc, function (_a) {
85689
- var tags = _a.tags;
85690
- return ts.forEach(tags, checkSourceElement);
85767
+ ts.forEach(node.jsDoc, function (_a) {
85768
+ var comment = _a.comment, tags = _a.tags;
85769
+ checkJSDocCommentWorker(comment);
85770
+ ts.forEach(tags, function (tag) {
85771
+ checkJSDocCommentWorker(tag.comment);
85772
+ if (ts.isInJSFile(node)) {
85773
+ checkSourceElement(tag);
85774
+ }
85691
85775
  });
85692
- }
85776
+ });
85693
85777
  var kind = node.kind;
85694
85778
  if (cancellationToken) {
85695
85779
  // Only bother checking on a few construct kinds. We don't want to be excessively
@@ -85775,6 +85859,10 @@ var ts;
85775
85859
  return checkJSDocTemplateTag(node);
85776
85860
  case 343 /* JSDocTypeTag */:
85777
85861
  return checkJSDocTypeTag(node);
85862
+ case 324 /* JSDocLink */:
85863
+ case 325 /* JSDocLinkCode */:
85864
+ case 326 /* JSDocLinkPlain */:
85865
+ return checkJSDocLinkLikeTag(node);
85778
85866
  case 340 /* JSDocParameterTag */:
85779
85867
  return checkJSDocParameterTag(node);
85780
85868
  case 347 /* JSDocPropertyTag */:
@@ -85869,6 +85957,15 @@ var ts;
85869
85957
  return checkMissingDeclaration(node);
85870
85958
  }
85871
85959
  }
85960
+ function checkJSDocCommentWorker(node) {
85961
+ if (ts.isArray(node)) {
85962
+ ts.forEach(node, function (tag) {
85963
+ if (ts.isJSDocLinkLike(tag)) {
85964
+ checkSourceElement(tag);
85965
+ }
85966
+ });
85967
+ }
85968
+ }
85872
85969
  function checkJSDocTypeIsInJsFile(node) {
85873
85970
  if (!ts.isInJSFile(node)) {
85874
85971
  grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
@@ -86424,7 +86521,7 @@ var ts;
86424
86521
  if (!result && isJSDoc_1) {
86425
86522
  var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
86426
86523
  if (container) {
86427
- return resolveJSDocMemberName(name, getSymbolOfNode(container));
86524
+ return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
86428
86525
  }
86429
86526
  }
86430
86527
  return result;
@@ -86470,11 +86567,11 @@ var ts;
86470
86567
  *
86471
86568
  * For unqualified names, a container K may be provided as a second argument.
86472
86569
  */
86473
- function resolveJSDocMemberName(name, container) {
86570
+ function resolveJSDocMemberName(name, ignoreErrors, container) {
86474
86571
  if (ts.isEntityName(name)) {
86475
86572
  // resolve static values first
86476
86573
  var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */;
86477
- var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86574
+ var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86478
86575
  if (!symbol && ts.isIdentifier(name) && container) {
86479
86576
  symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning));
86480
86577
  }
@@ -86482,7 +86579,7 @@ var ts;
86482
86579
  return symbol;
86483
86580
  }
86484
86581
  }
86485
- var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left);
86582
+ var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container);
86486
86583
  var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText;
86487
86584
  if (left) {
86488
86585
  var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype");
@@ -110771,7 +110868,9 @@ var ts;
110771
110868
  return;
110772
110869
  }
110773
110870
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110774
- 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 });
110775
110874
  }
110776
110875
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110777
110876
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110925,13 +111024,20 @@ var ts;
110925
111024
  if (sourceMapFilePath) {
110926
111025
  var sourceMap = sourceMapGenerator.toString();
110927
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));
110928
111029
  }
110929
111030
  }
110930
111031
  else {
110931
111032
  writer.writeLine();
110932
111033
  }
110933
111034
  // Write the output file
110934
- 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));
110935
111041
  // Reset state
110936
111042
  writer.clear();
110937
111043
  }
@@ -111074,34 +111180,56 @@ var ts;
111074
111180
  }
111075
111181
  /*@internal*/
111076
111182
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111183
+ var createHash = ts.maybeBind(host, host.createHash);
111077
111184
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111078
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111079
- 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))
111080
111200
  return buildInfoPath;
111081
111201
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111082
111202
  if (!jsFileText)
111083
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;
111084
111207
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111085
111208
  // error if no source map or for now if inline sourcemap
111086
111209
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111087
111210
  return sourceMapFilePath || "inline sourcemap decoding";
111211
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111212
+ return sourceMapFilePath;
111088
111213
  // read declaration text
111089
111214
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111090
111215
  if (declarationFilePath && !declarationText)
111091
111216
  return declarationFilePath;
111217
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111218
+ return declarationFilePath;
111092
111219
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111093
111220
  // error if no source map or for now if inline sourcemap
111094
111221
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111095
111222
  return declarationMapPath || "inline sourcemap decoding";
111096
- var buildInfo = getBuildInfo(buildInfoText);
111097
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111098
- return buildInfoPath;
111223
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111224
+ return declarationMapPath;
111099
111225
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111100
111226
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111101
111227
  /*onlyOwnText*/ true);
111102
111228
  var outputFiles = [];
111103
111229
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111104
111230
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111231
+ var changedDtsText;
111232
+ var changedDtsData;
111105
111233
  var emitHost = {
111106
111234
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111107
111235
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111117,7 +111245,7 @@ var ts;
111117
111245
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111118
111246
  getProjectReferenceRedirect: ts.returnUndefined,
111119
111247
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111120
- writeFile: function (name, text, writeByteOrderMark) {
111248
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111121
111249
  switch (name) {
111122
111250
  case jsFilePath:
111123
111251
  if (jsFileText === text)
@@ -111128,8 +111256,13 @@ var ts;
111128
111256
  return;
111129
111257
  break;
111130
111258
  case buildInfoPath:
111131
- var newBuildInfo = getBuildInfo(text);
111259
+ var newBuildInfo = data.buildInfo;
111132
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
+ }
111133
111266
  // Update sourceFileInfo
111134
111267
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111135
111268
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111137,11 +111270,13 @@ var ts;
111137
111270
  newBuildInfo.bundle.dts.sources = dts.sources;
111138
111271
  }
111139
111272
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111140
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111273
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111141
111274
  return;
111142
111275
  case declarationFilePath:
111143
111276
  if (declarationText === text)
111144
111277
  return;
111278
+ changedDtsText = text;
111279
+ changedDtsData = data;
111145
111280
  break;
111146
111281
  case declarationMapPath:
111147
111282
  if (declarationMapText === text)
@@ -111160,6 +111295,7 @@ var ts;
111160
111295
  getSourceFileFromReference: ts.returnUndefined,
111161
111296
  redirectTargetsMap: ts.createMultiMap(),
111162
111297
  getFileIncludeReasons: ts.notImplemented,
111298
+ createHash: createHash,
111163
111299
  };
111164
111300
  emitFiles(ts.notImplementedResolver, emitHost,
111165
111301
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116244,12 +116380,10 @@ var ts;
116244
116380
  }
116245
116381
  ts.createCompilerHost = createCompilerHost;
116246
116382
  /*@internal*/
116247
- // TODO(shkamat): update this after reworking ts build API
116248
116383
  function createCompilerHostWorker(options, setParentNodes, system) {
116249
116384
  if (system === void 0) { system = ts.sys; }
116250
116385
  var existingDirectories = new ts.Map();
116251
116386
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116252
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116253
116387
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116254
116388
  var text;
116255
116389
  try {
@@ -116282,7 +116416,7 @@ var ts;
116282
116416
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116283
116417
  // the system.writeFile will do its own directory creation and
116284
116418
  // the ensureDirectoriesExist call will always be redundant.
116285
- 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); });
116286
116420
  ts.performance.mark("afterIOWrite");
116287
116421
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116288
116422
  }
@@ -116292,35 +116426,6 @@ var ts;
116292
116426
  }
116293
116427
  }
116294
116428
  }
116295
- var outputFingerprints;
116296
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116297
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116298
- system.writeFile(fileName, data, writeByteOrderMark);
116299
- return;
116300
- }
116301
- if (!outputFingerprints) {
116302
- outputFingerprints = new ts.Map();
116303
- }
116304
- var hash = computeHash(data);
116305
- var mtimeBefore = system.getModifiedTime(fileName);
116306
- if (mtimeBefore) {
116307
- var fingerprint = outputFingerprints.get(fileName);
116308
- // If output has not been changed, and the file has no external modification
116309
- if (fingerprint &&
116310
- fingerprint.byteOrderMark === writeByteOrderMark &&
116311
- fingerprint.hash === hash &&
116312
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116313
- return;
116314
- }
116315
- }
116316
- system.writeFile(fileName, data, writeByteOrderMark);
116317
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116318
- outputFingerprints.set(fileName, {
116319
- hash: hash,
116320
- byteOrderMark: writeByteOrderMark,
116321
- mtime: mtimeAfter
116322
- });
116323
- }
116324
116429
  function getDefaultLibLocation() {
116325
116430
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116326
116431
  }
@@ -117920,6 +118025,7 @@ var ts;
117920
118025
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117921
118026
  redirectTargetsMap: redirectTargetsMap,
117922
118027
  getFileIncludeReasons: program.getFileIncludeReasons,
118028
+ createHash: ts.maybeBind(host, host.createHash),
117923
118029
  };
117924
118030
  }
117925
118031
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120033,13 +120139,9 @@ var ts;
120033
120139
  function createManyToManyPathMap() {
120034
120140
  function create(forward, reverse, deleted) {
120035
120141
  var map = {
120036
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120037
- forEach: function (fn) { return forward.forEach(fn); },
120038
120142
  getKeys: function (v) { return reverse.get(v); },
120039
120143
  getValues: function (k) { return forward.get(k); },
120040
- hasKey: function (k) { return forward.has(k); },
120041
120144
  keys: function () { return forward.keys(); },
120042
- deletedKeys: function () { return deleted; },
120043
120145
  deleteKey: function (k) {
120044
120146
  (deleted || (deleted = new ts.Set())).add(k);
120045
120147
  var set = forward.get(k);
@@ -120066,11 +120168,6 @@ var ts;
120066
120168
  });
120067
120169
  return map;
120068
120170
  },
120069
- clear: function () {
120070
- forward.clear();
120071
- reverse.clear();
120072
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120073
- }
120074
120171
  };
120075
120172
  return map;
120076
120173
  }
@@ -120198,18 +120295,21 @@ var ts;
120198
120295
  * Creates the state of file references and signature for the new program from oldState if it is safe
120199
120296
  */
120200
120297
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120298
+ var _a, _b, _c;
120201
120299
  var fileInfos = new ts.Map();
120202
120300
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120203
120301
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120204
- var hasCalledUpdateShapeSignature = new ts.Set();
120205
120302
  var useOldState = canReuseOldState(referencedMap, oldState);
120206
120303
  // Ensure source files have parent pointers set
120207
120304
  newProgram.getTypeChecker();
120208
120305
  // Create the reference map, and set the file infos
120209
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120210
- var sourceFile = _a[_i];
120306
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120307
+ var sourceFile = _d[_i];
120211
120308
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120212
- 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;
120213
120313
  if (referencedMap) {
120214
120314
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120215
120315
  if (newReferences) {
@@ -120217,19 +120317,26 @@ var ts;
120217
120317
  }
120218
120318
  // Copy old visible to outside files map
120219
120319
  if (useOldState) {
120220
- 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;
120221
120324
  if (exportedModules) {
120222
120325
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120223
120326
  }
120224
120327
  }
120225
120328
  }
120226
- 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
+ });
120227
120335
  }
120228
120336
  return {
120229
120337
  fileInfos: fileInfos,
120230
120338
  referencedMap: referencedMap,
120231
120339
  exportedModulesMap: exportedModulesMap,
120232
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120233
120340
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120234
120341
  };
120235
120342
  }
@@ -120243,71 +120350,42 @@ var ts;
120243
120350
  }
120244
120351
  BuilderState.releaseCache = releaseCache;
120245
120352
  /**
120246
- * Creates a clone of the state
120353
+ * Gets the files affected by the path from the program
120247
120354
  */
120248
- function clone(state) {
120355
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120249
120356
  var _a, _b;
120250
- // Dont need to backup allFiles info since its cache anyway
120251
- return {
120252
- fileInfos: new ts.Map(state.fileInfos),
120253
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120254
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120255
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120256
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120257
- };
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;
120258
120361
  }
120259
- BuilderState.clone = clone;
120260
- /**
120261
- * Gets the files affected by the path from the program
120262
- */
120263
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120264
- // Since the operation could be cancelled, the signatures are always stored in the cache
120265
- // They will be committed once it is safe to use them
120266
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120267
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120268
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120362
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120363
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120269
120364
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120270
120365
  if (!sourceFile) {
120271
120366
  return ts.emptyArray;
120272
120367
  }
120273
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120368
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120274
120369
  return [sourceFile];
120275
120370
  }
120276
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120277
- if (!cacheToUpdateSignature) {
120278
- // Commit all the signatures in the signature cache
120279
- updateSignaturesFromCache(state, signatureCache);
120280
- }
120281
- return result;
120282
- }
120283
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120284
- /**
120285
- * Updates the signatures from the cache into state's fileinfo signatures
120286
- * This should be called whenever it is safe to commit the state of the builder
120287
- */
120288
- function updateSignaturesFromCache(state, signatureCache) {
120289
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120371
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120290
120372
  }
120291
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120373
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120292
120374
  function updateSignatureOfFile(state, signature, path) {
120293
120375
  state.fileInfos.get(path).signature = signature;
120294
- state.hasCalledUpdateShapeSignature.add(path);
120376
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120295
120377
  }
120296
120378
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120297
120379
  /**
120298
120380
  * Returns if the shape of the signature has changed since last emit
120299
120381
  */
120300
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120382
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120383
+ var _a;
120301
120384
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120302
- ts.Debug.assert(!!sourceFile);
120303
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120304
120385
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120305
- 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))
120306
120387
  return false;
120307
- }
120308
120388
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120309
- if (!info)
120310
- return ts.Debug.fail();
120311
120389
  var prevSignature = info.signature;
120312
120390
  var latestSignature;
120313
120391
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120318,45 +120396,55 @@ var ts;
120318
120396
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120319
120397
  if (firstDts_1) {
120320
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; })); });
120321
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120322
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120323
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120399
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120400
+ if (latestSignature !== prevSignature) {
120401
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120324
120402
  }
120325
120403
  }
120326
120404
  }
120327
120405
  // Default is to use file version as signature
120328
120406
  if (latestSignature === undefined) {
120329
120407
  latestSignature = sourceFile.version;
120330
- 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);
120331
120410
  // All the references in this file are exported
120332
120411
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120333
120412
  if (references) {
120334
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120413
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120335
120414
  }
120336
120415
  else {
120337
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120416
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120338
120417
  }
120339
120418
  }
120340
120419
  }
120341
- 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;
120342
120423
  return latestSignature !== prevSignature;
120343
120424
  }
120344
120425
  BuilderState.updateShapeSignature = updateShapeSignature;
120426
+ function computeSignature(text, computeHash) {
120427
+ return (computeHash || ts.generateDjb2Hash)(text);
120428
+ }
120429
+ BuilderState.computeSignature = computeSignature;
120345
120430
  /**
120346
120431
  * Coverts the declaration emit result into exported modules map
120347
120432
  */
120348
- 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);
120349
120437
  if (!exportedModulesFromDeclarationEmit) {
120350
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120438
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120351
120439
  return;
120352
120440
  }
120353
120441
  var exportedModules;
120354
120442
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120355
120443
  if (exportedModules) {
120356
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120444
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120357
120445
  }
120358
120446
  else {
120359
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120447
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120360
120448
  }
120361
120449
  function addExportedModule(exportedModulePaths) {
120362
120450
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120368,19 +120456,6 @@ var ts;
120368
120456
  }
120369
120457
  }
120370
120458
  BuilderState.updateExportedModules = updateExportedModules;
120371
- /**
120372
- * Updates the exported modules from cache into state's exported modules map
120373
- * This should be called whenever it is safe to commit the state of the builder
120374
- */
120375
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120376
- var _a;
120377
- if (exportedModulesMapCache) {
120378
- ts.Debug.assert(!!state.exportedModulesMap);
120379
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120380
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120381
- }
120382
- }
120383
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120384
120459
  /**
120385
120460
  * Get all the dependencies of the sourceFile
120386
120461
  */
@@ -120501,7 +120576,7 @@ var ts;
120501
120576
  /**
120502
120577
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120503
120578
  */
120504
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120579
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120505
120580
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120506
120581
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120507
120582
  }
@@ -120521,7 +120596,7 @@ var ts;
120521
120596
  if (!seenFileNamesMap.has(currentPath)) {
120522
120597
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120523
120598
  seenFileNamesMap.set(currentPath, currentSourceFile);
120524
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120599
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120525
120600
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120526
120601
  }
120527
120602
  }
@@ -120547,32 +120622,33 @@ var ts;
120547
120622
  * Create the state so that we can iterate on changedFiles/affected files
120548
120623
  */
120549
120624
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120625
+ var _a, _b;
120550
120626
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120551
120627
  state.program = newProgram;
120552
120628
  var compilerOptions = newProgram.getCompilerOptions();
120553
120629
  state.compilerOptions = compilerOptions;
120630
+ var outFilePath = ts.outFile(compilerOptions);
120554
120631
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120555
- if (!ts.outFile(compilerOptions)) {
120632
+ if (!outFilePath) {
120556
120633
  state.semanticDiagnosticsPerFile = new ts.Map();
120557
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
+ }
120558
120638
  state.changedFilesSet = new ts.Set();
120639
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120559
120640
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120560
120641
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120561
120642
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120562
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);
120563
120648
  if (useOldState) {
120564
- // Verify the sanity of old state
120565
- if (!oldState.currentChangedFilePath) {
120566
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120567
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120568
- }
120569
- var changedFilesSet = oldState.changedFilesSet;
120570
- if (canCopySemanticDiagnostics) {
120571
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120572
- }
120573
120649
  // Copy old state's changed files set
120574
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120575
- 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) {
120576
120652
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120577
120653
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120578
120654
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120593,6 +120669,8 @@ var ts;
120593
120669
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120594
120670
  // versions dont match
120595
120671
  oldInfo.version !== info.version ||
120672
+ // Implied formats dont match
120673
+ oldInfo.impliedFormat !== info.impliedFormat ||
120596
120674
  // Referenced files changed
120597
120675
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120598
120676
  // Referenced file was deleted in the new program
@@ -120616,27 +120694,25 @@ var ts;
120616
120694
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120617
120695
  }
120618
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
+ }
120619
120702
  });
120620
120703
  // If the global file is removed, add all files as changed
120621
120704
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120622
120705
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120623
120706
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120624
120707
  }
120625
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120708
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120626
120709
  // Add all files to affectedFilesPendingEmit since emit changed
120627
120710
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120628
120711
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120629
120712
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120630
120713
  }
120631
- if (useOldState) {
120632
- // Any time the interpretation of a source file changes, mark it as changed
120633
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120634
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120635
- state.changedFilesSet.add(sourceFilePath);
120636
- }
120637
- });
120638
- }
120639
- 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);
120640
120716
  return state;
120641
120717
  }
120642
120718
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120672,30 +120748,35 @@ var ts;
120672
120748
  ts.BuilderState.releaseCache(state);
120673
120749
  state.program = undefined;
120674
120750
  }
120675
- /**
120676
- * Creates a clone of the state
120677
- */
120678
- function cloneBuilderProgramState(state) {
120679
- var _a;
120680
- var newState = ts.BuilderState.clone(state);
120681
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120682
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120683
- newState.affectedFiles = state.affectedFiles;
120684
- newState.affectedFilesIndex = state.affectedFilesIndex;
120685
- newState.currentChangedFilePath = state.currentChangedFilePath;
120686
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120687
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120688
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120689
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120690
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120691
- newState.program = state.program;
120692
- newState.compilerOptions = state.compilerOptions;
120693
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120694
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120695
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120696
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120697
- newState.programEmitComplete = state.programEmitComplete;
120698
- 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;
120699
120780
  }
120700
120781
  /**
120701
120782
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120710,7 +120791,7 @@ var ts;
120710
120791
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120711
120792
  */
120712
120793
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120713
- var _a;
120794
+ var _a, _b;
120714
120795
  while (true) {
120715
120796
  var affectedFiles = state.affectedFiles;
120716
120797
  if (affectedFiles) {
@@ -120730,10 +120811,8 @@ var ts;
120730
120811
  state.changedFilesSet.delete(state.currentChangedFilePath);
120731
120812
  state.currentChangedFilePath = undefined;
120732
120813
  // Commit the changes in file signature
120733
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120734
- state.currentAffectedFilesSignatures.clear();
120735
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120736
- (_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();
120737
120816
  state.affectedFiles = undefined;
120738
120817
  }
120739
120818
  // Get next changed file
@@ -120751,12 +120830,7 @@ var ts;
120751
120830
  return program;
120752
120831
  }
120753
120832
  // Get next batch of affected files
120754
- if (!state.currentAffectedFilesSignatures)
120755
- state.currentAffectedFilesSignatures = new ts.Map();
120756
- if (state.exportedModulesMap) {
120757
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120758
- }
120759
- 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);
120760
120834
  state.currentChangedFilePath = nextKey.value;
120761
120835
  state.affectedFilesIndex = 0;
120762
120836
  if (!state.seenAffectedFiles)
@@ -120808,7 +120882,6 @@ var ts;
120808
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
120809
120883
  */
120810
120884
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120811
- var _a;
120812
120885
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120813
120886
  // If affected files is everything except default library, then nothing more to do
120814
120887
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120816,10 +120889,9 @@ var ts;
120816
120889
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120817
120890
  // That means when affected file is handled, its signature can be out of date
120818
120891
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120819
- 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);
120820
120893
  return;
120821
120894
  }
120822
- 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);
120823
120895
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120824
120896
  return;
120825
120897
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120839,7 +120911,7 @@ var ts;
120839
120911
  // This ensures that we dont later during incremental builds considering wrong signature.
120840
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
120841
120913
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120842
- 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);
120843
120915
  // If not dts emit, nothing more to do
120844
120916
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120845
120917
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120860,27 +120932,10 @@ var ts;
120860
120932
  return !state.semanticDiagnosticsFromOldState.size;
120861
120933
  }
120862
120934
  function isChangedSignature(state, path) {
120863
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120864
- 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;
120865
120937
  return newSignature !== oldSignature;
120866
120938
  }
120867
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120868
- // Go through exported modules from cache first
120869
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120870
- var result = keys && ts.forEachKey(keys, fn);
120871
- if (result)
120872
- return result;
120873
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120874
- keys = state.exportedModulesMap.getKeys(filePath);
120875
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120876
- var _a;
120877
- // If the cache had an updated value, skip
120878
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120879
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120880
- fn(exportedFromPath) :
120881
- undefined;
120882
- });
120883
- }
120884
120939
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120885
120940
  var _a;
120886
120941
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120895,6 +120950,7 @@ var ts;
120895
120950
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120896
120951
  */
120897
120952
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120953
+ var _a;
120898
120954
  // If there was change in signature (dts output) for the changed file,
120899
120955
  // then only we need to handle pending file emit
120900
120956
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120921,11 +120977,10 @@ var ts;
120921
120977
  }
120922
120978
  }
120923
120979
  }
120924
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120925
120980
  var seenFileAndExportsOfFile = new ts.Set();
120926
120981
  // Go through exported modules from cache first
120927
120982
  // If exported modules has path, all files referencing file exported from are affected
120928
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120983
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120929
120984
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120930
120985
  return true;
120931
120986
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120939,19 +120994,18 @@ var ts;
120939
120994
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120940
120995
  */
120941
120996
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120942
- var _a;
120997
+ var _a, _b;
120943
120998
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120944
120999
  return undefined;
120945
121000
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120946
121001
  return true;
120947
121002
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120948
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120949
121003
  // If exported modules has path, all files referencing file exported from are affected
120950
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121004
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120951
121005
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120952
121006
  });
120953
121007
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120954
- (_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) {
120955
121009
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120956
121010
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120957
121011
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120972,12 +121026,13 @@ var ts;
120972
121026
  }
120973
121027
  else {
120974
121028
  state.seenAffectedFiles.add(affected.resolvedPath);
121029
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121030
+ state.buildInfoEmitPending = true;
120975
121031
  if (emitKind !== undefined) {
120976
121032
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120977
121033
  }
120978
121034
  if (isPendingEmit) {
120979
121035
  state.affectedFilesPendingEmitIndex++;
120980
- state.buildInfoEmitPending = true;
120981
121036
  }
120982
121037
  else {
120983
121038
  state.affectedFilesIndex++;
@@ -121025,25 +121080,62 @@ var ts;
121025
121080
  }
121026
121081
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121027
121082
  }
121083
+ function isProgramBundleEmitBuildInfo(info) {
121084
+ return !!ts.outFile(info.options || {});
121085
+ }
121086
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121028
121087
  /**
121029
121088
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121030
121089
  */
121031
- function getProgramBuildInfo(state, getCanonicalFileName) {
121032
- if (ts.outFile(state.compilerOptions))
121033
- return undefined;
121090
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121091
+ var outFilePath = ts.outFile(state.compilerOptions);
121092
+ if (outFilePath && !state.compilerOptions.composite)
121093
+ return;
121034
121094
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121035
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
+ }
121036
121117
  var fileNames = [];
121037
121118
  var fileNameToFileId = new ts.Map();
121038
121119
  var fileIdsList;
121039
121120
  var fileNamesToFileIdListId;
121121
+ var emitSignatures;
121040
121122
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121123
+ var _b, _c;
121041
121124
  var key = _a[0], value = _a[1];
121042
121125
  // Ensure fileId
121043
121126
  var fileId = toFileId(key);
121044
121127
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121045
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121046
- 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
+ }
121047
121139
  return value.version === actualSignature ?
121048
121140
  value.affectsGlobalScope || value.impliedFormat ?
121049
121141
  // If file version is same as signature, dont serialize signature
@@ -121051,11 +121143,11 @@ var ts;
121051
121143
  // If file info only contains version and signature and both are same we can just write string
121052
121144
  value.version :
121053
121145
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121054
- signature === undefined ?
121146
+ oldSignature === undefined ?
121055
121147
  // If we havent computed signature, use fileInfo as is
121056
121148
  value :
121057
121149
  // Serialize fileInfo with new updated signature
121058
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121150
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121059
121151
  // Signature of the FileInfo is undefined, serialize it as false
121060
121152
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121061
121153
  });
@@ -121070,17 +121162,13 @@ var ts;
121070
121162
  if (state.exportedModulesMap) {
121071
121163
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121072
121164
  var _a;
121073
- if (state.currentAffectedFilesExportedModulesMap) {
121074
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121075
- return undefined;
121076
- }
121077
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121078
- if (newValue) {
121079
- return [toFileId(key), toFileIdListId(newValue)];
121080
- }
121081
- }
121165
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121082
121166
  // Not in temporary cache, use existing value
121083
- 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;
121084
121172
  });
121085
121173
  }
121086
121174
  var semanticDiagnosticsPerFile;
@@ -121091,9 +121179,7 @@ var ts;
121091
121179
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121092
121180
  [
121093
121181
  toFileId(key),
121094
- state.hasReusableDiagnostic ?
121095
- value :
121096
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121182
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121097
121183
  ] :
121098
121184
  toFileId(key));
121099
121185
  }
@@ -121108,16 +121194,27 @@ var ts;
121108
121194
  }
121109
121195
  }
121110
121196
  }
121111
- 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 = {
121112
121205
  fileNames: fileNames,
121113
121206
  fileInfos: fileInfos,
121114
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121207
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121115
121208
  fileIdsList: fileIdsList,
121116
121209
  referencedMap: referencedMap,
121117
121210
  exportedModulesMap: exportedModulesMap,
121118
121211
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121119
121212
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121213
+ changeFileSet: changeFileSet,
121214
+ emitSignatures: emitSignatures,
121215
+ dtsChangeTime: state.dtsChangeTime,
121120
121216
  };
121217
+ return result;
121121
121218
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121122
121219
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121123
121220
  }
@@ -121142,24 +121239,21 @@ var ts;
121142
121239
  }
121143
121240
  return fileIdListId;
121144
121241
  }
121145
- }
121146
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121147
- var result;
121148
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121149
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121150
- var name = _a[_i];
121151
- var optionKey = name.toLowerCase();
121152
- var optionInfo = optionsNameMap.get(optionKey);
121153
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121154
- // We need to store `strict`, even though it won't be examined directly, so that the
121155
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121156
- optionKey === "strict" ||
121157
- // We need to store these to determine whether `lib` files need to be rechecked.
121158
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121159
- (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
+ }
121160
121254
  }
121255
+ return result;
121161
121256
  }
121162
- return result;
121163
121257
  }
121164
121258
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121165
121259
  if (option) {
@@ -121233,6 +121327,10 @@ var ts;
121233
121327
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121234
121328
  }
121235
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;
121236
121334
  function createBuilderProgram(kind, _a) {
121237
121335
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121238
121336
  // Return same program if underlying program doesnt change
@@ -121251,8 +121349,7 @@ var ts;
121251
121349
  */
121252
121350
  var computeHash = ts.maybeBind(host, host.createHash);
121253
121351
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121254
- var backupState;
121255
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121352
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121256
121353
  // To ensure that we arent storing any references to old program or new program without state
121257
121354
  newProgram = undefined; // TODO: GH#18217
121258
121355
  oldProgram = undefined;
@@ -121260,21 +121357,12 @@ var ts;
121260
121357
  var getState = function () { return state; };
121261
121358
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121262
121359
  builderProgram.getState = getState;
121263
- builderProgram.backupState = function () {
121264
- ts.Debug.assert(backupState === undefined);
121265
- backupState = cloneBuilderProgramState(state);
121266
- };
121267
- builderProgram.restoreState = function () {
121268
- state = ts.Debug.checkDefined(backupState);
121269
- backupState = undefined;
121270
- };
121360
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121361
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121271
121362
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121272
121363
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121273
121364
  builderProgram.emit = emit;
121274
- builderProgram.releaseProgram = function () {
121275
- releaseCache(state);
121276
- backupState = undefined;
121277
- };
121365
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121278
121366
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121279
121367
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121280
121368
  }
@@ -121332,35 +121420,62 @@ var ts;
121332
121420
  return toAffectedFileEmitResult(state,
121333
121421
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121334
121422
  // Otherwise just affected file
121335
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121336
- getWriteFileUpdatingSignatureCallback(writeFile) :
121423
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121424
+ getWriteFileCallback(writeFile, customTransformers) :
121337
121425
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121338
121426
  }
121339
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121427
+ function getWriteFileCallback(writeFile, customTransformers) {
121340
121428
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121341
- var _a;
121429
+ var _a, _b, _c;
121342
121430
  if (ts.isDeclarationFileName(fileName)) {
121343
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121344
- var file = sourceFiles[0];
121345
- var info = state.fileInfos.get(file.resolvedPath);
121346
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121347
- if (signature === file.version) {
121348
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121349
- if (newSignature !== file.version) { // Update it
121350
- if (host.storeFilesChangingSignatureDuringEmit)
121351
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121352
- if (state.exportedModulesMap)
121353
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121354
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121355
- 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
+ }
121356
121457
  }
121357
- else {
121358
- info.signature = newSignature;
121359
- if (state.exportedModulesMap)
121360
- 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;
121361
121469
  }
121362
121470
  }
121363
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
+ }
121364
121479
  }
121365
121480
  if (writeFile)
121366
121481
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121425,8 +121540,8 @@ var ts;
121425
121540
  }
121426
121541
  }
121427
121542
  }
121428
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121429
- getWriteFileUpdatingSignatureCallback(writeFile) :
121543
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121544
+ getWriteFileCallback(writeFile, customTransformers) :
121430
121545
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121431
121546
  }
121432
121547
  /**
@@ -121515,29 +121630,58 @@ var ts;
121515
121630
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121516
121631
  }
121517
121632
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121518
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121519
- var _a;
121633
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121634
+ var _a, _b, _c, _d;
121520
121635
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121521
121636
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121522
- var filePaths = program.fileNames.map(toPath);
121523
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121524
- var fileInfos = new ts.Map();
121525
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121526
- var state = {
121527
- fileInfos: fileInfos,
121528
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121529
- referencedMap: toManyToManyPathMap(program.referencedMap),
121530
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121531
- 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]; }),
121532
- hasReusableDiagnostic: true,
121533
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121534
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121535
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121536
- };
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
+ }
121537
121681
  return {
121538
121682
  getState: function () { return state; },
121539
- backupState: ts.noop,
121540
- restoreState: ts.noop,
121683
+ saveEmitState: ts.noop,
121684
+ restoreEmitState: ts.noop,
121541
121685
  getProgram: ts.notImplemented,
121542
121686
  getProgramOrUndefined: ts.returnUndefined,
121543
121687
  releaseProgram: ts.noop,
@@ -121582,12 +121726,24 @@ var ts;
121582
121726
  return map;
121583
121727
  }
121584
121728
  }
121585
- 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;
121586
121742
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121587
121743
  return {
121588
121744
  getState: ts.notImplemented,
121589
- backupState: ts.noop,
121590
- restoreState: ts.noop,
121745
+ saveEmitState: ts.noop,
121746
+ restoreEmitState: ts.noop,
121591
121747
  getProgram: getProgram,
121592
121748
  getProgramOrUndefined: function () { return getState().program; },
121593
121749
  releaseProgram: function () { return getState().program = undefined; },
@@ -121691,8 +121847,10 @@ var ts;
121691
121847
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121692
121848
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121693
121849
  var resolutionsWithFailedLookups = [];
121850
+ var resolutionsWithOnlyAffectingLocations = [];
121694
121851
  var resolvedFileToResolution = ts.createMultiMap();
121695
121852
  var hasChangedAutomaticTypeDirectiveNames = false;
121853
+ var affectingPathChecks;
121696
121854
  var failedLookupChecks;
121697
121855
  var startsWithPathChecks;
121698
121856
  var isInDirectoryChecks;
@@ -121719,6 +121877,7 @@ var ts;
121719
121877
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121720
121878
  var customFailedLookupPaths = new ts.Map();
121721
121879
  var directoryWatchesOfFailedLookups = new ts.Map();
121880
+ var fileWatchesOfAffectingLocations = new ts.Map();
121722
121881
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121723
121882
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121724
121883
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121761,6 +121920,7 @@ var ts;
121761
121920
  }
121762
121921
  function clear() {
121763
121922
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
121923
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121764
121924
  customFailedLookupPaths.clear();
121765
121925
  nonRelativeExternalModuleResolutions.clear();
121766
121926
  closeTypeRootsWatch();
@@ -121768,9 +121928,11 @@ var ts;
121768
121928
  resolvedTypeReferenceDirectives.clear();
121769
121929
  resolvedFileToResolution.clear();
121770
121930
  resolutionsWithFailedLookups.length = 0;
121931
+ resolutionsWithOnlyAffectingLocations.length = 0;
121771
121932
  failedLookupChecks = undefined;
121772
121933
  startsWithPathChecks = undefined;
121773
121934
  isInDirectoryChecks = undefined;
121935
+ affectingPathChecks = undefined;
121774
121936
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
121775
121937
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
121776
121938
  clearPerDirectoryResolutions();
@@ -121820,10 +121982,18 @@ var ts;
121820
121982
  watcher.watcher.close();
121821
121983
  }
121822
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
+ });
121823
121993
  hasChangedAutomaticTypeDirectiveNames = false;
121824
121994
  }
121825
121995
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
121826
- var _a;
121996
+ var _a, _b;
121827
121997
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
121828
121998
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
121829
121999
  if (!resolutionHost.getGlobalCache) {
@@ -121834,11 +122004,12 @@ var ts;
121834
122004
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
121835
122005
  // create different collection of failed lookup locations for second pass
121836
122006
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
121837
- 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;
121838
122008
  if (resolvedModule) {
121839
122009
  // Modify existing resolution so its saved in the directory cache as well
121840
122010
  primaryResult.resolvedModule = resolvedModule;
121841
122011
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122012
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
121842
122013
  return primaryResult;
121843
122014
  }
121844
122015
  }
@@ -122089,10 +122260,11 @@ var ts;
122089
122260
  }
122090
122261
  function watchFailedLookupLocationOfResolution(resolution) {
122091
122262
  ts.Debug.assert(!!resolution.refCount);
122092
- var failedLookupLocations = resolution.failedLookupLocations;
122093
- if (!failedLookupLocations.length)
122263
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122264
+ if (!failedLookupLocations.length && !affectingLocations.length)
122094
122265
  return;
122095
- resolutionsWithFailedLookups.push(resolution);
122266
+ if (failedLookupLocations.length)
122267
+ resolutionsWithFailedLookups.push(resolution);
122096
122268
  var setAtRoot = false;
122097
122269
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122098
122270
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122119,12 +122291,66 @@ var ts;
122119
122291
  // This is always non recursive
122120
122292
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122121
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
+ }
122122
122345
  }
122123
122346
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122124
122347
  var program = resolutionHost.getCurrentProgram();
122125
122348
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122126
122349
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122127
122350
  }
122351
+ else {
122352
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122353
+ }
122128
122354
  }
122129
122355
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122130
122356
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122146,38 +122372,44 @@ var ts;
122146
122372
  if (resolved && resolved.resolvedFileName) {
122147
122373
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122148
122374
  }
122149
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122150
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122151
- return;
122152
- }
122153
- var failedLookupLocations = resolution.failedLookupLocations;
122154
- var removeAtRoot = false;
122155
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122156
- var failedLookupLocation = failedLookupLocations_2[_i];
122157
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122158
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122159
- if (toWatch) {
122160
- var dirPath = toWatch.dirPath;
122161
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122162
- if (refCount) {
122163
- if (refCount === 1) {
122164
- 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;
122165
122396
  }
122166
122397
  else {
122167
- ts.Debug.assert(refCount > 1);
122168
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122398
+ removeDirectoryWatcher(dirPath);
122169
122399
  }
122170
122400
  }
122171
- if (dirPath === rootPath) {
122172
- removeAtRoot = true;
122173
- }
122174
- else {
122175
- removeDirectoryWatcher(dirPath);
122176
- }
122401
+ }
122402
+ if (removeAtRoot) {
122403
+ removeDirectoryWatcher(rootPath);
122177
122404
  }
122178
122405
  }
122179
- if (removeAtRoot) {
122180
- removeDirectoryWatcher(rootPath);
122406
+ else if (affectingLocations.length) {
122407
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
122408
+ }
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--;
122181
122413
  }
122182
122414
  }
122183
122415
  function removeDirectoryWatcher(dirPath) {
@@ -122256,7 +122488,7 @@ var ts;
122256
122488
  if (isCreatingWatchedDirectory) {
122257
122489
  // Watching directory is created
122258
122490
  // Invalidate any resolution has failed lookup in this directory
122259
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122491
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122260
122492
  }
122261
122493
  else {
122262
122494
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122274,7 +122506,7 @@ var ts;
122274
122506
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122275
122507
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122276
122508
  // Invalidate any resolution from this directory
122277
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122509
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122278
122510
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122279
122511
  }
122280
122512
  else {
@@ -122286,7 +122518,7 @@ var ts;
122286
122518
  return false;
122287
122519
  }
122288
122520
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122289
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122521
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122290
122522
  // If the invalidated file is from a node_modules package, invalidate everything else
122291
122523
  // in the package since we might not get notifications for other files in the package.
122292
122524
  // This hardens our logic against unreliable file watchers.
@@ -122298,21 +122530,32 @@ var ts;
122298
122530
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122299
122531
  }
122300
122532
  function invalidateResolutionsOfFailedLookupLocations() {
122301
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122533
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122302
122534
  return false;
122303
122535
  }
122304
122536
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122305
122537
  failedLookupChecks = undefined;
122306
122538
  startsWithPathChecks = undefined;
122307
122539
  isInDirectoryChecks = undefined;
122540
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122541
+ affectingPathChecks = undefined;
122308
122542
  return invalidated;
122309
122543
  }
122310
122544
  function canInvalidateFailedLookupResolution(resolution) {
122545
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122546
+ return true;
122547
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122548
+ return false;
122311
122549
  return resolution.failedLookupLocations.some(function (location) {
122312
122550
  var locationPath = resolutionHost.toPath(location);
122313
- return ts.contains(failedLookupChecks, locationPath) ||
122551
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122314
122552
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122315
- (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));
122316
122559
  });
122317
122560
  }
122318
122561
  function closeTypeRootsWatch() {
@@ -122703,9 +122946,9 @@ var ts;
122703
122946
  if (!preferSymlinks) {
122704
122947
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122705
122948
  // so we only need to remove them from the realpath filenames.
122706
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122707
- if (result_15)
122708
- 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;
122709
122952
  }
122710
122953
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122711
122954
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122725,10 +122968,10 @@ var ts;
122725
122968
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122726
122969
  var symlinkDirectory = symlinkDirectories_1[_i];
122727
122970
  var option = ts.resolvePath(symlinkDirectory, relative);
122728
- var result_16 = cb(option, target === referenceRedirect);
122971
+ var result_17 = cb(option, target === referenceRedirect);
122729
122972
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122730
- if (result_16)
122731
- return result_16;
122973
+ if (result_17)
122974
+ return result_17;
122732
122975
  }
122733
122976
  });
122734
122977
  });
@@ -123638,6 +123881,7 @@ var ts;
123638
123881
  readDirectory: ts.maybeBind(host, host.readDirectory),
123639
123882
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123640
123883
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123884
+ now: ts.maybeBind(host, host.now),
123641
123885
  };
123642
123886
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123643
123887
  try {
@@ -123698,6 +123942,7 @@ var ts;
123698
123942
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123699
123943
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123700
123944
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123945
+ now: ts.maybeBind(system, system.now),
123701
123946
  };
123702
123947
  }
123703
123948
  ts.createProgramHost = createProgramHost;
@@ -123765,20 +124010,27 @@ var ts;
123765
124010
  var ts;
123766
124011
  (function (ts) {
123767
124012
  function readBuilderProgram(compilerOptions, host) {
123768
- if (ts.outFile(compilerOptions))
123769
- return undefined;
123770
124013
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123771
124014
  if (!buildInfoPath)
123772
124015
  return undefined;
123773
- var content = host.readFile(buildInfoPath);
123774
- if (!content)
123775
- return undefined;
123776
- 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
+ }
123777
124029
  if (buildInfo.version !== ts.version)
123778
124030
  return undefined;
123779
124031
  if (!buildInfo.program)
123780
124032
  return undefined;
123781
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124033
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123782
124034
  }
123783
124035
  ts.readBuilderProgram = readBuilderProgram;
123784
124036
  function createIncrementalCompilerHost(options, system) {
@@ -123787,6 +124039,7 @@ var ts;
123787
124039
  host.createHash = ts.maybeBind(system, system.createHash);
123788
124040
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123789
124041
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124042
+ host.now = ts.maybeBind(system, system.now);
123790
124043
  ts.setGetSourceFileAsHashVersioned(host, system);
123791
124044
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123792
124045
  return host;
@@ -123831,7 +124084,6 @@ var ts;
123831
124084
  var builderProgram;
123832
124085
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
123833
124086
  var missingFilesMap; // Map of file watchers for the missing files
123834
- var packageJsonMap; // map of watchers for package json files used in module resolution
123835
124087
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
123836
124088
  var timerToUpdateProgram; // timer callback to recompile the program
123837
124089
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -123895,6 +124147,7 @@ var ts;
123895
124147
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
123896
124148
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
123897
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); };
123898
124151
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
123899
124152
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
123900
124153
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -123977,10 +124230,6 @@ var ts;
123977
124230
  });
123978
124231
  parsedConfigs = undefined;
123979
124232
  }
123980
- if (packageJsonMap) {
123981
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
123982
- packageJsonMap = undefined;
123983
- }
123984
124233
  }
123985
124234
  function getCurrentBuilderProgram() {
123986
124235
  return builderProgram;
@@ -124036,15 +124285,9 @@ var ts;
124036
124285
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124037
124286
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124038
124287
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124039
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124040
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124041
- var path = _a[0], data = _a[1];
124042
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124043
- });
124044
124288
  resolutionCache.finishCachingPerDirectoryResolution();
124045
124289
  // Update watches
124046
124290
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124047
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124048
124291
  if (needsUpdateInTypeRootWatch) {
124049
124292
  resolutionCache.updateTypeRootsWatch();
124050
124293
  }
@@ -124350,21 +124593,6 @@ var ts;
124350
124593
  ts.noopFileWatcher :
124351
124594
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124352
124595
  }
124353
- function watchPackageJsonLookupPath(packageJsonPath) {
124354
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124355
- return sourceFilesCache.has(packageJsonPath) ?
124356
- ts.noopFileWatcher :
124357
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124358
- }
124359
- function onPackageJsonChange(fileName, eventKind, path) {
124360
- updateCachedSystemWithFile(fileName, path, eventKind);
124361
- // package.json changes invalidate module resolution and can change the set of loaded files
124362
- // so if we witness a change to one, we have to do a full reload
124363
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124364
- changesAffectResolution = true;
124365
- // Update the program
124366
- scheduleProgramUpdate();
124367
- }
124368
124596
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124369
124597
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124370
124598
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124522,14 +124750,17 @@ var ts;
124522
124750
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124523
124751
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124524
124752
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124525
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124526
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124527
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124528
- 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";
124529
124759
  /**
124530
124760
  * Projects with no outputs (i.e. "solution" files)
124531
124761
  */
124532
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124762
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124763
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124533
124764
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124534
124765
  function resolveConfigFileProjectName(project) {
124535
124766
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124574,9 +124805,12 @@ var ts;
124574
124805
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124575
124806
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124576
124807
  }
124577
- function newer(date1, date2) {
124578
- 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();
124579
124812
  }
124813
+ ts.getCurrentTime = getCurrentTime;
124580
124814
  /*@internal*/
124581
124815
  function isCircularBuildOrder(buildOrder) {
124582
124816
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124666,6 +124900,7 @@ var ts;
124666
124900
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124667
124901
  };
124668
124902
  }
124903
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124669
124904
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124670
124905
  var state = {
124671
124906
  host: host,
@@ -124682,8 +124917,9 @@ var ts;
124682
124917
  resolvedConfigFilePaths: new ts.Map(),
124683
124918
  configFileCache: new ts.Map(),
124684
124919
  projectStatus: new ts.Map(),
124685
- buildInfoChecked: new ts.Map(),
124686
124920
  extendedConfigCache: new ts.Map(),
124921
+ buildInfoCache: new ts.Map(),
124922
+ outputTimeStamps: new ts.Map(),
124687
124923
  builderPrograms: new ts.Map(),
124688
124924
  diagnostics: new ts.Map(),
124689
124925
  projectPendingBuild: new ts.Map(),
@@ -124706,6 +124942,7 @@ var ts;
124706
124942
  allWatchedConfigFiles: new ts.Map(),
124707
124943
  allWatchedExtendedConfigFiles: new ts.Map(),
124708
124944
  allWatchedPackageJsonFiles: new ts.Map(),
124945
+ filesWatched: new ts.Map(),
124709
124946
  lastCachedPackageJsonLookups: new ts.Map(),
124710
124947
  timerToBuildInvalidatedProject: undefined,
124711
124948
  reportFileChangeDetected: false,
@@ -124812,11 +125049,12 @@ var ts;
124812
125049
  // Config file cache
124813
125050
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124814
125051
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124815
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124816
125052
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124817
125053
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124818
125054
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124819
125055
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125056
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125057
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124820
125058
  // Remove watches for the program no longer in the solution
124821
125059
  if (state.watch) {
124822
125060
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125106,21 +125344,21 @@ var ts;
125106
125344
  }
125107
125345
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125108
125346
  var _a;
125109
- var _b, _c;
125347
+ var _b, _c, _d;
125110
125348
  ts.Debug.assertIsDefined(program);
125111
125349
  ts.Debug.assert(step === BuildStep.Emit);
125112
125350
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125113
- program.backupState();
125351
+ var saved = program.saveEmitState();
125114
125352
  var declDiagnostics;
125115
125353
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125116
125354
  var outputFiles = [];
125117
125355
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125118
125356
  /*write*/ undefined,
125119
- /*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,
125120
125358
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125121
125359
  // Don't emit .d.ts if there are decl file errors
125122
125360
  if (declDiagnostics) {
125123
- program.restoreState();
125361
+ program.restoreEmitState(saved);
125124
125362
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125125
125363
  return {
125126
125364
  emitSkipped: true,
@@ -125130,37 +125368,44 @@ var ts;
125130
125368
  // Actual Emit
125131
125369
  var host = state.host, compilerHost = state.compilerHost;
125132
125370
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125133
- var newestDeclarationFileContentChangedTime = minimumDate;
125134
- var anyDtsChanged = false;
125371
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125135
125372
  var emitterDiagnostics = ts.createDiagnosticCollection();
125136
125373
  var emittedOutputs = new ts.Map();
125374
+ var options = program.getCompilerOptions();
125375
+ var isIncremental = ts.isIncrementalCompilation(options);
125376
+ var outputTimeStampMap;
125377
+ var now;
125137
125378
  outputFiles.forEach(function (_a) {
125138
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125139
- var priorChangeTime;
125140
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125141
- // Check for unchanged .d.ts files
125142
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125143
- priorChangeTime = host.getModifiedTime(name);
125144
- }
125145
- 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)) {
125146
125387
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125147
- anyDtsChanged = true;
125148
125388
  }
125149
125389
  }
125150
- emittedOutputs.set(toPath(state, name), name);
125151
125390
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125152
- if (priorChangeTime !== undefined) {
125153
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125391
+ if (!isIncremental && state.watch) {
125392
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125154
125393
  }
125155
125394
  });
125156
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125157
- /*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);
125158
125396
  return emitResult;
125159
125397
  }
125160
125398
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125161
125399
  ts.Debug.assertIsDefined(program);
125162
125400
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125163
- 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);
125164
125409
  if (emitResult.diagnostics.length) {
125165
125410
  reportErrors(state, emitResult.diagnostics);
125166
125411
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125173,7 +125418,7 @@ var ts;
125173
125418
  step = BuildStep.QueueReferencingProjects;
125174
125419
  return emitResult;
125175
125420
  }
125176
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125421
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125177
125422
  var _a;
125178
125423
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125179
125424
  if (emitDiagnostics.length) {
@@ -125184,13 +125429,11 @@ var ts;
125184
125429
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125185
125430
  }
125186
125431
  // Update time stamps for rest of the outputs
125187
- 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);
125188
125433
  state.diagnostics.delete(projectPath);
125189
125434
  state.projectStatus.set(projectPath, {
125190
125435
  type: ts.UpToDateStatusType.UpToDate,
125191
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125192
- maximumDate :
125193
- newestDeclarationFileContentChangedTime,
125436
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125194
125437
  oldestOutputFileName: oldestOutputFileName
125195
125438
  });
125196
125439
  afterProgramDone(state, program, config);
@@ -125225,13 +125468,21 @@ var ts;
125225
125468
  ts.Debug.assert(!!outputFiles.length);
125226
125469
  var emitterDiagnostics = ts.createDiagnosticCollection();
125227
125470
  var emittedOutputs = new ts.Map();
125471
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125472
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125228
125473
  outputFiles.forEach(function (_a) {
125229
- 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;
125230
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
+ }
125231
125483
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125232
125484
  });
125233
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125234
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125485
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125235
125486
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125236
125487
  }
125237
125488
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125330,7 +125581,7 @@ var ts;
125330
125581
  }
125331
125582
  continue;
125332
125583
  }
125333
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125584
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125334
125585
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125335
125586
  return {
125336
125587
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125415,7 +125666,8 @@ var ts;
125415
125666
  state.projectCompilerOptions = state.baseCompilerOptions;
125416
125667
  }
125417
125668
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125418
- 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());
125419
125671
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125420
125672
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125421
125673
  if (canEmitBuildInfo)
@@ -125423,9 +125675,99 @@ var ts;
125423
125675
  afterProgramDone(state, program, config);
125424
125676
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125425
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
+ }
125426
125768
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125427
125769
  // Check tsconfig time
125428
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125770
+ var tsconfigTime = getModifiedTime(state, configFile);
125429
125771
  if (oldestOutputFileTime < tsconfigTime) {
125430
125772
  return {
125431
125773
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125435,88 +125777,24 @@ var ts;
125435
125777
  }
125436
125778
  }
125437
125779
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125438
- var force = !!state.options.force;
125439
- var newestInputFileName = undefined;
125440
- var newestInputFileTime = minimumDate;
125441
- var host = state.host;
125442
- // Get timestamps of input files
125443
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125444
- var inputFile = _a[_i];
125445
- if (!host.fileExists(inputFile)) {
125446
- return {
125447
- type: ts.UpToDateStatusType.Unbuildable,
125448
- reason: inputFile + " does not exist"
125449
- };
125450
- }
125451
- if (!force) {
125452
- var inputTime = ts.getModifiedTime(host, inputFile);
125453
- if (inputTime > newestInputFileTime) {
125454
- newestInputFileName = inputFile;
125455
- newestInputFileTime = inputTime;
125456
- }
125457
- }
125458
- }
125780
+ var _a, _b, _c;
125459
125781
  // Container if no files are specified in the project
125460
125782
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125461
125783
  return {
125462
125784
  type: ts.UpToDateStatusType.ContainerOnly
125463
125785
  };
125464
125786
  }
125465
- // Collect the expected outputs of this project
125466
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125467
- // Now see if all outputs are newer than the newest input
125468
- var oldestOutputFileName = "(none)";
125469
- var oldestOutputFileTime = maximumDate;
125470
- var newestOutputFileName = "(none)";
125471
- var newestOutputFileTime = minimumDate;
125472
- var missingOutputFileName;
125473
- var newestDeclarationFileContentChangedTime = minimumDate;
125474
- var isOutOfDateWithInputs = false;
125475
- if (!force) {
125476
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125477
- var output = outputs_1[_b];
125478
- // Output is missing; can stop checking
125479
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125480
- if (!host.fileExists(output)) {
125481
- missingOutputFileName = output;
125482
- break;
125483
- }
125484
- var outputTime = ts.getModifiedTime(host, output);
125485
- if (outputTime < oldestOutputFileTime) {
125486
- oldestOutputFileTime = outputTime;
125487
- oldestOutputFileName = output;
125488
- }
125489
- // If an output is older than the newest input, we can stop checking
125490
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125491
- if (outputTime < newestInputFileTime) {
125492
- isOutOfDateWithInputs = true;
125493
- break;
125494
- }
125495
- if (outputTime > newestOutputFileTime) {
125496
- newestOutputFileTime = outputTime;
125497
- newestOutputFileName = output;
125498
- }
125499
- // Keep track of when the most recent time a .d.ts file was changed.
125500
- // In addition to file timestamps, we also keep track of when a .d.ts file
125501
- // had its file touched but not had its contents changed - this allows us
125502
- // to skip a downstream typecheck
125503
- if (ts.isDeclarationFileName(output)) {
125504
- var outputModifiedTime = ts.getModifiedTime(host, output);
125505
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125506
- }
125507
- }
125508
- }
125509
- var pseudoUpToDate = false;
125510
- var usesPrepend = false;
125511
- 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;
125512
125790
  if (project.projectReferences) {
125513
125791
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125514
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125515
- var ref = _d[_c];
125516
- usesPrepend = usesPrepend || !!(ref.prepend);
125792
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125793
+ var ref = _d[_i];
125517
125794
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125518
125795
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125519
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125796
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125797
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125520
125798
  // Its a circular reference ignore the status of this project
125521
125799
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125522
125800
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125538,75 +125816,194 @@ var ts;
125538
125816
  upstreamProjectName: ref.path
125539
125817
  };
125540
125818
  }
125541
- // Check oldest output file name only if there is no missing output file name
125542
- // (a check we will have skipped if this is a forced build)
125543
- if (!force && !missingOutputFileName) {
125544
- // If the upstream project's newest file is older than our oldest output, we
125545
- // can't be out of date because of it
125546
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125547
- continue;
125548
- }
125549
- // If the upstream project has only change .d.ts files, and we've built
125550
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125551
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125552
- pseudoUpToDate = true;
125553
- upstreamChangedProject = ref.path;
125554
- continue;
125555
- }
125556
- // We have an output older than an upstream output - we are out of date
125557
- 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))) {
125558
125861
  return {
125559
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125560
- outOfDateOutputFileName: oldestOutputFileName,
125561
- newerProjectName: ref.path
125862
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125863
+ buildInfoFile: buildInfoPath
125562
125864
  };
125563
125865
  }
125866
+ buildInfoProgram = buildInfo.program;
125564
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;
125565
125872
  }
125566
- if (missingOutputFileName !== undefined) {
125567
- return {
125568
- type: ts.UpToDateStatusType.OutputMissing,
125569
- missingOutputFileName: missingOutputFileName
125570
- };
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
+ }
125571
125914
  }
125572
- if (isOutOfDateWithInputs) {
125573
- return {
125574
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125575
- outOfDateOutputFileName: oldestOutputFileName,
125576
- newerInputFileName: newestInputFileName
125577
- };
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
+ }
125578
125951
  }
125579
- else {
125580
- // Check tsconfig time
125581
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125582
- if (configStatus)
125583
- return configStatus;
125584
- // Check extended config time
125585
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125586
- if (extendedConfigStatus)
125587
- return extendedConfigStatus;
125588
- // Check package file time
125589
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125590
- var path = _a[0];
125591
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125592
- });
125593
- if (dependentPackageFileStatus)
125594
- return dependentPackageFileStatus;
125595
- }
125596
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125597
- state.buildInfoChecked.set(resolvedPath, true);
125598
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125599
- if (buildInfoPath) {
125600
- var value = state.readFileWithCache(buildInfoPath);
125601
- var buildInfo = value && ts.getBuildInfo(value);
125602
- 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)) {
125603
125970
  return {
125604
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125605
- version: buildInfo.version
125971
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125972
+ outOfDateOutputFileName: buildInfoPath,
125973
+ newerProjectName: ref.path
125606
125974
  };
125607
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
+ };
125608
125990
  }
125609
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;
125610
126007
  if (usesPrepend && pseudoUpToDate) {
125611
126008
  return {
125612
126009
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125616,15 +126013,37 @@ var ts;
125616
126013
  }
125617
126014
  // Up to date
125618
126015
  return {
125619
- 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,
125620
126021
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125621
126022
  newestInputFileTime: newestInputFileTime,
125622
- newestOutputFileTime: newestOutputFileTime,
125623
126023
  newestInputFileName: newestInputFileName,
125624
- newestOutputFileName: newestOutputFileName,
125625
126024
  oldestOutputFileName: oldestOutputFileName
125626
126025
  };
125627
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
+ }
125628
126047
  function getUpToDateStatus(state, project, resolvedPath) {
125629
126048
  if (project === undefined) {
125630
126049
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125637,39 +126056,68 @@ var ts;
125637
126056
  state.projectStatus.set(resolvedPath, actual);
125638
126057
  return actual;
125639
126058
  }
125640
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126059
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125641
126060
  if (proj.options.noEmit)
125642
- 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
+ }
125643
126076
  var host = state.host;
125644
126077
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126078
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126079
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125645
126080
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125646
126081
  var reportVerbose = !!state.options.verbose;
125647
- var now = host.now ? host.now() : new Date();
125648
126082
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125649
126083
  var file = outputs_2[_i];
125650
- 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))
125651
126086
  continue;
125652
- }
125653
126087
  if (reportVerbose) {
125654
126088
  reportVerbose = false;
125655
126089
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125656
126090
  }
125657
- if (ts.isDeclarationFileName(file)) {
125658
- 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);
125659
126096
  }
125660
- host.setModifiedTime(file, now);
125661
126097
  }
125662
126098
  }
125663
- 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;
125664
126112
  }
125665
126113
  function updateOutputTimestamps(state, proj, resolvedPath) {
125666
126114
  if (state.options.dry) {
125667
126115
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125668
126116
  }
125669
- 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);
125670
126118
  state.projectStatus.set(resolvedPath, {
125671
126119
  type: ts.UpToDateStatusType.UpToDate,
125672
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126120
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125673
126121
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125674
126122
  });
125675
126123
  }
@@ -125715,6 +126163,7 @@ var ts;
125715
126163
  break;
125716
126164
  }
125717
126165
  // falls through
126166
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125718
126167
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125719
126168
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125720
126169
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125875,12 +126324,10 @@ var ts;
125875
126324
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125876
126325
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125877
126326
  return;
125878
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125879
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125880
- }, 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));
125881
126328
  }
125882
126329
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125883
- 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 () {
125884
126331
  var _a;
125885
126332
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125886
126333
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125912,7 +126359,7 @@ var ts;
125912
126359
  if (!state.watch)
125913
126360
  return;
125914
126361
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125915
- 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); },
125916
126363
  onDeleteValue: ts.closeFileWatcher,
125917
126364
  });
125918
126365
  }
@@ -125920,7 +126367,7 @@ var ts;
125920
126367
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125921
126368
  return;
125922
126369
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125923
- 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); },
125924
126371
  onDeleteValue: ts.closeFileWatcher,
125925
126372
  });
125926
126373
  }
@@ -126050,19 +126497,18 @@ var ts;
126050
126497
  }
126051
126498
  }
126052
126499
  function reportUpToDateStatus(state, configFileName, status) {
126053
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126054
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126055
- }
126056
126500
  switch (status.type) {
126057
126501
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126058
- 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));
126059
126503
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126060
- 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));
126061
126505
  case ts.UpToDateStatusType.OutputMissing:
126062
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));
126063
126509
  case ts.UpToDateStatusType.UpToDate:
126064
126510
  if (status.newestInputFileTime !== undefined) {
126065
- 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 || ""));
126066
126512
  }
126067
126513
  // Don't report anything for "up to date because it was already built" -- too verbose
126068
126514
  break;
@@ -126070,6 +126516,8 @@ var ts;
126070
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));
126071
126517
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126072
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));
126073
126521
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126074
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));
126075
126523
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126080,6 +126528,8 @@ var ts;
126080
126528
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126081
126529
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126082
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));
126083
126533
  case ts.UpToDateStatusType.ContainerOnly:
126084
126534
  // Don't report status on "solution" projects
126085
126535
  // falls through