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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220608";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220609";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -6392,7 +6392,7 @@ var ts;
6392
6392
  };
6393
6393
  }
6394
6394
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6395
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6395
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6396
6396
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6397
6397
  if (!ts.isString(relativeFileName))
6398
6398
  return;
@@ -6402,7 +6402,7 @@ var ts;
6402
6402
  if (callbacks) {
6403
6403
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6404
6404
  var fileCallback = callbacks_1[_i];
6405
- fileCallback(fileName, FileWatcherEventKind.Changed);
6405
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6406
6406
  }
6407
6407
  }
6408
6408
  },
@@ -6456,7 +6456,7 @@ var ts;
6456
6456
  }
6457
6457
  else {
6458
6458
  cache.set(path, {
6459
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6459
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6460
6460
  refCount: 1
6461
6461
  });
6462
6462
  }
@@ -6484,7 +6484,8 @@ var ts;
6484
6484
  var newTime = modifiedTime.getTime();
6485
6485
  if (oldTime !== newTime) {
6486
6486
  watchedFile.mtime = modifiedTime;
6487
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6487
+ // Pass modified times so tsc --build can use it
6488
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6488
6489
  return true;
6489
6490
  }
6490
6491
  return false;
@@ -6519,7 +6520,7 @@ var ts;
6519
6520
  */
6520
6521
  /*@internal*/
6521
6522
  function createDirectoryWatcherSupportingRecursive(_a) {
6522
- 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;
6523
+ 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;
6523
6524
  var cache = new ts.Map();
6524
6525
  var callbackCache = ts.createMultiMap();
6525
6526
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6619,7 +6620,7 @@ var ts;
6619
6620
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6620
6621
  // Iterate through existing children and update the watches if needed
6621
6622
  var parentWatcher = cache.get(dirPath);
6622
- if (parentWatcher && directoryExists(dirName)) {
6623
+ if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6623
6624
  // Schedule the update and postpone invoke for callbacks
6624
6625
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6625
6626
  return;
@@ -6692,7 +6693,7 @@ var ts;
6692
6693
  if (!parentWatcher)
6693
6694
  return false;
6694
6695
  var newChildWatches;
6695
- var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6696
+ var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6696
6697
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6697
6698
  // Filter our the symbolic link directories since those arent included in recursive watch
6698
6699
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6735,17 +6736,19 @@ var ts;
6735
6736
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6736
6737
  /*@internal*/
6737
6738
  function createFileWatcherCallback(callback) {
6738
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6739
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6739
6740
  }
6740
6741
  ts.createFileWatcherCallback = createFileWatcherCallback;
6741
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6742
- return function (eventName) {
6742
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6743
+ return function (eventName, _relativeFileName, modifiedTime) {
6743
6744
  if (eventName === "rename") {
6744
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6745
+ // Check time stamps rather than file system entry checks
6746
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6747
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6745
6748
  }
6746
6749
  else {
6747
6750
  // Change
6748
- callback(fileName, FileWatcherEventKind.Changed);
6751
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6749
6752
  }
6750
6753
  };
6751
6754
  }
@@ -6769,11 +6772,12 @@ var ts;
6769
6772
  }
6770
6773
  /*@internal*/
6771
6774
  function createSystemWatchFunctions(_a) {
6772
- 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;
6775
+ 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;
6773
6776
  var dynamicPollingWatchFile;
6774
6777
  var fixedChunkSizePollingWatchFile;
6775
6778
  var nonPollingWatchFile;
6776
6779
  var hostRecursiveDirectoryWatcher;
6780
+ var hitSystemWatcherLimit = false;
6777
6781
  return {
6778
6782
  watchFile: watchFile,
6779
6783
  watchDirectory: watchDirectory
@@ -6791,7 +6795,7 @@ var ts;
6791
6795
  case ts.WatchFileKind.FixedChunkSizePolling:
6792
6796
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6793
6797
  case ts.WatchFileKind.UseFsEvents:
6794
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6798
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6795
6799
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6796
6800
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6797
6801
  if (!nonPollingWatchFile) {
@@ -6852,7 +6856,7 @@ var ts;
6852
6856
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6853
6857
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6854
6858
  getCurrentDirectory: getCurrentDirectory,
6855
- directoryExists: directoryExists,
6859
+ fileSystemEntryExists: fileSystemEntryExists,
6856
6860
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6857
6861
  watchDirectory: nonRecursiveWatchDirectory,
6858
6862
  realpath: realpath,
@@ -6903,6 +6907,122 @@ var ts;
6903
6907
  };
6904
6908
  }
6905
6909
  }
6910
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6911
+ var lastDirectoryPartWithDirectorySeparator;
6912
+ var lastDirectoryPart;
6913
+ if (inodeWatching) {
6914
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6915
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6916
+ }
6917
+ /** Watcher for the file system entry depending on whether it is missing or present */
6918
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6919
+ watchMissingFileSystemEntry() :
6920
+ watchPresentFileSystemEntry();
6921
+ return {
6922
+ close: function () {
6923
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6924
+ watcher.close();
6925
+ watcher = undefined;
6926
+ }
6927
+ };
6928
+ function updateWatcher(createWatcher) {
6929
+ // If watcher is not closed, update it
6930
+ if (watcher) {
6931
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6932
+ watcher.close();
6933
+ watcher = createWatcher();
6934
+ }
6935
+ }
6936
+ /**
6937
+ * Watch the file or directory that is currently present
6938
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
6939
+ */
6940
+ function watchPresentFileSystemEntry() {
6941
+ if (hitSystemWatcherLimit) {
6942
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6943
+ return watchPresentFileSystemEntryWithFsWatchFile();
6944
+ }
6945
+ try {
6946
+ var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6947
+ callbackChangingToMissingFileSystemEntry :
6948
+ callback);
6949
+ // Watch the missing file or directory or error
6950
+ presentWatcher.on("error", function () {
6951
+ callback("rename", "");
6952
+ updateWatcher(watchMissingFileSystemEntry);
6953
+ });
6954
+ return presentWatcher;
6955
+ }
6956
+ catch (e) {
6957
+ // Catch the exception and use polling instead
6958
+ // 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
6959
+ // so instead of throwing error, use fs.watchFile
6960
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6961
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6962
+ return watchPresentFileSystemEntryWithFsWatchFile();
6963
+ }
6964
+ }
6965
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6966
+ // In some scenarios, file save operation fires event with fileName.ext~ instead of fileName.ext
6967
+ // To ensure we see the file going missing and coming back up (file delete and then recreated)
6968
+ // and watches being updated correctly we are calling back with fileName.ext as well as fileName.ext~
6969
+ // The worst is we have fired event that was not needed but we wont miss any changes
6970
+ // especially in cases where file goes missing and watches wrong inode
6971
+ var originalRelativeName;
6972
+ if (relativeName && ts.endsWith(relativeName, "~")) {
6973
+ originalRelativeName = relativeName;
6974
+ relativeName = relativeName.slice(0, relativeName.length - 1);
6975
+ }
6976
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6977
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6978
+ if (event === "rename" &&
6979
+ (!relativeName ||
6980
+ relativeName === lastDirectoryPart ||
6981
+ ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6982
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
6983
+ if (originalRelativeName)
6984
+ callback(event, originalRelativeName, modifiedTime);
6985
+ callback(event, relativeName, modifiedTime);
6986
+ if (inodeWatching) {
6987
+ // If this was rename event, inode has changed means we need to update watcher
6988
+ updateWatcher(modifiedTime === ts.missingFileModifiedTime ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6989
+ }
6990
+ else if (modifiedTime === ts.missingFileModifiedTime) {
6991
+ updateWatcher(watchMissingFileSystemEntry);
6992
+ }
6993
+ }
6994
+ else {
6995
+ if (originalRelativeName)
6996
+ callback(event, originalRelativeName);
6997
+ callback(event, relativeName);
6998
+ }
6999
+ }
7000
+ /**
7001
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
7002
+ * 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
7003
+ */
7004
+ function watchPresentFileSystemEntryWithFsWatchFile() {
7005
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7006
+ }
7007
+ /**
7008
+ * Watch the file or directory that is missing
7009
+ * and switch to existing file or directory when the missing filesystem entry is created
7010
+ */
7011
+ function watchMissingFileSystemEntry() {
7012
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7013
+ if (eventKind === FileWatcherEventKind.Created) {
7014
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7015
+ if (modifiedTime !== ts.missingFileModifiedTime) {
7016
+ callback("rename", "", modifiedTime);
7017
+ // Call the callback for current file or directory
7018
+ // For now it could be callback for the inner directory creation,
7019
+ // but just return current directory, better than current no-op
7020
+ updateWatcher(watchPresentFileSystemEntry);
7021
+ }
7022
+ }
7023
+ }, fallbackPollingInterval, fallbackOptions);
7024
+ }
7025
+ }
6906
7026
  }
6907
7027
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6908
7028
  /**
@@ -6955,7 +7075,6 @@ var ts;
6955
7075
  }
6956
7076
  var activeSession;
6957
7077
  var profilePath = "./profile.cpuprofile";
6958
- var hitSystemWatcherLimit = false;
6959
7078
  var Buffer = require("buffer").Buffer;
6960
7079
  var nodeVersion = getNodeMajorVersion();
6961
7080
  var isNode4OrLater = nodeVersion >= 4;
@@ -6970,20 +7089,21 @@ var ts;
6970
7089
  getModifiedTime: getModifiedTime,
6971
7090
  setTimeout: setTimeout,
6972
7091
  clearTimeout: clearTimeout,
6973
- fsWatch: fsWatch,
7092
+ fsWatchWorker: fsWatchWorker,
6974
7093
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6975
7094
  getCurrentDirectory: getCurrentDirectory,
6976
- fileExists: fileExists,
7095
+ fileSystemEntryExists: fileSystemEntryExists,
6977
7096
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6978
7097
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6979
7098
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6980
- directoryExists: directoryExists,
6981
7099
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6982
7100
  realpath: realpath,
6983
7101
  tscWatchFile: process.env.TSC_WATCHFILE,
6984
7102
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6985
7103
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6986
7104
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7105
+ inodeWatching: isLinuxOrMacOs,
7106
+ sysLog: sysLog,
6987
7107
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6988
7108
  var nodeSystem = {
6989
7109
  args: process.argv.slice(2),
@@ -7233,110 +7353,14 @@ var ts;
7233
7353
  // File changed
7234
7354
  eventKind = FileWatcherEventKind.Changed;
7235
7355
  }
7236
- callback(fileName, eventKind);
7356
+ callback(fileName, eventKind, curr.mtime);
7237
7357
  }
7238
7358
  }
7239
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7240
- var options;
7241
- var lastDirectoryPartWithDirectorySeparator;
7242
- var lastDirectoryPart;
7243
- if (isLinuxOrMacOs) {
7244
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7245
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7246
- }
7247
- /** Watcher for the file system entry depending on whether it is missing or present */
7248
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7249
- watchMissingFileSystemEntry() :
7250
- watchPresentFileSystemEntry();
7251
- return {
7252
- close: function () {
7253
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7254
- watcher.close();
7255
- watcher = undefined;
7256
- }
7257
- };
7258
- /**
7259
- * Invoke the callback with rename and update the watcher if not closed
7260
- * @param createWatcher
7261
- */
7262
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7263
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7264
- // Call the callback for current directory
7265
- callback("rename", "");
7266
- // If watcher is not closed, update it
7267
- if (watcher) {
7268
- watcher.close();
7269
- watcher = createWatcher();
7270
- }
7271
- }
7272
- /**
7273
- * Watch the file or directory that is currently present
7274
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
7275
- */
7276
- function watchPresentFileSystemEntry() {
7277
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7278
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7279
- if (options === undefined) {
7280
- if (fsSupportsRecursiveFsWatch) {
7281
- options = { persistent: true, recursive: !!recursive };
7282
- }
7283
- else {
7284
- options = { persistent: true };
7285
- }
7286
- }
7287
- if (hitSystemWatcherLimit) {
7288
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7289
- return watchPresentFileSystemEntryWithFsWatchFile();
7290
- }
7291
- try {
7292
- var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7293
- callbackChangingToMissingFileSystemEntry :
7294
- callback);
7295
- // Watch the missing file or directory or error
7296
- presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7297
- return presentWatcher;
7298
- }
7299
- catch (e) {
7300
- // Catch the exception and use polling instead
7301
- // 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
7302
- // so instead of throwing error, use fs.watchFile
7303
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7304
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7305
- return watchPresentFileSystemEntryWithFsWatchFile();
7306
- }
7307
- }
7308
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7309
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7310
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7311
- return event === "rename" &&
7312
- (!relativeName ||
7313
- relativeName === lastDirectoryPart ||
7314
- (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7315
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7316
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7317
- callback(event, relativeName);
7318
- }
7319
- /**
7320
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
7321
- * 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
7322
- */
7323
- function watchPresentFileSystemEntryWithFsWatchFile() {
7324
- return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7325
- }
7326
- /**
7327
- * Watch the file or directory that is missing
7328
- * and switch to existing file or directory when the missing filesystem entry is created
7329
- */
7330
- function watchMissingFileSystemEntry() {
7331
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7332
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7333
- // Call the callback for current file or directory
7334
- // For now it could be callback for the inner directory creation,
7335
- // but just return current directory, better than current no-op
7336
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7337
- }
7338
- }, fallbackPollingInterval, fallbackOptions);
7339
- }
7359
+ function fsWatchWorker(fileOrDirectory, recursive, callback) {
7360
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7361
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7362
+ return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7363
+ { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7340
7364
  }
7341
7365
  function readFileWorker(fileName, _encoding) {
7342
7366
  var buffer;
@@ -7483,12 +7507,19 @@ var ts;
7483
7507
  }
7484
7508
  function getModifiedTime(path) {
7485
7509
  var _a;
7510
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7511
+ // the CPU time performance.
7512
+ var originalStackTraceLimit = Error.stackTraceLimit;
7513
+ Error.stackTraceLimit = 0;
7486
7514
  try {
7487
7515
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7488
7516
  }
7489
7517
  catch (e) {
7490
7518
  return undefined;
7491
7519
  }
7520
+ finally {
7521
+ Error.stackTraceLimit = originalStackTraceLimit;
7522
+ }
7492
7523
  }
7493
7524
  function setModifiedTime(path, time) {
7494
7525
  try {
@@ -9513,8 +9544,8 @@ var ts;
9513
9544
  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"),
9514
9545
  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"),
9515
9546
  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."),
9516
- 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}'"),
9517
- 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}'"),
9547
+ 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}'"),
9548
+ 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}'"),
9518
9549
  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"),
9519
9550
  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"),
9520
9551
  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"),
@@ -9558,6 +9589,8 @@ var ts;
9558
9589
  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}'."),
9559
9590
  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}'."),
9560
9591
  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."),
9592
+ 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"),
9593
+ 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"),
9561
9594
  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}'"),
9562
9595
  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."),
9563
9596
  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."),
@@ -20395,6 +20428,10 @@ var ts;
20395
20428
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20396
20429
  }
20397
20430
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20431
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20432
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20433
+ }
20434
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20398
20435
  function getCompilerOptionValue(options, option) {
20399
20436
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20400
20437
  }
@@ -39452,6 +39489,7 @@ var ts;
39452
39489
  type: "boolean",
39453
39490
  affectsSemanticDiagnostics: true,
39454
39491
  affectsEmit: true,
39492
+ affectsMultiFileEmitBuildInfo: true,
39455
39493
  category: ts.Diagnostics.Watch_and_Build_Modes,
39456
39494
  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,
39457
39495
  defaultValueDescription: false,
@@ -39486,12 +39524,40 @@ var ts;
39486
39524
  affectsSourceFile: true,
39487
39525
  affectsModuleResolution: true,
39488
39526
  affectsEmit: true,
39527
+ affectsMultiFileEmitBuildInfo: true,
39489
39528
  paramType: ts.Diagnostics.VERSION,
39490
39529
  showInSimplifiedHelpView: true,
39491
39530
  category: ts.Diagnostics.Language_and_Environment,
39492
39531
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39493
39532
  defaultValueDescription: 0 /* ES3 */,
39494
39533
  };
