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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220608";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220609";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -6198,7 +6198,7 @@ var ts;
6198
6198
  };
6199
6199
  }
6200
6200
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6201
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6201
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6202
6202
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6203
6203
  if (!ts.isString(relativeFileName))
6204
6204
  return;
@@ -6208,7 +6208,7 @@ var ts;
6208
6208
  if (callbacks) {
6209
6209
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6210
6210
  var fileCallback = callbacks_1[_i];
6211
- fileCallback(fileName, FileWatcherEventKind.Changed);
6211
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6212
6212
  }
6213
6213
  }
6214
6214
  },
@@ -6262,7 +6262,7 @@ var ts;
6262
6262
  }
6263
6263
  else {
6264
6264
  cache.set(path, {
6265
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6265
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6266
6266
  refCount: 1
6267
6267
  });
6268
6268
  }
@@ -6290,7 +6290,8 @@ var ts;
6290
6290
  var newTime = modifiedTime.getTime();
6291
6291
  if (oldTime !== newTime) {
6292
6292
  watchedFile.mtime = modifiedTime;
6293
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6293
+ // Pass modified times so tsc --build can use it
6294
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6294
6295
  return true;
6295
6296
  }
6296
6297
  return false;
@@ -6325,7 +6326,7 @@ var ts;
6325
6326
  */
6326
6327
  /*@internal*/
6327
6328
  function createDirectoryWatcherSupportingRecursive(_a) {
6328
- 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;
6329
+ 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;
6329
6330
  var cache = new ts.Map();
6330
6331
  var callbackCache = ts.createMultiMap();
6331
6332
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6425,7 +6426,7 @@ var ts;
6425
6426
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6426
6427
  // Iterate through existing children and update the watches if needed
6427
6428
  var parentWatcher = cache.get(dirPath);
6428
- if (parentWatcher && directoryExists(dirName)) {
6429
+ if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6429
6430
  // Schedule the update and postpone invoke for callbacks
6430
6431
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6431
6432
  return;
@@ -6498,7 +6499,7 @@ var ts;
6498
6499
  if (!parentWatcher)
6499
6500
  return false;
6500
6501
  var newChildWatches;
6501
- var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6502
+ var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6502
6503
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6503
6504
  // Filter our the symbolic link directories since those arent included in recursive watch
6504
6505
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6541,17 +6542,19 @@ var ts;
6541
6542
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6542
6543
  /*@internal*/
6543
6544
  function createFileWatcherCallback(callback) {
6544
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6545
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6545
6546
  }
6546
6547
  ts.createFileWatcherCallback = createFileWatcherCallback;
6547
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6548
- return function (eventName) {
6548
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6549
+ return function (eventName, _relativeFileName, modifiedTime) {
6549
6550
  if (eventName === "rename") {
6550
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6551
+ // Check time stamps rather than file system entry checks
6552
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6553
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6551
6554
  }
6552
6555
  else {
6553
6556
  // Change
6554
- callback(fileName, FileWatcherEventKind.Changed);
6557
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6555
6558
  }
6556
6559
  };
6557
6560
  }
@@ -6575,11 +6578,12 @@ var ts;
6575
6578
  }
6576
6579
  /*@internal*/
6577
6580
  function createSystemWatchFunctions(_a) {
6578
- 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;
6581
+ 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;
6579
6582
  var dynamicPollingWatchFile;
6580
6583
  var fixedChunkSizePollingWatchFile;
6581
6584
  var nonPollingWatchFile;
6582
6585
  var hostRecursiveDirectoryWatcher;
6586
+ var hitSystemWatcherLimit = false;
6583
6587
  return {
6584
6588
  watchFile: watchFile,
6585
6589
  watchDirectory: watchDirectory
@@ -6597,7 +6601,7 @@ var ts;
6597
6601
  case ts.WatchFileKind.FixedChunkSizePolling:
6598
6602
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6599
6603
  case ts.WatchFileKind.UseFsEvents:
6600
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6604
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6601
6605
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6602
6606
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6603
6607
  if (!nonPollingWatchFile) {
@@ -6658,7 +6662,7 @@ var ts;
6658
6662
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6659
6663
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6660
6664
  getCurrentDirectory: getCurrentDirectory,
6661
- directoryExists: directoryExists,
6665
+ fileSystemEntryExists: fileSystemEntryExists,
6662
6666
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6663
6667
  watchDirectory: nonRecursiveWatchDirectory,
6664
6668
  realpath: realpath,
@@ -6709,6 +6713,122 @@ var ts;
6709
6713
  };
6710
6714
  }
6711
6715
  }
6716
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6717
+ var lastDirectoryPartWithDirectorySeparator;
6718
+ var lastDirectoryPart;
6719
+ if (inodeWatching) {
6720
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6721
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6722
+ }
6723
+ /** Watcher for the file system entry depending on whether it is missing or present */
6724
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6725
+ watchMissingFileSystemEntry() :
6726
+ watchPresentFileSystemEntry();
6727
+ return {
6728
+ close: function () {
6729
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6730
+ watcher.close();
6731
+ watcher = undefined;
6732
+ }
6733
+ };
6734
+ function updateWatcher(createWatcher) {
6735
+ // If watcher is not closed, update it
6736
+ if (watcher) {
6737
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6738
+ watcher.close();
6739
+ watcher = createWatcher();
6740
+ }
6741
+ }
6742
+ /**
6743
+ * Watch the file or directory that is currently present
6744
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
6745
+ */
6746
+ function watchPresentFileSystemEntry() {
6747
+ if (hitSystemWatcherLimit) {
6748
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6749
+ return watchPresentFileSystemEntryWithFsWatchFile();
6750
+ }
6751
+ try {
6752
+ var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6753
+ callbackChangingToMissingFileSystemEntry :
6754
+ callback);
6755
+ // Watch the missing file or directory or error
6756
+ presentWatcher.on("error", function () {
6757
+ callback("rename", "");
6758
+ updateWatcher(watchMissingFileSystemEntry);
6759
+ });
6760
+ return presentWatcher;
6761
+ }
6762
+ catch (e) {
6763
+ // Catch the exception and use polling instead
6764
+ // 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
6765
+ // so instead of throwing error, use fs.watchFile
6766
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6767
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6768
+ return watchPresentFileSystemEntryWithFsWatchFile();
6769
+ }
6770
+ }
6771
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6772
+ // In some scenarios, file save operation fires event with fileName.ext~ instead of fileName.ext
6773
+ // To ensure we see the file going missing and coming back up (file delete and then recreated)
6774
+ // and watches being updated correctly we are calling back with fileName.ext as well as fileName.ext~
6775
+ // The worst is we have fired event that was not needed but we wont miss any changes
6776
+ // especially in cases where file goes missing and watches wrong inode
6777
+ var originalRelativeName;
6778
+ if (relativeName && ts.endsWith(relativeName, "~")) {
6779
+ originalRelativeName = relativeName;
6780
+ relativeName = relativeName.slice(0, relativeName.length - 1);
6781
+ }
6782
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6783
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6784
+ if (event === "rename" &&
6785
+ (!relativeName ||
6786
+ relativeName === lastDirectoryPart ||
6787
+ ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6788
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
6789
+ if (originalRelativeName)
6790
+ callback(event, originalRelativeName, modifiedTime);
6791
+ callback(event, relativeName, modifiedTime);
6792
+ if (inodeWatching) {
6793
+ // If this was rename event, inode has changed means we need to update watcher
6794
+ updateWatcher(modifiedTime === ts.missingFileModifiedTime ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6795
+ }
6796
+ else if (modifiedTime === ts.missingFileModifiedTime) {
6797
+ updateWatcher(watchMissingFileSystemEntry);
6798
+ }
6799
+ }
6800
+ else {
6801
+ if (originalRelativeName)
6802
+ callback(event, originalRelativeName);
6803
+ callback(event, relativeName);
6804
+ }
6805
+ }
6806
+ /**
6807
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
6808
+ * 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
6809
+ */
6810
+ function watchPresentFileSystemEntryWithFsWatchFile() {
6811
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
6812
+ }
6813
+ /**
6814
+ * Watch the file or directory that is missing
6815
+ * and switch to existing file or directory when the missing filesystem entry is created
6816
+ */
6817
+ function watchMissingFileSystemEntry() {
6818
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
6819
+ if (eventKind === FileWatcherEventKind.Created) {
6820
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
6821
+ if (modifiedTime !== ts.missingFileModifiedTime) {
6822
+ callback("rename", "", modifiedTime);
6823
+ // Call the callback for current file or directory
6824
+ // For now it could be callback for the inner directory creation,
6825
+ // but just return current directory, better than current no-op
6826
+ updateWatcher(watchPresentFileSystemEntry);
6827
+ }
6828
+ }
6829
+ }, fallbackPollingInterval, fallbackOptions);
6830
+ }
6831
+ }
6712
6832
  }
6713
6833
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6714
6834
  /**
@@ -6761,7 +6881,6 @@ var ts;
6761
6881
  }
6762
6882
  var activeSession;
6763
6883
  var profilePath = "./profile.cpuprofile";
6764
- var hitSystemWatcherLimit = false;
6765
6884
  var Buffer = require("buffer").Buffer;
6766
6885
  var nodeVersion = getNodeMajorVersion();
6767
6886
  var isNode4OrLater = nodeVersion >= 4;
@@ -6776,20 +6895,21 @@ var ts;
6776
6895
  getModifiedTime: getModifiedTime,
6777
6896
  setTimeout: setTimeout,
6778
6897
  clearTimeout: clearTimeout,
6779
- fsWatch: fsWatch,
6898
+ fsWatchWorker: fsWatchWorker,
6780
6899
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6781
6900
  getCurrentDirectory: getCurrentDirectory,
6782
- fileExists: fileExists,
6901
+ fileSystemEntryExists: fileSystemEntryExists,
6783
6902
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6784
6903
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6785
6904
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6786
- directoryExists: directoryExists,
6787
6905
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6788
6906
  realpath: realpath,
6789
6907
  tscWatchFile: process.env.TSC_WATCHFILE,
6790
6908
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6791
6909
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6792
6910
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
6911
+ inodeWatching: isLinuxOrMacOs,
6912
+ sysLog: sysLog,
6793
6913
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6794
6914
  var nodeSystem = {
6795
6915
  args: process.argv.slice(2),
@@ -7039,110 +7159,14 @@ var ts;
7039
7159
  // File changed
7040
7160
  eventKind = FileWatcherEventKind.Changed;
7041
7161
  }
7042
- callback(fileName, eventKind);
7162
+ callback(fileName, eventKind, curr.mtime);
7043
7163
  }
7044
7164
  }
7045
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7046
- var options;
7047
- var lastDirectoryPartWithDirectorySeparator;
7048
- var lastDirectoryPart;
7049
- if (isLinuxOrMacOs) {
7050
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7051
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7052
- }
7053
- /** Watcher for the file system entry depending on whether it is missing or present */
7054
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7055
- watchMissingFileSystemEntry() :
7056
- watchPresentFileSystemEntry();
7057
- return {
7058
- close: function () {
7059
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7060
- watcher.close();
7061
- watcher = undefined;
7062
- }
7063
- };
7064
- /**
7065
- * Invoke the callback with rename and update the watcher if not closed
7066
- * @param createWatcher
7067
- */
7068
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7069
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7070
- // Call the callback for current directory
7071
- callback("rename", "");
7072
- // If watcher is not closed, update it
7073
- if (watcher) {
7074
- watcher.close();
7075
- watcher = createWatcher();
7076
- }
7077
- }
7078
- /**
7079
- * Watch the file or directory that is currently present
7080
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
7081
- */
7082
- function watchPresentFileSystemEntry() {
7083
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7084
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7085
- if (options === undefined) {
7086
- if (fsSupportsRecursiveFsWatch) {
7087
- options = { persistent: true, recursive: !!recursive };
7088
- }
7089
- else {
7090
- options = { persistent: true };
7091
- }
7092
- }
7093
- if (hitSystemWatcherLimit) {
7094
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7095
- return watchPresentFileSystemEntryWithFsWatchFile();
7096
- }
7097
- try {
7098
- var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7099
- callbackChangingToMissingFileSystemEntry :
7100
- callback);
7101
- // Watch the missing file or directory or error
7102
- presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7103
- return presentWatcher;
7104
- }
7105
- catch (e) {
7106
- // Catch the exception and use polling instead
7107
- // 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
7108
- // so instead of throwing error, use fs.watchFile
7109
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7110
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7111
- return watchPresentFileSystemEntryWithFsWatchFile();
7112
- }
7113
- }
7114
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7115
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7116
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7117
- return event === "rename" &&
7118
- (!relativeName ||
7119
- relativeName === lastDirectoryPart ||
7120
- (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7121
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7122
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7123
- callback(event, relativeName);
7124
- }
7125
- /**
7126
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
7127
- * 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
7128
- */
7129
- function watchPresentFileSystemEntryWithFsWatchFile() {
7130
- return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7131
- }
7132
- /**
7133
- * Watch the file or directory that is missing
7134
- * and switch to existing file or directory when the missing filesystem entry is created
7135
- */
7136
- function watchMissingFileSystemEntry() {
7137
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7138
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7139
- // Call the callback for current file or directory
7140
- // For now it could be callback for the inner directory creation,
7141
- // but just return current directory, better than current no-op
7142
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7143
- }
7144
- }, fallbackPollingInterval, fallbackOptions);
7145
- }
7165
+ function fsWatchWorker(fileOrDirectory, recursive, callback) {
7166
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7167
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7168
+ return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7169
+ { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7146
7170
  }
7147
7171
  function readFileWorker(fileName, _encoding) {
7148
7172
  var buffer;
@@ -7289,12 +7313,19 @@ var ts;
7289
7313
  }
7290
7314
  function getModifiedTime(path) {
7291
7315
  var _a;
7316
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7317
+ // the CPU time performance.
7318
+ var originalStackTraceLimit = Error.stackTraceLimit;
7319
+ Error.stackTraceLimit = 0;
7292
7320
  try {
7293
7321
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7294
7322
  }
7295
7323
  catch (e) {
7296
7324
  return undefined;
7297
7325
  }
7326
+ finally {
7327
+ Error.stackTraceLimit = originalStackTraceLimit;
7328
+ }
7298
7329
  }
7299
7330
  function setModifiedTime(path, time) {
7300
7331
  try {
@@ -9319,8 +9350,8 @@ var ts;
9319
9350
  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"),
9320
9351
  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"),
9321
9352
  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."),
9322
- 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}'"),
9323
- 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}'"),
9353
+ 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}'"),
9354
+ 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}'"),
9324
9355
  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"),
9325
9356
  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"),
9326
9357
  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"),
@@ -9364,6 +9395,8 @@ var ts;
9364
9395
  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}'."),
9365
9396
  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}'."),
9366
9397
  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."),
9398
+ 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"),
9399
+ 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"),
9367
9400
  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}'"),
9368
9401
  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."),
9369
9402
  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."),
@@ -20201,6 +20234,10 @@ var ts;
20201
20234
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20202
20235
  }
20203
20236
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20237
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20238
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20239
+ }
20240
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20204
20241
  function getCompilerOptionValue(options, option) {
20205
20242
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20206
20243
  }
@@ -39258,6 +39295,7 @@ var ts;
39258
39295
  type: "boolean",
39259
39296
  affectsSemanticDiagnostics: true,
39260
39297
  affectsEmit: true,
39298
+ affectsMultiFileEmitBuildInfo: true,
39261
39299
  category: ts.Diagnostics.Watch_and_Build_Modes,
39262
39300
  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,
39263
39301
  defaultValueDescription: false,
@@ -39292,12 +39330,40 @@ var ts;
39292
39330
  affectsSourceFile: true,
39293
39331
  affectsModuleResolution: true,
39294
39332
  affectsEmit: true,
39333
+ affectsMultiFileEmitBuildInfo: true,
39295
39334
  paramType: ts.Diagnostics.VERSION,
39296
39335
  showInSimplifiedHelpView: true,
39297
39336
  category: ts.Diagnostics.Language_and_Environment,
39298
39337
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39299
39338
  defaultValueDescription: 0 /* ES3 */,
39300
39339
  };
39340
+ /*@internal*/
39341
+ ts.moduleOptionDeclaration = {
39342
+ name: "module",
39343
+ shortName: "m",
39344
+ type: new ts.Map(ts.getEntries({
39345
+ none: ts.ModuleKind.None,
39346
+ commonjs: ts.ModuleKind.CommonJS,
39347
+ amd: ts.ModuleKind.AMD,
39348
+ system: ts.ModuleKind.System,
39349
+ umd: ts.ModuleKind.UMD,
39350
+ es6: ts.ModuleKind.ES2015,
39351
+ es2015: ts.ModuleKind.ES2015,
39352
+ es2020: ts.ModuleKind.ES2020,
39353
+ es2022: ts.ModuleKind.ES2022,
39354
+ esnext: ts.ModuleKind.ESNext,
39355
+ node16: ts.ModuleKind.Node16,
39356
+ nodenext: ts.ModuleKind.NodeNext,
39357
+ })),
39358
+ affectsModuleResolution: true,
39359
+ affectsEmit: true,
39360
+ affectsMultiFileEmitBuildInfo: true,
39361
+ paramType: ts.Diagnostics.KIND,
39362
+ showInSimplifiedHelpView: true,
39363
+ category: ts.Diagnostics.Modules,
39364
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39365
+ defaultValueDescription: undefined,
39366
+ };
39301
39367
  var commandOptionsWithoutBuild = [
39302
39368
  // CommandLine only options
39303
39369
  {
@@ -39359,37 +39425,14 @@ var ts;
39359
39425
  category: ts.Diagnostics.Command_line_Options,
39360
39426
  affectsSemanticDiagnostics: true,
39361
39427
  affectsEmit: true,
39428
+ affectsMultiFileEmitBuildInfo: true,
39362
39429
  isCommandLineOnly: true,
39363
39430
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39364
39431
  defaultValueDescription: false,
39365
39432
  },
39366
39433
  // Basic
39367
39434
  ts.targetOptionDeclaration,
39368
- {
39369
- name: "module",
39370
- shortName: "m",
39371
- type: new ts.Map(ts.getEntries({
39372
- none: ts.ModuleKind.None,
39373
- commonjs: ts.ModuleKind.CommonJS,
39374
- amd: ts.ModuleKind.AMD,
39375
- system: ts.ModuleKind.System,
39376
- umd: ts.ModuleKind.UMD,
39377
- es6: ts.ModuleKind.ES2015,
39378
- es2015: ts.ModuleKind.ES2015,
39379
- es2020: ts.ModuleKind.ES2020,
39380
- es2022: ts.ModuleKind.ES2022,
39381
- esnext: ts.ModuleKind.ESNext,
39382
- node16: ts.ModuleKind.Node16,
39383
- nodenext: ts.ModuleKind.NodeNext,
39384
- })),
39385
- affectsModuleResolution: true,
39386
- affectsEmit: true,
39387
- paramType: ts.Diagnostics.KIND,
39388
- showInSimplifiedHelpView: true,
39389
- category: ts.Diagnostics.Modules,
39390
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39391
- defaultValueDescription: undefined,
39392
- },
39435
+ ts.moduleOptionDeclaration,
39393
39436
  {
39394
39437
  name: "lib",
39395
39438
  type: "list",
@@ -39426,6 +39469,7 @@ var ts;
39426
39469
  type: jsxOptionMap,
39427
39470
  affectsSourceFile: true,
39428
39471
  affectsEmit: true,
39472
+ affectsMultiFileEmitBuildInfo: true,
39429
39473
  affectsModuleResolution: true,
39430
39474
  paramType: ts.Diagnostics.KIND,
39431
39475
  showInSimplifiedHelpView: true,
@@ -39438,6 +39482,7 @@ var ts;
39438
39482
  shortName: "d",
39439
39483
  type: "boolean",
39440
39484
  affectsEmit: true,
39485
+ affectsMultiFileEmitBuildInfo: true,
39441
39486
  showInSimplifiedHelpView: true,
39442
39487
  category: ts.Diagnostics.Emit,
39443
39488
  transpileOptionValue: undefined,
@@ -39448,6 +39493,7 @@ var ts;
39448
39493
  name: "declarationMap",
39449
39494
  type: "boolean",
39450
39495
  affectsEmit: true,
39496
+ affectsMultiFileEmitBuildInfo: true,
39451
39497
  showInSimplifiedHelpView: true,
39452
39498
  category: ts.Diagnostics.Emit,
39453
39499
  transpileOptionValue: undefined,
@@ -39458,6 +39504,7 @@ var ts;
39458
39504
  name: "emitDeclarationOnly",
39459
39505
  type: "boolean",
39460
39506
  affectsEmit: true,
39507
+ affectsMultiFileEmitBuildInfo: true,
39461
39508
  showInSimplifiedHelpView: true,
39462
39509
  category: ts.Diagnostics.Emit,
39463
39510
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39468,6 +39515,7 @@ var ts;
39468
39515
  name: "sourceMap",
39469
39516
  type: "boolean",
39470
39517
  affectsEmit: true,
39518
+ affectsMultiFileEmitBuildInfo: true,
39471
39519
  showInSimplifiedHelpView: true,
39472
39520
  category: ts.Diagnostics.Emit,
39473
39521
  defaultValueDescription: false,
@@ -39477,6 +39525,9 @@ var ts;
39477
39525
  name: "outFile",
39478
39526
  type: "string",
39479
39527
  affectsEmit: true,
39528
+ affectsMultiFileEmitBuildInfo: true,
39529
+ affectsDeclarationPath: true,
39530
+ affectsBundleEmitBuildInfo: true,
39480
39531
  isFilePath: true,
39481
39532
  paramType: ts.Diagnostics.FILE,
39482
39533
  showInSimplifiedHelpView: true,
@@ -39488,6 +39539,8 @@ var ts;
39488
39539
  name: "outDir",
39489
39540
  type: "string",
39490
39541
  affectsEmit: true,
39542
+ affectsMultiFileEmitBuildInfo: true,
39543
+ affectsDeclarationPath: true,
39491
39544
  isFilePath: true,
39492
39545
  paramType: ts.Diagnostics.DIRECTORY,
39493
39546
  showInSimplifiedHelpView: true,
@@ -39498,6 +39551,8 @@ var ts;
39498
39551
  name: "rootDir",
39499
39552
  type: "string",
39500
39553
  affectsEmit: true,
39554
+ affectsMultiFileEmitBuildInfo: true,
39555
+ affectsDeclarationPath: true,
39501
39556
  isFilePath: true,
39502
39557
  paramType: ts.Diagnostics.LOCATION,
39503
39558
  category: ts.Diagnostics.Modules,
@@ -39508,6 +39563,8 @@ var ts;
39508
39563
  name: "composite",
39509
39564
  type: "boolean",
39510
39565
  affectsEmit: true,
39566
+ affectsMultiFileEmitBuildInfo: true,
39567
+ affectsBundleEmitBuildInfo: true,
39511
39568
  isTSConfigOnly: true,
39512
39569
  category: ts.Diagnostics.Projects,
39513
39570
  transpileOptionValue: undefined,
@@ -39518,6 +39575,8 @@ var ts;
39518
39575
  name: "tsBuildInfoFile",
39519
39576
  type: "string",
39520
39577
  affectsEmit: true,
39578
+ affectsMultiFileEmitBuildInfo: true,
39579
+ affectsBundleEmitBuildInfo: true,
39521
39580
  isFilePath: true,
39522
39581
  paramType: ts.Diagnostics.FILE,
39523
39582
  category: ts.Diagnostics.Projects,
@@ -39529,6 +39588,7 @@ var ts;
39529
39588
  name: "removeComments",
39530
39589
  type: "boolean",
39531
39590
  affectsEmit: true,
39591
+ affectsMultiFileEmitBuildInfo: true,
39532
39592
  showInSimplifiedHelpView: true,
39533
39593
  category: ts.Diagnostics.Emit,
39534
39594
  defaultValueDescription: false,
@@ -39547,6 +39607,7 @@ var ts;
39547
39607
  name: "importHelpers",
39548
39608
  type: "boolean",
39549
39609
  affectsEmit: true,
39610
+ affectsMultiFileEmitBuildInfo: true,
39550
39611
  category: ts.Diagnostics.Emit,
39551
39612
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39552
39613
  defaultValueDescription: false,
@@ -39560,6 +39621,7 @@ var ts;
39560
39621
  })),
39561
39622
  affectsEmit: true,
39562
39623
  affectsSemanticDiagnostics: true,
39624
+ affectsMultiFileEmitBuildInfo: true,
39563
39625
  category: ts.Diagnostics.Emit,
39564
39626
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39565
39627
  defaultValueDescription: 0 /* Remove */,
@@ -39568,6 +39630,7 @@ var ts;
39568
39630
  name: "downlevelIteration",
39569
39631
  type: "boolean",
39570
39632
  affectsEmit: true,
39633
+ affectsMultiFileEmitBuildInfo: true,
39571
39634
  category: ts.Diagnostics.Emit,
39572
39635
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39573
39636
  defaultValueDescription: false,
@@ -39586,6 +39649,9 @@ var ts;
39586
39649
  type: "boolean",
39587
39650
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39588
39651
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39652
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39653
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39654
+ affectsMultiFileEmitBuildInfo: true,
39589
39655
  showInSimplifiedHelpView: true,
39590
39656
  category: ts.Diagnostics.Type_Checking,
39591
39657
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39595,6 +39661,7 @@ var ts;
39595
39661
  name: "noImplicitAny",
39596
39662
  type: "boolean",
39597
39663
  affectsSemanticDiagnostics: true,
39664
+ affectsMultiFileEmitBuildInfo: true,
39598
39665
  strictFlag: true,
39599
39666
  category: ts.Diagnostics.Type_Checking,
39600
39667
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39604,6 +39671,7 @@ var ts;
39604
39671
  name: "strictNullChecks",
39605
39672
  type: "boolean",
39606
39673
  affectsSemanticDiagnostics: true,
39674
+ affectsMultiFileEmitBuildInfo: true,
39607
39675
  strictFlag: true,
39608
39676
  category: ts.Diagnostics.Type_Checking,
39609
39677
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39612,6 +39680,8 @@ var ts;
39612
39680
  {
39613
39681
  name: "strictFunctionTypes",
39614
39682
  type: "boolean",
39683
+ affectsSemanticDiagnostics: true,
39684
+ affectsMultiFileEmitBuildInfo: true,
39615
39685
  strictFlag: true,
39616
39686
  category: ts.Diagnostics.Type_Checking,
39617
39687
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39620,6 +39690,8 @@ var ts;
39620
39690
  {
39621
39691
  name: "strictBindCallApply",
39622
39692
  type: "boolean",
39693
+ affectsSemanticDiagnostics: true,
39694
+ affectsMultiFileEmitBuildInfo: true,
39623
39695
  strictFlag: true,
39624
39696
  category: ts.Diagnostics.Type_Checking,
39625
39697
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39629,6 +39701,7 @@ var ts;
39629
39701
  name: "strictPropertyInitialization",
39630
39702
  type: "boolean",
39631
39703
  affectsSemanticDiagnostics: true,
39704
+ affectsMultiFileEmitBuildInfo: true,
39632
39705
  strictFlag: true,
39633
39706
  category: ts.Diagnostics.Type_Checking,
39634
39707
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39638,6 +39711,7 @@ var ts;
39638
39711
  name: "noImplicitThis",
39639
39712
  type: "boolean",
39640
39713
  affectsSemanticDiagnostics: true,
39714
+ affectsMultiFileEmitBuildInfo: true,
39641
39715
  strictFlag: true,
39642
39716
  category: ts.Diagnostics.Type_Checking,
39643
39717
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39647,6 +39721,7 @@ var ts;
39647
39721
  name: "useUnknownInCatchVariables",
39648
39722
  type: "boolean",
39649
39723
  affectsSemanticDiagnostics: true,
39724
+ affectsMultiFileEmitBuildInfo: true,
39650
39725
  strictFlag: true,
39651
39726
  category: ts.Diagnostics.Type_Checking,
39652
39727
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39656,6 +39731,8 @@ var ts;
39656
39731
  name: "alwaysStrict",
39657
39732
  type: "boolean",
39658
39733
  affectsSourceFile: true,
39734
+ affectsEmit: true,
39735
+ affectsMultiFileEmitBuildInfo: true,
39659
39736
  strictFlag: true,
39660
39737
  category: ts.Diagnostics.Type_Checking,
39661
39738
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39666,6 +39743,7 @@ var ts;
39666
39743
  name: "noUnusedLocals",
39667
39744
  type: "boolean",
39668
39745
  affectsSemanticDiagnostics: true,
39746
+ affectsMultiFileEmitBuildInfo: true,
39669
39747
  category: ts.Diagnostics.Type_Checking,
39670
39748
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39671
39749
  defaultValueDescription: false,
@@ -39674,6 +39752,7 @@ var ts;
39674
39752
  name: "noUnusedParameters",
39675
39753
  type: "boolean",
39676
39754
  affectsSemanticDiagnostics: true,
39755
+ affectsMultiFileEmitBuildInfo: true,
39677
39756
  category: ts.Diagnostics.Type_Checking,
39678
39757
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39679
39758
  defaultValueDescription: false,
@@ -39682,6 +39761,7 @@ var ts;
39682
39761
  name: "exactOptionalPropertyTypes",
39683
39762
  type: "boolean",
39684
39763
  affectsSemanticDiagnostics: true,
39764
+ affectsMultiFileEmitBuildInfo: true,
39685
39765
  category: ts.Diagnostics.Type_Checking,
39686
39766
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39687
39767
  defaultValueDescription: false,
@@ -39690,6 +39770,7 @@ var ts;
39690
39770
  name: "noImplicitReturns",
39691
39771
  type: "boolean",
39692
39772
  affectsSemanticDiagnostics: true,
39773
+ affectsMultiFileEmitBuildInfo: true,
39693
39774
  category: ts.Diagnostics.Type_Checking,
39694
39775
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39695
39776
  defaultValueDescription: false,
@@ -39699,6 +39780,7 @@ var ts;
39699
39780
  type: "boolean",
39700
39781
  affectsBindDiagnostics: true,
39701
39782
  affectsSemanticDiagnostics: true,
39783
+ affectsMultiFileEmitBuildInfo: true,
39702
39784
  category: ts.Diagnostics.Type_Checking,
39703
39785
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39704
39786
  defaultValueDescription: false,
@@ -39707,6 +39789,7 @@ var ts;
39707
39789
  name: "noUncheckedIndexedAccess",
39708
39790
  type: "boolean",
39709
39791
  affectsSemanticDiagnostics: true,
39792
+ affectsMultiFileEmitBuildInfo: true,
39710
39793
  category: ts.Diagnostics.Type_Checking,
39711
39794
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39712
39795
  defaultValueDescription: false,
@@ -39715,6 +39798,7 @@ var ts;
39715
39798
  name: "noImplicitOverride",
39716
39799
  type: "boolean",
39717
39800
  affectsSemanticDiagnostics: true,
39801
+ affectsMultiFileEmitBuildInfo: true,
39718
39802
  category: ts.Diagnostics.Type_Checking,
39719
39803
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39720
39804
  defaultValueDescription: false,
@@ -39722,6 +39806,8 @@ var ts;
39722
39806
  {
39723
39807
  name: "noPropertyAccessFromIndexSignature",
39724
39808
  type: "boolean",
39809
+ affectsSemanticDiagnostics: true,
39810
+ affectsMultiFileEmitBuildInfo: true,
39725
39811
  showInSimplifiedHelpView: false,
39726
39812
  category: ts.Diagnostics.Type_Checking,
39727
39813
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39807,6 +39893,7 @@ var ts;
39807
39893
  name: "allowSyntheticDefaultImports",
39808
39894
  type: "boolean",
39809
39895
  affectsSemanticDiagnostics: true,
39896
+ affectsMultiFileEmitBuildInfo: true,
39810
39897
  category: ts.Diagnostics.Interop_Constraints,
39811
39898
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39812
39899
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39816,6 +39903,7 @@ var ts;
39816
39903
  type: "boolean",
39817
39904
  affectsSemanticDiagnostics: true,
39818
39905
  affectsEmit: true,
39906
+ affectsMultiFileEmitBuildInfo: true,
39819
39907
  showInSimplifiedHelpView: true,
39820
39908
  category: ts.Diagnostics.Interop_Constraints,
39821
39909
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39832,6 +39920,7 @@ var ts;
39832
39920
  name: "allowUmdGlobalAccess",
39833
39921
  type: "boolean",
39834
39922
  affectsSemanticDiagnostics: true,
39923
+ affectsMultiFileEmitBuildInfo: true,
39835
39924
  category: ts.Diagnostics.Modules,
39836
39925
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39837
39926
  defaultValueDescription: false,
@@ -39853,6 +39942,7 @@ var ts;
39853
39942
  name: "sourceRoot",
39854
39943
  type: "string",
39855
39944
  affectsEmit: true,
39945
+ affectsMultiFileEmitBuildInfo: true,
39856
39946
  paramType: ts.Diagnostics.LOCATION,
39857
39947
  category: ts.Diagnostics.Emit,
39858
39948
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39861,6 +39951,7 @@ var ts;
39861
39951
  name: "mapRoot",
39862
39952
  type: "string",
39863
39953
  affectsEmit: true,
39954
+ affectsMultiFileEmitBuildInfo: true,
39864
39955
  paramType: ts.Diagnostics.LOCATION,
39865
39956
  category: ts.Diagnostics.Emit,
39866
39957
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39869,6 +39960,7 @@ var ts;
39869
39960
  name: "inlineSourceMap",
39870
39961
  type: "boolean",
39871
39962
  affectsEmit: true,
39963
+ affectsMultiFileEmitBuildInfo: true,
39872
39964
  category: ts.Diagnostics.Emit,
39873
39965
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39874
39966
  defaultValueDescription: false,
@@ -39877,6 +39969,7 @@ var ts;
39877
39969
  name: "inlineSources",
39878
39970
  type: "boolean",
39879
39971
  affectsEmit: true,
39972
+ affectsMultiFileEmitBuildInfo: true,
39880
39973
  category: ts.Diagnostics.Emit,
39881
39974
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39882
39975
  defaultValueDescription: false,
@@ -39886,6 +39979,7 @@ var ts;
39886
39979
  name: "experimentalDecorators",
39887
39980
  type: "boolean",
39888
39981
  affectsSemanticDiagnostics: true,
39982
+ affectsMultiFileEmitBuildInfo: true,
39889
39983
  category: ts.Diagnostics.Language_and_Environment,
39890
39984
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39891
39985
  defaultValueDescription: false,
@@ -39895,6 +39989,7 @@ var ts;
39895
39989
  type: "boolean",
39896
39990
  affectsSemanticDiagnostics: true,
39897
39991
  affectsEmit: true,
39992
+ affectsMultiFileEmitBuildInfo: true,
39898
39993
  category: ts.Diagnostics.Language_and_Environment,
39899
39994
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39900
39995
  defaultValueDescription: false,
@@ -39919,6 +40014,7 @@ var ts;
39919
40014
  type: "string",
39920
40015
  affectsSemanticDiagnostics: true,
39921
40016
  affectsEmit: true,
40017
+ affectsMultiFileEmitBuildInfo: true,
39922
40018
  affectsModuleResolution: true,
39923
40019
  category: ts.Diagnostics.Language_and_Environment,
39924
40020
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39936,6 +40032,9 @@ var ts;
39936
40032
  name: "out",
39937
40033
  type: "string",
39938
40034
  affectsEmit: true,
40035
+ affectsMultiFileEmitBuildInfo: true,
40036
+ affectsDeclarationPath: true,
40037
+ affectsBundleEmitBuildInfo: true,
39939
40038
  isFilePath: false,
39940
40039
  // for correct behaviour, please use outFile
39941
40040
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39947,6 +40046,7 @@ var ts;
39947
40046
  name: "reactNamespace",
39948
40047
  type: "string",
39949
40048
  affectsEmit: true,
40049
+ affectsMultiFileEmitBuildInfo: true,
39950
40050
  category: ts.Diagnostics.Language_and_Environment,
39951
40051
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39952
40052
  defaultValueDescription: "`React`",
@@ -39954,6 +40054,8 @@ var ts;
39954
40054
  {
39955
40055
  name: "skipDefaultLibCheck",
39956
40056
  type: "boolean",
40057
+ // We need to store these to determine whether `lib` files need to be rechecked
40058
+ affectsMultiFileEmitBuildInfo: true,
39957
40059
  category: ts.Diagnostics.Completeness,
39958
40060
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39959
40061
  defaultValueDescription: false,
@@ -39969,6 +40071,7 @@ var ts;
39969
40071
  name: "emitBOM",
39970
40072
  type: "boolean",
39971
40073
  affectsEmit: true,
40074
+ affectsMultiFileEmitBuildInfo: true,
39972
40075
  category: ts.Diagnostics.Emit,
39973
40076
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39974
40077
  defaultValueDescription: false,
@@ -39980,6 +40083,7 @@ var ts;
39980
40083
  lf: 1 /* LineFeed */
39981
40084
  })),
39982
40085
  affectsEmit: true,
40086
+ affectsMultiFileEmitBuildInfo: true,
39983
40087
  paramType: ts.Diagnostics.NEWLINE,
39984
40088
  category: ts.Diagnostics.Emit,
39985
40089
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39989,6 +40093,7 @@ var ts;
39989
40093
  name: "noErrorTruncation",
39990
40094
  type: "boolean",
39991
40095
  affectsSemanticDiagnostics: true,
40096
+ affectsMultiFileEmitBuildInfo: true,
39992
40097
  category: ts.Diagnostics.Output_Formatting,
39993
40098
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39994
40099
  defaultValueDescription: false,
@@ -40019,6 +40124,7 @@ var ts;
40019
40124
  name: "stripInternal",
40020
40125
  type: "boolean",
40021
40126
  affectsEmit: true,
40127
+ affectsMultiFileEmitBuildInfo: true,
40022
40128
  category: ts.Diagnostics.Emit,
40023
40129
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40024
40130
  defaultValueDescription: false,
@@ -40059,6 +40165,7 @@ var ts;
40059
40165
  name: "noImplicitUseStrict",
40060
40166
  type: "boolean",
40061
40167
  affectsSemanticDiagnostics: true,
40168
+ affectsMultiFileEmitBuildInfo: true,
40062
40169
  category: ts.Diagnostics.Backwards_Compatibility,
40063
40170
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40064
40171
  defaultValueDescription: false,
@@ -40067,6 +40174,7 @@ var ts;
40067
40174
  name: "noEmitHelpers",
40068
40175
  type: "boolean",
40069
40176
  affectsEmit: true,
40177
+ affectsMultiFileEmitBuildInfo: true,
40070
40178
  category: ts.Diagnostics.Emit,
40071
40179
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40072
40180
  defaultValueDescription: false,
@@ -40075,6 +40183,7 @@ var ts;
40075
40183
  name: "noEmitOnError",
40076
40184
  type: "boolean",
40077
40185
  affectsEmit: true,
40186
+ affectsMultiFileEmitBuildInfo: true,
40078
40187
  category: ts.Diagnostics.Emit,
40079
40188
  transpileOptionValue: undefined,
40080
40189
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40084,6 +40193,7 @@ var ts;
40084
40193
  name: "preserveConstEnums",
40085
40194
  type: "boolean",
40086
40195
  affectsEmit: true,
40196
+ affectsMultiFileEmitBuildInfo: true,
40087
40197
  category: ts.Diagnostics.Emit,
40088
40198
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40089
40199
  defaultValueDescription: false,
@@ -40092,6 +40202,8 @@ var ts;
40092
40202
  name: "declarationDir",
40093
40203
  type: "string",
40094
40204
  affectsEmit: true,
40205
+ affectsMultiFileEmitBuildInfo: true,
40206
+ affectsDeclarationPath: true,
40095
40207
  isFilePath: true,
40096
40208
  paramType: ts.Diagnostics.DIRECTORY,
40097
40209
  category: ts.Diagnostics.Emit,
@@ -40101,6 +40213,8 @@ var ts;
40101
40213
  {
40102
40214
  name: "skipLibCheck",
40103
40215
  type: "boolean",
40216
+ // We need to store these to determine whether `lib` files need to be rechecked
40217
+ affectsMultiFileEmitBuildInfo: true,
40104
40218
  category: ts.Diagnostics.Completeness,
40105
40219
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40106
40220
  defaultValueDescription: false,
@@ -40110,6 +40224,7 @@ var ts;
40110
40224
  type: "boolean",
40111
40225
  affectsBindDiagnostics: true,
40112
40226
  affectsSemanticDiagnostics: true,
40227
+ affectsMultiFileEmitBuildInfo: true,
40113
40228
  category: ts.Diagnostics.Type_Checking,
40114
40229
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40115
40230
  defaultValueDescription: undefined,
@@ -40119,6 +40234,7 @@ var ts;
40119
40234
  type: "boolean",
40120
40235
  affectsBindDiagnostics: true,
40121
40236
  affectsSemanticDiagnostics: true,
40237
+ affectsMultiFileEmitBuildInfo: true,
40122
40238
  category: ts.Diagnostics.Type_Checking,
40123
40239
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40124
40240
  defaultValueDescription: undefined,
@@ -40127,6 +40243,7 @@ var ts;
40127
40243
  name: "suppressExcessPropertyErrors",
40128
40244
  type: "boolean",
40129
40245
  affectsSemanticDiagnostics: true,
40246
+ affectsMultiFileEmitBuildInfo: true,
40130
40247
  category: ts.Diagnostics.Backwards_Compatibility,
40131
40248
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40132
40249
  defaultValueDescription: false,
@@ -40135,6 +40252,7 @@ var ts;
40135
40252
  name: "suppressImplicitAnyIndexErrors",
40136
40253
  type: "boolean",
40137
40254
  affectsSemanticDiagnostics: true,
40255
+ affectsMultiFileEmitBuildInfo: true,
40138
40256
  category: ts.Diagnostics.Backwards_Compatibility,
40139
40257
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40140
40258
  defaultValueDescription: false,
@@ -40159,6 +40277,7 @@ var ts;
40159
40277
  name: "noStrictGenericChecks",
40160
40278
  type: "boolean",
40161
40279
  affectsSemanticDiagnostics: true,
40280
+ affectsMultiFileEmitBuildInfo: true,
40162
40281
  category: ts.Diagnostics.Backwards_Compatibility,
40163
40282
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40164
40283
  defaultValueDescription: false,
@@ -40168,6 +40287,7 @@ var ts;
40168
40287
  type: "boolean",
40169
40288
  affectsSemanticDiagnostics: true,
40170
40289
  affectsEmit: true,
40290
+ affectsMultiFileEmitBuildInfo: true,
40171
40291
  category: ts.Diagnostics.Language_and_Environment,
40172
40292
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40173
40293
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40176,6 +40296,7 @@ var ts;
40176
40296
  name: "preserveValueImports",
40177
40297
  type: "boolean",
40178
40298
  affectsEmit: true,
40299
+ affectsMultiFileEmitBuildInfo: true,
40179
40300
  category: ts.Diagnostics.Emit,
40180
40301
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40181
40302
  defaultValueDescription: false,
@@ -40219,6 +40340,8 @@ var ts;
40219
40340
  /* @internal */
40220
40341
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40221
40342
  /* @internal */
40343
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40344
+ /* @internal */
40222
40345
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40223
40346
  /* @internal */
40224
40347
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41074,6 +41197,7 @@ var ts;
41074
41197
  return optionDefinition.type;
41075
41198
  }
41076
41199
  }