39534
+ /*@internal*/
39535
+ ts.moduleOptionDeclaration = {
39536
+ name: "module",
39537
+ shortName: "m",
39538
+ type: new ts.Map(ts.getEntries({
39539
+ none: ts.ModuleKind.None,
39540
+ commonjs: ts.ModuleKind.CommonJS,
39541
+ amd: ts.ModuleKind.AMD,
39542
+ system: ts.ModuleKind.System,
39543
+ umd: ts.ModuleKind.UMD,
39544
+ es6: ts.ModuleKind.ES2015,
39545
+ es2015: ts.ModuleKind.ES2015,
39546
+ es2020: ts.ModuleKind.ES2020,
39547
+ es2022: ts.ModuleKind.ES2022,
39548
+ esnext: ts.ModuleKind.ESNext,
39549
+ node16: ts.ModuleKind.Node16,
39550
+ nodenext: ts.ModuleKind.NodeNext,
39551
+ })),
39552
+ affectsModuleResolution: true,
39553
+ affectsEmit: true,
39554
+ affectsMultiFileEmitBuildInfo: true,
39555
+ paramType: ts.Diagnostics.KIND,
39556
+ showInSimplifiedHelpView: true,
39557
+ category: ts.Diagnostics.Modules,
39558
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39559
+ defaultValueDescription: undefined,
39560
+ };
39495
39561
  var commandOptionsWithoutBuild = [
39496
39562
  // CommandLine only options
39497
39563
  {
@@ -39553,37 +39619,14 @@ var ts;
39553
39619
  category: ts.Diagnostics.Command_line_Options,
39554
39620
  affectsSemanticDiagnostics: true,
39555
39621
  affectsEmit: true,
39622
+ affectsMultiFileEmitBuildInfo: true,
39556
39623
  isCommandLineOnly: true,
39557
39624
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39558
39625
  defaultValueDescription: false,
39559
39626
  },
39560
39627
  // Basic
39561
39628
  ts.targetOptionDeclaration,
39562
- {
39563
- name: "module",
39564
- shortName: "m",
39565
- type: new ts.Map(ts.getEntries({
39566
- none: ts.ModuleKind.None,
39567
- commonjs: ts.ModuleKind.CommonJS,
39568
- amd: ts.ModuleKind.AMD,
39569
- system: ts.ModuleKind.System,
39570
- umd: ts.ModuleKind.UMD,
39571
- es6: ts.ModuleKind.ES2015,
39572
- es2015: ts.ModuleKind.ES2015,
39573
- es2020: ts.ModuleKind.ES2020,
39574
- es2022: ts.ModuleKind.ES2022,
39575
- esnext: ts.ModuleKind.ESNext,
39576
- node16: ts.ModuleKind.Node16,
39577
- nodenext: ts.ModuleKind.NodeNext,
39578
- })),
39579
- affectsModuleResolution: true,
39580
- affectsEmit: true,
39581
- paramType: ts.Diagnostics.KIND,
39582
- showInSimplifiedHelpView: true,
39583
- category: ts.Diagnostics.Modules,
39584
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39585
- defaultValueDescription: undefined,
39586
- },
39629
+ ts.moduleOptionDeclaration,
39587
39630
  {
39588
39631
  name: "lib",
39589
39632
  type: "list",
@@ -39620,6 +39663,7 @@ var ts;
39620
39663
  type: jsxOptionMap,
39621
39664
  affectsSourceFile: true,
39622
39665
  affectsEmit: true,
39666
+ affectsMultiFileEmitBuildInfo: true,
39623
39667
  affectsModuleResolution: true,
39624
39668
  paramType: ts.Diagnostics.KIND,
39625
39669
  showInSimplifiedHelpView: true,
@@ -39632,6 +39676,7 @@ var ts;
39632
39676
  shortName: "d",
39633
39677
  type: "boolean",
39634
39678
  affectsEmit: true,
39679
+ affectsMultiFileEmitBuildInfo: true,
39635
39680
  showInSimplifiedHelpView: true,
39636
39681
  category: ts.Diagnostics.Emit,
39637
39682
  transpileOptionValue: undefined,
@@ -39642,6 +39687,7 @@ var ts;
39642
39687
  name: "declarationMap",
39643
39688
  type: "boolean",
39644
39689
  affectsEmit: true,
39690
+ affectsMultiFileEmitBuildInfo: true,
39645
39691
  showInSimplifiedHelpView: true,
39646
39692
  category: ts.Diagnostics.Emit,
39647
39693
  transpileOptionValue: undefined,
@@ -39652,6 +39698,7 @@ var ts;
39652
39698
  name: "emitDeclarationOnly",
39653
39699
  type: "boolean",
39654
39700
  affectsEmit: true,
39701
+ affectsMultiFileEmitBuildInfo: true,
39655
39702
  showInSimplifiedHelpView: true,
39656
39703
  category: ts.Diagnostics.Emit,
39657
39704
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39662,6 +39709,7 @@ var ts;
39662
39709
  name: "sourceMap",
39663
39710
  type: "boolean",
39664
39711
  affectsEmit: true,
39712
+ affectsMultiFileEmitBuildInfo: true,
39665
39713
  showInSimplifiedHelpView: true,
39666
39714
  category: ts.Diagnostics.Emit,
39667
39715
  defaultValueDescription: false,
@@ -39671,6 +39719,9 @@ var ts;
39671
39719
  name: "outFile",
39672
39720
  type: "string",
39673
39721
  affectsEmit: true,
39722
+ affectsMultiFileEmitBuildInfo: true,
39723
+ affectsDeclarationPath: true,
39724
+ affectsBundleEmitBuildInfo: true,
39674
39725
  isFilePath: true,
39675
39726
  paramType: ts.Diagnostics.FILE,
39676
39727
  showInSimplifiedHelpView: true,
@@ -39682,6 +39733,8 @@ var ts;
39682
39733
  name: "outDir",
39683
39734
  type: "string",
39684
39735
  affectsEmit: true,
39736
+ affectsMultiFileEmitBuildInfo: true,
39737
+ affectsDeclarationPath: true,
39685
39738
  isFilePath: true,
39686
39739
  paramType: ts.Diagnostics.DIRECTORY,
39687
39740
  showInSimplifiedHelpView: true,
@@ -39692,6 +39745,8 @@ var ts;
39692
39745
  name: "rootDir",
39693
39746
  type: "string",
39694
39747
  affectsEmit: true,
39748
+ affectsMultiFileEmitBuildInfo: true,
39749
+ affectsDeclarationPath: true,
39695
39750
  isFilePath: true,
39696
39751
  paramType: ts.Diagnostics.LOCATION,
39697
39752
  category: ts.Diagnostics.Modules,
@@ -39702,6 +39757,8 @@ var ts;
39702
39757
  name: "composite",
39703
39758
  type: "boolean",
39704
39759
  affectsEmit: true,
39760
+ affectsMultiFileEmitBuildInfo: true,
39761
+ affectsBundleEmitBuildInfo: true,
39705
39762
  isTSConfigOnly: true,
39706
39763
  category: ts.Diagnostics.Projects,
39707
39764
  transpileOptionValue: undefined,
@@ -39712,6 +39769,8 @@ var ts;
39712
39769
  name: "tsBuildInfoFile",
39713
39770
  type: "string",
39714
39771
  affectsEmit: true,
39772
+ affectsMultiFileEmitBuildInfo: true,
39773
+ affectsBundleEmitBuildInfo: true,
39715
39774
  isFilePath: true,
39716
39775
  paramType: ts.Diagnostics.FILE,
39717
39776
  category: ts.Diagnostics.Projects,
@@ -39723,6 +39782,7 @@ var ts;
39723
39782
  name: "removeComments",
39724
39783
  type: "boolean",
39725
39784
  affectsEmit: true,
39785
+ affectsMultiFileEmitBuildInfo: true,
39726
39786
  showInSimplifiedHelpView: true,
39727
39787
  category: ts.Diagnostics.Emit,
39728
39788
  defaultValueDescription: false,
@@ -39741,6 +39801,7 @@ var ts;
39741
39801
  name: "importHelpers",
39742
39802
  type: "boolean",
39743
39803
  affectsEmit: true,
39804
+ affectsMultiFileEmitBuildInfo: true,
39744
39805
  category: ts.Diagnostics.Emit,
39745
39806
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39746
39807
  defaultValueDescription: false,
@@ -39754,6 +39815,7 @@ var ts;
39754
39815
  })),
39755
39816
  affectsEmit: true,
39756
39817
  affectsSemanticDiagnostics: true,
39818
+ affectsMultiFileEmitBuildInfo: true,
39757
39819
  category: ts.Diagnostics.Emit,
39758
39820
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39759
39821
  defaultValueDescription: 0 /* Remove */,
@@ -39762,6 +39824,7 @@ var ts;
39762
39824
  name: "downlevelIteration",
39763
39825
  type: "boolean",
39764
39826
  affectsEmit: true,
39827
+ affectsMultiFileEmitBuildInfo: true,
39765
39828
  category: ts.Diagnostics.Emit,
39766
39829
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39767
39830
  defaultValueDescription: false,
@@ -39780,6 +39843,9 @@ var ts;
39780
39843
  type: "boolean",
39781
39844
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39782
39845
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39846
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39847
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39848
+ affectsMultiFileEmitBuildInfo: true,
39783
39849
  showInSimplifiedHelpView: true,
39784
39850
  category: ts.Diagnostics.Type_Checking,
39785
39851
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39789,6 +39855,7 @@ var ts;
39789
39855
  name: "noImplicitAny",
39790
39856
  type: "boolean",
39791
39857
  affectsSemanticDiagnostics: true,
39858
+ affectsMultiFileEmitBuildInfo: true,
39792
39859
  strictFlag: true,
39793
39860
  category: ts.Diagnostics.Type_Checking,
39794
39861
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39798,6 +39865,7 @@ var ts;
39798
39865
  name: "strictNullChecks",
39799
39866
  type: "boolean",
39800
39867
  affectsSemanticDiagnostics: true,
39868
+ affectsMultiFileEmitBuildInfo: true,
39801
39869
  strictFlag: true,
39802
39870
  category: ts.Diagnostics.Type_Checking,
39803
39871
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39806,6 +39874,8 @@ var ts;
39806
39874
  {
39807
39875
  name: "strictFunctionTypes",
39808
39876
  type: "boolean",
39877
+ affectsSemanticDiagnostics: true,
39878
+ affectsMultiFileEmitBuildInfo: true,
39809
39879
  strictFlag: true,
39810
39880
  category: ts.Diagnostics.Type_Checking,
39811
39881
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39814,6 +39884,8 @@ var ts;
39814
39884
  {
39815
39885
  name: "strictBindCallApply",
39816
39886
  type: "boolean",
39887
+ affectsSemanticDiagnostics: true,
39888
+ affectsMultiFileEmitBuildInfo: true,
39817
39889
  strictFlag: true,
39818
39890
  category: ts.Diagnostics.Type_Checking,
39819
39891
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39823,6 +39895,7 @@ var ts;
39823
39895
  name: "strictPropertyInitialization",
39824
39896
  type: "boolean",
39825
39897
  affectsSemanticDiagnostics: true,
39898
+ affectsMultiFileEmitBuildInfo: true,
39826
39899
  strictFlag: true,
39827
39900
  category: ts.Diagnostics.Type_Checking,
39828
39901
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39832,6 +39905,7 @@ var ts;
39832
39905
  name: "noImplicitThis",
39833
39906
  type: "boolean",
39834
39907
  affectsSemanticDiagnostics: true,
39908
+ affectsMultiFileEmitBuildInfo: true,
39835
39909
  strictFlag: true,
39836
39910
  category: ts.Diagnostics.Type_Checking,
39837
39911
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39841,6 +39915,7 @@ var ts;
39841
39915
  name: "useUnknownInCatchVariables",
39842
39916
  type: "boolean",
39843
39917
  affectsSemanticDiagnostics: true,
39918
+ affectsMultiFileEmitBuildInfo: true,
39844
39919
  strictFlag: true,
39845
39920
  category: ts.Diagnostics.Type_Checking,
39846
39921
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39850,6 +39925,8 @@ var ts;
39850
39925
  name: "alwaysStrict",
39851
39926
  type: "boolean",
39852
39927
  affectsSourceFile: true,
39928
+ affectsEmit: true,
39929
+ affectsMultiFileEmitBuildInfo: true,
39853
39930
  strictFlag: true,
39854
39931
  category: ts.Diagnostics.Type_Checking,
39855
39932
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39860,6 +39937,7 @@ var ts;
39860
39937
  name: "noUnusedLocals",
39861
39938
  type: "boolean",
39862
39939
  affectsSemanticDiagnostics: true,
39940
+ affectsMultiFileEmitBuildInfo: true,
39863
39941
  category: ts.Diagnostics.Type_Checking,
39864
39942
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39865
39943
  defaultValueDescription: false,
@@ -39868,6 +39946,7 @@ var ts;
39868
39946
  name: "noUnusedParameters",
39869
39947
  type: "boolean",
39870
39948
  affectsSemanticDiagnostics: true,
39949
+ affectsMultiFileEmitBuildInfo: true,
39871
39950
  category: ts.Diagnostics.Type_Checking,
39872
39951
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39873
39952
  defaultValueDescription: false,
@@ -39876,6 +39955,7 @@ var ts;
39876
39955
  name: "exactOptionalPropertyTypes",
39877
39956
  type: "boolean",
39878
39957
  affectsSemanticDiagnostics: true,
39958
+ affectsMultiFileEmitBuildInfo: true,
39879
39959
  category: ts.Diagnostics.Type_Checking,
39880
39960
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39881
39961
  defaultValueDescription: false,
@@ -39884,6 +39964,7 @@ var ts;
39884
39964
  name: "noImplicitReturns",
39885
39965
  type: "boolean",
39886
39966
  affectsSemanticDiagnostics: true,
39967
+ affectsMultiFileEmitBuildInfo: true,
39887
39968
  category: ts.Diagnostics.Type_Checking,
39888
39969
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39889
39970
  defaultValueDescription: false,
@@ -39893,6 +39974,7 @@ var ts;
39893
39974
  type: "boolean",
39894
39975
  affectsBindDiagnostics: true,
39895
39976
  affectsSemanticDiagnostics: true,
39977
+ affectsMultiFileEmitBuildInfo: true,
39896
39978
  category: ts.Diagnostics.Type_Checking,
39897
39979
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39898
39980
  defaultValueDescription: false,
@@ -39901,6 +39983,7 @@ var ts;
39901
39983
  name: "noUncheckedIndexedAccess",
39902
39984
  type: "boolean",
39903
39985
  affectsSemanticDiagnostics: true,
39986
+ affectsMultiFileEmitBuildInfo: true,
39904
39987
  category: ts.Diagnostics.Type_Checking,
39905
39988
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39906
39989
  defaultValueDescription: false,
@@ -39909,6 +39992,7 @@ var ts;
39909
39992
  name: "noImplicitOverride",
39910
39993
  type: "boolean",
39911
39994
  affectsSemanticDiagnostics: true,
39995
+ affectsMultiFileEmitBuildInfo: true,
39912
39996
  category: ts.Diagnostics.Type_Checking,
39913
39997
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39914
39998
  defaultValueDescription: false,
@@ -39916,6 +40000,8 @@ var ts;
39916
40000
  {
39917
40001
  name: "noPropertyAccessFromIndexSignature",
39918
40002
  type: "boolean",
40003
+ affectsSemanticDiagnostics: true,
40004
+ affectsMultiFileEmitBuildInfo: true,
39919
40005
  showInSimplifiedHelpView: false,
39920
40006
  category: ts.Diagnostics.Type_Checking,
39921
40007
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -40001,6 +40087,7 @@ var ts;
40001
40087
  name: "allowSyntheticDefaultImports",
40002
40088
  type: "boolean",
40003
40089
  affectsSemanticDiagnostics: true,
40090
+ affectsMultiFileEmitBuildInfo: true,
40004
40091
  category: ts.Diagnostics.Interop_Constraints,
40005
40092
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
40006
40093
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -40010,6 +40097,7 @@ var ts;
40010
40097
  type: "boolean",
40011
40098
  affectsSemanticDiagnostics: true,
40012
40099
  affectsEmit: true,
40100
+ affectsMultiFileEmitBuildInfo: true,
40013
40101
  showInSimplifiedHelpView: true,
40014
40102
  category: ts.Diagnostics.Interop_Constraints,
40015
40103
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -40026,6 +40114,7 @@ var ts;
40026
40114
  name: "allowUmdGlobalAccess",
40027
40115
  type: "boolean",
40028
40116
  affectsSemanticDiagnostics: true,
40117
+ affectsMultiFileEmitBuildInfo: true,
40029
40118
  category: ts.Diagnostics.Modules,
40030
40119
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
40031
40120
  defaultValueDescription: false,
@@ -40047,6 +40136,7 @@ var ts;
40047
40136
  name: "sourceRoot",
40048
40137
  type: "string",
40049
40138
  affectsEmit: true,
40139
+ affectsMultiFileEmitBuildInfo: true,
40050
40140
  paramType: ts.Diagnostics.LOCATION,
40051
40141
  category: ts.Diagnostics.Emit,
40052
40142
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -40055,6 +40145,7 @@ var ts;
40055
40145
  name: "mapRoot",
40056
40146
  type: "string",
40057
40147
  affectsEmit: true,
40148
+ affectsMultiFileEmitBuildInfo: true,
40058
40149
  paramType: ts.Diagnostics.LOCATION,
40059
40150
  category: ts.Diagnostics.Emit,
40060
40151
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -40063,6 +40154,7 @@ var ts;
40063
40154
  name: "inlineSourceMap",
40064
40155
  type: "boolean",
40065
40156
  affectsEmit: true,
40157
+ affectsMultiFileEmitBuildInfo: true,
40066
40158
  category: ts.Diagnostics.Emit,
40067
40159
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
40068
40160
  defaultValueDescription: false,
@@ -40071,6 +40163,7 @@ var ts;
40071
40163
  name: "inlineSources",
40072
40164
  type: "boolean",
40073
40165
  affectsEmit: true,
40166
+ affectsMultiFileEmitBuildInfo: true,
40074
40167
  category: ts.Diagnostics.Emit,
40075
40168
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
40076
40169
  defaultValueDescription: false,
@@ -40080,6 +40173,7 @@ var ts;
40080
40173
  name: "experimentalDecorators",
40081
40174
  type: "boolean",
40082
40175
  affectsSemanticDiagnostics: true,
40176
+ affectsMultiFileEmitBuildInfo: true,
40083
40177
  category: ts.Diagnostics.Language_and_Environment,
40084
40178
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
40085
40179
  defaultValueDescription: false,
@@ -40089,6 +40183,7 @@ var ts;
40089
40183
  type: "boolean",
40090
40184
  affectsSemanticDiagnostics: true,
40091
40185
  affectsEmit: true,
40186
+ affectsMultiFileEmitBuildInfo: true,
40092
40187
  category: ts.Diagnostics.Language_and_Environment,
40093
40188
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
40094
40189
  defaultValueDescription: false,
@@ -40113,6 +40208,7 @@ var ts;
40113
40208
  type: "string",
40114
40209
  affectsSemanticDiagnostics: true,
40115
40210
  affectsEmit: true,
40211
+ affectsMultiFileEmitBuildInfo: true,
40116
40212
  affectsModuleResolution: true,
40117
40213
  category: ts.Diagnostics.Language_and_Environment,
40118
40214
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -40130,6 +40226,9 @@ var ts;
40130
40226
  name: "out",
40131
40227
  type: "string",
40132
40228
  affectsEmit: true,
40229
+ affectsMultiFileEmitBuildInfo: true,
40230
+ affectsDeclarationPath: true,
40231
+ affectsBundleEmitBuildInfo: true,
40133
40232
  isFilePath: false,
40134
40233
  // for correct behaviour, please use outFile
40135
40234
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -40141,6 +40240,7 @@ var ts;
40141
40240
  name: "reactNamespace",
40142
40241
  type: "string",
40143
40242
  affectsEmit: true,
40243
+ affectsMultiFileEmitBuildInfo: true,
40144
40244
  category: ts.Diagnostics.Language_and_Environment,
40145
40245
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
40146
40246
  defaultValueDescription: "`React`",
@@ -40148,6 +40248,8 @@ var ts;
40148
40248
  {
40149
40249
  name: "skipDefaultLibCheck",
40150
40250
  type: "boolean",
40251
+ // We need to store these to determine whether `lib` files need to be rechecked
40252
+ affectsMultiFileEmitBuildInfo: true,
40151
40253
  category: ts.Diagnostics.Completeness,
40152
40254
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
40153
40255
  defaultValueDescription: false,
@@ -40163,6 +40265,7 @@ var ts;
40163
40265
  name: "emitBOM",
40164
40266
  type: "boolean",
40165
40267
  affectsEmit: true,
40268
+ affectsMultiFileEmitBuildInfo: true,
40166
40269
  category: ts.Diagnostics.Emit,
40167
40270
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
40168
40271
  defaultValueDescription: false,
@@ -40174,6 +40277,7 @@ var ts;
40174
40277
  lf: 1 /* LineFeed */
40175
40278
  })),
40176
40279
  affectsEmit: true,
40280
+ affectsMultiFileEmitBuildInfo: true,
40177
40281
  paramType: ts.Diagnostics.NEWLINE,
40178
40282
  category: ts.Diagnostics.Emit,
40179
40283
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -40183,6 +40287,7 @@ var ts;
40183
40287
  name: "noErrorTruncation",
40184
40288
  type: "boolean",
40185
40289
  affectsSemanticDiagnostics: true,
40290
+ affectsMultiFileEmitBuildInfo: true,
40186
40291
  category: ts.Diagnostics.Output_Formatting,
40187
40292
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
40188
40293
  defaultValueDescription: false,
@@ -40213,6 +40318,7 @@ var ts;
40213
40318
  name: "stripInternal",
40214
40319
  type: "boolean",
40215
40320
  affectsEmit: true,
40321
+ affectsMultiFileEmitBuildInfo: true,
40216
40322
  category: ts.Diagnostics.Emit,
40217
40323
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40218
40324
  defaultValueDescription: false,
@@ -40253,6 +40359,7 @@ var ts;
40253
40359
  name: "noImplicitUseStrict",
40254
40360
  type: "boolean",
40255
40361
  affectsSemanticDiagnostics: true,
40362
+ affectsMultiFileEmitBuildInfo: true,
40256
40363
  category: ts.Diagnostics.Backwards_Compatibility,
40257
40364
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40258
40365
  defaultValueDescription: false,
@@ -40261,6 +40368,7 @@ var ts;
40261
40368
  name: "noEmitHelpers",
40262
40369
  type: "boolean",
40263
40370
  affectsEmit: true,
40371
+ affectsMultiFileEmitBuildInfo: true,
40264
40372
  category: ts.Diagnostics.Emit,
40265
40373
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40266
40374
  defaultValueDescription: false,
@@ -40269,6 +40377,7 @@ var ts;
40269
40377
  name: "noEmitOnError",
40270
40378
  type: "boolean",
40271
40379
  affectsEmit: true,
40380
+ affectsMultiFileEmitBuildInfo: true,
40272
40381
  category: ts.Diagnostics.Emit,
40273
40382
  transpileOptionValue: undefined,
40274
40383
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40278,6 +40387,7 @@ var ts;
40278
40387
  name: "preserveConstEnums",
40279
40388
  type: "boolean",
40280
40389
  affectsEmit: true,
40390
+ affectsMultiFileEmitBuildInfo: true,
40281
40391
  category: ts.Diagnostics.Emit,
40282
40392
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40283
40393
  defaultValueDescription: false,
@@ -40286,6 +40396,8 @@ var ts;
40286
40396
  name: "declarationDir",
40287
40397
  type: "string",
40288
40398
  affectsEmit: true,
40399
+ affectsMultiFileEmitBuildInfo: true,
40400
+ affectsDeclarationPath: true,
40289
40401
  isFilePath: true,
40290
40402
  paramType: ts.Diagnostics.DIRECTORY,
40291
40403
  category: ts.Diagnostics.Emit,
@@ -40295,6 +40407,8 @@ var ts;
40295
40407
  {
40296
40408
  name: "skipLibCheck",
40297
40409
  type: "boolean",
40410
+ // We need to store these to determine whether `lib` files need to be rechecked
40411
+ affectsMultiFileEmitBuildInfo: true,
40298
40412
  category: ts.Diagnostics.Completeness,
40299
40413
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40300
40414
  defaultValueDescription: false,
@@ -40304,6 +40418,7 @@ var ts;
40304
40418
  type: "boolean",
40305
40419
  affectsBindDiagnostics: true,
40306
40420
  affectsSemanticDiagnostics: true,
40421
+ affectsMultiFileEmitBuildInfo: true,
40307
40422
  category: ts.Diagnostics.Type_Checking,
40308
40423
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40309
40424
  defaultValueDescription: undefined,
@@ -40313,6 +40428,7 @@ var ts;
40313
40428
  type: "boolean",
40314
40429
  affectsBindDiagnostics: true,
40315
40430
  affectsSemanticDiagnostics: true,
40431
+ affectsMultiFileEmitBuildInfo: true,
40316
40432
  category: ts.Diagnostics.Type_Checking,
40317
40433
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40318
40434
  defaultValueDescription: undefined,
@@ -40321,6 +40437,7 @@ var ts;
40321
40437
  name: "suppressExcessPropertyErrors",
40322
40438
  type: "boolean",
40323
40439
  affectsSemanticDiagnostics: true,
40440
+ affectsMultiFileEmitBuildInfo: true,
40324
40441
  category: ts.Diagnostics.Backwards_Compatibility,
40325
40442
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40326
40443
  defaultValueDescription: false,
@@ -40329,6 +40446,7 @@ var ts;
40329
40446
  name: "suppressImplicitAnyIndexErrors",
40330
40447
  type: "boolean",
40331
40448
  affectsSemanticDiagnostics: true,
40449
+ affectsMultiFileEmitBuildInfo: true,
40332
40450
  category: ts.Diagnostics.Backwards_Compatibility,
40333
40451
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40334
40452
  defaultValueDescription: false,
@@ -40353,6 +40471,7 @@ var ts;
40353
40471
  name: "noStrictGenericChecks",
40354
40472
  type: "boolean",
40355
40473
  affectsSemanticDiagnostics: true,
40474
+ affectsMultiFileEmitBuildInfo: true,
40356
40475
  category: ts.Diagnostics.Backwards_Compatibility,
40357
40476
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40358
40477
  defaultValueDescription: false,
@@ -40362,6 +40481,7 @@ var ts;
40362
40481
  type: "boolean",
40363
40482
  affectsSemanticDiagnostics: true,
40364
40483
  affectsEmit: true,
40484
+ affectsMultiFileEmitBuildInfo: true,
40365
40485
  category: ts.Diagnostics.Language_and_Environment,
40366
40486
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40367
40487
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40370,6 +40490,7 @@ var ts;
40370
40490
  name: "preserveValueImports",
40371
40491
  type: "boolean",
40372
40492
  affectsEmit: true,
40493
+ affectsMultiFileEmitBuildInfo: true,
40373
40494
  category: ts.Diagnostics.Emit,
40374
40495
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40375
40496
  defaultValueDescription: false,
@@ -40413,6 +40534,8 @@ var ts;
40413
40534
  /* @internal */
40414
40535
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40415
40536
  /* @internal */
40537
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40538
+ /* @internal */
40416
40539
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40417
40540
  /* @internal */
40418
40541
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41268,6 +41391,7 @@ var ts;
41268
41391
  return optionDefinition.type;
41269
41392
  }
41270
41393
  }
41394
+ /* @internal */
41271
41395
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41272
41396
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41273
41397
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41276,6 +41400,7 @@ var ts;
41276
41400
  }
41277
41401
  });
41278
41402
  }
41403
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41279
41404
  function serializeCompilerOptions(options, pathOptions) {
41280
41405
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41281
41406
  }
@@ -42441,16 +42566,18 @@ var ts;
42441
42566
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42442
42567
  return { fileName: resolved.path, packageId: resolved.packageId };
42443
42568
  }
42444
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42445
- var _a;
42569
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42570
+ var _a, _b;
42446
42571
  if (resultFromCache) {
42447
42572
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42573
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42448
42574
  return resultFromCache;
42449
42575
  }
42450
42576
  return {
42451
42577
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42452
42578
  failedLookupLocations: failedLookupLocations,
42453
- resolutionDiagnostics: diagnostics
42579
+ affectingLocations: affectingLocations,
42580
+ resolutionDiagnostics: diagnostics,
42454
42581
  };
42455
42582
  }
42456
42583
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42639,6 +42766,7 @@ var ts;
42639
42766
  }
42640
42767
  }
42641
42768
  var failedLookupLocations = [];
42769
+ var affectingLocations = [];
42642
42770
  var features = getDefaultNodeResolutionFeatures(options);
42643
42771
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42644
42772
  // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
@@ -42657,6 +42785,7 @@ var ts;
42657
42785
  host: host,
42658
42786
  traceEnabled: traceEnabled,
42659
42787
  failedLookupLocations: failedLookupLocations,
42788
+ affectingLocations: affectingLocations,
42660
42789
  packageJsonInfoCache: cache,
42661
42790
  features: features,
42662
42791
  conditions: conditions,
@@ -42681,7 +42810,7 @@ var ts;
42681
42810
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42682
42811
  };
42683
42812
  }
42684
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42813
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42685
42814
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42686
42815
  if (traceEnabled)
42687
42816
  traceResult(result);
@@ -42761,6 +42890,7 @@ var ts;
42761
42890
  host: host,
42762
42891
  traceEnabled: isTraceEnabled(options, host),
42763
42892
  failedLookupLocations: [],
42893
+ affectingLocations: [],
42764
42894
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42765
42895
  conditions: ts.emptyArray,
42766
42896
  features: NodeResolutionFeatures.None,
@@ -43415,6 +43545,7 @@ var ts;
43415
43545
  var _a, _b;
43416
43546
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43417
43547
  var failedLookupLocations = [];
43548
+ var affectingLocations = [];
43418
43549
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43419
43550
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43420
43551
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43427,6 +43558,7 @@ var ts;
43427
43558
  host: host,
43428
43559
  traceEnabled: traceEnabled,
43429
43560
  failedLookupLocations: failedLookupLocations,
43561
+ affectingLocations: affectingLocations,
43430
43562
  packageJsonInfoCache: cache,
43431
43563
  features: features,
43432
43564
  conditions: conditions,
@@ -43434,7 +43566,7 @@ var ts;
43434
43566
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43435
43567
  };
43436
43568
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43437
- 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);
43569
+ 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);
43438
43570
  function tryResolve(extensions) {
43439
43571
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43440
43572
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43729,6 +43861,7 @@ var ts;
43729
43861
  host: host,
43730
43862
  traceEnabled: isTraceEnabled(options, host),
43731
43863
  failedLookupLocations: [],
43864
+ affectingLocations: [],
43732
43865
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43733
43866
  conditions: ["node", "require", "types"],
43734
43867
  features: features,
@@ -43817,6 +43950,7 @@ var ts;
43817
43950
  compilerOptions: options,
43818
43951
  traceEnabled: isTraceEnabled(options, host),
43819
43952
  failedLookupLocations: [],
43953
+ affectingLocations: [],
43820
43954
  packageJsonInfoCache: packageJsonInfoCache,
43821
43955
  features: 0,
43822
43956
  conditions: [],
@@ -43849,6 +43983,7 @@ var ts;
43849
43983
  if (typeof existing !== "boolean") {
43850
43984
  if (traceEnabled)
43851
43985
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43986
+ state.affectingLocations.push(packageJsonPath);
43852
43987
  return existing;
43853
43988
  }
43854
43989
  else {
@@ -43867,6 +44002,7 @@ var ts;
43867
44002
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43868
44003
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43869
44004
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
44005
+ state.affectingLocations.push(packageJsonPath);
43870
44006
  return result;
43871
44007
  }
43872
44008
  else {
@@ -44530,12 +44666,25 @@ var ts;
44530
44666
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44531
44667
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44532
44668
  var failedLookupLocations = [];
44669
+ var affectingLocations = [];
44533
44670
  var containingDirectory = ts.getDirectoryPath(containingFile);
44534
44671
  var diagnostics = [];
44535
- 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); } };
44672
+ var state = {
44673
+ compilerOptions: compilerOptions,
44674
+ host: host,
44675
+ traceEnabled: traceEnabled,
44676
+ failedLookupLocations: failedLookupLocations,
44677
+ affectingLocations: affectingLocations,
44678
+ packageJsonInfoCache: cache,
44679
+ features: NodeResolutionFeatures.None,
44680
+ conditions: [],
44681
+ requestContainingDirectory: containingDirectory,
44682
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44683
+ };
44536
44684
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44537
44685
  // No originalPath because classic resolution doesn't resolve realPath
44538
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44686
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
44687
+ /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44539
44688
  function tryResolve(extensions) {
44540
44689
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44541
44690
  if (resolvedUsingSettings) {
@@ -44578,10 +44727,23 @@ var ts;
44578
44727
  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);
44579
44728
  }
44580
44729
  var failedLookupLocations = [];
44730
+ var affectingLocations = [];
44581
44731
  var diagnostics = [];
44582
- 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); } };
44732
+ var state = {
44733
+ compilerOptions: compilerOptions,
44734
+ host: host,
44735
+ traceEnabled: traceEnabled,
44736
+ failedLookupLocations: failedLookupLocations,
44737
+ affectingLocations: affectingLocations,
44738
+ packageJsonInfoCache: packageJsonInfoCache,
44739
+ features: NodeResolutionFeatures.None,
44740
+ conditions: [],
44741
+ requestContainingDirectory: undefined,
44742
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44743
+ };
44583
44744
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44584
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44745
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44746
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44585
44747
  }
44586
44748
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44587
44749
  /**
@@ -48142,16 +48304,6 @@ var ts;
48142
48304
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
48143
48305
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
48144
48306
  })(TypeFacts || (TypeFacts = {}));
48145
- var typeofEQFacts = new ts.Map(ts.getEntries({
48146
- string: 1 /* TypeofEQString */,
48147
- number: 2 /* TypeofEQNumber */,
48148
- bigint: 4 /* TypeofEQBigInt */,
48149
- boolean: 8 /* TypeofEQBoolean */,
48150
- symbol: 16 /* TypeofEQSymbol */,
48151
- undefined: 65536 /* EQUndefined */,
48152
- object: 32 /* TypeofEQObject */,
48153
- function: 64 /* TypeofEQFunction */
48154
- }));
48155
48307
  var typeofNEFacts = new ts.Map(ts.getEntries({
48156
48308
  string: 256 /* TypeofNEString */,
48157
48309
  number: 512 /* TypeofNENumber */,
@@ -48950,14 +49102,6 @@ var ts;
48950
49102
  var awaitedTypeStack = [];
48951
49103
  var diagnostics = ts.createDiagnosticCollection();
48952
49104
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48953
- var typeofTypesByName = new ts.Map(ts.getEntries({
48954
- string: stringType,
48955
- number: numberType,
48956
- bigint: bigintType,
48957
- boolean: booleanType,
48958
- symbol: esSymbolType,
48959
- undefined: undefinedType
48960
- }));
48961
49105
  var typeofType = createTypeofType();
48962
49106
  var _jsxNamespace;
48963
49107
  var _jsxFactoryEntity;
@@ -51833,7 +51977,7 @@ var ts;
51833
51977
  return type;
51834
51978
  }
51835
51979
  function createTypeofType() {
51836
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51980
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51837
51981
  }
51838
51982
  function createTypeParameter(symbol) {
51839
51983
  var type = createType(262144 /* TypeParameter */);
@@ -52619,6 +52763,9 @@ var ts;
52619
52763
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52620
52764
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52621
52765
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
52766
+ if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
52767
+ return ts.factory.createArrayTypeNode(typeArgumentNodes[0]);
52768
+ }
52622
52769
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52623
52770
  }
52624
52771
  var objectFlags = ts.getObjectFlags(type);
@@ -52809,7 +52956,7 @@ var ts;
52809
52956
  // Always use 'typeof T' for type of class, enum, and module objects
52810
52957
  else if (symbol.flags & 32 /* Class */
52811
52958
  && !getBaseTypeVariableOfClass(symbol)
52812
- && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) ||
52959
+ && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) ||
52813
52960
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52814
52961
  shouldWriteTypeOfFunctionSymbol()) {
52815
52962
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56439,6 +56586,17 @@ var ts;
56439
56586
  });
56440
56587
  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
56441
56588
  members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
56589
+ if (initialSize === members_4.size) {
56590
+ if (type.aliasSymbol) {
56591
+ result.aliasSymbol = type.aliasSymbol;
56592
+ result.aliasTypeArguments = type.aliasTypeArguments;
56593
+ }
56594
+ if (ts.getObjectFlags(type) & 4 /* Reference */) {
56595
+ result.aliasSymbol = type.symbol;
56596
+ var args = getTypeArguments(type);
56597
+ result.aliasTypeArguments = ts.length(args) ? args : undefined;
56598
+ }
56599
+ }
56442
56600
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56443
56601
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56444
56602
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -70047,19 +70205,17 @@ var ts;
70047
70205
  }
70048
70206
  return links.switchTypes;
70049
70207
  }
70050
- function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
70208
+ // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are
70209
+ // represented as undefined. Return undefined if one or more case clause expressions are not string literals.
70210
+ function getSwitchClauseTypeOfWitnesses(switchStatement) {
70211
+ if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) {
70212
+ return undefined;
70213
+ }
70051
70214
  var witnesses = [];
70052
70215
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
70053
70216
  var clause = _a[_i];
70054
- if (clause.kind === 289 /* CaseClause */) {
70055
- if (ts.isStringLiteralLike(clause.expression)) {
70056
- witnesses.push(clause.expression.text);
70057
- continue;
70058
- }
70059
- return ts.emptyArray;
70060
- }
70061
- if (retainDefault)
70062
- witnesses.push(/*explicitDefaultStatement*/ undefined);
70217
+ var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined;
70218
+ witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined);
70063
70219
  }
70064
70220
  return witnesses;
70065
70221
  }
@@ -71249,14 +71405,9 @@ var ts;
71249
71405
  }
71250
71406
  return type;
71251
71407
  }
71252
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71253
- return type;
71254
- }
71255
- var facts = assumeTrue ?
71256
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71257
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71258
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71259
- return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71408
+ return assumeTrue ?
71409
+ narrowTypeByTypeName(type, literal.text) :
71410
+ getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
71260
71411
  }