41200
+ /* @internal */
41077
41201
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41078
41202
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41079
41203
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41082,6 +41206,7 @@ var ts;
41082
41206
  }
41083
41207
  });
41084
41208
  }
41209
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41085
41210
  function serializeCompilerOptions(options, pathOptions) {
41086
41211
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41087
41212
  }
@@ -42247,16 +42372,18 @@ var ts;
42247
42372
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42248
42373
  return { fileName: resolved.path, packageId: resolved.packageId };
42249
42374
  }
42250
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42251
- var _a;
42375
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42376
+ var _a, _b;
42252
42377
  if (resultFromCache) {
42253
42378
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42379
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42254
42380
  return resultFromCache;
42255
42381
  }
42256
42382
  return {
42257
42383
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42258
42384
  failedLookupLocations: failedLookupLocations,
42259
- resolutionDiagnostics: diagnostics
42385
+ affectingLocations: affectingLocations,
42386
+ resolutionDiagnostics: diagnostics,
42260
42387
  };
42261
42388
  }
42262
42389
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42445,6 +42572,7 @@ var ts;
42445
42572
  }
42446
42573
  }
42447
42574
  var failedLookupLocations = [];
42575
+ var affectingLocations = [];
42448
42576
  var features = getDefaultNodeResolutionFeatures(options);
42449
42577
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42450
42578
  // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
@@ -42463,6 +42591,7 @@ var ts;
42463
42591
  host: host,
42464
42592
  traceEnabled: traceEnabled,
42465
42593
  failedLookupLocations: failedLookupLocations,
42594
+ affectingLocations: affectingLocations,
42466
42595
  packageJsonInfoCache: cache,
42467
42596
  features: features,
42468
42597
  conditions: conditions,
@@ -42487,7 +42616,7 @@ var ts;
42487
42616
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42488
42617
  };
42489
42618
  }
42490
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42619
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42491
42620
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42492
42621
  if (traceEnabled)
42493
42622
  traceResult(result);
@@ -42567,6 +42696,7 @@ var ts;
42567
42696
  host: host,
42568
42697
  traceEnabled: isTraceEnabled(options, host),
42569
42698
  failedLookupLocations: [],
42699
+ affectingLocations: [],
42570
42700
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42571
42701
  conditions: ts.emptyArray,
42572
42702
  features: NodeResolutionFeatures.None,
@@ -43221,6 +43351,7 @@ var ts;
43221
43351
  var _a, _b;
43222
43352
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43223
43353
  var failedLookupLocations = [];
43354
+ var affectingLocations = [];
43224
43355
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43225
43356
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43226
43357
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43233,6 +43364,7 @@ var ts;
43233
43364
  host: host,
43234
43365
  traceEnabled: traceEnabled,
43235
43366
  failedLookupLocations: failedLookupLocations,
43367
+ affectingLocations: affectingLocations,
43236
43368
  packageJsonInfoCache: cache,
43237
43369
  features: features,
43238
43370
  conditions: conditions,
@@ -43240,7 +43372,7 @@ var ts;
43240
43372
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43241
43373
  };
43242
43374
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43243
- 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);
43375
+ 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);
43244
43376
  function tryResolve(extensions) {
43245
43377
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43246
43378
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43535,6 +43667,7 @@ var ts;
43535
43667
  host: host,
43536
43668
  traceEnabled: isTraceEnabled(options, host),
43537
43669
  failedLookupLocations: [],
43670
+ affectingLocations: [],
43538
43671
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43539
43672
  conditions: ["node", "require", "types"],
43540
43673
  features: features,
@@ -43623,6 +43756,7 @@ var ts;
43623
43756
  compilerOptions: options,
43624
43757
  traceEnabled: isTraceEnabled(options, host),
43625
43758
  failedLookupLocations: [],
43759
+ affectingLocations: [],
43626
43760
  packageJsonInfoCache: packageJsonInfoCache,
43627
43761
  features: 0,
43628
43762
  conditions: [],
@@ -43655,6 +43789,7 @@ var ts;
43655
43789
  if (typeof existing !== "boolean") {
43656
43790
  if (traceEnabled)
43657
43791
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43792
+ state.affectingLocations.push(packageJsonPath);
43658
43793
  return existing;
43659
43794
  }
43660
43795
  else {
@@ -43673,6 +43808,7 @@ var ts;
43673
43808
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43674
43809
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43675
43810
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
43811
+ state.affectingLocations.push(packageJsonPath);
43676
43812
  return result;
43677
43813
  }
43678
43814
  else {
@@ -44336,12 +44472,25 @@ var ts;
44336
44472
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44337
44473
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44338
44474
  var failedLookupLocations = [];
44475
+ var affectingLocations = [];
44339
44476
  var containingDirectory = ts.getDirectoryPath(containingFile);
44340
44477
  var diagnostics = [];
44341
- 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); } };
44478
+ var state = {
44479
+ compilerOptions: compilerOptions,
44480
+ host: host,
44481
+ traceEnabled: traceEnabled,
44482
+ failedLookupLocations: failedLookupLocations,
44483
+ affectingLocations: affectingLocations,
44484
+ packageJsonInfoCache: cache,
44485
+ features: NodeResolutionFeatures.None,
44486
+ conditions: [],
44487
+ requestContainingDirectory: containingDirectory,
44488
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44489
+ };
44342
44490
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44343
44491
  // No originalPath because classic resolution doesn't resolve realPath
44344
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44492
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
44493
+ /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44345
44494
  function tryResolve(extensions) {
44346
44495
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44347
44496
  if (resolvedUsingSettings) {
@@ -44384,10 +44533,23 @@ var ts;
44384
44533
  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);
44385
44534
  }
44386
44535
  var failedLookupLocations = [];
44536
+ var affectingLocations = [];
44387
44537
  var diagnostics = [];
44388
- 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); } };
44538
+ var state = {
44539
+ compilerOptions: compilerOptions,
44540
+ host: host,
44541
+ traceEnabled: traceEnabled,
44542
+ failedLookupLocations: failedLookupLocations,
44543
+ affectingLocations: affectingLocations,
44544
+ packageJsonInfoCache: packageJsonInfoCache,
44545
+ features: NodeResolutionFeatures.None,
44546
+ conditions: [],
44547
+ requestContainingDirectory: undefined,
44548
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44549
+ };
44389
44550
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44390
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44551
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44552
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44391
44553
  }
44392
44554
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44393
44555
  /**
@@ -47948,16 +48110,6 @@ var ts;
47948
48110
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47949
48111
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47950
48112
  })(TypeFacts || (TypeFacts = {}));
47951
- var typeofEQFacts = new ts.Map(ts.getEntries({
47952
- string: 1 /* TypeofEQString */,
47953
- number: 2 /* TypeofEQNumber */,
47954
- bigint: 4 /* TypeofEQBigInt */,
47955
- boolean: 8 /* TypeofEQBoolean */,
47956
- symbol: 16 /* TypeofEQSymbol */,
47957
- undefined: 65536 /* EQUndefined */,
47958
- object: 32 /* TypeofEQObject */,
47959
- function: 64 /* TypeofEQFunction */
47960
- }));
47961
48113
  var typeofNEFacts = new ts.Map(ts.getEntries({
47962
48114
  string: 256 /* TypeofNEString */,
47963
48115
  number: 512 /* TypeofNENumber */,
@@ -48756,14 +48908,6 @@ var ts;
48756
48908
  var awaitedTypeStack = [];
48757
48909
  var diagnostics = ts.createDiagnosticCollection();
48758
48910
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48759
- var typeofTypesByName = new ts.Map(ts.getEntries({
48760
- string: stringType,
48761
- number: numberType,
48762
- bigint: bigintType,
48763
- boolean: booleanType,
48764
- symbol: esSymbolType,
48765
- undefined: undefinedType
48766
- }));
48767
48911
  var typeofType = createTypeofType();
48768
48912
  var _jsxNamespace;
48769
48913
  var _jsxFactoryEntity;
@@ -51639,7 +51783,7 @@ var ts;
51639
51783
  return type;
51640
51784
  }
51641
51785
  function createTypeofType() {
51642
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51786
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51643
51787
  }
51644
51788
  function createTypeParameter(symbol) {
51645
51789
  var type = createType(262144 /* TypeParameter */);
@@ -52425,6 +52569,9 @@ var ts;
52425
52569
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52426
52570
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52427
52571
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
52572
+ if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
52573
+ return ts.factory.createArrayTypeNode(typeArgumentNodes[0]);
52574
+ }
52428
52575
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52429
52576
  }
52430
52577
  var objectFlags = ts.getObjectFlags(type);
@@ -52615,7 +52762,7 @@ var ts;
52615
52762
  // Always use 'typeof T' for type of class, enum, and module objects
52616
52763
  else if (symbol.flags & 32 /* Class */
52617
52764
  && !getBaseTypeVariableOfClass(symbol)
52618
- && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) ||
52765
+ && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) ||
52619
52766
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52620
52767
  shouldWriteTypeOfFunctionSymbol()) {
52621
52768
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56245,6 +56392,17 @@ var ts;
56245
56392
  });
56246
56393
  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
56247
56394
  members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
56395
+ if (initialSize === members_4.size) {
56396
+ if (type.aliasSymbol) {
56397
+ result.aliasSymbol = type.aliasSymbol;
56398
+ result.aliasTypeArguments = type.aliasTypeArguments;
56399
+ }
56400
+ if (ts.getObjectFlags(type) & 4 /* Reference */) {
56401
+ result.aliasSymbol = type.symbol;
56402
+ var args = getTypeArguments(type);
56403
+ result.aliasTypeArguments = ts.length(args) ? args : undefined;
56404
+ }
56405
+ }
56248
56406
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56249
56407
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56250
56408
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -69853,19 +70011,17 @@ var ts;
69853
70011
  }
69854
70012
  return links.switchTypes;
69855
70013
  }
69856
- function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
70014
+ // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are
70015
+ // represented as undefined. Return undefined if one or more case clause expressions are not string literals.
70016
+ function getSwitchClauseTypeOfWitnesses(switchStatement) {
70017
+ if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) {
70018
+ return undefined;
70019
+ }
69857
70020
  var witnesses = [];
69858
70021
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
69859
70022
  var clause = _a[_i];
69860
- if (clause.kind === 289 /* CaseClause */) {
69861
- if (ts.isStringLiteralLike(clause.expression)) {
69862
- witnesses.push(clause.expression.text);
69863
- continue;
69864
- }
69865
- return ts.emptyArray;
69866
- }
69867
- if (retainDefault)
69868
- witnesses.push(/*explicitDefaultStatement*/ undefined);
70023
+ var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined;
70024
+ witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined);
69869
70025
  }
69870
70026
  return witnesses;
69871
70027
  }
@@ -71055,14 +71211,9 @@ var ts;
71055
71211
  }
71056
71212
  return type;
71057
71213
  }
71058
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71059
- return type;
71060
- }
71061
- var facts = assumeTrue ?
71062
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71063
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71064
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71065
- return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71214
+ return assumeTrue ?
71215
+ narrowTypeByTypeName(type, literal.text) :
71216
+ getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
71066
71217
  }