71261
71412
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71262
71413
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71303,102 +71454,52 @@ var ts;
71303
71454
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71304
71455
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71305
71456
  }
71306
- function getImpliedTypeFromTypeofGuard(type, text) {
71307
- switch (text) {
71308
- case "object":
71309
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71310
- case "function":
71311
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71312
- default:
71313
- return typeofTypesByName.get(text);
71457
+ function narrowTypeByTypeName(type, typeName) {
71458
+ switch (typeName) {
71459
+ case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */);
71460
+ case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */);
71461
+ case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */);
71462
+ case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */);
71463
+ case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */);
71464
+ case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]);
71465
+ case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */);
71466
+ case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */);
71314
71467
  }
71468
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71315
71469
  }
71316
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71317
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71318
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71319
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71320
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71321
- // filtering by type-facts.
71322
- function narrowTypeByImpliedType(type, candidate) {
71323
- if (type.flags & 3 /* AnyOrUnknown */) {
71324
- return candidate;
71325
- }
71470
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71326
71471
  return mapType(type, function (t) {
71327
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71328
- return t;
71329
- }
71330
- return mapType(candidate, function (c) {
71331
- if (!areTypesComparable(t, c)) {
71332
- return neverType;
71333
- }
71334
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71335
- return isTypeSubtypeOf(c, t) ? c : neverType;
71336
- }
71337
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71338
- return c;
71339
- }
71340
- return getIntersectionType([t, c]);
71341
- });
71472
+ // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
71473
+ // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
71474
+ // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
71475
+ // but are classified as "function" according to `typeof`.
71476
+ return isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType :
71477
+ // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
71478
+ // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
71479
+ isTypeSubtypeOf(impliedType, t) ? impliedType :
71480
+ // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
71481
+ // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
71482
+ // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
71483
+ getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) :
71484
+ neverType;
71342
71485
  });
71343
71486
  }
71344
71487
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71345
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71346
- if (!switchWitnesses.length) {
71488
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71489
+ if (!witnesses) {
71347
71490
  return type;
71348
71491
  }
71349
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71350
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71351
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71352
- var clauseWitnesses;
71353
- var switchFacts;
71354
- if (defaultCaseLocation > -1) {
71355
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71356
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71357
- // witness array.
71358
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71359
- // The adjusted clause start and end after removing the `default` statement.
71360
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71361
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71362
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71363
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71364
- }
71365
- else {
71366
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71367
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71368
- }
71492
+ // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause.
71493
+ var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; });
71494
+ var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd);
71369
71495
  if (hasDefaultClause) {
71370
- return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
71496
+ // In the default clause we filter constituents down to those that are not-equal to all handled cases.
71497
+ var notEqualFacts_1 = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
71498
+ return filterType(type, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; });
71371
71499
  }
71372
- /*
71373
- The implied type is the raw type suggested by a
71374
- value being caught in this clause.
71375
-
71376
- When the clause contains a default case we ignore
71377
- the implied type and try to narrow using any facts
71378
- we can learn: see `switchFacts`.
71379
-
71380
- Example:
71381
- switch (typeof x) {
71382
- case 'number':
71383
- case 'string': break;
71384
- default: break;
71385
- case 'number':
71386
- case 'boolean': break
71387
- }
71388
-
71389
- In the first clause (case `number` and `string`) the
71390
- implied type is number | string.
71391
-
71392
- In the default clause we de not compute an implied type.
71393
-
71394
- In the third clause (case `number` and `boolean`)
71395
- the naive implied type is number | boolean, however
71396
- we use the type facts to narrow the implied type to
71397
- boolean. We know that number cannot be selected
71398
- because it is caught in the first clause.
71399
- */
71400
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71401
- return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71500
+ // In the non-default cause we create a union of the type narrowed by each of the listed cases.
71501
+ var clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71502
+ return getUnionType(ts.map(clauseWitnesses, function (text) { return text ? narrowTypeByTypeName(type, text) : neverType; }));
71402
71503
  }
71403
71504
  function isMatchingConstructorReference(expr) {
71404
71505
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -78210,45 +78311,12 @@ var ts;
78210
78311
  ? 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
78211
78312
  : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
78212
78313
  }
78213
- /**
78214
- * Collect the TypeFacts learned from a typeof switch with
78215
- * total clauses `witnesses`, and the active clause ranging
78216
- * from `start` to `end`. Parameter `hasDefault` denotes
78217
- * whether the active clause contains a default clause.
78218
- */
78219
- function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
78314
+ // Return the combined not-equal type facts for all cases except those between the start and end indices.
78315
+ function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) {
78220
78316
  var facts = 0 /* None */;
78221
- // When in the default we only collect inequality facts
78222
- // because default is 'in theory' a set of infinite
78223
- // equalities.
78224
- if (hasDefault) {
78225
- // Value is not equal to any types after the active clause.
78226
- for (var i = end; i < witnesses.length; i++) {
78227
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78228
- }
78229
- // Remove inequalities for types that appear in the
78230
- // active clause because they appear before other
78231
- // types collected so far.
78232
- for (var i = start; i < end; i++) {
78233
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78234
- }
78235
- // Add inequalities for types before the active clause unconditionally.
78236
- for (var i = 0; i < start; i++) {
78237
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78238
- }
78239
- }
78240
- // When in an active clause without default the set of
78241
- // equalities is finite.
78242
- else {
78243
- // Add equalities for all types in the active clause.
78244
- for (var i = start; i < end; i++) {
78245
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78246
- }
78247
- // Remove equalities for types that appear before the
78248
- // active clause.
78249
- for (var i = 0; i < start; i++) {
78250
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78251
- }
78317
+ for (var i = 0; i < witnesses.length; i++) {
78318
+ var witness = i < start || i >= end ? witnesses[i] : undefined;
78319
+ facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0;
78252
78320
  }
78253
78321
  return facts;
78254
78322
  }
@@ -78258,16 +78326,19 @@ var ts;
78258
78326
  }
78259
78327
  function computeExhaustiveSwitchStatement(node) {
78260
78328
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78261
- var operandType = getTypeOfExpression(node.expression.expression);
78262
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78263
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78264
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78265
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78266
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78267
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78268
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
78329
+ var witnesses = getSwitchClauseTypeOfWitnesses(node);
78330
+ if (!witnesses) {
78331
+ return false;
78269
78332
  }
78270
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
78333
+ var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
78334
+ // Get the not-equal flags for all handled cases.
78335
+ var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
78336
+ if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
78337
+ // We special case the top types to be exhaustive when all cases are handled.
78338
+ return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */;
78339
+ }
78340
+ // A missing not-equal flag indicates that the type wasn't handled by some case.
78341
+ return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
78271
78342
  }
78272
78343
  var type = getTypeOfExpression(node.expression);
78273
78344
  if (!isLiteralType(type)) {
@@ -111002,7 +111073,9 @@ var ts;
111002
111073
  return;
111003
111074
  }
111004
111075
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
111005
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
111076
+ var buildInfo = { bundle: bundle, program: program, version: version };
111077
+ // Pass buildinfo as additional data to avoid having to reparse
111078
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
111006
111079
  }
111007
111080
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
111008
111081
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -111156,13 +111229,20 @@ var ts;
111156
111229
  if (sourceMapFilePath) {
111157
111230
  var sourceMap = sourceMapGenerator.toString();
111158
111231
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111232
+ if (printer.bundleFileInfo)
111233
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111159
111234
  }
111160
111235
  }
111161
111236
  else {
111162
111237
  writer.writeLine();
111163
111238
  }
111164
111239
  // Write the output file
111165
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111240
+ var text = writer.getText();
111241
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111242
+ // 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
111243
+ // 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
111244
+ if (printer.bundleFileInfo)
111245
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111166
111246
  // Reset state
111167
111247
  writer.clear();
111168
111248
  }
@@ -111305,34 +111385,56 @@ var ts;
111305
111385
  }
111306
111386
  /*@internal*/
111307
111387
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111388
+ var createHash = ts.maybeBind(host, host.createHash);
111308
111389
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111309
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111310
- if (!buildInfoText)
111390
+ var buildInfo;
111391
+ if (host.getBuildInfo) {
111392
+ // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111393
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111394
+ if (!hostBuildInfo)
111395
+ return buildInfoPath;
111396
+ buildInfo = hostBuildInfo;
111397
+ }
111398
+ else {
111399
+ var buildInfoText = host.readFile(buildInfoPath);
111400
+ if (!buildInfoText)
111401
+ return buildInfoPath;
111402
+ buildInfo = getBuildInfo(buildInfoText);
111403
+ }
111404
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111311
111405
  return buildInfoPath;
111312
111406
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111313
111407
  if (!jsFileText)
111314
111408
  return jsFilePath;
111409
+ // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111410
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111411
+ return jsFilePath;
111315
111412
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111316
111413
  // error if no source map or for now if inline sourcemap
111317
111414
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111318
111415
  return sourceMapFilePath || "inline sourcemap decoding";
111416
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111417
+ return sourceMapFilePath;
111319
111418
  // read declaration text
111320
111419
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111321
111420
  if (declarationFilePath && !declarationText)
111322
111421
  return declarationFilePath;
111422
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111423
+ return declarationFilePath;
111323
111424
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111324
111425
  // error if no source map or for now if inline sourcemap
111325
111426
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111326
111427
  return declarationMapPath || "inline sourcemap decoding";
111327
- var buildInfo = getBuildInfo(buildInfoText);
111328
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111329
- return buildInfoPath;
111428
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111429
+ return declarationMapPath;
111330
111430
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111331
111431
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111332
111432
  /*onlyOwnText*/ true);
111333
111433
  var outputFiles = [];
111334
111434
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111335
111435
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111436
+ var changedDtsText;
111437
+ var changedDtsData;
111336
111438
  var emitHost = {
111337
111439
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111338
111440
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111348,7 +111450,7 @@ var ts;
111348
111450
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111349
111451
  getProjectReferenceRedirect: ts.returnUndefined,
111350
111452
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111351
- writeFile: function (name, text, writeByteOrderMark) {
111453
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111352
111454
  switch (name) {
111353
111455
  case jsFilePath:
111354
111456
  if (jsFileText === text)
@@ -111359,8 +111461,13 @@ var ts;
111359
111461
  return;
111360
111462
  break;
111361
111463
  case buildInfoPath:
111362
- var newBuildInfo = getBuildInfo(text);
111464
+ var newBuildInfo = data.buildInfo;
111363
111465
  newBuildInfo.program = buildInfo.program;
111466
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111467
+ // Update the output signature
111468
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111469
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111470
+ }
111364
111471
  // Update sourceFileInfo
111365
111472
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111366
111473
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111368,11 +111475,13 @@ var ts;
111368
111475
  newBuildInfo.bundle.dts.sources = dts.sources;
111369
111476
  }
111370
111477
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111371
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111478
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111372
111479
  return;
111373
111480
  case declarationFilePath:
111374
111481
  if (declarationText === text)
111375
111482
  return;
111483
+ changedDtsText = text;
111484
+ changedDtsData = data;
111376
111485
  break;
111377
111486
  case declarationMapPath:
111378
111487
  if (declarationMapText === text)
@@ -111391,6 +111500,7 @@ var ts;
111391
111500
  getSourceFileFromReference: ts.returnUndefined,
111392
111501
  redirectTargetsMap: ts.createMultiMap(),
111393
111502
  getFileIncludeReasons: ts.notImplemented,
111503
+ createHash: createHash,
111394
111504
  };
111395
111505
  emitFiles(ts.notImplementedResolver, emitHost,
111396
111506
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116475,12 +116585,10 @@ var ts;
116475
116585
  }
116476
116586
  ts.createCompilerHost = createCompilerHost;
116477
116587
  /*@internal*/
116478
- // TODO(shkamat): update this after reworking ts build API
116479
116588
  function createCompilerHostWorker(options, setParentNodes, system) {
116480
116589
  if (system === void 0) { system = ts.sys; }
116481
116590
  var existingDirectories = new ts.Map();
116482
116591
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116483
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116484
116592
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116485
116593
  var text;
116486
116594
  try {
@@ -116513,7 +116621,7 @@ var ts;
116513
116621
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116514
116622
  // the system.writeFile will do its own directory creation and
116515
116623
  // the ensureDirectoriesExist call will always be redundant.
116516
- 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); });
116624
+ 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); });
116517
116625
  ts.performance.mark("afterIOWrite");
116518
116626
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116519
116627
  }
@@ -116523,35 +116631,6 @@ var ts;
116523
116631
  }
116524
116632
  }
116525
116633
  }
116526
- var outputFingerprints;
116527
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116528
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116529
- system.writeFile(fileName, data, writeByteOrderMark);
116530
- return;
116531
- }
116532
- if (!outputFingerprints) {
116533
- outputFingerprints = new ts.Map();
116534
- }
116535
- var hash = computeHash(data);
116536
- var mtimeBefore = system.getModifiedTime(fileName);
116537
- if (mtimeBefore) {
116538
- var fingerprint = outputFingerprints.get(fileName);
116539
- // If output has not been changed, and the file has no external modification
116540
- if (fingerprint &&
116541
- fingerprint.byteOrderMark === writeByteOrderMark &&
116542
- fingerprint.hash === hash &&
116543
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116544
- return;
116545
- }
116546
- }
116547
- system.writeFile(fileName, data, writeByteOrderMark);
116548
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116549
- outputFingerprints.set(fileName, {
116550
- hash: hash,
116551
- byteOrderMark: writeByteOrderMark,
116552
- mtime: mtimeAfter
116553
- });
116554
- }
116555
116634
  function getDefaultLibLocation() {
116556
116635
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116557
116636
  }
@@ -118151,6 +118230,7 @@ var ts;
118151
118230
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
118152
118231
  redirectTargetsMap: redirectTargetsMap,
118153
118232
  getFileIncludeReasons: program.getFileIncludeReasons,
118233
+ createHash: ts.maybeBind(host, host.createHash),
118154
118234
  };
118155
118235
  }
118156
118236
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120264,13 +120344,9 @@ var ts;
120264
120344
  function createManyToManyPathMap() {
120265
120345
  function create(forward, reverse, deleted) {
120266
120346
  var map = {
120267
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120268
- forEach: function (fn) { return forward.forEach(fn); },
120269
120347
  getKeys: function (v) { return reverse.get(v); },
120270
120348
  getValues: function (k) { return forward.get(k); },
120271
- hasKey: function (k) { return forward.has(k); },
120272
120349
  keys: function () { return forward.keys(); },
120273
- deletedKeys: function () { return deleted; },
120274
120350
  deleteKey: function (k) {
120275
120351
  (deleted || (deleted = new ts.Set())).add(k);
120276
120352
  var set = forward.get(k);
@@ -120297,11 +120373,6 @@ var ts;
120297
120373
  });
120298
120374
  return map;
120299
120375
  },
120300
- clear: function () {
120301
- forward.clear();
120302
- reverse.clear();
120303
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120304
- }
120305
120376
  };
120306
120377
  return map;
120307
120378
  }
@@ -120429,18 +120500,21 @@ var ts;
120429
120500
  * Creates the state of file references and signature for the new program from oldState if it is safe
120430
120501
  */
120431
120502
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120503
+ var _a, _b, _c;
120432
120504
  var fileInfos = new ts.Map();
120433
120505
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120434
120506
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120435
- var hasCalledUpdateShapeSignature = new ts.Set();
120436
120507
  var useOldState = canReuseOldState(referencedMap, oldState);
120437
120508
  // Ensure source files have parent pointers set
120438
120509
  newProgram.getTypeChecker();
120439
120510
  // Create the reference map, and set the file infos
120440
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120441
- var sourceFile = _a[_i];
120511
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120512
+ var sourceFile = _d[_i];
120442
120513
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120443
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120514
+ var oldUncommittedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120515
+ var signature = oldUncommittedSignature === undefined ?
120516
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120517
+ oldUncommittedSignature || undefined;
120444
120518
  if (referencedMap) {
120445
120519
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120446
120520
  if (newReferences) {
@@ -120448,19 +120522,26 @@ var ts;
120448
120522
  }
120449
120523
  // Copy old visible to outside files map
120450
120524
  if (useOldState) {
120451
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120525
+ var oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120526
+ var exportedModules = oldUncommittedExportedModules === undefined ?
120527
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120528
+ oldUncommittedExportedModules || undefined;
120452
120529
  if (exportedModules) {
120453
120530
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120454
120531
  }
120455
120532
  }
120456
120533
  }
120457
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120534
+ fileInfos.set(sourceFile.resolvedPath, {
120535
+ version: version_2,
120536
+ signature: signature,
120537
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120538
+ impliedFormat: sourceFile.impliedNodeFormat
120539
+ });
120458
120540
  }
120459
120541
  return {
120460
120542
  fileInfos: fileInfos,
120461
120543
  referencedMap: referencedMap,
120462
120544
  exportedModulesMap: exportedModulesMap,
120463
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120464
120545
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120465
120546
  };
120466
120547
  }
@@ -120474,71 +120555,42 @@ var ts;
120474
120555
  }
120475
120556
  BuilderState.releaseCache = releaseCache;
120476
120557
  /**
120477
- * Creates a clone of the state
120558
+ * Gets the files affected by the path from the program
120478
120559
  */
120479
- function clone(state) {
120560
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120480
120561
  var _a, _b;
120481
- // Dont need to backup allFiles info since its cache anyway
120482
- return {
120483
- fileInfos: new ts.Map(state.fileInfos),
120484
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120485
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120486
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120487
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120488
- };
120562
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120563
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120564
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120565
+ return result;
120489
120566
  }
120490
- BuilderState.clone = clone;
120491
- /**
120492
- * Gets the files affected by the path from the program
120493
- */
120494
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120495
- // Since the operation could be cancelled, the signatures are always stored in the cache
120496
- // They will be committed once it is safe to use them
120497
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120498
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120499
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120567
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120568
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120500
120569
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120501
120570
  if (!sourceFile) {
120502
120571
  return ts.emptyArray;
120503
120572
  }
120504
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120573
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120505
120574
  return [sourceFile];
120506
120575
  }