71067
71218
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71068
71219
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71109,102 +71260,52 @@ var ts;
71109
71260
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71110
71261
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71111
71262
  }
71112
- function getImpliedTypeFromTypeofGuard(type, text) {
71113
- switch (text) {
71114
- case "object":
71115
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71116
- case "function":
71117
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71118
- default:
71119
- return typeofTypesByName.get(text);
71263
+ function narrowTypeByTypeName(type, typeName) {
71264
+ switch (typeName) {
71265
+ case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */);
71266
+ case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */);
71267
+ case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */);
71268
+ case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */);
71269
+ case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */);
71270
+ case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]);
71271
+ case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */);
71272
+ case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */);
71120
71273
  }
71274
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71121
71275
  }
71122
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71123
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71124
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71125
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71126
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71127
- // filtering by type-facts.
71128
- function narrowTypeByImpliedType(type, candidate) {
71129
- if (type.flags & 3 /* AnyOrUnknown */) {
71130
- return candidate;
71131
- }
71276
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71132
71277
  return mapType(type, function (t) {
71133
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71134
- return t;
71135
- }
71136
- return mapType(candidate, function (c) {
71137
- if (!areTypesComparable(t, c)) {
71138
- return neverType;
71139
- }
71140
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71141
- return isTypeSubtypeOf(c, t) ? c : neverType;
71142
- }
71143
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71144
- return c;
71145
- }
71146
- return getIntersectionType([t, c]);
71147
- });
71278
+ // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
71279
+ // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
71280
+ // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
71281
+ // but are classified as "function" according to `typeof`.
71282
+ return isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType :
71283
+ // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
71284
+ // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
71285
+ isTypeSubtypeOf(impliedType, t) ? impliedType :
71286
+ // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
71287
+ // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
71288
+ // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
71289
+ getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) :
71290
+ neverType;
71148
71291
  });
71149
71292
  }
71150
71293
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71151
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71152
- if (!switchWitnesses.length) {
71294
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71295
+ if (!witnesses) {
71153
71296
  return type;
71154
71297
  }
71155
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71156
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71157
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71158
- var clauseWitnesses;
71159
- var switchFacts;
71160
- if (defaultCaseLocation > -1) {
71161
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71162
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71163
- // witness array.
71164
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71165
- // The adjusted clause start and end after removing the `default` statement.
71166
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71167
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71168
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71169
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71170
- }
71171
- else {
71172
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71173
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71174
- }
71298
+ // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause.
71299
+ var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; });
71300
+ var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd);
71175
71301
  if (hasDefaultClause) {
71176
- return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
71302
+ // In the default clause we filter constituents down to those that are not-equal to all handled cases.
71303
+ var notEqualFacts_1 = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
71304
+ return filterType(type, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; });
71177
71305
  }
71178
- /*
71179
- The implied type is the raw type suggested by a
71180
- value being caught in this clause.
71181
-
71182
- When the clause contains a default case we ignore
71183
- the implied type and try to narrow using any facts
71184
- we can learn: see `switchFacts`.
71185
-
71186
- Example:
71187
- switch (typeof x) {
71188
- case 'number':
71189
- case 'string': break;
71190
- default: break;
71191
- case 'number':
71192
- case 'boolean': break
71193
- }
71194
-
71195
- In the first clause (case `number` and `string`) the
71196
- implied type is number | string.
71197
-
71198
- In the default clause we de not compute an implied type.
71199
-
71200
- In the third clause (case `number` and `boolean`)
71201
- the naive implied type is number | boolean, however
71202
- we use the type facts to narrow the implied type to
71203
- boolean. We know that number cannot be selected
71204
- because it is caught in the first clause.
71205
- */
71206
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71207
- return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71306
+ // In the non-default cause we create a union of the type narrowed by each of the listed cases.
71307
+ var clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71308
+ return getUnionType(ts.map(clauseWitnesses, function (text) { return text ? narrowTypeByTypeName(type, text) : neverType; }));
71208
71309
  }
71209
71310
  function isMatchingConstructorReference(expr) {
71210
71311
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -78016,45 +78117,12 @@ var ts;
78016
78117
  ? 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
78017
78118
  : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
78018
78119
  }
78019
- /**
78020
- * Collect the TypeFacts learned from a typeof switch with
78021
- * total clauses `witnesses`, and the active clause ranging
78022
- * from `start` to `end`. Parameter `hasDefault` denotes
78023
- * whether the active clause contains a default clause.
78024
- */
78025
- function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
78120
+ // Return the combined not-equal type facts for all cases except those between the start and end indices.
78121
+ function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) {
78026
78122
  var facts = 0 /* None */;
78027
- // When in the default we only collect inequality facts
78028
- // because default is 'in theory' a set of infinite
78029
- // equalities.
78030
- if (hasDefault) {
78031
- // Value is not equal to any types after the active clause.
78032
- for (var i = end; i < witnesses.length; i++) {
78033
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78034
- }
78035
- // Remove inequalities for types that appear in the
78036
- // active clause because they appear before other
78037
- // types collected so far.
78038
- for (var i = start; i < end; i++) {
78039
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78040
- }
78041
- // Add inequalities for types before the active clause unconditionally.
78042
- for (var i = 0; i < start; i++) {
78043
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78044
- }
78045
- }
78046
- // When in an active clause without default the set of
78047
- // equalities is finite.
78048
- else {
78049
- // Add equalities for all types in the active clause.
78050
- for (var i = start; i < end; i++) {
78051
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78052
- }
78053
- // Remove equalities for types that appear before the
78054
- // active clause.
78055
- for (var i = 0; i < start; i++) {
78056
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78057
- }
78123
+ for (var i = 0; i < witnesses.length; i++) {
78124
+ var witness = i < start || i >= end ? witnesses[i] : undefined;
78125
+ facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0;
78058
78126
  }
78059
78127
  return facts;
78060
78128
  }
@@ -78064,16 +78132,19 @@ var ts;
78064
78132
  }
78065
78133
  function computeExhaustiveSwitchStatement(node) {
78066
78134
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78067
- var operandType = getTypeOfExpression(node.expression.expression);
78068
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78069
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78070
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78071
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78072
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78073
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78074
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
78135
+ var witnesses = getSwitchClauseTypeOfWitnesses(node);
78136
+ if (!witnesses) {
78137
+ return false;
78138
+ }
78139
+ var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
78140
+ // Get the not-equal flags for all handled cases.
78141
+ var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
78142
+ if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
78143
+ // We special case the top types to be exhaustive when all cases are handled.
78144
+ return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */;
78075
78145
  }
78076
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
78146
+ // A missing not-equal flag indicates that the type wasn't handled by some case.
78147
+ return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
78077
78148
  }
78078
78149
  var type = getTypeOfExpression(node.expression);
78079
78150
  if (!isLiteralType(type)) {
@@ -110808,7 +110879,9 @@ var ts;
110808
110879
  return;
110809
110880
  }
110810
110881
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110811
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110882
+ var buildInfo = { bundle: bundle, program: program, version: version };
110883
+ // Pass buildinfo as additional data to avoid having to reparse
110884
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110812
110885
  }
110813
110886
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110814
110887
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110962,13 +111035,20 @@ var ts;
110962
111035
  if (sourceMapFilePath) {
110963
111036
  var sourceMap = sourceMapGenerator.toString();
110964
111037
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111038
+ if (printer.bundleFileInfo)
111039
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110965
111040
  }
110966
111041
  }
110967
111042
  else {
110968
111043
  writer.writeLine();
110969
111044
  }
110970
111045
  // Write the output file
110971
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111046
+ var text = writer.getText();
111047
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111048
+ // 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
111049
+ // 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
111050
+ if (printer.bundleFileInfo)
111051
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110972
111052
  // Reset state
110973
111053
  writer.clear();
110974
111054
  }
@@ -111111,34 +111191,56 @@ var ts;
111111
111191
  }
111112
111192
  /*@internal*/
111113
111193
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111194
+ var createHash = ts.maybeBind(host, host.createHash);
111114
111195
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111115
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111116
- if (!buildInfoText)
111196
+ var buildInfo;
111197
+ if (host.getBuildInfo) {
111198
+ // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111199
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111200
+ if (!hostBuildInfo)
111201
+ return buildInfoPath;
111202
+ buildInfo = hostBuildInfo;
111203
+ }
111204
+ else {
111205
+ var buildInfoText = host.readFile(buildInfoPath);
111206
+ if (!buildInfoText)
111207
+ return buildInfoPath;
111208
+ buildInfo = getBuildInfo(buildInfoText);
111209
+ }
111210
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111117
111211
  return buildInfoPath;
111118
111212
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111119
111213
  if (!jsFileText)
111120
111214
  return jsFilePath;
111215
+ // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111216
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111217
+ return jsFilePath;
111121
111218
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111122
111219
  // error if no source map or for now if inline sourcemap
111123
111220
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111124
111221
  return sourceMapFilePath || "inline sourcemap decoding";
111222
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111223
+ return sourceMapFilePath;
111125
111224
  // read declaration text
111126
111225
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111127
111226
  if (declarationFilePath && !declarationText)
111128
111227
  return declarationFilePath;
111228
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111229
+ return declarationFilePath;
111129
111230
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111130
111231
  // error if no source map or for now if inline sourcemap
111131
111232
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111132
111233
  return declarationMapPath || "inline sourcemap decoding";
111133
- var buildInfo = getBuildInfo(buildInfoText);
111134
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111135
- return buildInfoPath;
111234
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111235
+ return declarationMapPath;
111136
111236
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111137
111237
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111138
111238
  /*onlyOwnText*/ true);
111139
111239
  var outputFiles = [];
111140
111240
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111141
111241
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111242
+ var changedDtsText;
111243
+ var changedDtsData;
111142
111244
  var emitHost = {
111143
111245
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111144
111246
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111154,7 +111256,7 @@ var ts;
111154
111256
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111155
111257
  getProjectReferenceRedirect: ts.returnUndefined,
111156
111258
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111157
- writeFile: function (name, text, writeByteOrderMark) {
111259
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111158
111260
  switch (name) {
111159
111261
  case jsFilePath:
111160
111262
  if (jsFileText === text)
@@ -111165,8 +111267,13 @@ var ts;
111165
111267
  return;
111166
111268
  break;
111167
111269
  case buildInfoPath:
111168
- var newBuildInfo = getBuildInfo(text);
111270
+ var newBuildInfo = data.buildInfo;
111169
111271
  newBuildInfo.program = buildInfo.program;
111272
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111273
+ // Update the output signature
111274
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111275
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111276
+ }
111170
111277
  // Update sourceFileInfo
111171
111278
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111172
111279
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111174,11 +111281,13 @@ var ts;
111174
111281
  newBuildInfo.bundle.dts.sources = dts.sources;
111175
111282
  }
111176
111283
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111177
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111284
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111178
111285
  return;
111179
111286
  case declarationFilePath:
111180
111287
  if (declarationText === text)
111181
111288
  return;
111289
+ changedDtsText = text;
111290
+ changedDtsData = data;
111182
111291
  break;
111183
111292
  case declarationMapPath:
111184
111293
  if (declarationMapText === text)
@@ -111197,6 +111306,7 @@ var ts;
111197
111306
  getSourceFileFromReference: ts.returnUndefined,
111198
111307
  redirectTargetsMap: ts.createMultiMap(),
111199
111308
  getFileIncludeReasons: ts.notImplemented,
111309
+ createHash: createHash,
111200
111310
  };
111201
111311
  emitFiles(ts.notImplementedResolver, emitHost,
111202
111312
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116281,12 +116391,10 @@ var ts;
116281
116391
  }
116282
116392
  ts.createCompilerHost = createCompilerHost;
116283
116393
  /*@internal*/
116284
- // TODO(shkamat): update this after reworking ts build API
116285
116394
  function createCompilerHostWorker(options, setParentNodes, system) {
116286
116395
  if (system === void 0) { system = ts.sys; }
116287
116396
  var existingDirectories = new ts.Map();
116288
116397
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116289
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116290
116398
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116291
116399
  var text;
116292
116400
  try {
@@ -116319,7 +116427,7 @@ var ts;
116319
116427
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116320
116428
  // the system.writeFile will do its own directory creation and
116321
116429
  // the ensureDirectoriesExist call will always be redundant.
116322
- 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); });
116430
+ 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); });
116323
116431
  ts.performance.mark("afterIOWrite");
116324
116432
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116325
116433
  }
@@ -116329,35 +116437,6 @@ var ts;
116329
116437
  }
116330
116438
  }
116331
116439
  }
116332
- var outputFingerprints;
116333
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116334
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116335
- system.writeFile(fileName, data, writeByteOrderMark);
116336
- return;
116337
- }
116338
- if (!outputFingerprints) {
116339
- outputFingerprints = new ts.Map();
116340
- }
116341
- var hash = computeHash(data);
116342
- var mtimeBefore = system.getModifiedTime(fileName);
116343
- if (mtimeBefore) {
116344
- var fingerprint = outputFingerprints.get(fileName);
116345
- // If output has not been changed, and the file has no external modification
116346
- if (fingerprint &&
116347
- fingerprint.byteOrderMark === writeByteOrderMark &&
116348
- fingerprint.hash === hash &&
116349
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116350
- return;
116351
- }
116352
- }
116353
- system.writeFile(fileName, data, writeByteOrderMark);
116354
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116355
- outputFingerprints.set(fileName, {
116356
- hash: hash,
116357
- byteOrderMark: writeByteOrderMark,
116358
- mtime: mtimeAfter
116359
- });
116360
- }
116361
116440
  function getDefaultLibLocation() {
116362
116441
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116363
116442
  }
@@ -117957,6 +118036,7 @@ var ts;
117957
118036
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117958
118037
  redirectTargetsMap: redirectTargetsMap,
117959
118038
  getFileIncludeReasons: program.getFileIncludeReasons,
118039
+ createHash: ts.maybeBind(host, host.createHash),
117960
118040
  };
117961
118041
  }
117962
118042
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120070,13 +120150,9 @@ var ts;
120070
120150
  function createManyToManyPathMap() {
120071
120151
  function create(forward, reverse, deleted) {
120072
120152
  var map = {
120073
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120074
- forEach: function (fn) { return forward.forEach(fn); },
120075
120153
  getKeys: function (v) { return reverse.get(v); },
120076
120154
  getValues: function (k) { return forward.get(k); },
120077
- hasKey: function (k) { return forward.has(k); },
120078
120155
  keys: function () { return forward.keys(); },
120079
- deletedKeys: function () { return deleted; },
120080
120156
  deleteKey: function (k) {
120081
120157
  (deleted || (deleted = new ts.Set())).add(k);
120082
120158
  var set = forward.get(k);
@@ -120103,11 +120179,6 @@ var ts;
120103
120179
  });
120104
120180
  return map;
120105
120181
  },
120106
- clear: function () {
120107
- forward.clear();
120108
- reverse.clear();
120109
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120110
- }
120111
120182
  };
120112
120183
  return map;
120113
120184
  }
@@ -120235,18 +120306,21 @@ var ts;
120235
120306
  * Creates the state of file references and signature for the new program from oldState if it is safe
120236
120307
  */
120237
120308
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120309
+ var _a, _b, _c;
120238
120310
  var fileInfos = new ts.Map();
120239
120311
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120240
120312
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120241
- var hasCalledUpdateShapeSignature = new ts.Set();
120242
120313
  var useOldState = canReuseOldState(referencedMap, oldState);
120243
120314
  // Ensure source files have parent pointers set
120244
120315
  newProgram.getTypeChecker();
120245
120316
  // Create the reference map, and set the file infos
120246
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120247
- var sourceFile = _a[_i];
120317
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120318
+ var sourceFile = _d[_i];
120248
120319
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120249
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120320
+ var oldUncommittedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120321
+ var signature = oldUncommittedSignature === undefined ?
120322
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120323
+ oldUncommittedSignature || undefined;
120250
120324
  if (referencedMap) {
120251
120325
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120252
120326
  if (newReferences) {
@@ -120254,19 +120328,26 @@ var ts;
120254
120328
  }
120255
120329
  // Copy old visible to outside files map
120256
120330
  if (useOldState) {
120257
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120331
+ var oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120332
+ var exportedModules = oldUncommittedExportedModules === undefined ?
120333
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120334
+ oldUncommittedExportedModules || undefined;
120258
120335
  if (exportedModules) {
120259
120336
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120260
120337
  }
120261
120338
  }
120262
120339
  }
120263
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120340
+ fileInfos.set(sourceFile.resolvedPath, {
120341
+ version: version_2,
120342
+ signature: signature,
120343
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120344
+ impliedFormat: sourceFile.impliedNodeFormat
120345
+ });
120264
120346
  }
120265
120347
  return {
120266
120348
  fileInfos: fileInfos,
120267
120349
  referencedMap: referencedMap,
120268
120350
  exportedModulesMap: exportedModulesMap,
120269
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120270
120351
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120271
120352
  };
120272
120353
  }
@@ -120280,71 +120361,42 @@ var ts;
120280
120361
  }
120281
120362
  BuilderState.releaseCache = releaseCache;
120282
120363
  /**
120283
- * Creates a clone of the state
120364
+ * Gets the files affected by the path from the program
120284
120365
  */
120285
- function clone(state) {
120366
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120286
120367
  var _a, _b;
120287
- // Dont need to backup allFiles info since its cache anyway
120288
- return {
120289
- fileInfos: new ts.Map(state.fileInfos),
120290
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120291
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120292
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120293
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120294
- };
120368
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120369
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120370
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120371
+ return result;
120295
120372
  }
120296
- BuilderState.clone = clone;
120297
- /**
120298
- * Gets the files affected by the path from the program
120299
- */
120300
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120301
- // Since the operation could be cancelled, the signatures are always stored in the cache
120302
- // They will be committed once it is safe to use them
120303
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120304
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120305
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120373
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120374
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120306
120375
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120307
120376
  if (!sourceFile) {
120308
120377
  return ts.emptyArray;
120309
120378
  }
120310
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120379
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120311
120380
  return [sourceFile];
120312
120381
  }
120313
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120314
- if (!cacheToUpdateSignature) {
120315
- // Commit all the signatures in the signature cache
120316
- updateSignaturesFromCache(state, signatureCache);
120317
- }
120318
- return result;
120319
- }
120320
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120321
- /**
120322
- * Updates the signatures from the cache into state's fileinfo signatures
120323
- * This should be called whenever it is safe to commit the state of the builder
120324
- */
120325
- function updateSignaturesFromCache(state, signatureCache) {
120326
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120382
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120327
120383
  }
120328
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120384
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120329
120385
  function updateSignatureOfFile(state, signature, path) {
120330
120386
  state.fileInfos.get(path).signature = signature;
120331
- state.hasCalledUpdateShapeSignature.add(path);
120387
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120332
120388
  }
120333
120389
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120334
120390
  /**
120335
120391
  * Returns if the shape of the signature has changed since last emit
120336
120392
  */
120337
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120393
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120394
+ var _a;
120338
120395
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120339
- ts.Debug.assert(!!sourceFile);
120340
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120341
120396
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120342
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120397
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
120343
120398
  return false;
120344
- }
120345
120399
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120346
- if (!info)
120347
- return ts.Debug.fail();
120348
120400
  var prevSignature = info.signature;
120349
120401
  var latestSignature;
120350
120402
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120355,45 +120407,55 @@ var ts;
120355
120407
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120356
120408
  if (firstDts_1) {
120357
120409
  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; })); });
120358
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120359
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120360
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120410
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120411
+ if (latestSignature !== prevSignature) {
120412
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120361
120413
  }
120362
120414
  }
120363
120415
  }
120364
120416
  // Default is to use file version as signature
120365
120417
  if (latestSignature === undefined) {
120366
120418
  latestSignature = sourceFile.version;
120367
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120419
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
120420
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120368
120421
  // All the references in this file are exported
120369
120422
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120370
120423
  if (references) {
120371
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120424
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120372
120425
  }
120373
120426
  else {
120374
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120427
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120375
120428
  }
120376
120429
  }
120377
120430
  }
120378
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120431
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120432
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120433
+ info.signature = latestSignature;
120379
120434
  return latestSignature !== prevSignature;
120380
120435
  }
120381
120436
  BuilderState.updateShapeSignature = updateShapeSignature;
120437
+ function computeSignature(text, computeHash) {
120438
+ return (computeHash || ts.generateDjb2Hash)(text);
120439
+ }
120440
+ BuilderState.computeSignature = computeSignature;
120382
120441
  /**
120383
120442
  * Coverts the declaration emit result into exported modules map
120384
120443
  */
120385
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120444
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120445
+ if (!state.exportedModulesMap)
120446
+ return;
120447
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120386
120448
  if (!exportedModulesFromDeclarationEmit) {
120387
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120449
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120388
120450
  return;
120389
120451
  }
120390
120452
  var exportedModules;
120391
120453
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120392
120454
  if (exportedModules) {
120393
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120455
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120394
120456
  }
120395
120457
  else {
120396
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120458
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120397
120459
  }
120398
120460
  function addExportedModule(exportedModulePaths) {
120399
120461
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120405,19 +120467,6 @@ var ts;
120405
120467
  }
120406
120468
  }
120407
120469
  BuilderState.updateExportedModules = updateExportedModules;
120408
- /**
120409
- * Updates the exported modules from cache into state's exported modules map
120410
- * This should be called whenever it is safe to commit the state of the builder
120411
- */
120412
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120413
- var _a;
120414
- if (exportedModulesMapCache) {
120415
- ts.Debug.assert(!!state.exportedModulesMap);
120416
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120417
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120418
- }
120419
- }
120420
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120421
120470
  /**
120422
120471
  * Get all the dependencies of the sourceFile
120423
120472
  */
@@ -120538,7 +120587,7 @@ var ts;
120538
120587
  /**
120539
120588
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120540
120589
  */
120541
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120590
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120542
120591
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120543
120592
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120544
120593
  }
@@ -120558,7 +120607,7 @@ var ts;
120558
120607
  if (!seenFileNamesMap.has(currentPath)) {
120559
120608
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120560
120609
  seenFileNamesMap.set(currentPath, currentSourceFile);
120561
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120610
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120562
120611
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120563
120612
  }
120564
120613
  }
@@ -120584,32 +120633,33 @@ var ts;
120584
120633
  * Create the state so that we can iterate on changedFiles/affected files
120585
120634
  */
120586
120635
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120636
+ var _a, _b;
120587
120637
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120588
120638
  state.program = newProgram;
120589
120639
  var compilerOptions = newProgram.getCompilerOptions();
120590
120640
  state.compilerOptions = compilerOptions;
120641
+ var outFilePath = ts.outFile(compilerOptions);
120591
120642
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120592
- if (!ts.outFile(compilerOptions)) {
120643
+ if (!outFilePath) {
120593
120644
  state.semanticDiagnosticsPerFile = new ts.Map();
120594
120645
  }
120646
+ 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)) {
120647
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120648
+ }
120595
120649
  state.changedFilesSet = new ts.Set();
120650
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120596
120651
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120597
120652
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120598
120653
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120599
120654
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120655
+ var canCopyEmitSignatures = compilerOptions.composite &&
120656
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120657
+ !outFilePath &&
120658
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120600
120659
  if (useOldState) {
120601
- // Verify the sanity of old state
120602
- if (!oldState.currentChangedFilePath) {
120603
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120604
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120605
- }
120606
- var changedFilesSet = oldState.changedFilesSet;
120607
- if (canCopySemanticDiagnostics) {
120608
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120609
- }
120610
120660
  // Copy old state's changed files set
120611
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120612
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120661
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120662
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
120613
120663
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120614
120664
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120615
120665
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120630,6 +120680,8 @@ var ts;
120630
120680
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120631
120681
  // versions dont match
120632
120682
  oldInfo.version !== info.version ||
120683
+ // Implied formats dont match
120684
+ oldInfo.impliedFormat !== info.impliedFormat ||
120633
120685
  // Referenced files changed
120634
120686
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120635
120687
  // Referenced file was deleted in the new program
@@ -120653,27 +120705,25 @@ var ts;
120653
120705
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120654
120706
  }
120655
120707
  }
120708
+ if (canCopyEmitSignatures) {
120709
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120710
+ if (oldEmitSignature)
120711
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120712
+ }
120656
120713
  });
120657
120714
  // If the global file is removed, add all files as changed
120658
120715
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120659
120716
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120660
120717
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120661
120718
  }
120662
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120719
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120663
120720
  // Add all files to affectedFilesPendingEmit since emit changed
120664
120721
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120665
120722
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120666
120723
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120667
120724
  }
120668
- if (useOldState) {
120669
- // Any time the interpretation of a source file changes, mark it as changed
120670
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120671
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120672
- state.changedFilesSet.add(sourceFilePath);
120673
- }
120674
- });
120675
- }
120676
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120725
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120726
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120677
120727
  return state;
120678
120728
  }
120679
120729
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120709,30 +120759,35 @@ var ts;
120709
120759
  ts.BuilderState.releaseCache(state);
120710
120760
  state.program = undefined;
120711
120761
  }
120712
- /**
120713
- * Creates a clone of the state
120714
- */
120715
- function cloneBuilderProgramState(state) {
120716
- var _a;
120717
- var newState = ts.BuilderState.clone(state);
120718
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120719
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120720
- newState.affectedFiles = state.affectedFiles;
120721
- newState.affectedFilesIndex = state.affectedFilesIndex;
120722
- newState.currentChangedFilePath = state.currentChangedFilePath;
120723
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120724
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120725
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120726
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120727
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120728
- newState.program = state.program;
120729
- newState.compilerOptions = state.compilerOptions;
120730
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120731
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120732
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120733
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120734
- newState.programEmitComplete = state.programEmitComplete;
120735
- return newState;
120762
+ function backupBuilderProgramEmitState(state) {
120763
+ var outFilePath = ts.outFile(state.compilerOptions);
120764
+ // Only in --out changeFileSet is kept around till emit
120765
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120766
+ return {
120767
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120768
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120769
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120770
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120771
+ programEmitComplete: state.programEmitComplete,
120772
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120773
+ outSignature: state.outSignature,
120774
+ dtsChangeTime: state.dtsChangeTime,
120775
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120776
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120777
+ };
120778
+ }
120779
+ function restoreBuilderProgramEmitState(state, savedEmitState) {
120780
+ state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
120781
+ state.affectedFilesPendingEmitKind = savedEmitState.affectedFilesPendingEmitKind;
120782
+ state.affectedFilesPendingEmitIndex = savedEmitState.affectedFilesPendingEmitIndex;
120783
+ state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
120784
+ state.programEmitComplete = savedEmitState.programEmitComplete;
120785
+ state.emitSignatures = savedEmitState.emitSignatures;
120786
+ state.outSignature = savedEmitState.outSignature;
120787
+ state.dtsChangeTime = savedEmitState.dtsChangeTime;
120788
+ state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
120789
+ if (savedEmitState.changedFilesSet)
120790
+ state.changedFilesSet = savedEmitState.changedFilesSet;
120736
120791
  }
120737
120792
  /**
120738
120793
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120747,7 +120802,7 @@ var ts;
120747
120802
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120748
120803
  */
120749
120804
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120750
- var _a;
120805
+ var _a, _b;
120751
120806
  while (true) {
120752
120807
  var affectedFiles = state.affectedFiles;
120753
120808
  if (affectedFiles) {
@@ -120767,10 +120822,8 @@ var ts;
120767
120822
  state.changedFilesSet.delete(state.currentChangedFilePath);
120768
120823
  state.currentChangedFilePath = undefined;
120769
120824
  // Commit the changes in file signature
120770
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120771
- state.currentAffectedFilesSignatures.clear();
120772
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120773
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120825
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120826
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120774
120827
  state.affectedFiles = undefined;
120775
120828
  }
120776
120829
  // Get next changed file
@@ -120788,12 +120841,7 @@ var ts;
120788
120841
  return program;
120789
120842
  }
120790
120843
  // Get next batch of affected files
120791
- if (!state.currentAffectedFilesSignatures)
120792
- state.currentAffectedFilesSignatures = new ts.Map();
120793
- if (state.exportedModulesMap) {
120794
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120795
- }
120796
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120844
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120797
120845
  state.currentChangedFilePath = nextKey.value;
120798
120846
  state.affectedFilesIndex = 0;
120799
120847
  if (!state.seenAffectedFiles)
@@ -120845,7 +120893,6 @@ var ts;
120845
120893
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120846
120894
  */
120847
120895
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120848
- var _a;
120849
120896
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120850
120897
  // If affected files is everything except default library, then nothing more to do
120851
120898
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120853,10 +120900,9 @@ var ts;
120853
120900
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120854
120901
  // That means when affected file is handled, its signature can be out of date
120855
120902
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120856
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120903
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120857
120904
  return;
120858
120905
  }
120859
- 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);
120860
120906
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120861
120907
  return;
120862
120908
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120876,7 +120922,7 @@ var ts;
120876
120922
  // This ensures that we dont later during incremental builds considering wrong signature.
120877
120923
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120878
120924
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120879
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120925
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120880
120926
  // If not dts emit, nothing more to do
120881
120927
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120882
120928
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120897,27 +120943,10 @@ var ts;
120897
120943
  return !state.semanticDiagnosticsFromOldState.size;
120898
120944
  }
120899
120945
  function isChangedSignature(state, path) {
120900
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120901
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120946
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120947
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120902
120948
  return newSignature !== oldSignature;
120903
120949
  }
120904
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120905
- // Go through exported modules from cache first
120906
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120907
- var result = keys && ts.forEachKey(keys, fn);
120908
- if (result)
120909
- return result;
120910
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120911
- keys = state.exportedModulesMap.getKeys(filePath);
120912
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120913
- var _a;
120914
- // If the cache had an updated value, skip
120915
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120916
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120917
- fn(exportedFromPath) :
120918
- undefined;
120919
- });
120920
- }
120921
120950
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120922
120951
  var _a;
120923
120952
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120932,6 +120961,7 @@ var ts;
120932
120961
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120933
120962
  */
120934
120963
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120964
+ var _a;
120935
120965
  // If there was change in signature (dts output) for the changed file,
120936
120966
  // then only we need to handle pending file emit
120937
120967
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120958,11 +120988,10 @@ var ts;
120958
120988
  }
120959
120989
  }
120960
120990
  }
120961
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120962
120991
  var seenFileAndExportsOfFile = new ts.Set();
120963
120992
  // Go through exported modules from cache first
120964
120993
  // If exported modules has path, all files referencing file exported from are affected
120965
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120994
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120966
120995
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120967
120996
  return true;
120968
120997
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120976,19 +121005,18 @@ var ts;
120976
121005
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120977
121006
  */
120978
121007
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120979
- var _a;
121008
+ var _a, _b;
120980
121009
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120981
121010
  return undefined;
120982
121011
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120983
121012
  return true;
120984
121013
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120985
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120986
121014
  // If exported modules has path, all files referencing file exported from are affected
120987
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121015
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120988
121016
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120989
121017
  });
120990
121018
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120991
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
121019
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120992
121020
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120993
121021
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120994
121022
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -121009,12 +121037,13 @@ var ts;
121009
121037
  }
121010
121038
  else {
121011
121039
  state.seenAffectedFiles.add(affected.resolvedPath);
121040
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121041
+ state.buildInfoEmitPending = true;
121012
121042
  if (emitKind !== undefined) {
121013
121043
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
121014
121044
  }
121015
121045
  if (isPendingEmit) {
121016
121046
  state.affectedFilesPendingEmitIndex++;
121017
- state.buildInfoEmitPending = true;
121018
121047
  }
121019
121048
  else {
121020
121049
  state.affectedFilesIndex++;
@@ -121062,25 +121091,62 @@ var ts;
121062
121091
  }
121063
121092
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121064
121093
  }
121094
+ function isProgramBundleEmitBuildInfo(info) {
121095
+ return !!ts.outFile(info.options || {});
121096
+ }
121097
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121065
121098
  /**
121066
121099
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121067
121100
  */
121068
- function getProgramBuildInfo(state, getCanonicalFileName) {
121069
- if (ts.outFile(state.compilerOptions))
121070
- return undefined;
121101
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121102
+ var outFilePath = ts.outFile(state.compilerOptions);
121103
+ if (outFilePath && !state.compilerOptions.composite)
121104
+ return;
121071
121105
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121072
121106
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121107
+ // Update the dtsChange time in buildInfo
121108
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121109
+ if (outFilePath) {
121110
+ var fileNames_1 = [];
121111
+ var fileInfos_1 = [];
121112
+ state.program.getRootFileNames().forEach(function (f) {
121113
+ var sourceFile = state.program.getSourceFile(f);
121114
+ if (!sourceFile)
121115
+ return;
121116
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121117
+ fileInfos_1.push(sourceFile.version);
121118
+ });
121119
+ var result_15 = {
121120
+ fileNames: fileNames_1,
121121
+ fileInfos: fileInfos_1,
121122
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121123
+ outSignature: state.outSignature,
121124
+ dtsChangeTime: state.dtsChangeTime,
121125
+ };
121126
+ return result_15;
121127
+ }
121073
121128
  var fileNames = [];
121074
121129
  var fileNameToFileId = new ts.Map();
121075
121130
  var fileIdsList;
121076
121131
  var fileNamesToFileIdListId;
121132
+ var emitSignatures;
121077
121133
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121134
+ var _b, _c;
121078
121135
  var key = _a[0], value = _a[1];
121079
121136
  // Ensure fileId
121080
121137
  var fileId = toFileId(key);
121081
121138
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121082
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121083
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
121139
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
121140
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
121141
+ if (state.compilerOptions.composite) {
121142
+ var file = state.program.getSourceFileByPath(key);
121143
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
121144
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
121145
+ if (emitSignature !== actualSignature) {
121146
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
121147
+ }
121148
+ }
121149
+ }
121084
121150
  return value.version === actualSignature ?
121085
121151
  value.affectsGlobalScope || value.impliedFormat ?
121086
121152
  // If file version is same as signature, dont serialize signature
@@ -121088,11 +121154,11 @@ var ts;
121088
121154
  // If file info only contains version and signature and both are same we can just write string
121089
121155
  value.version :
121090
121156
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121091
- signature === undefined ?
121157
+ oldSignature === undefined ?
121092
121158
  // If we havent computed signature, use fileInfo as is
121093
121159
  value :
121094
121160
  // Serialize fileInfo with new updated signature
121095
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121161
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121096
121162
  // Signature of the FileInfo is undefined, serialize it as false
121097
121163
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121098
121164
  });
@@ -121107,17 +121173,13 @@ var ts;
121107
121173
  if (state.exportedModulesMap) {
121108
121174
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121109
121175
  var _a;
121110
- if (state.currentAffectedFilesExportedModulesMap) {
121111
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121112
- return undefined;
121113
- }
121114
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121115
- if (newValue) {
121116
- return [toFileId(key), toFileIdListId(newValue)];
121117
- }
121118
- }
121176
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121119
121177
  // Not in temporary cache, use existing value
121120
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121178
+ if (oldValue === undefined)
121179
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121180
+ if (oldValue)
121181
+ return [toFileId(key), toFileIdListId(oldValue)];
121182
+ return undefined;
121121
121183
  });
121122
121184
  }
121123
121185
  var semanticDiagnosticsPerFile;
@@ -121128,9 +121190,7 @@ var ts;
121128
121190
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121129
121191
  [
121130
121192
  toFileId(key),
121131
- state.hasReusableDiagnostic ?
121132
- value :
121133
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121193
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121134
121194
  ] :
121135
121195
  toFileId(key));
121136
121196
  }
@@ -121145,16 +121205,27 @@ var ts;
121145
121205
  }
121146
121206
  }
121147
121207
  }
121148
- return {
121208
+ var changeFileSet;
121209
+ if (state.changedFilesSet.size) {
121210
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
121211
+ var path = _e[_d];
121212
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
121213
+ }
121214
+ }
121215
+ var result = {
121149
121216
  fileNames: fileNames,
121150
121217
  fileInfos: fileInfos,
121151
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121218
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121152
121219
  fileIdsList: fileIdsList,
121153
121220
  referencedMap: referencedMap,
121154
121221
  exportedModulesMap: exportedModulesMap,
121155
121222
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121156
121223
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121224
+ changeFileSet: changeFileSet,
121225
+ emitSignatures: emitSignatures,
121226
+ dtsChangeTime: state.dtsChangeTime,
121157
121227
  };