120507
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120508
- if (!cacheToUpdateSignature) {
120509
- // Commit all the signatures in the signature cache
120510
- updateSignaturesFromCache(state, signatureCache);
120511
- }
120512
- return result;
120576
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120513
120577
  }
120514
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120515
- /**
120516
- * Updates the signatures from the cache into state's fileinfo signatures
120517
- * This should be called whenever it is safe to commit the state of the builder
120518
- */
120519
- function updateSignaturesFromCache(state, signatureCache) {
120520
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120521
- }
120522
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120578
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120523
120579
  function updateSignatureOfFile(state, signature, path) {
120524
120580
  state.fileInfos.get(path).signature = signature;
120525
- state.hasCalledUpdateShapeSignature.add(path);
120581
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120526
120582
  }
120527
120583
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120528
120584
  /**
120529
120585
  * Returns if the shape of the signature has changed since last emit
120530
120586
  */
120531
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120587
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120588
+ var _a;
120532
120589
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120533
- ts.Debug.assert(!!sourceFile);
120534
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120535
120590
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120536
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120591
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
120537
120592
  return false;
120538
- }
120539
120593
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120540
- if (!info)
120541
- return ts.Debug.fail();
120542
120594
  var prevSignature = info.signature;
120543
120595
  var latestSignature;
120544
120596
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120549,45 +120601,55 @@ var ts;
120549
120601
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120550
120602
  if (firstDts_1) {
120551
120603
  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; })); });
120552
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120553
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120554
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120604
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120605
+ if (latestSignature !== prevSignature) {
120606
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120555
120607
  }
120556
120608
  }
120557
120609
  }
120558
120610
  // Default is to use file version as signature
120559
120611
  if (latestSignature === undefined) {
120560
120612
  latestSignature = sourceFile.version;
120561
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120613
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
120614
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120562
120615
  // All the references in this file are exported
120563
120616
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120564
120617
  if (references) {
120565
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120618
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120566
120619
  }
120567
120620
  else {
120568
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120621
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120569
120622
  }
120570
120623
  }
120571
120624
  }
120572
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120625
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120626
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120627
+ info.signature = latestSignature;
120573
120628
  return latestSignature !== prevSignature;
120574
120629
  }
120575
120630
  BuilderState.updateShapeSignature = updateShapeSignature;
120631
+ function computeSignature(text, computeHash) {
120632
+ return (computeHash || ts.generateDjb2Hash)(text);
120633
+ }
120634
+ BuilderState.computeSignature = computeSignature;
120576
120635
  /**
120577
120636
  * Coverts the declaration emit result into exported modules map
120578
120637
  */
120579
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120638
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120639
+ if (!state.exportedModulesMap)
120640
+ return;
120641
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120580
120642
  if (!exportedModulesFromDeclarationEmit) {
120581
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120643
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120582
120644
  return;
120583
120645
  }
120584
120646
  var exportedModules;
120585
120647
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120586
120648
  if (exportedModules) {
120587
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120649
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120588
120650
  }
120589
120651
  else {
120590
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120652
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120591
120653
  }
120592
120654
  function addExportedModule(exportedModulePaths) {
120593
120655
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120599,19 +120661,6 @@ var ts;
120599
120661
  }
120600
120662
  }
120601
120663
  BuilderState.updateExportedModules = updateExportedModules;
120602
- /**
120603
- * Updates the exported modules from cache into state's exported modules map
120604
- * This should be called whenever it is safe to commit the state of the builder
120605
- */
120606
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120607
- var _a;
120608
- if (exportedModulesMapCache) {
120609
- ts.Debug.assert(!!state.exportedModulesMap);
120610
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120611
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120612
- }
120613
- }
120614
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120615
120664
  /**
120616
120665
  * Get all the dependencies of the sourceFile
120617
120666
  */
@@ -120732,7 +120781,7 @@ var ts;
120732
120781
  /**
120733
120782
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120734
120783
  */
120735
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120784
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120736
120785
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120737
120786
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120738
120787
  }
@@ -120752,7 +120801,7 @@ var ts;
120752
120801
  if (!seenFileNamesMap.has(currentPath)) {
120753
120802
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120754
120803
  seenFileNamesMap.set(currentPath, currentSourceFile);
120755
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120804
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120756
120805
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120757
120806
  }
120758
120807
  }
@@ -120778,32 +120827,33 @@ var ts;
120778
120827
  * Create the state so that we can iterate on changedFiles/affected files
120779
120828
  */
120780
120829
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120830
+ var _a, _b;
120781
120831
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120782
120832
  state.program = newProgram;
120783
120833
  var compilerOptions = newProgram.getCompilerOptions();
120784
120834
  state.compilerOptions = compilerOptions;
120835
+ var outFilePath = ts.outFile(compilerOptions);
120785
120836
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120786
- if (!ts.outFile(compilerOptions)) {
120837
+ if (!outFilePath) {
120787
120838
  state.semanticDiagnosticsPerFile = new ts.Map();
120788
120839
  }
120840
+ 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)) {
120841
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120842
+ }
120789
120843
  state.changedFilesSet = new ts.Set();
120844
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120790
120845
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120791
120846
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120792
120847
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120793
120848
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120849
+ var canCopyEmitSignatures = compilerOptions.composite &&
120850
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120851
+ !outFilePath &&
120852
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120794
120853
  if (useOldState) {
120795
- // Verify the sanity of old state
120796
- if (!oldState.currentChangedFilePath) {
120797
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120798
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120799
- }
120800
- var changedFilesSet = oldState.changedFilesSet;
120801
- if (canCopySemanticDiagnostics) {
120802
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120803
- }
120804
120854
  // Copy old state's changed files set
120805
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120806
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120855
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120856
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
120807
120857
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120808
120858
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120809
120859
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120824,6 +120874,8 @@ var ts;
120824
120874
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120825
120875
  // versions dont match
120826
120876
  oldInfo.version !== info.version ||
120877
+ // Implied formats dont match
120878
+ oldInfo.impliedFormat !== info.impliedFormat ||
120827
120879
  // Referenced files changed
120828
120880
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120829
120881
  // Referenced file was deleted in the new program
@@ -120847,27 +120899,25 @@ var ts;
120847
120899
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120848
120900
  }
120849
120901
  }
120902
+ if (canCopyEmitSignatures) {
120903
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120904
+ if (oldEmitSignature)
120905
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120906
+ }
120850
120907
  });
120851
120908
  // If the global file is removed, add all files as changed
120852
120909
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120853
120910
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120854
120911
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120855
120912
  }
120856
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120913
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120857
120914
  // Add all files to affectedFilesPendingEmit since emit changed
120858
120915
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120859
120916
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120860
120917
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120861
120918
  }
120862
- if (useOldState) {
120863
- // Any time the interpretation of a source file changes, mark it as changed
120864
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120865
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120866
- state.changedFilesSet.add(sourceFilePath);
120867
- }
120868
- });
120869
- }
120870
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120919
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120920
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120871
120921
  return state;
120872
120922
  }
120873
120923
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120903,30 +120953,35 @@ var ts;
120903
120953
  ts.BuilderState.releaseCache(state);
120904
120954
  state.program = undefined;
120905
120955
  }
120906
- /**
120907
- * Creates a clone of the state
120908
- */
120909
- function cloneBuilderProgramState(state) {
120910
- var _a;
120911
- var newState = ts.BuilderState.clone(state);
120912
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120913
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120914
- newState.affectedFiles = state.affectedFiles;
120915
- newState.affectedFilesIndex = state.affectedFilesIndex;
120916
- newState.currentChangedFilePath = state.currentChangedFilePath;
120917
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120918
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120919
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120920
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120921
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120922
- newState.program = state.program;
120923
- newState.compilerOptions = state.compilerOptions;
120924
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120925
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120926
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120927
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120928
- newState.programEmitComplete = state.programEmitComplete;
120929
- return newState;
120956
+ function backupBuilderProgramEmitState(state) {
120957
+ var outFilePath = ts.outFile(state.compilerOptions);
120958
+ // Only in --out changeFileSet is kept around till emit
120959
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120960
+ return {
120961
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120962
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120963
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120964
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120965
+ programEmitComplete: state.programEmitComplete,
120966
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120967
+ outSignature: state.outSignature,
120968
+ dtsChangeTime: state.dtsChangeTime,
120969
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120970
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120971
+ };
120972
+ }
120973
+ function restoreBuilderProgramEmitState(state, savedEmitState) {
120974
+ state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
120975
+ state.affectedFilesPendingEmitKind = savedEmitState.affectedFilesPendingEmitKind;
120976
+ state.affectedFilesPendingEmitIndex = savedEmitState.affectedFilesPendingEmitIndex;
120977
+ state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
120978
+ state.programEmitComplete = savedEmitState.programEmitComplete;
120979
+ state.emitSignatures = savedEmitState.emitSignatures;
120980
+ state.outSignature = savedEmitState.outSignature;
120981
+ state.dtsChangeTime = savedEmitState.dtsChangeTime;
120982
+ state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
120983
+ if (savedEmitState.changedFilesSet)
120984
+ state.changedFilesSet = savedEmitState.changedFilesSet;
120930
120985
  }
120931
120986
  /**
120932
120987
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120941,7 +120996,7 @@ var ts;
120941
120996
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120942
120997
  */
120943
120998
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120944
- var _a;
120999
+ var _a, _b;
120945
121000
  while (true) {
120946
121001
  var affectedFiles = state.affectedFiles;
120947
121002
  if (affectedFiles) {
@@ -120961,10 +121016,8 @@ var ts;
120961
121016
  state.changedFilesSet.delete(state.currentChangedFilePath);
120962
121017
  state.currentChangedFilePath = undefined;
120963
121018
  // Commit the changes in file signature
120964
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120965
- state.currentAffectedFilesSignatures.clear();
120966
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120967
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
121019
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
121020
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120968
121021
  state.affectedFiles = undefined;
120969
121022
  }
120970
121023
  // Get next changed file
@@ -120982,12 +121035,7 @@ var ts;
120982
121035
  return program;
120983
121036
  }
120984
121037
  // Get next batch of affected files
120985
- if (!state.currentAffectedFilesSignatures)
120986
- state.currentAffectedFilesSignatures = new ts.Map();
120987
- if (state.exportedModulesMap) {
120988
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120989
- }
120990
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
121038
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120991
121039
  state.currentChangedFilePath = nextKey.value;
120992
121040
  state.affectedFilesIndex = 0;
120993
121041
  if (!state.seenAffectedFiles)
@@ -121039,7 +121087,6 @@ var ts;
121039
121087
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121040
121088
  */
121041
121089
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121042
- var _a;
121043
121090
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121044
121091
  // If affected files is everything except default library, then nothing more to do
121045
121092
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121047,10 +121094,9 @@ var ts;
121047
121094
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121048
121095
  // That means when affected file is handled, its signature can be out of date
121049
121096
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121050
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
121097
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
121051
121098
  return;
121052
121099
  }
121053
- 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);
121054
121100
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121055
121101
  return;
121056
121102
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -121070,7 +121116,7 @@ var ts;
121070
121116
  // This ensures that we dont later during incremental builds considering wrong signature.
121071
121117
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121072
121118
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121073
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
121119
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
121074
121120
  // If not dts emit, nothing more to do
121075
121121
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121076
121122
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121091,27 +121137,10 @@ var ts;
121091
121137
  return !state.semanticDiagnosticsFromOldState.size;
121092
121138
  }
121093
121139
  function isChangedSignature(state, path) {
121094
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
121095
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121140
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
121141
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121096
121142
  return newSignature !== oldSignature;
121097
121143
  }
121098
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
121099
- // Go through exported modules from cache first
121100
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
121101
- var result = keys && ts.forEachKey(keys, fn);
121102
- if (result)
121103
- return result;
121104
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
121105
- keys = state.exportedModulesMap.getKeys(filePath);
121106
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
121107
- var _a;
121108
- // If the cache had an updated value, skip
121109
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
121110
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
121111
- fn(exportedFromPath) :
121112
- undefined;
121113
- });
121114
- }
121115
121144
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121116
121145
  var _a;
121117
121146
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -121126,6 +121155,7 @@ var ts;
121126
121155
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121127
121156
  */
121128
121157
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121158
+ var _a;
121129
121159
  // If there was change in signature (dts output) for the changed file,
121130
121160
  // then only we need to handle pending file emit
121131
121161
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -121152,11 +121182,10 @@ var ts;
121152
121182
  }
121153
121183
  }
121154
121184
  }
121155
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
121156
121185
  var seenFileAndExportsOfFile = new ts.Set();
121157
121186
  // Go through exported modules from cache first
121158
121187
  // If exported modules has path, all files referencing file exported from are affected
121159
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
121188
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121160
121189
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121161
121190
  return true;
121162
121191
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -121170,19 +121199,18 @@ var ts;
121170
121199
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121171
121200
  */
121172
121201
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121173
- var _a;
121202
+ var _a, _b;
121174
121203
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121175
121204
  return undefined;
121176
121205
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121177
121206
  return true;
121178
121207
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121179
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
121180
121208
  // If exported modules has path, all files referencing file exported from are affected
121181
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121209
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121182
121210
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121183
121211
  });
121184
121212
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121185
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
121213
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121186
121214
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121187
121215
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121188
121216
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -121203,12 +121231,13 @@ var ts;
121203
121231
  }
121204
121232
  else {
121205
121233
  state.seenAffectedFiles.add(affected.resolvedPath);
121234
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121235
+ state.buildInfoEmitPending = true;
121206
121236
  if (emitKind !== undefined) {
121207
121237
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
121208
121238
  }
121209
121239
  if (isPendingEmit) {
121210
121240
  state.affectedFilesPendingEmitIndex++;
121211
- state.buildInfoEmitPending = true;
121212
121241
  }
121213
121242
  else {
121214
121243
  state.affectedFilesIndex++;
@@ -121256,25 +121285,62 @@ var ts;
121256
121285
  }
121257
121286
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121258
121287
  }
121288
+ function isProgramBundleEmitBuildInfo(info) {
121289
+ return !!ts.outFile(info.options || {});
121290
+ }
121291
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121259
121292
  /**
121260
121293
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121261
121294
  */
121262
- function getProgramBuildInfo(state, getCanonicalFileName) {
121263
- if (ts.outFile(state.compilerOptions))
121264
- return undefined;
121295
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121296
+ var outFilePath = ts.outFile(state.compilerOptions);
121297
+ if (outFilePath && !state.compilerOptions.composite)
121298
+ return;
121265
121299
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121266
121300
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121301
+ // Update the dtsChange time in buildInfo
121302
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121303
+ if (outFilePath) {
121304
+ var fileNames_1 = [];
121305
+ var fileInfos_1 = [];
121306
+ state.program.getRootFileNames().forEach(function (f) {
121307
+ var sourceFile = state.program.getSourceFile(f);
121308
+ if (!sourceFile)
121309
+ return;
121310
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121311
+ fileInfos_1.push(sourceFile.version);
121312
+ });
121313
+ var result_15 = {
121314
+ fileNames: fileNames_1,
121315
+ fileInfos: fileInfos_1,
121316
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121317
+ outSignature: state.outSignature,
121318
+ dtsChangeTime: state.dtsChangeTime,
121319
+ };
121320
+ return result_15;
121321
+ }
121267
121322
  var fileNames = [];
121268
121323
  var fileNameToFileId = new ts.Map();
121269
121324
  var fileIdsList;
121270
121325
  var fileNamesToFileIdListId;
121326
+ var emitSignatures;
121271
121327
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121328
+ var _b, _c;
121272
121329
  var key = _a[0], value = _a[1];
121273
121330
  // Ensure fileId
121274
121331
  var fileId = toFileId(key);
121275
121332
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121276
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121277
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
121333
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
121334
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
121335
+ if (state.compilerOptions.composite) {
121336
+ var file = state.program.getSourceFileByPath(key);
121337
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
121338
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
121339
+ if (emitSignature !== actualSignature) {
121340
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
121341
+ }
121342
+ }
121343
+ }
121278
121344
  return value.version === actualSignature ?
121279
121345
  value.affectsGlobalScope || value.impliedFormat ?
121280
121346
  // If file version is same as signature, dont serialize signature
@@ -121282,11 +121348,11 @@ var ts;
121282
121348
  // If file info only contains version and signature and both are same we can just write string
121283
121349
  value.version :
121284
121350
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121285
- signature === undefined ?
121351
+ oldSignature === undefined ?
121286
121352
  // If we havent computed signature, use fileInfo as is
121287
121353
  value :
121288
121354
  // Serialize fileInfo with new updated signature
121289
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121355
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121290
121356
  // Signature of the FileInfo is undefined, serialize it as false
121291
121357
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121292
121358
  });
@@ -121301,17 +121367,13 @@ var ts;
121301
121367
  if (state.exportedModulesMap) {
121302
121368
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121303
121369
  var _a;
121304
- if (state.currentAffectedFilesExportedModulesMap) {
121305
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121306
- return undefined;
121307
- }
121308
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121309
- if (newValue) {
121310
- return [toFileId(key), toFileIdListId(newValue)];
121311
- }
121312
- }
121370
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121313
121371
  // Not in temporary cache, use existing value
121314
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121372
+ if (oldValue === undefined)
121373
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121374
+ if (oldValue)
121375
+ return [toFileId(key), toFileIdListId(oldValue)];
121376
+ return undefined;
121315
121377
  });
121316
121378
  }
121317
121379
  var semanticDiagnosticsPerFile;
@@ -121322,9 +121384,7 @@ var ts;
121322
121384
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121323
121385
  [
121324
121386
  toFileId(key),
121325
- state.hasReusableDiagnostic ?
121326
- value :
121327
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121387
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121328
121388
  ] :
121329
121389
  toFileId(key));
121330
121390
  }
@@ -121339,16 +121399,27 @@ var ts;
121339
121399
  }
121340
121400
  }
121341
121401
  }
121342
- return {
121402
+ var changeFileSet;
121403
+ if (state.changedFilesSet.size) {
121404
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
121405
+ var path = _e[_d];
121406
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
121407
+ }
121408
+ }
121409
+ var result = {
121343
121410
  fileNames: fileNames,
121344
121411
  fileInfos: fileInfos,
121345
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121412
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121346
121413
  fileIdsList: fileIdsList,
121347
121414
  referencedMap: referencedMap,
121348
121415
  exportedModulesMap: exportedModulesMap,
121349
121416
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121350
121417
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121418
+ changeFileSet: changeFileSet,
121419
+ emitSignatures: emitSignatures,
121420
+ dtsChangeTime: state.dtsChangeTime,
121351
121421
  };