121228
+ return result;
121158
121229
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121159
121230
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121160
121231
  }
@@ -121179,24 +121250,21 @@ var ts;
121179
121250
  }
121180
121251
  return fileIdListId;
121181
121252
  }
121182
- }
121183
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121184
- var result;
121185
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121186
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121187
- var name = _a[_i];
121188
- var optionKey = name.toLowerCase();
121189
- var optionInfo = optionsNameMap.get(optionKey);
121190
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121191
- // We need to store `strict`, even though it won't be examined directly, so that the
121192
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121193
- optionKey === "strict" ||
121194
- // We need to store these to determine whether `lib` files need to be rechecked.
121195
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121196
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
121253
+ /**
121254
+ * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
121255
+ */
121256
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
121257
+ var result;
121258
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121259
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121260
+ var name = _a[_i];
121261
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
121262
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
121263
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
121264
+ }
121197
121265
  }
121266
+ return result;
121198
121267
  }
121199
- return result;
121200
121268
  }
121201
121269
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121202
121270
  if (option) {
@@ -121270,6 +121338,10 @@ var ts;
121270
121338
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121271
121339
  }
121272
121340
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121341
+ function computeSignature(text, data, computeHash) {
121342
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121343
+ }
121344
+ ts.computeSignature = computeSignature;
121273
121345
  function createBuilderProgram(kind, _a) {
121274
121346
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121275
121347
  // Return same program if underlying program doesnt change
@@ -121288,8 +121360,7 @@ var ts;
121288
121360
  */
121289
121361
  var computeHash = ts.maybeBind(host, host.createHash);
121290
121362
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121291
- var backupState;
121292
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121363
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121293
121364
  // To ensure that we arent storing any references to old program or new program without state
121294
121365
  newProgram = undefined; // TODO: GH#18217
121295
121366
  oldProgram = undefined;
@@ -121297,21 +121368,12 @@ var ts;
121297
121368
  var getState = function () { return state; };
121298
121369
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121299
121370
  builderProgram.getState = getState;
121300
- builderProgram.backupState = function () {
121301
- ts.Debug.assert(backupState === undefined);
121302
- backupState = cloneBuilderProgramState(state);
121303
- };
121304
- builderProgram.restoreState = function () {
121305
- state = ts.Debug.checkDefined(backupState);
121306
- backupState = undefined;
121307
- };
121371
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121372
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121308
121373
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121309
121374
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121310
121375
  builderProgram.emit = emit;
121311
- builderProgram.releaseProgram = function () {
121312
- releaseCache(state);
121313
- backupState = undefined;
121314
- };
121376
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121315
121377
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121316
121378
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121317
121379
  }
@@ -121369,35 +121431,62 @@ var ts;
121369
121431
  return toAffectedFileEmitResult(state,
121370
121432
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121371
121433
  // Otherwise just affected file
121372
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121373
- getWriteFileUpdatingSignatureCallback(writeFile) :
121434
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121435
+ getWriteFileCallback(writeFile, customTransformers) :
121374
121436
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121375
121437
  }
121376
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121438
+ function getWriteFileCallback(writeFile, customTransformers) {
121377
121439
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121378
- var _a;
121440
+ var _a, _b, _c;
121379
121441
  if (ts.isDeclarationFileName(fileName)) {
121380
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121381
- var file = sourceFiles[0];
121382
- var info = state.fileInfos.get(file.resolvedPath);
121383
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121384
- if (signature === file.version) {
121385
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121386
- if (newSignature !== file.version) { // Update it
121387
- if (host.storeFilesChangingSignatureDuringEmit)
121388
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121389
- if (state.exportedModulesMap)
121390
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121391
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121392
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121442
+ if (!ts.outFile(state.compilerOptions)) {
121443
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121444
+ var newSignature = void 0;
121445
+ if (!customTransformers) {
121446
+ var file = sourceFiles[0];
121447
+ var info = state.fileInfos.get(file.resolvedPath);
121448
+ if (info.signature === file.version) {
121449
+ newSignature = computeSignature(text, data, computeHash);
121450
+ if (newSignature !== file.version) { // Update it
121451
+ if (host.storeFilesChangingSignatureDuringEmit)
121452
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121453
+ if (state.exportedModulesMap)
121454
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121455
+ if (state.affectedFiles) {
121456
+ // Keep old signature so we know what to undo if cancellation happens
121457
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121458
+ if (existing === undefined)
121459
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121460
+ info.signature = newSignature;
121461
+ }
121462
+ else {
121463
+ // These are directly commited
121464
+ info.signature = newSignature;
121465
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121466
+ }
121467
+ }
121393
121468
  }
121394
- else {
121395
- info.signature = newSignature;
121396
- if (state.exportedModulesMap)
121397
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121469
+ }
121470
+ // Store d.ts emit hash so later can be compared to check if d.ts has changed.
121471
+ // Currently we do this only for composite projects since these are the only projects that can be referenced by other projects
121472
+ // and would need their d.ts change time in --build mode
121473
+ if (state.compilerOptions.composite) {
121474
+ var filePath = sourceFiles[0].resolvedPath;
121475
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121476
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
121477
+ if (newSignature !== oldSignature) {
121478
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121479
+ state.hasChangedEmitSignature = true;
121398
121480
  }
121399
121481
  }
121400
121482
  }
121483
+ else if (state.compilerOptions.composite) {
121484
+ var newSignature = computeSignature(text, data, computeHash);
121485
+ if (newSignature !== state.outSignature) {
121486
+ state.outSignature = newSignature;
121487
+ state.hasChangedEmitSignature = true;
121488
+ }
121489
+ }
121401
121490
  }
121402
121491
  if (writeFile)
121403
121492
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121462,8 +121551,8 @@ var ts;
121462
121551
  }
121463
121552
  }
121464
121553
  }
121465
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121466
- getWriteFileUpdatingSignatureCallback(writeFile) :
121554
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121555
+ getWriteFileCallback(writeFile, customTransformers) :
121467
121556
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121468
121557
  }
121469
121558
  /**
@@ -121552,29 +121641,58 @@ var ts;
121552
121641
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121553
121642
  }
121554
121643
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121555
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121556
- var _a;
121644
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121645
+ var _a, _b, _c, _d;
121557
121646
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121558
121647
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121559
- var filePaths = program.fileNames.map(toPath);
121560
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121561
- var fileInfos = new ts.Map();
121562
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121563
- var state = {
121564
- fileInfos: fileInfos,
121565
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121566
- referencedMap: toManyToManyPathMap(program.referencedMap),
121567
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121568
- 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]; }),
121569
- hasReusableDiagnostic: true,
121570
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121571
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121572
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121573
- };
121648
+ var state;
121649
+ var filePaths;
121650
+ var filePathsSetList;
121651
+ if (isProgramBundleEmitBuildInfo(program)) {
121652
+ state = {
121653
+ fileInfos: new ts.Map(),
121654
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121655
+ dtsChangeTime: program.dtsChangeTime,
121656
+ outSignature: program.outSignature,
121657
+ };
121658
+ }
121659
+ else {
121660
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121661
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121662
+ var fileInfos_2 = new ts.Map();
121663
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121664
+ program.fileInfos.forEach(function (fileInfo, index) {
121665
+ var path = toFilePath(index + 1);
121666
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121667
+ fileInfos_2.set(path, stateFileInfo);
121668
+ if (emitSignatures_1 && stateFileInfo.signature)
121669
+ emitSignatures_1.set(path, stateFileInfo.signature);
121670
+ });
121671
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121672
+ if (ts.isNumber(value))
121673
+ emitSignatures_1.delete(toFilePath(value));
121674
+ else
121675
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121676
+ });
121677
+ state = {
121678
+ fileInfos: fileInfos_2,
121679
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121680
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121681
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121682
+ 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]; }),
121683
+ hasReusableDiagnostic: true,
121684
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121685
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121686
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121687
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121688
+ dtsChangeTime: program.dtsChangeTime,
121689
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121690
+ };
121691
+ }
121574
121692
  return {
121575
121693
  getState: function () { return state; },
121576
- backupState: ts.noop,
121577
- restoreState: ts.noop,
121694
+ saveEmitState: ts.noop,
121695
+ restoreEmitState: ts.noop,
121578
121696
  getProgram: ts.notImplemented,
121579
121697
  getProgramOrUndefined: ts.returnUndefined,
121580
121698
  releaseProgram: ts.noop,
@@ -121619,12 +121737,24 @@ var ts;
121619
121737
  return map;
121620
121738
  }
121621
121739
  }
121622
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121740
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121741
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121742
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121743
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121744
+ var fileInfos = new ts.Map();
121745
+ program.fileInfos.forEach(function (fileInfo, index) {
121746
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121747
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121748
+ fileInfos.set(path, version);
121749
+ });
121750
+ return fileInfos;
121751
+ }
121752
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121623
121753
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121624
121754
  return {
121625
121755
  getState: ts.notImplemented,
121626
- backupState: ts.noop,
121627
- restoreState: ts.noop,
121756
+ saveEmitState: ts.noop,
121757
+ restoreEmitState: ts.noop,
121628
121758
  getProgram: getProgram,
121629
121759
  getProgramOrUndefined: function () { return getState().program; },
121630
121760
  releaseProgram: function () { return getState().program = undefined; },
@@ -121728,8 +121858,10 @@ var ts;
121728
121858
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121729
121859
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121730
121860
  var resolutionsWithFailedLookups = [];
121861
+ var resolutionsWithOnlyAffectingLocations = [];
121731
121862
  var resolvedFileToResolution = ts.createMultiMap();
121732
121863
  var hasChangedAutomaticTypeDirectiveNames = false;
121864
+ var affectingPathChecks;
121733
121865
  var failedLookupChecks;
121734
121866
  var startsWithPathChecks;
121735
121867
  var isInDirectoryChecks;
@@ -121756,6 +121888,7 @@ var ts;
121756
121888
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121757
121889
  var customFailedLookupPaths = new ts.Map();
121758
121890
  var directoryWatchesOfFailedLookups = new ts.Map();
121891
+ var fileWatchesOfAffectingLocations = new ts.Map();
121759
121892
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121760
121893
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121761
121894
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121798,6 +121931,7 @@ var ts;
121798
121931
  }
121799
121932
  function clear() {
121800
121933
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
121934
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121801
121935
  customFailedLookupPaths.clear();
121802
121936
  nonRelativeExternalModuleResolutions.clear();
121803
121937
  closeTypeRootsWatch();
@@ -121805,9 +121939,11 @@ var ts;
121805
121939
  resolvedTypeReferenceDirectives.clear();
121806
121940
  resolvedFileToResolution.clear();
121807
121941
  resolutionsWithFailedLookups.length = 0;
121942
+ resolutionsWithOnlyAffectingLocations.length = 0;
121808
121943
  failedLookupChecks = undefined;
121809
121944
  startsWithPathChecks = undefined;
121810
121945
  isInDirectoryChecks = undefined;
121946
+ affectingPathChecks = undefined;
121811
121947
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
121812
121948
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
121813
121949
  clearPerDirectoryResolutions();
@@ -121857,10 +121993,18 @@ var ts;
121857
121993
  watcher.watcher.close();
121858
121994
  }
121859
121995
  });
121996
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
121997
+ if (watcher.refCount === 0) {
121998
+ fileWatchesOfAffectingLocations.delete(path);
121999
+ watcher.watcher.close();
122000
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122001
+ watcher.watcher = ts.noopFileWatcher;
122002
+ }
122003
+ });
121860
122004
  hasChangedAutomaticTypeDirectiveNames = false;
121861
122005
  }
121862
122006
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
121863
- var _a;
122007
+ var _a, _b;
121864
122008
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
121865
122009
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
121866
122010
  if (!resolutionHost.getGlobalCache) {
@@ -121871,11 +122015,12 @@ var ts;
121871
122015
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
121872
122016
  // create different collection of failed lookup locations for second pass
121873
122017
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
121874
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
122018
+ 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;
121875
122019
  if (resolvedModule) {
121876
122020
  // Modify existing resolution so its saved in the directory cache as well
121877
122021
  primaryResult.resolvedModule = resolvedModule;
121878
122022
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122023
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
121879
122024
  return primaryResult;
121880
122025
  }
121881
122026
  }
@@ -122126,10 +122271,11 @@ var ts;
122126
122271
  }
122127
122272
  function watchFailedLookupLocationOfResolution(resolution) {
122128
122273
  ts.Debug.assert(!!resolution.refCount);
122129
- var failedLookupLocations = resolution.failedLookupLocations;
122130
- if (!failedLookupLocations.length)
122274
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122275
+ if (!failedLookupLocations.length && !affectingLocations.length)
122131
122276
  return;
122132
- resolutionsWithFailedLookups.push(resolution);
122277
+ if (failedLookupLocations.length)
122278
+ resolutionsWithFailedLookups.push(resolution);
122133
122279
  var setAtRoot = false;
122134
122280
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122135
122281
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122156,12 +122302,66 @@ var ts;
122156
122302
  // This is always non recursive
122157
122303
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122158
122304
  }
122305
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
122306
+ }
122307
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
122308
+ ts.Debug.assert(!!resolution.refCount);
122309
+ if (addToResolutionsWithOnlyAffectingLocations)
122310
+ resolutionsWithOnlyAffectingLocations.push(resolution);
122311
+ var affectingLocations = resolution.affectingLocations;
122312
+ // Watch package json
122313
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122314
+ var affectingLocation = affectingLocations_1[_i];
122315
+ createFileWatcherOfAffectingLocation(affectingLocation);
122316
+ }
122317
+ }
122318
+ function createFileWatcherOfAffectingLocation(affectingLocation) {
122319
+ var path = resolutionHost.toPath(affectingLocation);
122320
+ var fileWatcher = fileWatchesOfAffectingLocations.get(path);
122321
+ if (fileWatcher) {
122322
+ fileWatcher.refCount++;
122323
+ return;
122324
+ }
122325
+ var locationToWatch = affectingLocation;
122326
+ var locationToWatchPath = path;
122327
+ if (resolutionHost.realpath) {
122328
+ locationToWatch = resolutionHost.realpath(affectingLocation);
122329
+ locationToWatchPath = resolutionHost.toPath(locationToWatch);
122330
+ if (path !== locationToWatchPath) {
122331
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
122332
+ if (fileWatcher_1) {
122333
+ fileWatcher_1.refCount++;
122334
+ fileWatcher_1.paths.add(path);
122335
+ fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
122336
+ return;
122337
+ }
122338
+ }
122339
+ }
122340
+ var paths = new ts.Set();
122341
+ paths.add(locationToWatchPath);
122342
+ var watcher = {
122343
+ watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
122344
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
122345
+ paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
122346
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122347
+ }),
122348
+ refCount: 1,
122349
+ paths: paths,
122350
+ };
122351
+ fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
122352
+ if (path !== locationToWatchPath) {
122353
+ fileWatchesOfAffectingLocations.set(path, watcher);
122354
+ paths.add(path);
122355
+ }
122159
122356
  }
122160
122357
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122161
122358
  var program = resolutionHost.getCurrentProgram();
122162
122359
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122163
122360
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122164
122361
  }
122362
+ else {
122363
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122364
+ }
122165
122365
  }
122166
122366
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122167
122367
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122183,38 +122383,44 @@ var ts;
122183
122383
  if (resolved && resolved.resolvedFileName) {
122184
122384
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122185
122385
  }
122186
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122187
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122188
- return;
122189
- }
122190
- var failedLookupLocations = resolution.failedLookupLocations;
122191
- var removeAtRoot = false;
122192
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122193
- var failedLookupLocation = failedLookupLocations_2[_i];
122194
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122195
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122196
- if (toWatch) {
122197
- var dirPath = toWatch.dirPath;
122198
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122199
- if (refCount) {
122200
- if (refCount === 1) {
122201
- customFailedLookupPaths.delete(failedLookupLocationPath);
122386
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122387
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122388
+ var removeAtRoot = false;
122389
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122390
+ var failedLookupLocation = failedLookupLocations_2[_i];
122391
+ var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122392
+ var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122393
+ if (toWatch) {
122394
+ var dirPath = toWatch.dirPath;
122395
+ var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122396
+ if (refCount) {
122397
+ if (refCount === 1) {
122398
+ customFailedLookupPaths.delete(failedLookupLocationPath);
122399
+ }
122400
+ else {
122401
+ ts.Debug.assert(refCount > 1);
122402
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122403
+ }
122404
+ }
122405
+ if (dirPath === rootPath) {
122406
+ removeAtRoot = true;
122202
122407
  }
122203
122408
  else {
122204
- ts.Debug.assert(refCount > 1);
122205
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122409
+ removeDirectoryWatcher(dirPath);
122206
122410
  }
122207
122411
  }
122208
- if (dirPath === rootPath) {
122209
- removeAtRoot = true;
122210
- }
122211
- else {
122212
- removeDirectoryWatcher(dirPath);
122213
- }
122412
+ }
122413
+ if (removeAtRoot) {
122414
+ removeDirectoryWatcher(rootPath);
122214
122415
  }
122215
122416
  }
122216
- if (removeAtRoot) {
122217
- removeDirectoryWatcher(rootPath);
122417
+ else if (affectingLocations.length) {
122418
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
122419
+ }
122420
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
122421
+ var affectingLocation = affectingLocations_2[_a];
122422
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
122423
+ watcher.refCount--;
122218
122424
  }
122219
122425
  }
122220
122426
  function removeDirectoryWatcher(dirPath) {
@@ -122293,7 +122499,7 @@ var ts;
122293
122499
  if (isCreatingWatchedDirectory) {
122294
122500
  // Watching directory is created
122295
122501
  // Invalidate any resolution has failed lookup in this directory
122296
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122502
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122297
122503
  }
122298
122504
  else {
122299
122505
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122311,7 +122517,7 @@ var ts;
122311
122517
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122312
122518
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122313
122519
  // Invalidate any resolution from this directory
122314
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122520
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122315
122521
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122316
122522
  }
122317
122523
  else {
@@ -122323,7 +122529,7 @@ var ts;
122323
122529
  return false;
122324
122530
  }
122325
122531
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122326
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122532
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122327
122533
  // If the invalidated file is from a node_modules package, invalidate everything else
122328
122534
  // in the package since we might not get notifications for other files in the package.
122329
122535
  // This hardens our logic against unreliable file watchers.
@@ -122335,21 +122541,32 @@ var ts;
122335
122541
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122336
122542
  }
122337
122543
  function invalidateResolutionsOfFailedLookupLocations() {
122338
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122544
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122339
122545
  return false;
122340
122546
  }
122341
122547
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122342
122548
  failedLookupChecks = undefined;
122343
122549
  startsWithPathChecks = undefined;
122344
122550
  isInDirectoryChecks = undefined;
122551
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122552
+ affectingPathChecks = undefined;
122345
122553
  return invalidated;
122346
122554
  }
122347
122555
  function canInvalidateFailedLookupResolution(resolution) {
122556
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122557
+ return true;
122558
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122559
+ return false;
122348
122560
  return resolution.failedLookupLocations.some(function (location) {
122349
122561
  var locationPath = resolutionHost.toPath(location);
122350
- return ts.contains(failedLookupChecks, locationPath) ||
122562
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122351
122563
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122352
- (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }));
122564
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
122565
+ });
122566
+ }
122567
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
122568
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
122569
+ return affectingPathChecks.has(resolutionHost.toPath(location));
122353
122570
  });
122354
122571
  }
122355
122572
  function closeTypeRootsWatch() {
@@ -122740,9 +122957,9 @@ var ts;
122740
122957
  if (!preferSymlinks) {
122741
122958
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122742
122959
  // so we only need to remove them from the realpath filenames.
122743
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122744
- if (result_15)
122745
- return result_15;
122960
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122961
+ if (result_16)
122962
+ return result_16;
122746
122963
  }
122747
122964
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122748
122965
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122762,10 +122979,10 @@ var ts;
122762
122979
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122763
122980
  var symlinkDirectory = symlinkDirectories_1[_i];
122764
122981
  var option = ts.resolvePath(symlinkDirectory, relative);
122765
- var result_16 = cb(option, target === referenceRedirect);
122982
+ var result_17 = cb(option, target === referenceRedirect);
122766
122983
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122767
- if (result_16)
122768
- return result_16;
122984
+ if (result_17)
122985
+ return result_17;
122769
122986
  }
122770
122987
  });
122771
122988
  });
@@ -123675,6 +123892,7 @@ var ts;
123675
123892
  readDirectory: ts.maybeBind(host, host.readDirectory),
123676
123893
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123677
123894
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123895
+ now: ts.maybeBind(host, host.now),
123678
123896
  };
123679
123897
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123680
123898
  try {
@@ -123735,6 +123953,7 @@ var ts;
123735
123953
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123736
123954
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123737
123955
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123956
+ now: ts.maybeBind(system, system.now),
123738
123957
  };
123739
123958
  }
123740
123959
  ts.createProgramHost = createProgramHost;
@@ -123802,20 +124021,27 @@ var ts;
123802
124021
  var ts;
123803
124022
  (function (ts) {
123804
124023
  function readBuilderProgram(compilerOptions, host) {
123805
- if (ts.outFile(compilerOptions))
123806
- return undefined;
123807
124024
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123808
124025
  if (!buildInfoPath)
123809
124026
  return undefined;
123810
- var content = host.readFile(buildInfoPath);
123811
- if (!content)
123812
- return undefined;
123813
- var buildInfo = ts.getBuildInfo(content);
124027
+ var buildInfo;
124028
+ if (host.getBuildInfo) {
124029
+ // host provides buildinfo, get it from there. This allows host to cache it
124030
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
124031
+ if (!buildInfo)
124032
+ return undefined;
124033
+ }
124034
+ else {
124035
+ var content = host.readFile(buildInfoPath);
124036
+ if (!content)
124037
+ return undefined;
124038
+ buildInfo = ts.getBuildInfo(content);
124039
+ }
123814
124040
  if (buildInfo.version !== ts.version)
123815
124041
  return undefined;
123816
124042
  if (!buildInfo.program)
123817
124043
  return undefined;
123818
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124044
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123819
124045
  }
123820
124046
  ts.readBuilderProgram = readBuilderProgram;
123821
124047
  function createIncrementalCompilerHost(options, system) {
@@ -123824,6 +124050,7 @@ var ts;
123824
124050
  host.createHash = ts.maybeBind(system, system.createHash);
123825
124051
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123826
124052
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124053
+ host.now = ts.maybeBind(system, system.now);
123827
124054
  ts.setGetSourceFileAsHashVersioned(host, system);
123828
124055
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123829
124056
  return host;
@@ -123868,7 +124095,6 @@ var ts;
123868
124095
  var builderProgram;
123869
124096
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
123870
124097
  var missingFilesMap; // Map of file watchers for the missing files
123871
- var packageJsonMap; // map of watchers for package json files used in module resolution
123872
124098
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
123873
124099
  var timerToUpdateProgram; // timer callback to recompile the program
123874
124100
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -123932,6 +124158,7 @@ var ts;
123932
124158
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
123933
124159
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
123934
124160
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124161
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
123935
124162
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
123936
124163
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
123937
124164
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -124014,10 +124241,6 @@ var ts;
124014
124241
  });
124015
124242
  parsedConfigs = undefined;
124016
124243
  }
124017
- if (packageJsonMap) {
124018
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
124019
- packageJsonMap = undefined;
124020
- }
124021
124244
  }
124022
124245
  function getCurrentBuilderProgram() {
124023
124246
  return builderProgram;
@@ -124073,15 +124296,9 @@ var ts;
124073
124296
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124074
124297
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124075
124298
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124076
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124077
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124078
- var path = _a[0], data = _a[1];
124079
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124080
- });
124081
124299
  resolutionCache.finishCachingPerDirectoryResolution();
124082
124300
  // Update watches
124083
124301
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124084
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124085
124302
  if (needsUpdateInTypeRootWatch) {
124086
124303
  resolutionCache.updateTypeRootsWatch();
124087
124304
  }
@@ -124387,21 +124604,6 @@ var ts;
124387
124604
  ts.noopFileWatcher :
124388
124605
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124389
124606
  }
124390
- function watchPackageJsonLookupPath(packageJsonPath) {
124391
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124392
- return sourceFilesCache.has(packageJsonPath) ?
124393
- ts.noopFileWatcher :
124394
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124395
- }
124396
- function onPackageJsonChange(fileName, eventKind, path) {
124397
- updateCachedSystemWithFile(fileName, path, eventKind);
124398
- // package.json changes invalidate module resolution and can change the set of loaded files
124399
- // so if we witness a change to one, we have to do a full reload
124400
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124401
- changesAffectResolution = true;
124402
- // Update the program
124403
- scheduleProgramUpdate();
124404
- }
124405
124607
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124406
124608
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124407
124609
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124559,14 +124761,17 @@ var ts;
124559
124761
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124560
124762
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124561
124763
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124562
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124563
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124564
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124565
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124764
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124765
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124766
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124767
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124768
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124769
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124566
124770
  /**
124567
124771
  * Projects with no outputs (i.e. "solution" files)
124568
124772
  */
124569
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124773
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124774
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124570
124775
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124571
124776
  function resolveConfigFileProjectName(project) {
124572
124777
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124611,9 +124816,12 @@ var ts;
124611
124816
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124612
124817
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124613
124818
  }
124614
- function newer(date1, date2) {
124615
- return date2 > date1 ? date2 : date1;
124819
+ /*@internal*/
124820
+ /** Helper to use now method instead of current date for testing purposes to get consistent baselines */
124821
+ function getCurrentTime(host) {
124822
+ return host.now ? host.now() : new Date();
124616
124823
  }
124824
+ ts.getCurrentTime = getCurrentTime;
124617
124825
  /*@internal*/
124618
124826
  function isCircularBuildOrder(buildOrder) {
124619
124827
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124703,6 +124911,7 @@ var ts;
124703
124911
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124704
124912
  };
124705
124913
  }
124914
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124706
124915
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124707
124916
  var state = {
124708
124917
  host: host,
@@ -124719,8 +124928,9 @@ var ts;
124719
124928
  resolvedConfigFilePaths: new ts.Map(),
124720
124929
  configFileCache: new ts.Map(),
124721
124930
  projectStatus: new ts.Map(),
124722
- buildInfoChecked: new ts.Map(),
124723
124931
  extendedConfigCache: new ts.Map(),
124932
+ buildInfoCache: new ts.Map(),
124933
+ outputTimeStamps: new ts.Map(),
124724
124934
  builderPrograms: new ts.Map(),
124725
124935
  diagnostics: new ts.Map(),
124726
124936
  projectPendingBuild: new ts.Map(),
@@ -124743,6 +124953,7 @@ var ts;
124743
124953
  allWatchedConfigFiles: new ts.Map(),
124744
124954
  allWatchedExtendedConfigFiles: new ts.Map(),
124745
124955
  allWatchedPackageJsonFiles: new ts.Map(),
124956
+ filesWatched: new ts.Map(),
124746
124957
  lastCachedPackageJsonLookups: new ts.Map(),
124747
124958
  timerToBuildInvalidatedProject: undefined,
124748
124959
  reportFileChangeDetected: false,
@@ -124849,11 +125060,12 @@ var ts;
124849
125060
  // Config file cache
124850
125061
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124851
125062
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124852
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124853
125063
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124854
125064
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124855
125065
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124856
125066
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125067
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125068
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124857
125069
  // Remove watches for the program no longer in the solution
124858
125070
  if (state.watch) {
124859
125071
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125143,21 +125355,21 @@ var ts;
125143
125355
  }
125144
125356
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125145
125357
  var _a;
125146
- var _b, _c;
125358
+ var _b, _c, _d;
125147
125359
  ts.Debug.assertIsDefined(program);
125148
125360
  ts.Debug.assert(step === BuildStep.Emit);
125149
125361
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125150
- program.backupState();
125362
+ var saved = program.saveEmitState();
125151
125363
  var declDiagnostics;
125152
125364
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125153
125365
  var outputFiles = [];
125154
125366
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125155
125367
  /*write*/ undefined,
125156
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
125368
+ /*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,
125157
125369
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125158
125370
  // Don't emit .d.ts if there are decl file errors
125159
125371
  if (declDiagnostics) {
125160
- program.restoreState();
125372
+ program.restoreEmitState(saved);
125161
125373
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125162
125374
  return {
125163
125375
  emitSkipped: true,
@@ -125167,37 +125379,44 @@ var ts;
125167
125379
  // Actual Emit
125168
125380
  var host = state.host, compilerHost = state.compilerHost;
125169
125381
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125170
- var newestDeclarationFileContentChangedTime = minimumDate;
125171
- var anyDtsChanged = false;
125382
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125172
125383
  var emitterDiagnostics = ts.createDiagnosticCollection();
125173
125384
  var emittedOutputs = new ts.Map();
125385
+ var options = program.getCompilerOptions();
125386
+ var isIncremental = ts.isIncrementalCompilation(options);
125387
+ var outputTimeStampMap;
125388
+ var now;
125174
125389
  outputFiles.forEach(function (_a) {
125175
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125176
- var priorChangeTime;
125177
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125178
- // Check for unchanged .d.ts files
125179
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125180
- priorChangeTime = host.getModifiedTime(name);
125181
- }
125182
- else {
125390
+ var _b, _c;
125391
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125392
+ var path = toPath(state, name);
125393
+ emittedOutputs.set(toPath(state, name), name);
125394
+ if (buildInfo) {
125395
+ setBuildInfo(state, buildInfo, projectPath, options);
125396
+ // Buildinfo has information on when last dts change time
125397
+ 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)) {
125183
125398
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125184
- anyDtsChanged = true;
125185
125399
  }
125186
125400
  }
125187
- emittedOutputs.set(toPath(state, name), name);
125188
125401
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125189
- if (priorChangeTime !== undefined) {
125190
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125402
+ if (!isIncremental && state.watch) {
125403
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125191
125404
  }
125192
125405
  });
125193
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125194
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125406
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125195
125407
  return emitResult;
125196
125408
  }
125197
125409
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125198
125410
  ts.Debug.assertIsDefined(program);
125199
125411
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125200
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125412
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125413
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
125414
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125415
+ if (writeFileCallback)
125416
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125417
+ else
125418
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125419
+ }, cancellationToken);
125201
125420
  if (emitResult.diagnostics.length) {
125202
125421
  reportErrors(state, emitResult.diagnostics);
125203
125422
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125210,7 +125429,7 @@ var ts;
125210
125429
  step = BuildStep.QueueReferencingProjects;
125211
125430
  return emitResult;
125212
125431
  }
125213
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125432
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125214
125433
  var _a;
125215
125434
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125216
125435
  if (emitDiagnostics.length) {
@@ -125221,13 +125440,11 @@ var ts;
125221
125440
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125222
125441
  }
125223
125442
  // Update time stamps for rest of the outputs
125224
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125443
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125225
125444
  state.diagnostics.delete(projectPath);
125226
125445
  state.projectStatus.set(projectPath, {
125227
125446
  type: ts.UpToDateStatusType.UpToDate,
125228
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125229
- maximumDate :
125230
- newestDeclarationFileContentChangedTime,
125447
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125231
125448
  oldestOutputFileName: oldestOutputFileName
125232
125449
  });
125233
125450
  afterProgramDone(state, program, config);
@@ -125262,13 +125479,21 @@ var ts;
125262
125479
  ts.Debug.assert(!!outputFiles.length);
125263
125480
  var emitterDiagnostics = ts.createDiagnosticCollection();
125264
125481
  var emittedOutputs = new ts.Map();
125482
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125483
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125265
125484
  outputFiles.forEach(function (_a) {
125266
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125485
+ var _b, _c;
125486
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125267
125487
  emittedOutputs.set(toPath(state, name), name);
125488
+ if (buildInfo) {
125489
+ setBuildInfo(state, buildInfo, projectPath, config.options);
125490
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125491
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125492
+ }
125493
+ }
125268
125494
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125269
125495
  });
125270
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125271
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125496
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125272
125497
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125273
125498
  }
125274
125499
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125367,7 +125592,7 @@ var ts;
125367
125592
  }
125368
125593
  continue;
125369
125594
  }
125370
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125595
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125371
125596
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125372
125597
  return {
125373
125598
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125452,7 +125677,8 @@ var ts;
125452
125677
  state.projectCompilerOptions = state.baseCompilerOptions;
125453
125678
  }
125454
125679
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125455
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125680
+ // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors
125681
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125456
125682
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125457
125683
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125458
125684
  if (canEmitBuildInfo)
@@ -125460,9 +125686,99 @@ var ts;
125460
125686
  afterProgramDone(state, program, config);
125461
125687
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125462
125688
  }
125689
+ function isFileWatcherWithModifiedTime(value) {
125690
+ return !!value.watcher;
125691
+ }
125692
+ function getModifiedTime(state, fileName) {
125693
+ var path = toPath(state, fileName);
125694
+ var existing = state.filesWatched.get(path);
125695
+ if (state.watch && !!existing) {
125696
+ if (!isFileWatcherWithModifiedTime(existing))
125697
+ return existing;
125698
+ if (existing.modifiedTime)
125699
+ return existing.modifiedTime;
125700
+ }
125701
+ // In watch mode we store the modified times in the cache
125702
+ // This is either Date | FileWatcherWithModifiedTime because we query modified times first and
125703
+ // then after complete compilation of the project, watch the files so we dont want to loose these modified times.
125704
+ var result = ts.getModifiedTime(state.host, fileName);
125705
+ if (state.watch) {
125706
+ if (existing)
125707
+ existing.modifiedTime = result;
125708
+ else
125709
+ state.filesWatched.set(path, result);
125710
+ }
125711
+ return result;
125712
+ }
125713
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125714
+ var path = toPath(state, file);
125715
+ var existing = state.filesWatched.get(path);
125716
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125717
+ existing.callbacks.push(callback);
125718
+ }
125719
+ else {
125720
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125721
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125722
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125723
+ existing.modifiedTime = modifiedTime;
125724
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125725
+ }, pollingInterval, options, watchType, project);
125726
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125727
+ }
125728
+ return {
125729
+ close: function () {
125730
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125731
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125732
+ if (existing.callbacks.length === 1) {
125733
+ state.filesWatched.delete(path);
125734
+ ts.closeFileWatcherOf(existing);
125735
+ }
125736
+ else {
125737
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125738
+ }
125739
+ }
125740
+ };
125741
+ }
125742
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125743
+ // Output timestamps are stored only in watch mode
125744
+ if (!state.watch)
125745
+ return undefined;
125746
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125747
+ if (!result)
125748
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125749
+ return result;
125750
+ }
125751
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125752
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125753
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125754
+ if (existing) {
125755
+ existing.buildInfo = buildInfo;
125756
+ existing.modifiedTime = getCurrentTime(state.host);
125757
+ }
125758
+ else {
125759
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125760
+ }
125761
+ }
125762
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125763
+ var path = toPath(state, buildInfoPath);
125764
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125765
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125766
+ }
125767
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125768
+ var path = toPath(state, buildInfoPath);
125769
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125770
+ if (existing !== undefined && existing.path === path) {
125771
+ return existing.buildInfo || undefined;
125772
+ }
125773
+ var value = state.readFileWithCache(buildInfoPath);
125774
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125775
+ ts.Debug.assert(modifiedTime || !buildInfo);
125776
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125777
+ return buildInfo;
125778
+ }
125463
125779
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125464
125780
  // Check tsconfig time
125465
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125781
+ var tsconfigTime = getModifiedTime(state, configFile);
125466
125782
  if (oldestOutputFileTime < tsconfigTime) {
125467
125783
  return {
125468
125784
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125472,88 +125788,24 @@ var ts;
125472
125788
  }
125473
125789
  }
125474
125790
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125475
- var force = !!state.options.force;
125476
- var newestInputFileName = undefined;
125477
- var newestInputFileTime = minimumDate;
125478
- var host = state.host;
125479
- // Get timestamps of input files
125480
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125481
- var inputFile = _a[_i];
125482
- if (!host.fileExists(inputFile)) {
125483
- return {
125484
- type: ts.UpToDateStatusType.Unbuildable,
125485
- reason: inputFile + " does not exist"
125486
- };
125487
- }
125488
- if (!force) {
125489
- var inputTime = ts.getModifiedTime(host, inputFile);
125490
- if (inputTime > newestInputFileTime) {
125491
- newestInputFileName = inputFile;
125492
- newestInputFileTime = inputTime;
125493
- }
125494
- }
125495
- }
125791
+ var _a, _b, _c;
125496
125792
  // Container if no files are specified in the project
125497
125793
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125498
125794
  return {
125499
125795
  type: ts.UpToDateStatusType.ContainerOnly
125500
125796
  };
125501
125797
  }
125502
- // Collect the expected outputs of this project
125503
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125504
- // Now see if all outputs are newer than the newest input
125505
- var oldestOutputFileName = "(none)";
125506
- var oldestOutputFileTime = maximumDate;
125507
- var newestOutputFileName = "(none)";
125508
- var newestOutputFileTime = minimumDate;
125509
- var missingOutputFileName;
125510
- var newestDeclarationFileContentChangedTime = minimumDate;
125511
- var isOutOfDateWithInputs = false;
125512
- if (!force) {
125513
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125514
- var output = outputs_1[_b];
125515
- // Output is missing; can stop checking
125516
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125517
- if (!host.fileExists(output)) {
125518
- missingOutputFileName = output;
125519
- break;
125520
- }
125521
- var outputTime = ts.getModifiedTime(host, output);
125522
- if (outputTime < oldestOutputFileTime) {
125523
- oldestOutputFileTime = outputTime;
125524
- oldestOutputFileName = output;
125525
- }
125526
- // If an output is older than the newest input, we can stop checking
125527
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125528
- if (outputTime < newestInputFileTime) {
125529
- isOutOfDateWithInputs = true;
125530
- break;
125531
- }
125532
- if (outputTime > newestOutputFileTime) {
125533
- newestOutputFileTime = outputTime;
125534
- newestOutputFileName = output;
125535
- }
125536
- // Keep track of when the most recent time a .d.ts file was changed.
125537
- // In addition to file timestamps, we also keep track of when a .d.ts file
125538
- // had its file touched but not had its contents changed - this allows us
125539
- // to skip a downstream typecheck
125540
- if (ts.isDeclarationFileName(output)) {
125541
- var outputModifiedTime = ts.getModifiedTime(host, output);
125542
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125543
- }
125544
- }
125545
- }
125546
- var pseudoUpToDate = false;
125547
- var usesPrepend = false;
125548
- var upstreamChangedProject;
125798
+ // Fast check to see if reference projects are upto date and error free
125799
+ var referenceStatuses;
125800
+ var force = !!state.options.force;
125549
125801
  if (project.projectReferences) {
125550
125802
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125551
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125552
- var ref = _d[_c];
125553
- usesPrepend = usesPrepend || !!(ref.prepend);
125803
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125804
+ var ref = _d[_i];
125554
125805
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125555
125806
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125556
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125807
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125808
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125557
125809
  // Its a circular reference ignore the status of this project
125558
125810
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125559
125811
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125575,75 +125827,194 @@ var ts;
125575
125827
  upstreamProjectName: ref.path
125576
125828
  };
125577
125829
  }
125578
- // Check oldest output file name only if there is no missing output file name
125579
- // (a check we will have skipped if this is a forced build)
125580
- if (!force && !missingOutputFileName) {
125581
- // If the upstream project's newest file is older than our oldest output, we
125582
- // can't be out of date because of it
125583
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125584
- continue;
125585
- }
125586
- // If the upstream project has only change .d.ts files, and we've built
125587
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125588
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125589
- pseudoUpToDate = true;
125590
- upstreamChangedProject = ref.path;
125591
- continue;
125592
- }
125593
- // We have an output older than an upstream output - we are out of date
125594
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125830
+ if (!force)
125831
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125832
+ }
125833
+ }
125834
+ if (force)
125835
+ return { type: ts.UpToDateStatusType.ForceBuild };
125836
+ // Check buildinfo first
125837
+ var host = state.host;
125838
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125839
+ var oldestOutputFileName;
125840
+ var oldestOutputFileTime = maximumDate;
125841
+ var buildInfoTime;
125842
+ var buildInfoProgram;
125843
+ var buildInfoVersionMap;
125844
+ var newestDeclarationFileContentChangedTime;
125845
+ if (buildInfoPath) {
125846
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125847
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125848
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125849
+ if (!buildInfoCacheEntry_1) {
125850
+ state.buildInfoCache.set(resolvedPath, {
125851
+ path: toPath(state, buildInfoPath),
125852
+ buildInfo: false,
125853
+ modifiedTime: buildInfoTime
125854
+ });
125855
+ }
125856
+ return {
125857
+ type: ts.UpToDateStatusType.OutputMissing,
125858
+ missingOutputFileName: buildInfoPath
125859
+ };
125860
+ }
125861
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125862
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125863
+ return {
125864
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125865
+ version: buildInfo.version
125866
+ };
125867
+ }
125868
+ if (buildInfo.program) {
125869
+ // If there are pending changes that are not emitted, project is out of date
125870
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125871
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125595
125872
  return {
125596
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125597
- outOfDateOutputFileName: oldestOutputFileName,
125598
- newerProjectName: ref.path
125873
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125874
+ buildInfoFile: buildInfoPath
125599
125875
  };
125600
125876
  }
125877
+ buildInfoProgram = buildInfo.program;
125601
125878
  }
125879
+ oldestOutputFileTime = buildInfoTime;
125880
+ oldestOutputFileName = buildInfoPath;
125881
+ // Get the last dtsChange time from build info
125882
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125602
125883
  }
125603
- if (missingOutputFileName !== undefined) {
125604
- return {
125605
- type: ts.UpToDateStatusType.OutputMissing,
125606
- missingOutputFileName: missingOutputFileName
125607
- };
125884
+ // Check input files
125885
+ var newestInputFileName = undefined;
125886
+ var newestInputFileTime = minimumDate;
125887
+ /** 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 */
125888
+ var pseudoInputUpToDate = false;
125889
+ // Get timestamps of input files
125890
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125891
+ var inputFile = _f[_e];
125892
+ var inputTime = getModifiedTime(state, inputFile);
125893
+ if (inputTime === ts.missingFileModifiedTime) {
125894
+ return {
125895
+ type: ts.UpToDateStatusType.Unbuildable,
125896
+ reason: inputFile + " does not exist"
125897
+ };
125898
+ }
125899
+ // If an buildInfo is older than the newest input, we can stop checking
125900
+ if (buildInfoTime && buildInfoTime < inputTime) {
125901
+ var version_3 = void 0;
125902
+ var currentVersion = void 0;
125903
+ if (buildInfoProgram) {
125904
+ // Read files and see if they are same, read is anyways cached
125905
+ if (!buildInfoVersionMap)
125906
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125907
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125908
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125909
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125910
+ if (version_3 && version_3 === currentVersion)
125911
+ pseudoInputUpToDate = true;
125912
+ }
125913
+ if (!version_3 || version_3 !== currentVersion) {
125914
+ return {
125915
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125916
+ outOfDateOutputFileName: buildInfoPath,
125917
+ newerInputFileName: inputFile
125918
+ };
125919
+ }
125920
+ }
125921
+ if (inputTime > newestInputFileTime) {
125922
+ newestInputFileName = inputFile;
125923
+ newestInputFileTime = inputTime;
125924
+ }
125608
125925
  }