121422
+ return result;
121352
121423
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121353
121424
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121354
121425
  }
@@ -121373,24 +121444,21 @@ var ts;
121373
121444
  }
121374
121445
  return fileIdListId;
121375
121446
  }
121376
- }
121377
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121378
- var result;
121379
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121380
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121381
- var name = _a[_i];
121382
- var optionKey = name.toLowerCase();
121383
- var optionInfo = optionsNameMap.get(optionKey);
121384
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121385
- // We need to store `strict`, even though it won't be examined directly, so that the
121386
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121387
- optionKey === "strict" ||
121388
- // We need to store these to determine whether `lib` files need to be rechecked.
121389
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121390
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
121447
+ /**
121448
+ * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
121449
+ */
121450
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
121451
+ var result;
121452
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121453
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121454
+ var name = _a[_i];
121455
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
121456
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
121457
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
121458
+ }
121391
121459
  }
121460
+ return result;
121392
121461
  }
121393
- return result;
121394
121462
  }
121395
121463
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121396
121464
  if (option) {
@@ -121464,6 +121532,10 @@ var ts;
121464
121532
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121465
121533
  }
121466
121534
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121535
+ function computeSignature(text, data, computeHash) {
121536
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121537
+ }
121538
+ ts.computeSignature = computeSignature;
121467
121539
  function createBuilderProgram(kind, _a) {
121468
121540
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121469
121541
  // Return same program if underlying program doesnt change
@@ -121482,8 +121554,7 @@ var ts;
121482
121554
  */
121483
121555
  var computeHash = ts.maybeBind(host, host.createHash);
121484
121556
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121485
- var backupState;
121486
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121557
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121487
121558
  // To ensure that we arent storing any references to old program or new program without state
121488
121559
  newProgram = undefined; // TODO: GH#18217
121489
121560
  oldProgram = undefined;
@@ -121491,21 +121562,12 @@ var ts;
121491
121562
  var getState = function () { return state; };
121492
121563
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121493
121564
  builderProgram.getState = getState;
121494
- builderProgram.backupState = function () {
121495
- ts.Debug.assert(backupState === undefined);
121496
- backupState = cloneBuilderProgramState(state);
121497
- };
121498
- builderProgram.restoreState = function () {
121499
- state = ts.Debug.checkDefined(backupState);
121500
- backupState = undefined;
121501
- };
121565
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121566
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121502
121567
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121503
121568
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121504
121569
  builderProgram.emit = emit;
121505
- builderProgram.releaseProgram = function () {
121506
- releaseCache(state);
121507
- backupState = undefined;
121508
- };
121570
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121509
121571
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121510
121572
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121511
121573
  }
@@ -121563,35 +121625,62 @@ var ts;
121563
121625
  return toAffectedFileEmitResult(state,
121564
121626
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121565
121627
  // Otherwise just affected file
121566
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121567
- getWriteFileUpdatingSignatureCallback(writeFile) :
121628
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121629
+ getWriteFileCallback(writeFile, customTransformers) :
121568
121630
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121569
121631
  }
121570
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121632
+ function getWriteFileCallback(writeFile, customTransformers) {
121571
121633
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121572
- var _a;
121634
+ var _a, _b, _c;
121573
121635
  if (ts.isDeclarationFileName(fileName)) {
121574
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121575
- var file = sourceFiles[0];
121576
- var info = state.fileInfos.get(file.resolvedPath);
121577
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121578
- if (signature === file.version) {
121579
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121580
- if (newSignature !== file.version) { // Update it
121581
- if (host.storeFilesChangingSignatureDuringEmit)
121582
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121583
- if (state.exportedModulesMap)
121584
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121585
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121586
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121636
+ if (!ts.outFile(state.compilerOptions)) {
121637
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121638
+ var newSignature = void 0;
121639
+ if (!customTransformers) {
121640
+ var file = sourceFiles[0];
121641
+ var info = state.fileInfos.get(file.resolvedPath);
121642
+ if (info.signature === file.version) {
121643
+ newSignature = computeSignature(text, data, computeHash);
121644
+ if (newSignature !== file.version) { // Update it
121645
+ if (host.storeFilesChangingSignatureDuringEmit)
121646
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121647
+ if (state.exportedModulesMap)
121648
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121649
+ if (state.affectedFiles) {
121650
+ // Keep old signature so we know what to undo if cancellation happens
121651
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121652
+ if (existing === undefined)
121653
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121654
+ info.signature = newSignature;
121655
+ }
121656
+ else {
121657
+ // These are directly commited
121658
+ info.signature = newSignature;
121659
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121660
+ }
121661
+ }
121587
121662
  }
121588
- else {
121589
- info.signature = newSignature;
121590
- if (state.exportedModulesMap)
121591
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121663
+ }
121664
+ // Store d.ts emit hash so later can be compared to check if d.ts has changed.
121665
+ // Currently we do this only for composite projects since these are the only projects that can be referenced by other projects
121666
+ // and would need their d.ts change time in --build mode
121667
+ if (state.compilerOptions.composite) {
121668
+ var filePath = sourceFiles[0].resolvedPath;
121669
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121670
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
121671
+ if (newSignature !== oldSignature) {
121672
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121673
+ state.hasChangedEmitSignature = true;
121592
121674
  }
121593
121675
  }
121594
121676
  }
121677
+ else if (state.compilerOptions.composite) {
121678
+ var newSignature = computeSignature(text, data, computeHash);
121679
+ if (newSignature !== state.outSignature) {
121680
+ state.outSignature = newSignature;
121681
+ state.hasChangedEmitSignature = true;
121682
+ }
121683
+ }
121595
121684
  }
121596
121685
  if (writeFile)
121597
121686
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121656,8 +121745,8 @@ var ts;
121656
121745
  }
121657
121746
  }
121658
121747
  }
121659
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121660
- getWriteFileUpdatingSignatureCallback(writeFile) :
121748
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121749
+ getWriteFileCallback(writeFile, customTransformers) :
121661
121750
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121662
121751
  }
121663
121752
  /**
@@ -121746,29 +121835,58 @@ var ts;
121746
121835
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121747
121836
  }
121748
121837
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121749
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121750
- var _a;
121838
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121839
+ var _a, _b, _c, _d;
121751
121840
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121752
121841
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121753
- var filePaths = program.fileNames.map(toPath);
121754
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121755
- var fileInfos = new ts.Map();
121756
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121757
- var state = {
121758
- fileInfos: fileInfos,
121759
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121760
- referencedMap: toManyToManyPathMap(program.referencedMap),
121761
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121762
- 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]; }),
121763
- hasReusableDiagnostic: true,
121764
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121765
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121766
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121767
- };
121842
+ var state;
121843
+ var filePaths;
121844
+ var filePathsSetList;
121845
+ if (isProgramBundleEmitBuildInfo(program)) {
121846
+ state = {
121847
+ fileInfos: new ts.Map(),
121848
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121849
+ dtsChangeTime: program.dtsChangeTime,
121850
+ outSignature: program.outSignature,
121851
+ };
121852
+ }
121853
+ else {
121854
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121855
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121856
+ var fileInfos_2 = new ts.Map();
121857
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121858
+ program.fileInfos.forEach(function (fileInfo, index) {
121859
+ var path = toFilePath(index + 1);
121860
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121861
+ fileInfos_2.set(path, stateFileInfo);
121862
+ if (emitSignatures_1 && stateFileInfo.signature)
121863
+ emitSignatures_1.set(path, stateFileInfo.signature);
121864
+ });
121865
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121866
+ if (ts.isNumber(value))
121867
+ emitSignatures_1.delete(toFilePath(value));
121868
+ else
121869
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121870
+ });
121871
+ state = {
121872
+ fileInfos: fileInfos_2,
121873
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121874
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121875
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121876
+ 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]; }),
121877
+ hasReusableDiagnostic: true,
121878
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121879
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121880
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121881
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121882
+ dtsChangeTime: program.dtsChangeTime,
121883
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121884
+ };
121885
+ }
121768
121886
  return {
121769
121887
  getState: function () { return state; },
121770
- backupState: ts.noop,
121771
- restoreState: ts.noop,
121888
+ saveEmitState: ts.noop,
121889
+ restoreEmitState: ts.noop,
121772
121890
  getProgram: ts.notImplemented,
121773
121891
  getProgramOrUndefined: ts.returnUndefined,
121774
121892
  releaseProgram: ts.noop,
@@ -121813,12 +121931,24 @@ var ts;
121813
121931
  return map;
121814
121932
  }
121815
121933
  }
121816
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121934
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121935
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121936
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121937
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121938
+ var fileInfos = new ts.Map();
121939
+ program.fileInfos.forEach(function (fileInfo, index) {
121940
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121941
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121942
+ fileInfos.set(path, version);
121943
+ });
121944
+ return fileInfos;
121945
+ }
121946
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121817
121947
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121818
121948
  return {
121819
121949
  getState: ts.notImplemented,
121820
- backupState: ts.noop,
121821
- restoreState: ts.noop,
121950
+ saveEmitState: ts.noop,
121951
+ restoreEmitState: ts.noop,
121822
121952
  getProgram: getProgram,
121823
121953
  getProgramOrUndefined: function () { return getState().program; },
121824
121954
  releaseProgram: function () { return getState().program = undefined; },
@@ -121922,8 +122052,10 @@ var ts;
121922
122052
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121923
122053
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121924
122054
  var resolutionsWithFailedLookups = [];
122055
+ var resolutionsWithOnlyAffectingLocations = [];
121925
122056
  var resolvedFileToResolution = ts.createMultiMap();
121926
122057
  var hasChangedAutomaticTypeDirectiveNames = false;
122058
+ var affectingPathChecks;
121927
122059
  var failedLookupChecks;
121928
122060
  var startsWithPathChecks;
121929
122061
  var isInDirectoryChecks;
@@ -121950,6 +122082,7 @@ var ts;
121950
122082
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121951
122083
  var customFailedLookupPaths = new ts.Map();
121952
122084
  var directoryWatchesOfFailedLookups = new ts.Map();
122085
+ var fileWatchesOfAffectingLocations = new ts.Map();
121953
122086
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121954
122087
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121955
122088
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121992,6 +122125,7 @@ var ts;
121992
122125
  }
121993
122126
  function clear() {
121994
122127
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
122128
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121995
122129
  customFailedLookupPaths.clear();
121996
122130
  nonRelativeExternalModuleResolutions.clear();
121997
122131
  closeTypeRootsWatch();
@@ -121999,9 +122133,11 @@ var ts;
121999
122133
  resolvedTypeReferenceDirectives.clear();
122000
122134
  resolvedFileToResolution.clear();
122001
122135
  resolutionsWithFailedLookups.length = 0;
122136
+ resolutionsWithOnlyAffectingLocations.length = 0;
122002
122137
  failedLookupChecks = undefined;
122003
122138
  startsWithPathChecks = undefined;
122004
122139
  isInDirectoryChecks = undefined;
122140
+ affectingPathChecks = undefined;
122005
122141
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122006
122142
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122007
122143
  clearPerDirectoryResolutions();
@@ -122051,10 +122187,18 @@ var ts;
122051
122187
  watcher.watcher.close();
122052
122188
  }
122053
122189
  });
122190
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
122191
+ if (watcher.refCount === 0) {
122192
+ fileWatchesOfAffectingLocations.delete(path);
122193
+ watcher.watcher.close();
122194
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122195
+ watcher.watcher = ts.noopFileWatcher;
122196
+ }
122197
+ });
122054
122198
  hasChangedAutomaticTypeDirectiveNames = false;
122055
122199
  }
122056
122200
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
122057
- var _a;
122201
+ var _a, _b;
122058
122202
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
122059
122203
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
122060
122204
  if (!resolutionHost.getGlobalCache) {
@@ -122065,11 +122209,12 @@ var ts;
122065
122209
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
122066
122210
  // create different collection of failed lookup locations for second pass
122067
122211
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
122068
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
122212
+ 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;
122069
122213
  if (resolvedModule) {
122070
122214
  // Modify existing resolution so its saved in the directory cache as well
122071
122215
  primaryResult.resolvedModule = resolvedModule;
122072
122216
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122217
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
122073
122218
  return primaryResult;
122074
122219
  }
122075
122220
  }
@@ -122320,10 +122465,11 @@ var ts;
122320
122465
  }
122321
122466
  function watchFailedLookupLocationOfResolution(resolution) {
122322
122467
  ts.Debug.assert(!!resolution.refCount);
122323
- var failedLookupLocations = resolution.failedLookupLocations;
122324
- if (!failedLookupLocations.length)
122468
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122469
+ if (!failedLookupLocations.length && !affectingLocations.length)
122325
122470
  return;
122326
- resolutionsWithFailedLookups.push(resolution);
122471
+ if (failedLookupLocations.length)
122472
+ resolutionsWithFailedLookups.push(resolution);
122327
122473
  var setAtRoot = false;
122328
122474
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122329
122475
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122350,12 +122496,66 @@ var ts;
122350
122496
  // This is always non recursive
122351
122497
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122352
122498
  }
122499
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
122500
+ }
122501
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
122502
+ ts.Debug.assert(!!resolution.refCount);
122503
+ if (addToResolutionsWithOnlyAffectingLocations)
122504
+ resolutionsWithOnlyAffectingLocations.push(resolution);
122505
+ var affectingLocations = resolution.affectingLocations;
122506
+ // Watch package json
122507
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122508
+ var affectingLocation = affectingLocations_1[_i];
122509
+ createFileWatcherOfAffectingLocation(affectingLocation);
122510
+ }
122511
+ }
122512
+ function createFileWatcherOfAffectingLocation(affectingLocation) {
122513
+ var path = resolutionHost.toPath(affectingLocation);
122514
+ var fileWatcher = fileWatchesOfAffectingLocations.get(path);
122515
+ if (fileWatcher) {
122516
+ fileWatcher.refCount++;
122517
+ return;
122518
+ }
122519
+ var locationToWatch = affectingLocation;
122520
+ var locationToWatchPath = path;
122521
+ if (resolutionHost.realpath) {
122522
+ locationToWatch = resolutionHost.realpath(affectingLocation);
122523
+ locationToWatchPath = resolutionHost.toPath(locationToWatch);
122524
+ if (path !== locationToWatchPath) {
122525
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
122526
+ if (fileWatcher_1) {
122527
+ fileWatcher_1.refCount++;
122528
+ fileWatcher_1.paths.add(path);
122529
+ fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
122530
+ return;
122531
+ }
122532
+ }
122533
+ }
122534
+ var paths = new ts.Set();
122535
+ paths.add(locationToWatchPath);
122536
+ var watcher = {
122537
+ watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
122538
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
122539
+ paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
122540
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122541
+ }),
122542
+ refCount: 1,
122543
+ paths: paths,
122544
+ };
122545
+ fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
122546
+ if (path !== locationToWatchPath) {
122547
+ fileWatchesOfAffectingLocations.set(path, watcher);
122548
+ paths.add(path);
122549
+ }
122353
122550
  }
122354
122551
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122355
122552
  var program = resolutionHost.getCurrentProgram();
122356
122553
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122357
122554
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122358
122555
  }
122556
+ else {
122557
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122558
+ }
122359
122559
  }
122360
122560
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122361
122561
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122377,38 +122577,44 @@ var ts;
122377
122577
  if (resolved && resolved.resolvedFileName) {
122378
122578
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122379
122579
  }
122380
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122381
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122382
- return;
122383
- }
122384
- var failedLookupLocations = resolution.failedLookupLocations;
122385
- var removeAtRoot = false;
122386
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122387
- var failedLookupLocation = failedLookupLocations_2[_i];
122388
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122389
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122390
- if (toWatch) {
122391
- var dirPath = toWatch.dirPath;
122392
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122393
- if (refCount) {
122394
- if (refCount === 1) {
122395
- customFailedLookupPaths.delete(failedLookupLocationPath);
122580
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122581
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122582
+ var removeAtRoot = false;
122583
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122584
+ var failedLookupLocation = failedLookupLocations_2[_i];
122585
+ var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122586
+ var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122587
+ if (toWatch) {
122588
+ var dirPath = toWatch.dirPath;
122589
+ var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122590
+ if (refCount) {
122591
+ if (refCount === 1) {
122592
+ customFailedLookupPaths.delete(failedLookupLocationPath);
122593
+ }
122594
+ else {
122595
+ ts.Debug.assert(refCount > 1);
122596
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122597
+ }
122598
+ }
122599
+ if (dirPath === rootPath) {
122600
+ removeAtRoot = true;
122396
122601
  }
122397
122602
  else {
122398
- ts.Debug.assert(refCount > 1);
122399
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122603
+ removeDirectoryWatcher(dirPath);
122400
122604
  }
122401
122605
  }
122402
- if (dirPath === rootPath) {
122403
- removeAtRoot = true;
122404
- }
122405
- else {
122406
- removeDirectoryWatcher(dirPath);
122407
- }
122606
+ }
122607
+ if (removeAtRoot) {
122608
+ removeDirectoryWatcher(rootPath);
122408
122609
  }
122409
122610
  }
122410
- if (removeAtRoot) {
122411
- removeDirectoryWatcher(rootPath);
122611
+ else if (affectingLocations.length) {
122612
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
122613
+ }
122614
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
122615
+ var affectingLocation = affectingLocations_2[_a];
122616
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
122617
+ watcher.refCount--;
122412
122618
  }
122413
122619
  }
122414
122620
  function removeDirectoryWatcher(dirPath) {
@@ -122487,7 +122693,7 @@ var ts;
122487
122693
  if (isCreatingWatchedDirectory) {
122488
122694
  // Watching directory is created
122489
122695
  // Invalidate any resolution has failed lookup in this directory
122490
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122696
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122491
122697
  }
122492
122698
  else {
122493
122699
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122505,7 +122711,7 @@ var ts;
122505
122711
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122506
122712
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122507
122713
  // Invalidate any resolution from this directory
122508
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122714
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122509
122715
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122510
122716
  }
122511
122717
  else {
@@ -122517,7 +122723,7 @@ var ts;
122517
122723
  return false;
122518
122724
  }
122519
122725
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122520
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122726
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122521
122727
  // If the invalidated file is from a node_modules package, invalidate everything else
122522
122728
  // in the package since we might not get notifications for other files in the package.
122523
122729
  // This hardens our logic against unreliable file watchers.
@@ -122529,21 +122735,32 @@ var ts;
122529
122735
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122530
122736
  }
122531
122737
  function invalidateResolutionsOfFailedLookupLocations() {
122532
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122738
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122533
122739
  return false;
122534
122740
  }
122535
122741
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122536
122742
  failedLookupChecks = undefined;
122537
122743
  startsWithPathChecks = undefined;
122538
122744
  isInDirectoryChecks = undefined;
122745
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122746
+ affectingPathChecks = undefined;
122539
122747
  return invalidated;
122540
122748
  }
122541
122749
  function canInvalidateFailedLookupResolution(resolution) {
122750
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122751
+ return true;
122752
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122753
+ return false;
122542
122754
  return resolution.failedLookupLocations.some(function (location) {
122543
122755
  var locationPath = resolutionHost.toPath(location);
122544
- return ts.contains(failedLookupChecks, locationPath) ||
122756
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122545
122757
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122546
- (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }));
122758
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
122759
+ });
122760
+ }
122761
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
122762
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
122763
+ return affectingPathChecks.has(resolutionHost.toPath(location));
122547
122764
  });
122548
122765
  }
122549
122766
  function closeTypeRootsWatch() {
@@ -122934,9 +123151,9 @@ var ts;
122934
123151
  if (!preferSymlinks) {
122935
123152
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122936
123153
  // so we only need to remove them from the realpath filenames.
122937
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122938
- if (result_15)
122939
- return result_15;
123154
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
123155
+ if (result_16)
123156
+ return result_16;
122940
123157
  }
122941
123158
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122942
123159
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122956,10 +123173,10 @@ var ts;
122956
123173
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122957
123174
  var symlinkDirectory = symlinkDirectories_1[_i];
122958
123175
  var option = ts.resolvePath(symlinkDirectory, relative);
122959
- var result_16 = cb(option, target === referenceRedirect);
123176
+ var result_17 = cb(option, target === referenceRedirect);
122960
123177
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122961
- if (result_16)
122962
- return result_16;
123178
+ if (result_17)
123179
+ return result_17;
122963
123180
  }
122964
123181
  });
122965
123182
  });
@@ -123869,6 +124086,7 @@ var ts;
123869
124086
  readDirectory: ts.maybeBind(host, host.readDirectory),
123870
124087
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123871
124088
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
124089
+ now: ts.maybeBind(host, host.now),
123872
124090
  };
123873
124091
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123874
124092
  try {
@@ -123929,6 +124147,7 @@ var ts;
123929
124147
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123930
124148
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123931
124149
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
124150
+ now: ts.maybeBind(system, system.now),
123932
124151
  };
123933
124152
  }
123934
124153
  ts.createProgramHost = createProgramHost;
@@ -123996,20 +124215,27 @@ var ts;
123996
124215
  var ts;
123997
124216
  (function (ts) {
123998
124217
  function readBuilderProgram(compilerOptions, host) {
123999
- if (ts.outFile(compilerOptions))
124000
- return undefined;
124001
124218
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
124002
124219
  if (!buildInfoPath)
124003
124220
  return undefined;
124004
- var content = host.readFile(buildInfoPath);
124005
- if (!content)
124006
- return undefined;
124007
- var buildInfo = ts.getBuildInfo(content);
124221
+ var buildInfo;
124222
+ if (host.getBuildInfo) {
124223
+ // host provides buildinfo, get it from there. This allows host to cache it
124224
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
124225
+ if (!buildInfo)
124226
+ return undefined;
124227
+ }
124228
+ else {
124229
+ var content = host.readFile(buildInfoPath);
124230
+ if (!content)
124231
+ return undefined;
124232
+ buildInfo = ts.getBuildInfo(content);
124233
+ }
124008
124234
  if (buildInfo.version !== ts.version)
124009
124235
  return undefined;
124010
124236
  if (!buildInfo.program)
124011
124237
  return undefined;
124012
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124238
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124013
124239
  }
124014
124240
  ts.readBuilderProgram = readBuilderProgram;
124015
124241
  function createIncrementalCompilerHost(options, system) {
@@ -124018,6 +124244,7 @@ var ts;
124018
124244
  host.createHash = ts.maybeBind(system, system.createHash);
124019
124245
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
124020
124246
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124247
+ host.now = ts.maybeBind(system, system.now);
124021
124248
  ts.setGetSourceFileAsHashVersioned(host, system);
124022
124249
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
124023
124250
  return host;
@@ -124062,7 +124289,6 @@ var ts;
124062
124289
  var builderProgram;
124063
124290
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
124064
124291
  var missingFilesMap; // Map of file watchers for the missing files
124065
- var packageJsonMap; // map of watchers for package json files used in module resolution
124066
124292
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
124067
124293
  var timerToUpdateProgram; // timer callback to recompile the program
124068
124294
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -124126,6 +124352,7 @@ var ts;
124126
124352
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
124127
124353
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
124128
124354
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124355
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
124129
124356
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
124130
124357
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
124131
124358
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -124208,10 +124435,6 @@ var ts;
124208
124435
  });
124209
124436
  parsedConfigs = undefined;
124210
124437
  }
124211
- if (packageJsonMap) {
124212
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
124213
- packageJsonMap = undefined;
124214
- }
124215
124438
  }
124216
124439
  function getCurrentBuilderProgram() {
124217
124440
  return builderProgram;
@@ -124267,15 +124490,9 @@ var ts;
124267
124490
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124268
124491
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124269
124492
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124270
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124271
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124272
- var path = _a[0], data = _a[1];
124273
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124274
- });
124275
124493
  resolutionCache.finishCachingPerDirectoryResolution();
124276
124494
  // Update watches
124277
124495
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124278
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124279
124496
  if (needsUpdateInTypeRootWatch) {
124280
124497
  resolutionCache.updateTypeRootsWatch();
124281
124498
  }
@@ -124581,21 +124798,6 @@ var ts;
124581
124798
  ts.noopFileWatcher :
124582
124799
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124583
124800
  }
124584
- function watchPackageJsonLookupPath(packageJsonPath) {
124585
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124586
- return sourceFilesCache.has(packageJsonPath) ?
124587
- ts.noopFileWatcher :
124588
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124589
- }
124590
- function onPackageJsonChange(fileName, eventKind, path) {
124591
- updateCachedSystemWithFile(fileName, path, eventKind);
124592
- // package.json changes invalidate module resolution and can change the set of loaded files
124593
- // so if we witness a change to one, we have to do a full reload
124594
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124595
- changesAffectResolution = true;
124596
- // Update the program
124597
- scheduleProgramUpdate();
124598
- }
124599
124801
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124600
124802
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124601
124803
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124753,14 +124955,17 @@ var ts;
124753
124955
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124754
124956
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124755
124957
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124756
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124757
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124758
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124759
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124958
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124959
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124960
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124961
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124962
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124963
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124760
124964
  /**
124761
124965
  * Projects with no outputs (i.e. "solution" files)
124762
124966
  */