125609
- if (isOutOfDateWithInputs) {
125610
- return {
125611
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125612
- outOfDateOutputFileName: oldestOutputFileName,
125613
- newerInputFileName: newestInputFileName
125614
- };
125926
+ // Now see if all outputs are newer than the newest input
125927
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125928
+ if (!buildInfoPath) {
125929
+ // Collect the expected outputs of this project
125930
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125931
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125932
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125933
+ var output = outputs_1[_g];
125934
+ var path = toPath(state, output);
125935
+ // Output is missing; can stop checking
125936
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125937
+ if (!outputTime) {
125938
+ outputTime = ts.getModifiedTime(state.host, output);
125939
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125940
+ }
125941
+ if (outputTime === ts.missingFileModifiedTime) {
125942
+ return {
125943
+ type: ts.UpToDateStatusType.OutputMissing,
125944
+ missingOutputFileName: output
125945
+ };
125946
+ }
125947
+ // If an output is older than the newest input, we can stop checking
125948
+ if (outputTime < newestInputFileTime) {
125949
+ return {
125950
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125951
+ outOfDateOutputFileName: output,
125952
+ newerInputFileName: newestInputFileName
125953
+ };
125954
+ }
125955
+ // No need to get newestDeclarationFileContentChangedTime since thats needed only for composite projects
125956
+ // And composite projects are the only ones that can be referenced
125957
+ if (outputTime < oldestOutputFileTime) {
125958
+ oldestOutputFileTime = outputTime;
125959
+ oldestOutputFileName = output;
125960
+ }
125961
+ }
125615
125962
  }
125616
- else {
125617
- // Check tsconfig time
125618
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125619
- if (configStatus)
125620
- return configStatus;
125621
- // Check extended config time
125622
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125623
- if (extendedConfigStatus)
125624
- return extendedConfigStatus;
125625
- // Check package file time
125626
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125627
- var path = _a[0];
125628
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125629
- });
125630
- if (dependentPackageFileStatus)
125631
- return dependentPackageFileStatus;
125632
- }
125633
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125634
- state.buildInfoChecked.set(resolvedPath, true);
125635
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125636
- if (buildInfoPath) {
125637
- var value = state.readFileWithCache(buildInfoPath);
125638
- var buildInfo = value && ts.getBuildInfo(value);
125639
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125963
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125964
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125965
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125966
+ /** Inputs are up-to-date, just need either timestamp update or bundle prepend manipulation to make it look up-to-date */
125967
+ var pseudoUpToDate = false;
125968
+ var usesPrepend = false;
125969
+ var upstreamChangedProject;
125970
+ if (referenceStatuses) {
125971
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125972
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125973
+ usesPrepend = usesPrepend || !!(ref.prepend);
125974
+ // If the upstream project's newest file is older than our oldest output, we
125975
+ // can't be out of date because of it
125976
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125977
+ continue;
125978
+ }
125979
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125980
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125640
125981
  return {
125641
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125642
- version: buildInfo.version
125982
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125983
+ outOfDateOutputFileName: buildInfoPath,
125984
+ newerProjectName: ref.path
125643
125985
  };
125644
125986
  }
125987
+ // If the upstream project has only change .d.ts files, and we've built
125988
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125989
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125990
+ pseudoUpToDate = true;
125991
+ upstreamChangedProject = ref.path;
125992
+ continue;
125993
+ }
125994
+ // We have an output older than an upstream output - we are out of date
125995
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125996
+ return {
125997
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125998
+ outOfDateOutputFileName: oldestOutputFileName,
125999
+ newerProjectName: ref.path
126000
+ };
125645
126001
  }
125646
126002
  }
126003
+ // Check tsconfig time
126004
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
126005
+ if (configStatus)
126006
+ return configStatus;
126007
+ // Check extended config time
126008
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
126009
+ if (extendedConfigStatus)
126010
+ return extendedConfigStatus;
126011
+ // Check package file time
126012
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
126013
+ var path = _a[0];
126014
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
126015
+ });
126016
+ if (dependentPackageFileStatus)
126017
+ return dependentPackageFileStatus;
125647
126018
  if (usesPrepend && pseudoUpToDate) {
125648
126019
  return {
125649
126020
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125653,15 +126024,37 @@ var ts;
125653
126024
  }
125654
126025
  // Up to date
125655
126026
  return {
125656
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
126027
+ type: pseudoUpToDate ?
126028
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
126029
+ pseudoInputUpToDate ?
126030
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
126031
+ ts.UpToDateStatusType.UpToDate,
125657
126032
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125658
126033
  newestInputFileTime: newestInputFileTime,
125659
- newestOutputFileTime: newestOutputFileTime,
125660
126034
  newestInputFileName: newestInputFileName,
125661
- newestOutputFileName: newestOutputFileName,
125662
126035
  oldestOutputFileName: oldestOutputFileName
125663
126036
  };
125664
126037
  }
126038
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
126039
+ if (seenRefs.has(resolvedRefPath))
126040
+ return false;
126041
+ seenRefs.add(resolvedRefPath);
126042
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
126043
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
126044
+ return true;
126045
+ if (resolvedConfig.projectReferences) {
126046
+ // Check references
126047
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
126048
+ var ref = _a[_i];
126049
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
126050
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
126051
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
126052
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
126053
+ return true;
126054
+ }
126055
+ }
126056
+ return false;
126057
+ }
125665
126058
  function getUpToDateStatus(state, project, resolvedPath) {
125666
126059
  if (project === undefined) {
125667
126060
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125674,39 +126067,68 @@ var ts;
125674
126067
  state.projectStatus.set(resolvedPath, actual);
125675
126068
  return actual;
125676
126069
  }
125677
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126070
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125678
126071
  if (proj.options.noEmit)
125679
- return priorNewestUpdateTime;
126072
+ return;
126073
+ var now;
126074
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
126075
+ if (buildInfoPath) {
126076
+ // For incremental projects, only buildinfo needs to be upto date with timestamp check
126077
+ // as we dont check output files for up-to-date ness
126078
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
126079
+ if (!!state.options.verbose)
126080
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
126081
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
126082
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
126083
+ }
126084
+ state.outputTimeStamps.delete(projectPath);
126085
+ return;
126086
+ }
125680
126087
  var host = state.host;
125681
126088
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126089
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126090
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125682
126091
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125683
126092
  var reportVerbose = !!state.options.verbose;
125684
- var now = host.now ? host.now() : new Date();
125685
126093
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125686
126094
  var file = outputs_2[_i];
125687
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
126095
+ var path = toPath(state, file);
126096
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125688
126097
  continue;
125689
- }
125690
126098
  if (reportVerbose) {
125691
126099
  reportVerbose = false;
125692
126100
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125693
126101
  }
125694
- if (ts.isDeclarationFileName(file)) {
125695
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
126102
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
126103
+ // Store output timestamps in a map because non incremental build will need to check them to determine up-to-dateness
126104
+ if (outputTimeStampMap) {
126105
+ outputTimeStampMap.set(path, now);
126106
+ modifiedOutputs.add(path);
125696
126107
  }
125697
- host.setModifiedTime(file, now);
125698
126108
  }
125699
126109
  }
125700
- return priorNewestUpdateTime;
126110
+ // Clear out timestamps not in output list any more
126111
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.forEach(function (_value, key) {
126112
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs.has(key))
126113
+ outputTimeStampMap.delete(key);
126114
+ });
126115
+ }
126116
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
126117
+ var _a;
126118
+ if (!options.composite)
126119
+ return undefined;
126120
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126121
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126122
+ 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;
125701
126123
  }
125702
126124
  function updateOutputTimestamps(state, proj, resolvedPath) {
125703
126125
  if (state.options.dry) {
125704
126126
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125705
126127
  }
125706
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126128
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125707
126129
  state.projectStatus.set(resolvedPath, {
125708
126130
  type: ts.UpToDateStatusType.UpToDate,
125709
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126131
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125710
126132
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125711
126133
  });
125712
126134
  }
@@ -125752,6 +126174,7 @@ var ts;
125752
126174
  break;
125753
126175
  }
125754
126176
  // falls through
126177
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125755
126178
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125756
126179
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125757
126180
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125912,12 +126335,10 @@ var ts;
125912
126335
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125913
126336
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125914
126337
  return;
125915
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125916
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125917
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126338
+ 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));
125918
126339
  }
125919
126340
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125920
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126341
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125921
126342
  var _a;
125922
126343
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125923
126344
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125949,7 +126370,7 @@ var ts;
125949
126370
  if (!state.watch)
125950
126371
  return;
125951
126372
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125952
- 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); },
126373
+ 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); },
125953
126374
  onDeleteValue: ts.closeFileWatcher,
125954
126375
  });
125955
126376
  }
@@ -125957,7 +126378,7 @@ var ts;
125957
126378
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125958
126379
  return;
125959
126380
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125960
- 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); },
126381
+ 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); },
125961
126382
  onDeleteValue: ts.closeFileWatcher,
125962
126383
  });
125963
126384
  }
@@ -126087,19 +126508,18 @@ var ts;
126087
126508
  }
126088
126509
  }
126089
126510
  function reportUpToDateStatus(state, configFileName, status) {
126090
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126091
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126092
- }
126093
126511
  switch (status.type) {
126094
126512
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126095
- 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));
126513
+ 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));
126096
126514
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126097
- 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));
126515
+ 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));
126098
126516
  case ts.UpToDateStatusType.OutputMissing:
126099
126517
  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));
126518
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
126519
+ 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));
126100
126520
  case ts.UpToDateStatusType.UpToDate:
126101
126521
  if (status.newestInputFileTime !== undefined) {
126102
- 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 || ""));
126522
+ 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 || ""));
126103
126523
  }
126104
126524
  // Don't report anything for "up to date because it was already built" -- too verbose
126105
126525
  break;
@@ -126107,6 +126527,8 @@ var ts;
126107
126527
  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));
126108
126528
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126109
126529
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126530
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126531
+ 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));
126110
126532
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126111
126533
  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));
126112
126534
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126117,6 +126539,8 @@ var ts;
126117
126539
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126118
126540
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126119
126541
  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);
126542
+ case ts.UpToDateStatusType.ForceBuild:
126543
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126120
126544
  case ts.UpToDateStatusType.ContainerOnly:
126121
126545
  // Don't report status on "solution" projects
126122
126546
  // falls through
@@ -167822,7 +168246,8 @@ var ts;
167822
168246
  }
167823
168247
  return {
167824
168248
  resolvedFileName: resolvedFileName,
167825
- failedLookupLocations: result.failedLookupLocations
168249
+ failedLookupLocations: result.failedLookupLocations,
168250
+ affectingLocations: result.affectingLocations,
167826
168251
  };
167827
168252
  });
167828
168253
  };
@@ -169958,6 +170383,10 @@ var ts;
169958
170383
  return this.projectService.watchFactory.watchDirectory(directory, cb, flags, this.projectService.getWatchOptions(this), ts.WatchType.FailedLookupLocations, this);
169959
170384
  };
169960
170385
  /*@internal*/
170386
+ Project.prototype.watchAffectingFileLocation = function (file, cb) {
170387
+ return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this);
170388
+ };
170389
+ /*@internal*/
169961
170390
  Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () {
169962
170391
  return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation");
169963
170392
  };