124763
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124967
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124968
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124764
124969
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124765
124970
  function resolveConfigFileProjectName(project) {
124766
124971
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124805,9 +125010,12 @@ var ts;
124805
125010
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124806
125011
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124807
125012
  }
124808
- function newer(date1, date2) {
124809
- return date2 > date1 ? date2 : date1;
125013
+ /*@internal*/
125014
+ /** Helper to use now method instead of current date for testing purposes to get consistent baselines */
125015
+ function getCurrentTime(host) {
125016
+ return host.now ? host.now() : new Date();
124810
125017
  }
125018
+ ts.getCurrentTime = getCurrentTime;
124811
125019
  /*@internal*/
124812
125020
  function isCircularBuildOrder(buildOrder) {
124813
125021
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124897,6 +125105,7 @@ var ts;
124897
125105
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124898
125106
  };
124899
125107
  }
125108
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124900
125109
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124901
125110
  var state = {
124902
125111
  host: host,
@@ -124913,8 +125122,9 @@ var ts;
124913
125122
  resolvedConfigFilePaths: new ts.Map(),
124914
125123
  configFileCache: new ts.Map(),
124915
125124
  projectStatus: new ts.Map(),
124916
- buildInfoChecked: new ts.Map(),
124917
125125
  extendedConfigCache: new ts.Map(),
125126
+ buildInfoCache: new ts.Map(),
125127
+ outputTimeStamps: new ts.Map(),
124918
125128
  builderPrograms: new ts.Map(),
124919
125129
  diagnostics: new ts.Map(),
124920
125130
  projectPendingBuild: new ts.Map(),
@@ -124937,6 +125147,7 @@ var ts;
124937
125147
  allWatchedConfigFiles: new ts.Map(),
124938
125148
  allWatchedExtendedConfigFiles: new ts.Map(),
124939
125149
  allWatchedPackageJsonFiles: new ts.Map(),
125150
+ filesWatched: new ts.Map(),
124940
125151
  lastCachedPackageJsonLookups: new ts.Map(),
124941
125152
  timerToBuildInvalidatedProject: undefined,
124942
125153
  reportFileChangeDetected: false,
@@ -125043,11 +125254,12 @@ var ts;
125043
125254
  // Config file cache
125044
125255
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
125045
125256
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
125046
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
125047
125257
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
125048
125258
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
125049
125259
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
125050
125260
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125261
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125262
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
125051
125263
  // Remove watches for the program no longer in the solution
125052
125264
  if (state.watch) {
125053
125265
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125337,21 +125549,21 @@ var ts;
125337
125549
  }
125338
125550
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125339
125551
  var _a;
125340
- var _b, _c;
125552
+ var _b, _c, _d;
125341
125553
  ts.Debug.assertIsDefined(program);
125342
125554
  ts.Debug.assert(step === BuildStep.Emit);
125343
125555
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125344
- program.backupState();
125556
+ var saved = program.saveEmitState();
125345
125557
  var declDiagnostics;
125346
125558
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125347
125559
  var outputFiles = [];
125348
125560
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125349
125561
  /*write*/ undefined,
125350
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
125562
+ /*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,
125351
125563
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125352
125564
  // Don't emit .d.ts if there are decl file errors
125353
125565
  if (declDiagnostics) {
125354
- program.restoreState();
125566
+ program.restoreEmitState(saved);
125355
125567
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125356
125568
  return {
125357
125569
  emitSkipped: true,
@@ -125361,37 +125573,44 @@ var ts;
125361
125573
  // Actual Emit
125362
125574
  var host = state.host, compilerHost = state.compilerHost;
125363
125575
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125364
- var newestDeclarationFileContentChangedTime = minimumDate;
125365
- var anyDtsChanged = false;
125576
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125366
125577
  var emitterDiagnostics = ts.createDiagnosticCollection();
125367
125578
  var emittedOutputs = new ts.Map();
125579
+ var options = program.getCompilerOptions();
125580
+ var isIncremental = ts.isIncrementalCompilation(options);
125581
+ var outputTimeStampMap;
125582
+ var now;
125368
125583
  outputFiles.forEach(function (_a) {
125369
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125370
- var priorChangeTime;
125371
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125372
- // Check for unchanged .d.ts files
125373
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125374
- priorChangeTime = host.getModifiedTime(name);
125375
- }
125376
- else {
125584
+ var _b, _c;
125585
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125586
+ var path = toPath(state, name);
125587
+ emittedOutputs.set(toPath(state, name), name);
125588
+ if (buildInfo) {
125589
+ setBuildInfo(state, buildInfo, projectPath, options);
125590
+ // Buildinfo has information on when last dts change time
125591
+ 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)) {
125377
125592
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125378
- anyDtsChanged = true;
125379
125593
  }
125380
125594
  }
125381
- emittedOutputs.set(toPath(state, name), name);
125382
125595
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125383
- if (priorChangeTime !== undefined) {
125384
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125596
+ if (!isIncremental && state.watch) {
125597
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125385
125598
  }
125386
125599
  });
125387
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125388
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125600
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125389
125601
  return emitResult;
125390
125602
  }
125391
125603
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125392
125604
  ts.Debug.assertIsDefined(program);
125393
125605
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125394
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125606
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125607
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
125608
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125609
+ if (writeFileCallback)
125610
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125611
+ else
125612
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125613
+ }, cancellationToken);
125395
125614
  if (emitResult.diagnostics.length) {
125396
125615
  reportErrors(state, emitResult.diagnostics);
125397
125616
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125404,7 +125623,7 @@ var ts;
125404
125623
  step = BuildStep.QueueReferencingProjects;
125405
125624
  return emitResult;
125406
125625
  }
125407
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125626
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125408
125627
  var _a;
125409
125628
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125410
125629
  if (emitDiagnostics.length) {
@@ -125415,13 +125634,11 @@ var ts;
125415
125634
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125416
125635
  }
125417
125636
  // Update time stamps for rest of the outputs
125418
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125637
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125419
125638
  state.diagnostics.delete(projectPath);
125420
125639
  state.projectStatus.set(projectPath, {
125421
125640
  type: ts.UpToDateStatusType.UpToDate,
125422
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125423
- maximumDate :
125424
- newestDeclarationFileContentChangedTime,
125641
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125425
125642
  oldestOutputFileName: oldestOutputFileName
125426
125643
  });
125427
125644
  afterProgramDone(state, program, config);
@@ -125456,13 +125673,21 @@ var ts;
125456
125673
  ts.Debug.assert(!!outputFiles.length);
125457
125674
  var emitterDiagnostics = ts.createDiagnosticCollection();
125458
125675
  var emittedOutputs = new ts.Map();
125676
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125677
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125459
125678
  outputFiles.forEach(function (_a) {
125460
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125679
+ var _b, _c;
125680
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125461
125681
  emittedOutputs.set(toPath(state, name), name);
125682
+ if (buildInfo) {
125683
+ setBuildInfo(state, buildInfo, projectPath, config.options);
125684
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125685
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125686
+ }
125687
+ }
125462
125688
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125463
125689
  });
125464
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125465
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125690
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125466
125691
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125467
125692
  }
125468
125693
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125561,7 +125786,7 @@ var ts;
125561
125786
  }
125562
125787
  continue;
125563
125788
  }
125564
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125789
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125565
125790
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125566
125791
  return {
125567
125792
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125646,7 +125871,8 @@ var ts;
125646
125871
  state.projectCompilerOptions = state.baseCompilerOptions;
125647
125872
  }
125648
125873
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125649
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125874
+ // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors
125875
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125650
125876
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125651
125877
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125652
125878
  if (canEmitBuildInfo)
@@ -125654,9 +125880,99 @@ var ts;
125654
125880
  afterProgramDone(state, program, config);
125655
125881
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125656
125882
  }
125883
+ function isFileWatcherWithModifiedTime(value) {
125884
+ return !!value.watcher;
125885
+ }
125886
+ function getModifiedTime(state, fileName) {
125887
+ var path = toPath(state, fileName);
125888
+ var existing = state.filesWatched.get(path);
125889
+ if (state.watch && !!existing) {
125890
+ if (!isFileWatcherWithModifiedTime(existing))
125891
+ return existing;
125892
+ if (existing.modifiedTime)
125893
+ return existing.modifiedTime;
125894
+ }
125895
+ // In watch mode we store the modified times in the cache
125896
+ // This is either Date | FileWatcherWithModifiedTime because we query modified times first and
125897
+ // then after complete compilation of the project, watch the files so we dont want to loose these modified times.
125898
+ var result = ts.getModifiedTime(state.host, fileName);
125899
+ if (state.watch) {
125900
+ if (existing)
125901
+ existing.modifiedTime = result;
125902
+ else
125903
+ state.filesWatched.set(path, result);
125904
+ }
125905
+ return result;
125906
+ }
125907
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125908
+ var path = toPath(state, file);
125909
+ var existing = state.filesWatched.get(path);
125910
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125911
+ existing.callbacks.push(callback);
125912
+ }
125913
+ else {
125914
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125915
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125916
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125917
+ existing.modifiedTime = modifiedTime;
125918
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125919
+ }, pollingInterval, options, watchType, project);
125920
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125921
+ }
125922
+ return {
125923
+ close: function () {
125924
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125925
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125926
+ if (existing.callbacks.length === 1) {
125927
+ state.filesWatched.delete(path);
125928
+ ts.closeFileWatcherOf(existing);
125929
+ }
125930
+ else {
125931
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125932
+ }
125933
+ }
125934
+ };
125935
+ }
125936
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125937
+ // Output timestamps are stored only in watch mode
125938
+ if (!state.watch)
125939
+ return undefined;
125940
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125941
+ if (!result)
125942
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125943
+ return result;
125944
+ }
125945
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125946
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125947
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125948
+ if (existing) {
125949
+ existing.buildInfo = buildInfo;
125950
+ existing.modifiedTime = getCurrentTime(state.host);
125951
+ }
125952
+ else {
125953
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125954
+ }
125955
+ }
125956
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125957
+ var path = toPath(state, buildInfoPath);
125958
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125959
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125960
+ }
125961
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125962
+ var path = toPath(state, buildInfoPath);
125963
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125964
+ if (existing !== undefined && existing.path === path) {
125965
+ return existing.buildInfo || undefined;
125966
+ }
125967
+ var value = state.readFileWithCache(buildInfoPath);
125968
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125969
+ ts.Debug.assert(modifiedTime || !buildInfo);
125970
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125971
+ return buildInfo;
125972
+ }
125657
125973
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125658
125974
  // Check tsconfig time
125659
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125975
+ var tsconfigTime = getModifiedTime(state, configFile);
125660
125976
  if (oldestOutputFileTime < tsconfigTime) {
125661
125977
  return {
125662
125978
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125666,88 +125982,24 @@ var ts;
125666
125982
  }
125667
125983
  }
125668
125984
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125669
- var force = !!state.options.force;
125670
- var newestInputFileName = undefined;
125671
- var newestInputFileTime = minimumDate;
125672
- var host = state.host;
125673
- // Get timestamps of input files
125674
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125675
- var inputFile = _a[_i];
125676
- if (!host.fileExists(inputFile)) {
125677
- return {
125678
- type: ts.UpToDateStatusType.Unbuildable,
125679
- reason: inputFile + " does not exist"
125680
- };
125681
- }
125682
- if (!force) {
125683
- var inputTime = ts.getModifiedTime(host, inputFile);
125684
- if (inputTime > newestInputFileTime) {
125685
- newestInputFileName = inputFile;
125686
- newestInputFileTime = inputTime;
125687
- }
125688
- }
125689
- }
125985
+ var _a, _b, _c;
125690
125986
  // Container if no files are specified in the project
125691
125987
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125692
125988
  return {
125693
125989
  type: ts.UpToDateStatusType.ContainerOnly
125694
125990
  };
125695
125991
  }
125696
- // Collect the expected outputs of this project
125697
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125698
- // Now see if all outputs are newer than the newest input
125699
- var oldestOutputFileName = "(none)";
125700
- var oldestOutputFileTime = maximumDate;
125701
- var newestOutputFileName = "(none)";
125702
- var newestOutputFileTime = minimumDate;
125703
- var missingOutputFileName;
125704
- var newestDeclarationFileContentChangedTime = minimumDate;
125705
- var isOutOfDateWithInputs = false;
125706
- if (!force) {
125707
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125708
- var output = outputs_1[_b];
125709
- // Output is missing; can stop checking
125710
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125711
- if (!host.fileExists(output)) {
125712
- missingOutputFileName = output;
125713
- break;
125714
- }
125715
- var outputTime = ts.getModifiedTime(host, output);
125716
- if (outputTime < oldestOutputFileTime) {
125717
- oldestOutputFileTime = outputTime;
125718
- oldestOutputFileName = output;
125719
- }
125720
- // If an output is older than the newest input, we can stop checking
125721
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125722
- if (outputTime < newestInputFileTime) {
125723
- isOutOfDateWithInputs = true;
125724
- break;
125725
- }
125726
- if (outputTime > newestOutputFileTime) {
125727
- newestOutputFileTime = outputTime;
125728
- newestOutputFileName = output;
125729
- }
125730
- // Keep track of when the most recent time a .d.ts file was changed.
125731
- // In addition to file timestamps, we also keep track of when a .d.ts file
125732
- // had its file touched but not had its contents changed - this allows us
125733
- // to skip a downstream typecheck
125734
- if (ts.isDeclarationFileName(output)) {
125735
- var outputModifiedTime = ts.getModifiedTime(host, output);
125736
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125737
- }
125738
- }
125739
- }
125740
- var pseudoUpToDate = false;
125741
- var usesPrepend = false;
125742
- var upstreamChangedProject;
125992
+ // Fast check to see if reference projects are upto date and error free
125993
+ var referenceStatuses;
125994
+ var force = !!state.options.force;
125743
125995
  if (project.projectReferences) {
125744
125996
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125745
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125746
- var ref = _d[_c];
125747
- usesPrepend = usesPrepend || !!(ref.prepend);
125997
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125998
+ var ref = _d[_i];
125748
125999
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125749
126000
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125750
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
126001
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
126002
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125751
126003
  // Its a circular reference ignore the status of this project
125752
126004
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125753
126005
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125769,75 +126021,194 @@ var ts;
125769
126021
  upstreamProjectName: ref.path
125770
126022
  };
125771
126023
  }
125772
- // Check oldest output file name only if there is no missing output file name
125773
- // (a check we will have skipped if this is a forced build)
125774
- if (!force && !missingOutputFileName) {
125775
- // If the upstream project's newest file is older than our oldest output, we
125776
- // can't be out of date because of it
125777
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125778
- continue;
125779
- }
125780
- // If the upstream project has only change .d.ts files, and we've built
125781
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125782
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125783
- pseudoUpToDate = true;
125784
- upstreamChangedProject = ref.path;
125785
- continue;
125786
- }
125787
- // We have an output older than an upstream output - we are out of date
125788
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
126024
+ if (!force)
126025
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
126026
+ }
126027
+ }
126028
+ if (force)
126029
+ return { type: ts.UpToDateStatusType.ForceBuild };
126030
+ // Check buildinfo first
126031
+ var host = state.host;
126032
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
126033
+ var oldestOutputFileName;
126034
+ var oldestOutputFileTime = maximumDate;
126035
+ var buildInfoTime;
126036
+ var buildInfoProgram;
126037
+ var buildInfoVersionMap;
126038
+ var newestDeclarationFileContentChangedTime;
126039
+ if (buildInfoPath) {
126040
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
126041
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
126042
+ if (buildInfoTime === ts.missingFileModifiedTime) {
126043
+ if (!buildInfoCacheEntry_1) {
126044
+ state.buildInfoCache.set(resolvedPath, {
126045
+ path: toPath(state, buildInfoPath),
126046
+ buildInfo: false,
126047
+ modifiedTime: buildInfoTime
126048
+ });
126049
+ }
126050
+ return {
126051
+ type: ts.UpToDateStatusType.OutputMissing,
126052
+ missingOutputFileName: buildInfoPath
126053
+ };
126054
+ }
126055
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
126056
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
126057
+ return {
126058
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
126059
+ version: buildInfo.version
126060
+ };
126061
+ }
126062
+ if (buildInfo.program) {
126063
+ // If there are pending changes that are not emitted, project is out of date
126064
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
126065
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125789
126066
  return {
125790
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125791
- outOfDateOutputFileName: oldestOutputFileName,
125792
- newerProjectName: ref.path
126067
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
126068
+ buildInfoFile: buildInfoPath
125793
126069
  };
125794
126070
  }
126071
+ buildInfoProgram = buildInfo.program;
125795
126072
  }
126073
+ oldestOutputFileTime = buildInfoTime;
126074
+ oldestOutputFileName = buildInfoPath;
126075
+ // Get the last dtsChange time from build info
126076
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125796
126077
  }
125797
- if (missingOutputFileName !== undefined) {
125798
- return {
125799
- type: ts.UpToDateStatusType.OutputMissing,
125800
- missingOutputFileName: missingOutputFileName
125801
- };
126078
+ // Check input files
126079
+ var newestInputFileName = undefined;
126080
+ var newestInputFileTime = minimumDate;
126081
+ /** 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 */
126082
+ var pseudoInputUpToDate = false;
126083
+ // Get timestamps of input files
126084
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
126085
+ var inputFile = _f[_e];
126086
+ var inputTime = getModifiedTime(state, inputFile);
126087
+ if (inputTime === ts.missingFileModifiedTime) {
126088
+ return {
126089
+ type: ts.UpToDateStatusType.Unbuildable,
126090
+ reason: inputFile + " does not exist"
126091
+ };
126092
+ }
126093
+ // If an buildInfo is older than the newest input, we can stop checking
126094
+ if (buildInfoTime && buildInfoTime < inputTime) {
126095
+ var version_3 = void 0;
126096
+ var currentVersion = void 0;
126097
+ if (buildInfoProgram) {
126098
+ // Read files and see if they are same, read is anyways cached
126099
+ if (!buildInfoVersionMap)
126100
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
126101
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
126102
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
126103
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
126104
+ if (version_3 && version_3 === currentVersion)
126105
+ pseudoInputUpToDate = true;
126106
+ }
126107
+ if (!version_3 || version_3 !== currentVersion) {
126108
+ return {
126109
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
126110
+ outOfDateOutputFileName: buildInfoPath,
126111
+ newerInputFileName: inputFile
126112
+ };
126113
+ }
126114
+ }
126115
+ if (inputTime > newestInputFileTime) {
126116
+ newestInputFileName = inputFile;
126117
+ newestInputFileTime = inputTime;
126118
+ }
125802
126119
  }
125803
- if (isOutOfDateWithInputs) {
125804
- return {
125805
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125806
- outOfDateOutputFileName: oldestOutputFileName,
125807
- newerInputFileName: newestInputFileName
125808
- };
126120
+ // Now see if all outputs are newer than the newest input
126121
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
126122
+ if (!buildInfoPath) {
126123
+ // Collect the expected outputs of this project
126124
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
126125
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
126126
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
126127
+ var output = outputs_1[_g];
126128
+ var path = toPath(state, output);
126129
+ // Output is missing; can stop checking
126130
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
126131
+ if (!outputTime) {
126132
+ outputTime = ts.getModifiedTime(state.host, output);
126133
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
126134
+ }
126135
+ if (outputTime === ts.missingFileModifiedTime) {
126136
+ return {
126137
+ type: ts.UpToDateStatusType.OutputMissing,
126138
+ missingOutputFileName: output
126139
+ };
126140
+ }
126141
+ // If an output is older than the newest input, we can stop checking
126142
+ if (outputTime < newestInputFileTime) {
126143
+ return {
126144
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
126145
+ outOfDateOutputFileName: output,
126146
+ newerInputFileName: newestInputFileName
126147
+ };
126148
+ }
126149
+ // No need to get newestDeclarationFileContentChangedTime since thats needed only for composite projects
126150
+ // And composite projects are the only ones that can be referenced
126151
+ if (outputTime < oldestOutputFileTime) {
126152
+ oldestOutputFileTime = outputTime;
126153
+ oldestOutputFileName = output;
126154
+ }
126155
+ }
125809
126156
  }
125810
- else {
125811
- // Check tsconfig time
125812
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125813
- if (configStatus)
125814
- return configStatus;
125815
- // Check extended config time
125816
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125817
- if (extendedConfigStatus)
125818
- return extendedConfigStatus;
125819
- // Check package file time
125820
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125821
- var path = _a[0];
125822
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125823
- });
125824
- if (dependentPackageFileStatus)
125825
- return dependentPackageFileStatus;
125826
- }
125827
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125828
- state.buildInfoChecked.set(resolvedPath, true);
125829
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125830
- if (buildInfoPath) {
125831
- var value = state.readFileWithCache(buildInfoPath);
125832
- var buildInfo = value && ts.getBuildInfo(value);
125833
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
126157
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
126158
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
126159
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
126160
+ /** Inputs are up-to-date, just need either timestamp update or bundle prepend manipulation to make it look up-to-date */
126161
+ var pseudoUpToDate = false;
126162
+ var usesPrepend = false;
126163
+ var upstreamChangedProject;
126164
+ if (referenceStatuses) {
126165
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
126166
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
126167
+ usesPrepend = usesPrepend || !!(ref.prepend);
126168
+ // If the upstream project's newest file is older than our oldest output, we
126169
+ // can't be out of date because of it
126170
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
126171
+ continue;
126172
+ }
126173
+ // Check if tsbuildinfo path is shared, then we need to rebuild
126174
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125834
126175
  return {
125835
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125836
- version: buildInfo.version
126176
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
126177
+ outOfDateOutputFileName: buildInfoPath,
126178
+ newerProjectName: ref.path
125837
126179
  };
125838
126180
  }
126181
+ // If the upstream project has only change .d.ts files, and we've built
126182
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
126183
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
126184
+ pseudoUpToDate = true;
126185
+ upstreamChangedProject = ref.path;
126186
+ continue;
126187
+ }
126188
+ // We have an output older than an upstream output - we are out of date
126189
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
126190
+ return {
126191
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
126192
+ outOfDateOutputFileName: oldestOutputFileName,
126193
+ newerProjectName: ref.path
126194
+ };
125839
126195
  }
125840
126196
  }
126197
+ // Check tsconfig time
126198
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
126199
+ if (configStatus)
126200
+ return configStatus;
126201
+ // Check extended config time
126202
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
126203
+ if (extendedConfigStatus)
126204
+ return extendedConfigStatus;
126205
+ // Check package file time
126206
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
126207
+ var path = _a[0];
126208
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
126209
+ });
126210
+ if (dependentPackageFileStatus)
126211
+ return dependentPackageFileStatus;
125841
126212
  if (usesPrepend && pseudoUpToDate) {
125842
126213
  return {
125843
126214
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125847,15 +126218,37 @@ var ts;
125847
126218
  }
125848
126219
  // Up to date
125849
126220
  return {
125850
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
126221
+ type: pseudoUpToDate ?
126222
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
126223
+ pseudoInputUpToDate ?
126224
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
126225
+ ts.UpToDateStatusType.UpToDate,
125851
126226
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125852
126227
  newestInputFileTime: newestInputFileTime,
125853
- newestOutputFileTime: newestOutputFileTime,
125854
126228
  newestInputFileName: newestInputFileName,
125855
- newestOutputFileName: newestOutputFileName,
125856
126229
  oldestOutputFileName: oldestOutputFileName
125857
126230
  };
125858
126231
  }
126232
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
126233
+ if (seenRefs.has(resolvedRefPath))
126234
+ return false;
126235
+ seenRefs.add(resolvedRefPath);
126236
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
126237
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
126238
+ return true;
126239
+ if (resolvedConfig.projectReferences) {
126240
+ // Check references
126241
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
126242
+ var ref = _a[_i];
126243
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
126244
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
126245
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
126246
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
126247
+ return true;
126248
+ }
126249
+ }
126250
+ return false;
126251
+ }
125859
126252
  function getUpToDateStatus(state, project, resolvedPath) {
125860
126253
  if (project === undefined) {
125861
126254
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125868,39 +126261,68 @@ var ts;
125868
126261
  state.projectStatus.set(resolvedPath, actual);
125869
126262
  return actual;
125870
126263
  }
125871
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126264
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125872
126265
  if (proj.options.noEmit)
125873
- return priorNewestUpdateTime;
126266
+ return;
126267
+ var now;
126268
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
126269
+ if (buildInfoPath) {
126270
+ // For incremental projects, only buildinfo needs to be upto date with timestamp check
126271
+ // as we dont check output files for up-to-date ness
126272
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
126273
+ if (!!state.options.verbose)
126274
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
126275
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
126276
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
126277
+ }
126278
+ state.outputTimeStamps.delete(projectPath);
126279
+ return;
126280
+ }
125874
126281
  var host = state.host;
125875
126282
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126283
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126284
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125876
126285
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125877
126286
  var reportVerbose = !!state.options.verbose;
125878
- var now = host.now ? host.now() : new Date();
125879
126287
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125880
126288
  var file = outputs_2[_i];
125881
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
126289
+ var path = toPath(state, file);
126290
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125882
126291
  continue;
125883
- }
125884
126292
  if (reportVerbose) {
125885
126293
  reportVerbose = false;
125886
126294
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125887
126295
  }
125888
- if (ts.isDeclarationFileName(file)) {
125889
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
126296
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
126297
+ // Store output timestamps in a map because non incremental build will need to check them to determine up-to-dateness
126298
+ if (outputTimeStampMap) {
126299
+ outputTimeStampMap.set(path, now);
126300
+ modifiedOutputs.add(path);
125890
126301
  }
125891
- host.setModifiedTime(file, now);
125892
126302
  }
125893
126303
  }
125894
- return priorNewestUpdateTime;
126304
+ // Clear out timestamps not in output list any more
126305
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.forEach(function (_value, key) {
126306
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs.has(key))
126307
+ outputTimeStampMap.delete(key);
126308
+ });
126309
+ }
126310
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
126311
+ var _a;
126312
+ if (!options.composite)
126313
+ return undefined;
126314
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126315
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126316
+ 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;
125895
126317
  }
125896
126318
  function updateOutputTimestamps(state, proj, resolvedPath) {
125897
126319
  if (state.options.dry) {
125898
126320
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125899
126321
  }
125900
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126322
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125901
126323
  state.projectStatus.set(resolvedPath, {
125902
126324
  type: ts.UpToDateStatusType.UpToDate,
125903
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126325
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125904
126326
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125905
126327
  });
125906
126328
  }
@@ -125946,6 +126368,7 @@ var ts;
125946
126368
  break;
125947
126369
  }
125948
126370
  // falls through
126371
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125949
126372
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125950
126373
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125951
126374
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -126106,12 +126529,10 @@ var ts;
126106
126529
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
126107
126530
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
126108
126531
  return;
126109
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
126110
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
126111
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126532
+ 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));
126112
126533
  }
126113
126534
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
126114
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126535
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
126115
126536
  var _a;
126116
126537
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
126117
126538
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -126143,7 +126564,7 @@ var ts;
126143
126564
  if (!state.watch)
126144
126565
  return;
126145
126566
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
126146
- 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); },
126567
+ 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); },
126147
126568
  onDeleteValue: ts.closeFileWatcher,
126148
126569
  });
126149
126570
  }
@@ -126151,7 +126572,7 @@ var ts;
126151
126572
  if (!state.watch || !state.lastCachedPackageJsonLookups)
126152
126573
  return;
126153
126574
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
126154
- 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); },
126575
+ 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); },
126155
126576
  onDeleteValue: ts.closeFileWatcher,
126156
126577
  });
126157
126578
  }
@@ -126281,19 +126702,18 @@ var ts;
126281
126702
  }
126282
126703
  }
126283
126704
  function reportUpToDateStatus(state, configFileName, status) {
126284
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126285
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126286
- }
126287
126705
  switch (status.type) {
126288
126706
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126289
- 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));
126707
+ 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));
126290
126708
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126291
- 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));
126709
+ 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));
126292
126710
  case ts.UpToDateStatusType.OutputMissing:
126293
126711
  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));
126712
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
126713
+ 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));
126294
126714
  case ts.UpToDateStatusType.UpToDate:
126295
126715
  if (status.newestInputFileTime !== undefined) {
126296
- 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 || ""));
126716
+ 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 || ""));
126297
126717
  }
126298
126718
  // Don't report anything for "up to date because it was already built" -- too verbose
126299
126719
  break;
@@ -126301,6 +126721,8 @@ var ts;
126301
126721
  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));
126302
126722
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126303
126723
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126724
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126725
+ 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));
126304
126726
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126305
126727
  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));
126306
126728
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126311,6 +126733,8 @@ var ts;
126311
126733
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126312
126734
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126313
126735
  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);
126736
+ case ts.UpToDateStatusType.ForceBuild:
126737
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126314
126738
  case ts.UpToDateStatusType.ContainerOnly:
126315
126739
  // Don't report status on "solution" projects
126316
126740
  // falls through
@@ -168435,7 +168859,8 @@ var ts;
168435
168859
  }
168436
168860
  return {
168437
168861
  resolvedFileName: resolvedFileName,
168438
- failedLookupLocations: result.failedLookupLocations
168862
+ failedLookupLocations: result.failedLookupLocations,
168863
+ affectingLocations: result.affectingLocations,
168439
168864
  };
168440
168865
  });
168441
168866
  };