typescript 4.8.0-dev.20220605 → 4.8.0-dev.20220609

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.20220605";
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
  }
@@ -39238,6 +39275,7 @@ var ts;
39238
39275
  ["es2022.error", "lib.es2022.error.d.ts"],
39239
39276
  ["es2022.intl", "lib.es2022.intl.d.ts"],
39240
39277
  ["es2022.object", "lib.es2022.object.d.ts"],
39278
+ ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
39241
39279
  ["es2022.string", "lib.es2022.string.d.ts"],
39242
39280
  ["esnext.array", "lib.es2022.array.d.ts"],
39243
39281
  ["esnext.symbol", "lib.es2019.symbol.d.ts"],
@@ -39451,6 +39489,7 @@ var ts;
39451
39489
  type: "boolean",
39452
39490
  affectsSemanticDiagnostics: true,
39453
39491
  affectsEmit: true,
39492
+ affectsMultiFileEmitBuildInfo: true,
39454
39493
  category: ts.Diagnostics.Watch_and_Build_Modes,
39455
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,
39456
39495
  defaultValueDescription: false,
@@ -39485,12 +39524,40 @@ var ts;
39485
39524
  affectsSourceFile: true,
39486
39525
  affectsModuleResolution: true,
39487
39526
  affectsEmit: true,
39527
+ affectsMultiFileEmitBuildInfo: true,
39488
39528
  paramType: ts.Diagnostics.VERSION,
39489
39529
  showInSimplifiedHelpView: true,
39490
39530
  category: ts.Diagnostics.Language_and_Environment,
39491
39531
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39492
39532
  defaultValueDescription: 0 /* ES3 */,
39493
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
+ };
39494
39561
  var commandOptionsWithoutBuild = [
39495
39562
  // CommandLine only options
39496
39563
  {
@@ -39552,37 +39619,14 @@ var ts;
39552
39619
  category: ts.Diagnostics.Command_line_Options,
39553
39620
  affectsSemanticDiagnostics: true,
39554
39621
  affectsEmit: true,
39622
+ affectsMultiFileEmitBuildInfo: true,
39555
39623
  isCommandLineOnly: true,
39556
39624
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39557
39625
  defaultValueDescription: false,
39558
39626
  },
39559
39627
  // Basic
39560
39628
  ts.targetOptionDeclaration,
39561
- {
39562
- name: "module",
39563
- shortName: "m",
39564
- type: new ts.Map(ts.getEntries({
39565
- none: ts.ModuleKind.None,
39566
- commonjs: ts.ModuleKind.CommonJS,
39567
- amd: ts.ModuleKind.AMD,
39568
- system: ts.ModuleKind.System,
39569
- umd: ts.ModuleKind.UMD,
39570
- es6: ts.ModuleKind.ES2015,
39571
- es2015: ts.ModuleKind.ES2015,
39572
- es2020: ts.ModuleKind.ES2020,
39573
- es2022: ts.ModuleKind.ES2022,
39574
- esnext: ts.ModuleKind.ESNext,
39575
- node16: ts.ModuleKind.Node16,
39576
- nodenext: ts.ModuleKind.NodeNext,
39577
- })),
39578
- affectsModuleResolution: true,
39579
- affectsEmit: true,
39580
- paramType: ts.Diagnostics.KIND,
39581
- showInSimplifiedHelpView: true,
39582
- category: ts.Diagnostics.Modules,
39583
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39584
- defaultValueDescription: undefined,
39585
- },
39629
+ ts.moduleOptionDeclaration,
39586
39630
  {
39587
39631
  name: "lib",
39588
39632
  type: "list",
@@ -39619,6 +39663,7 @@ var ts;
39619
39663
  type: jsxOptionMap,
39620
39664
  affectsSourceFile: true,
39621
39665
  affectsEmit: true,
39666
+ affectsMultiFileEmitBuildInfo: true,
39622
39667
  affectsModuleResolution: true,
39623
39668
  paramType: ts.Diagnostics.KIND,
39624
39669
  showInSimplifiedHelpView: true,
@@ -39631,6 +39676,7 @@ var ts;
39631
39676
  shortName: "d",
39632
39677
  type: "boolean",
39633
39678
  affectsEmit: true,
39679
+ affectsMultiFileEmitBuildInfo: true,
39634
39680
  showInSimplifiedHelpView: true,
39635
39681
  category: ts.Diagnostics.Emit,
39636
39682
  transpileOptionValue: undefined,
@@ -39641,6 +39687,7 @@ var ts;
39641
39687
  name: "declarationMap",
39642
39688
  type: "boolean",
39643
39689
  affectsEmit: true,
39690
+ affectsMultiFileEmitBuildInfo: true,
39644
39691
  showInSimplifiedHelpView: true,
39645
39692
  category: ts.Diagnostics.Emit,
39646
39693
  transpileOptionValue: undefined,
@@ -39651,6 +39698,7 @@ var ts;
39651
39698
  name: "emitDeclarationOnly",
39652
39699
  type: "boolean",
39653
39700
  affectsEmit: true,
39701
+ affectsMultiFileEmitBuildInfo: true,
39654
39702
  showInSimplifiedHelpView: true,
39655
39703
  category: ts.Diagnostics.Emit,
39656
39704
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39661,6 +39709,7 @@ var ts;
39661
39709
  name: "sourceMap",
39662
39710
  type: "boolean",
39663
39711
  affectsEmit: true,
39712
+ affectsMultiFileEmitBuildInfo: true,
39664
39713
  showInSimplifiedHelpView: true,
39665
39714
  category: ts.Diagnostics.Emit,
39666
39715
  defaultValueDescription: false,
@@ -39670,6 +39719,9 @@ var ts;
39670
39719
  name: "outFile",
39671
39720
  type: "string",
39672
39721
  affectsEmit: true,
39722
+ affectsMultiFileEmitBuildInfo: true,
39723
+ affectsDeclarationPath: true,
39724
+ affectsBundleEmitBuildInfo: true,
39673
39725
  isFilePath: true,
39674
39726
  paramType: ts.Diagnostics.FILE,
39675
39727
  showInSimplifiedHelpView: true,
@@ -39681,6 +39733,8 @@ var ts;
39681
39733
  name: "outDir",
39682
39734
  type: "string",
39683
39735
  affectsEmit: true,
39736
+ affectsMultiFileEmitBuildInfo: true,
39737
+ affectsDeclarationPath: true,
39684
39738
  isFilePath: true,
39685
39739
  paramType: ts.Diagnostics.DIRECTORY,
39686
39740
  showInSimplifiedHelpView: true,
@@ -39691,6 +39745,8 @@ var ts;
39691
39745
  name: "rootDir",
39692
39746
  type: "string",
39693
39747
  affectsEmit: true,
39748
+ affectsMultiFileEmitBuildInfo: true,
39749
+ affectsDeclarationPath: true,
39694
39750
  isFilePath: true,
39695
39751
  paramType: ts.Diagnostics.LOCATION,
39696
39752
  category: ts.Diagnostics.Modules,
@@ -39701,6 +39757,8 @@ var ts;
39701
39757
  name: "composite",
39702
39758
  type: "boolean",
39703
39759
  affectsEmit: true,
39760
+ affectsMultiFileEmitBuildInfo: true,
39761
+ affectsBundleEmitBuildInfo: true,
39704
39762
  isTSConfigOnly: true,
39705
39763
  category: ts.Diagnostics.Projects,
39706
39764
  transpileOptionValue: undefined,
@@ -39711,6 +39769,8 @@ var ts;
39711
39769
  name: "tsBuildInfoFile",
39712
39770
  type: "string",
39713
39771
  affectsEmit: true,
39772
+ affectsMultiFileEmitBuildInfo: true,
39773
+ affectsBundleEmitBuildInfo: true,
39714
39774
  isFilePath: true,
39715
39775
  paramType: ts.Diagnostics.FILE,
39716
39776
  category: ts.Diagnostics.Projects,
@@ -39722,6 +39782,7 @@ var ts;
39722
39782
  name: "removeComments",
39723
39783
  type: "boolean",
39724
39784
  affectsEmit: true,
39785
+ affectsMultiFileEmitBuildInfo: true,
39725
39786
  showInSimplifiedHelpView: true,
39726
39787
  category: ts.Diagnostics.Emit,
39727
39788
  defaultValueDescription: false,
@@ -39740,6 +39801,7 @@ var ts;
39740
39801
  name: "importHelpers",
39741
39802
  type: "boolean",
39742
39803
  affectsEmit: true,
39804
+ affectsMultiFileEmitBuildInfo: true,
39743
39805
  category: ts.Diagnostics.Emit,
39744
39806
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39745
39807
  defaultValueDescription: false,
@@ -39753,6 +39815,7 @@ var ts;
39753
39815
  })),
39754
39816
  affectsEmit: true,
39755
39817
  affectsSemanticDiagnostics: true,
39818
+ affectsMultiFileEmitBuildInfo: true,
39756
39819
  category: ts.Diagnostics.Emit,
39757
39820
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39758
39821
  defaultValueDescription: 0 /* Remove */,
@@ -39761,6 +39824,7 @@ var ts;
39761
39824
  name: "downlevelIteration",
39762
39825
  type: "boolean",
39763
39826
  affectsEmit: true,
39827
+ affectsMultiFileEmitBuildInfo: true,
39764
39828
  category: ts.Diagnostics.Emit,
39765
39829
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39766
39830
  defaultValueDescription: false,
@@ -39779,6 +39843,9 @@ var ts;
39779
39843
  type: "boolean",
39780
39844
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39781
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,
39782
39849
  showInSimplifiedHelpView: true,
39783
39850
  category: ts.Diagnostics.Type_Checking,
39784
39851
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39788,6 +39855,7 @@ var ts;
39788
39855
  name: "noImplicitAny",
39789
39856
  type: "boolean",
39790
39857
  affectsSemanticDiagnostics: true,
39858
+ affectsMultiFileEmitBuildInfo: true,
39791
39859
  strictFlag: true,
39792
39860
  category: ts.Diagnostics.Type_Checking,
39793
39861
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39797,6 +39865,7 @@ var ts;
39797
39865
  name: "strictNullChecks",
39798
39866
  type: "boolean",
39799
39867
  affectsSemanticDiagnostics: true,
39868
+ affectsMultiFileEmitBuildInfo: true,
39800
39869
  strictFlag: true,
39801
39870
  category: ts.Diagnostics.Type_Checking,
39802
39871
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39805,6 +39874,8 @@ var ts;
39805
39874
  {
39806
39875
  name: "strictFunctionTypes",
39807
39876
  type: "boolean",
39877
+ affectsSemanticDiagnostics: true,
39878
+ affectsMultiFileEmitBuildInfo: true,
39808
39879
  strictFlag: true,
39809
39880
  category: ts.Diagnostics.Type_Checking,
39810
39881
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39813,6 +39884,8 @@ var ts;
39813
39884
  {
39814
39885
  name: "strictBindCallApply",
39815
39886
  type: "boolean",
39887
+ affectsSemanticDiagnostics: true,
39888
+ affectsMultiFileEmitBuildInfo: true,
39816
39889
  strictFlag: true,
39817
39890
  category: ts.Diagnostics.Type_Checking,
39818
39891
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39822,6 +39895,7 @@ var ts;
39822
39895
  name: "strictPropertyInitialization",
39823
39896
  type: "boolean",
39824
39897
  affectsSemanticDiagnostics: true,
39898
+ affectsMultiFileEmitBuildInfo: true,
39825
39899
  strictFlag: true,
39826
39900
  category: ts.Diagnostics.Type_Checking,
39827
39901
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39831,6 +39905,7 @@ var ts;
39831
39905
  name: "noImplicitThis",
39832
39906
  type: "boolean",
39833
39907
  affectsSemanticDiagnostics: true,
39908
+ affectsMultiFileEmitBuildInfo: true,
39834
39909
  strictFlag: true,
39835
39910
  category: ts.Diagnostics.Type_Checking,
39836
39911
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39840,6 +39915,7 @@ var ts;
39840
39915
  name: "useUnknownInCatchVariables",
39841
39916
  type: "boolean",
39842
39917
  affectsSemanticDiagnostics: true,
39918
+ affectsMultiFileEmitBuildInfo: true,
39843
39919
  strictFlag: true,
39844
39920
  category: ts.Diagnostics.Type_Checking,
39845
39921
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39849,6 +39925,8 @@ var ts;
39849
39925
  name: "alwaysStrict",
39850
39926
  type: "boolean",
39851
39927
  affectsSourceFile: true,
39928
+ affectsEmit: true,
39929
+ affectsMultiFileEmitBuildInfo: true,
39852
39930
  strictFlag: true,
39853
39931
  category: ts.Diagnostics.Type_Checking,
39854
39932
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39859,6 +39937,7 @@ var ts;
39859
39937
  name: "noUnusedLocals",
39860
39938
  type: "boolean",
39861
39939
  affectsSemanticDiagnostics: true,
39940
+ affectsMultiFileEmitBuildInfo: true,
39862
39941
  category: ts.Diagnostics.Type_Checking,
39863
39942
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39864
39943
  defaultValueDescription: false,
@@ -39867,6 +39946,7 @@ var ts;
39867
39946
  name: "noUnusedParameters",
39868
39947
  type: "boolean",
39869
39948
  affectsSemanticDiagnostics: true,
39949
+ affectsMultiFileEmitBuildInfo: true,
39870
39950
  category: ts.Diagnostics.Type_Checking,
39871
39951
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39872
39952
  defaultValueDescription: false,
@@ -39875,6 +39955,7 @@ var ts;
39875
39955
  name: "exactOptionalPropertyTypes",
39876
39956
  type: "boolean",
39877
39957
  affectsSemanticDiagnostics: true,
39958
+ affectsMultiFileEmitBuildInfo: true,
39878
39959
  category: ts.Diagnostics.Type_Checking,
39879
39960
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39880
39961
  defaultValueDescription: false,
@@ -39883,6 +39964,7 @@ var ts;
39883
39964
  name: "noImplicitReturns",
39884
39965
  type: "boolean",
39885
39966
  affectsSemanticDiagnostics: true,
39967
+ affectsMultiFileEmitBuildInfo: true,
39886
39968
  category: ts.Diagnostics.Type_Checking,
39887
39969
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39888
39970
  defaultValueDescription: false,
@@ -39892,6 +39974,7 @@ var ts;
39892
39974
  type: "boolean",
39893
39975
  affectsBindDiagnostics: true,
39894
39976
  affectsSemanticDiagnostics: true,
39977
+ affectsMultiFileEmitBuildInfo: true,
39895
39978
  category: ts.Diagnostics.Type_Checking,
39896
39979
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39897
39980
  defaultValueDescription: false,
@@ -39900,6 +39983,7 @@ var ts;
39900
39983
  name: "noUncheckedIndexedAccess",
39901
39984
  type: "boolean",
39902
39985
  affectsSemanticDiagnostics: true,
39986
+ affectsMultiFileEmitBuildInfo: true,
39903
39987
  category: ts.Diagnostics.Type_Checking,
39904
39988
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39905
39989
  defaultValueDescription: false,
@@ -39908,6 +39992,7 @@ var ts;
39908
39992
  name: "noImplicitOverride",
39909
39993
  type: "boolean",
39910
39994
  affectsSemanticDiagnostics: true,
39995
+ affectsMultiFileEmitBuildInfo: true,
39911
39996
  category: ts.Diagnostics.Type_Checking,
39912
39997
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39913
39998
  defaultValueDescription: false,
@@ -39915,6 +40000,8 @@ var ts;
39915
40000
  {
39916
40001
  name: "noPropertyAccessFromIndexSignature",
39917
40002
  type: "boolean",
40003
+ affectsSemanticDiagnostics: true,
40004
+ affectsMultiFileEmitBuildInfo: true,
39918
40005
  showInSimplifiedHelpView: false,
39919
40006
  category: ts.Diagnostics.Type_Checking,
39920
40007
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -40000,6 +40087,7 @@ var ts;
40000
40087
  name: "allowSyntheticDefaultImports",
40001
40088
  type: "boolean",
40002
40089
  affectsSemanticDiagnostics: true,
40090
+ affectsMultiFileEmitBuildInfo: true,
40003
40091
  category: ts.Diagnostics.Interop_Constraints,
40004
40092
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
40005
40093
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -40009,6 +40097,7 @@ var ts;
40009
40097
  type: "boolean",
40010
40098
  affectsSemanticDiagnostics: true,
40011
40099
  affectsEmit: true,
40100
+ affectsMultiFileEmitBuildInfo: true,
40012
40101
  showInSimplifiedHelpView: true,
40013
40102
  category: ts.Diagnostics.Interop_Constraints,
40014
40103
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -40025,6 +40114,7 @@ var ts;
40025
40114
  name: "allowUmdGlobalAccess",
40026
40115
  type: "boolean",
40027
40116
  affectsSemanticDiagnostics: true,
40117
+ affectsMultiFileEmitBuildInfo: true,
40028
40118
  category: ts.Diagnostics.Modules,
40029
40119
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
40030
40120
  defaultValueDescription: false,
@@ -40046,6 +40136,7 @@ var ts;
40046
40136
  name: "sourceRoot",
40047
40137
  type: "string",
40048
40138
  affectsEmit: true,
40139
+ affectsMultiFileEmitBuildInfo: true,
40049
40140
  paramType: ts.Diagnostics.LOCATION,
40050
40141
  category: ts.Diagnostics.Emit,
40051
40142
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -40054,6 +40145,7 @@ var ts;
40054
40145
  name: "mapRoot",
40055
40146
  type: "string",
40056
40147
  affectsEmit: true,
40148
+ affectsMultiFileEmitBuildInfo: true,
40057
40149
  paramType: ts.Diagnostics.LOCATION,
40058
40150
  category: ts.Diagnostics.Emit,
40059
40151
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -40062,6 +40154,7 @@ var ts;
40062
40154
  name: "inlineSourceMap",
40063
40155
  type: "boolean",
40064
40156
  affectsEmit: true,
40157
+ affectsMultiFileEmitBuildInfo: true,
40065
40158
  category: ts.Diagnostics.Emit,
40066
40159
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
40067
40160
  defaultValueDescription: false,
@@ -40070,6 +40163,7 @@ var ts;
40070
40163
  name: "inlineSources",
40071
40164
  type: "boolean",
40072
40165
  affectsEmit: true,
40166
+ affectsMultiFileEmitBuildInfo: true,
40073
40167
  category: ts.Diagnostics.Emit,
40074
40168
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
40075
40169
  defaultValueDescription: false,
@@ -40079,6 +40173,7 @@ var ts;
40079
40173
  name: "experimentalDecorators",
40080
40174
  type: "boolean",
40081
40175
  affectsSemanticDiagnostics: true,
40176
+ affectsMultiFileEmitBuildInfo: true,
40082
40177
  category: ts.Diagnostics.Language_and_Environment,
40083
40178
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
40084
40179
  defaultValueDescription: false,
@@ -40088,6 +40183,7 @@ var ts;
40088
40183
  type: "boolean",
40089
40184
  affectsSemanticDiagnostics: true,
40090
40185
  affectsEmit: true,
40186
+ affectsMultiFileEmitBuildInfo: true,
40091
40187
  category: ts.Diagnostics.Language_and_Environment,
40092
40188
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
40093
40189
  defaultValueDescription: false,
@@ -40112,6 +40208,7 @@ var ts;
40112
40208
  type: "string",
40113
40209
  affectsSemanticDiagnostics: true,
40114
40210
  affectsEmit: true,
40211
+ affectsMultiFileEmitBuildInfo: true,
40115
40212
  affectsModuleResolution: true,
40116
40213
  category: ts.Diagnostics.Language_and_Environment,
40117
40214
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -40129,6 +40226,9 @@ var ts;
40129
40226
  name: "out",
40130
40227
  type: "string",
40131
40228
  affectsEmit: true,
40229
+ affectsMultiFileEmitBuildInfo: true,
40230
+ affectsDeclarationPath: true,
40231
+ affectsBundleEmitBuildInfo: true,
40132
40232
  isFilePath: false,
40133
40233
  // for correct behaviour, please use outFile
40134
40234
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -40140,6 +40240,7 @@ var ts;
40140
40240
  name: "reactNamespace",
40141
40241
  type: "string",
40142
40242
  affectsEmit: true,
40243
+ affectsMultiFileEmitBuildInfo: true,
40143
40244
  category: ts.Diagnostics.Language_and_Environment,
40144
40245
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
40145
40246
  defaultValueDescription: "`React`",
@@ -40147,6 +40248,8 @@ var ts;
40147
40248
  {
40148
40249
  name: "skipDefaultLibCheck",
40149
40250
  type: "boolean",
40251
+ // We need to store these to determine whether `lib` files need to be rechecked
40252
+ affectsMultiFileEmitBuildInfo: true,
40150
40253
  category: ts.Diagnostics.Completeness,
40151
40254
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
40152
40255
  defaultValueDescription: false,
@@ -40162,6 +40265,7 @@ var ts;
40162
40265
  name: "emitBOM",
40163
40266
  type: "boolean",
40164
40267
  affectsEmit: true,
40268
+ affectsMultiFileEmitBuildInfo: true,
40165
40269
  category: ts.Diagnostics.Emit,
40166
40270
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
40167
40271
  defaultValueDescription: false,
@@ -40173,6 +40277,7 @@ var ts;
40173
40277
  lf: 1 /* LineFeed */
40174
40278
  })),
40175
40279
  affectsEmit: true,
40280
+ affectsMultiFileEmitBuildInfo: true,
40176
40281
  paramType: ts.Diagnostics.NEWLINE,
40177
40282
  category: ts.Diagnostics.Emit,
40178
40283
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -40182,6 +40287,7 @@ var ts;
40182
40287
  name: "noErrorTruncation",
40183
40288
  type: "boolean",
40184
40289
  affectsSemanticDiagnostics: true,
40290
+ affectsMultiFileEmitBuildInfo: true,
40185
40291
  category: ts.Diagnostics.Output_Formatting,
40186
40292
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
40187
40293
  defaultValueDescription: false,
@@ -40212,6 +40318,7 @@ var ts;
40212
40318
  name: "stripInternal",
40213
40319
  type: "boolean",
40214
40320
  affectsEmit: true,
40321
+ affectsMultiFileEmitBuildInfo: true,
40215
40322
  category: ts.Diagnostics.Emit,
40216
40323
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40217
40324
  defaultValueDescription: false,
@@ -40252,6 +40359,7 @@ var ts;
40252
40359
  name: "noImplicitUseStrict",
40253
40360
  type: "boolean",
40254
40361
  affectsSemanticDiagnostics: true,
40362
+ affectsMultiFileEmitBuildInfo: true,
40255
40363
  category: ts.Diagnostics.Backwards_Compatibility,
40256
40364
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40257
40365
  defaultValueDescription: false,
@@ -40260,6 +40368,7 @@ var ts;
40260
40368
  name: "noEmitHelpers",
40261
40369
  type: "boolean",
40262
40370
  affectsEmit: true,
40371
+ affectsMultiFileEmitBuildInfo: true,
40263
40372
  category: ts.Diagnostics.Emit,
40264
40373
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40265
40374
  defaultValueDescription: false,
@@ -40268,6 +40377,7 @@ var ts;
40268
40377
  name: "noEmitOnError",
40269
40378
  type: "boolean",
40270
40379
  affectsEmit: true,
40380
+ affectsMultiFileEmitBuildInfo: true,
40271
40381
  category: ts.Diagnostics.Emit,
40272
40382
  transpileOptionValue: undefined,
40273
40383
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40277,6 +40387,7 @@ var ts;
40277
40387
  name: "preserveConstEnums",
40278
40388
  type: "boolean",
40279
40389
  affectsEmit: true,
40390
+ affectsMultiFileEmitBuildInfo: true,
40280
40391
  category: ts.Diagnostics.Emit,
40281
40392
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40282
40393
  defaultValueDescription: false,
@@ -40285,6 +40396,8 @@ var ts;
40285
40396
  name: "declarationDir",
40286
40397
  type: "string",
40287
40398
  affectsEmit: true,
40399
+ affectsMultiFileEmitBuildInfo: true,
40400
+ affectsDeclarationPath: true,
40288
40401
  isFilePath: true,
40289
40402
  paramType: ts.Diagnostics.DIRECTORY,
40290
40403
  category: ts.Diagnostics.Emit,
@@ -40294,6 +40407,8 @@ var ts;
40294
40407
  {
40295
40408
  name: "skipLibCheck",
40296
40409
  type: "boolean",
40410
+ // We need to store these to determine whether `lib` files need to be rechecked
40411
+ affectsMultiFileEmitBuildInfo: true,
40297
40412
  category: ts.Diagnostics.Completeness,
40298
40413
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40299
40414
  defaultValueDescription: false,
@@ -40303,6 +40418,7 @@ var ts;
40303
40418
  type: "boolean",
40304
40419
  affectsBindDiagnostics: true,
40305
40420
  affectsSemanticDiagnostics: true,
40421
+ affectsMultiFileEmitBuildInfo: true,
40306
40422
  category: ts.Diagnostics.Type_Checking,
40307
40423
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40308
40424
  defaultValueDescription: undefined,
@@ -40312,6 +40428,7 @@ var ts;
40312
40428
  type: "boolean",
40313
40429
  affectsBindDiagnostics: true,
40314
40430
  affectsSemanticDiagnostics: true,
40431
+ affectsMultiFileEmitBuildInfo: true,
40315
40432
  category: ts.Diagnostics.Type_Checking,
40316
40433
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40317
40434
  defaultValueDescription: undefined,
@@ -40320,6 +40437,7 @@ var ts;
40320
40437
  name: "suppressExcessPropertyErrors",
40321
40438
  type: "boolean",
40322
40439
  affectsSemanticDiagnostics: true,
40440
+ affectsMultiFileEmitBuildInfo: true,
40323
40441
  category: ts.Diagnostics.Backwards_Compatibility,
40324
40442
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40325
40443
  defaultValueDescription: false,
@@ -40328,6 +40446,7 @@ var ts;
40328
40446
  name: "suppressImplicitAnyIndexErrors",
40329
40447
  type: "boolean",
40330
40448
  affectsSemanticDiagnostics: true,
40449
+ affectsMultiFileEmitBuildInfo: true,
40331
40450
  category: ts.Diagnostics.Backwards_Compatibility,
40332
40451
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40333
40452
  defaultValueDescription: false,
@@ -40352,6 +40471,7 @@ var ts;
40352
40471
  name: "noStrictGenericChecks",
40353
40472
  type: "boolean",
40354
40473
  affectsSemanticDiagnostics: true,
40474
+ affectsMultiFileEmitBuildInfo: true,
40355
40475
  category: ts.Diagnostics.Backwards_Compatibility,
40356
40476
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40357
40477
  defaultValueDescription: false,
@@ -40361,6 +40481,7 @@ var ts;
40361
40481
  type: "boolean",
40362
40482
  affectsSemanticDiagnostics: true,
40363
40483
  affectsEmit: true,
40484
+ affectsMultiFileEmitBuildInfo: true,
40364
40485
  category: ts.Diagnostics.Language_and_Environment,
40365
40486
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40366
40487
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40369,6 +40490,7 @@ var ts;
40369
40490
  name: "preserveValueImports",
40370
40491
  type: "boolean",
40371
40492
  affectsEmit: true,
40493
+ affectsMultiFileEmitBuildInfo: true,
40372
40494
  category: ts.Diagnostics.Emit,
40373
40495
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40374
40496
  defaultValueDescription: false,
@@ -40412,6 +40534,8 @@ var ts;
40412
40534
  /* @internal */
40413
40535
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40414
40536
  /* @internal */
40537
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40538
+ /* @internal */
40415
40539
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40416
40540
  /* @internal */
40417
40541
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41267,6 +41391,7 @@ var ts;
41267
41391
  return optionDefinition.type;
41268
41392
  }
41269
41393
  }
41394
+ /* @internal */
41270
41395
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41271
41396
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41272
41397
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41275,6 +41400,7 @@ var ts;
41275
41400
  }
41276
41401
  });
41277
41402
  }
41403
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41278
41404
  function serializeCompilerOptions(options, pathOptions) {
41279
41405
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41280
41406
  }
@@ -42440,16 +42566,18 @@ var ts;
42440
42566
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42441
42567
  return { fileName: resolved.path, packageId: resolved.packageId };
42442
42568
  }
42443
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42444
- var _a;
42569
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42570
+ var _a, _b;
42445
42571
  if (resultFromCache) {
42446
42572
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42573
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42447
42574
  return resultFromCache;
42448
42575
  }
42449
42576
  return {
42450
42577
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42451
42578
  failedLookupLocations: failedLookupLocations,
42452
- resolutionDiagnostics: diagnostics
42579
+ affectingLocations: affectingLocations,
42580
+ resolutionDiagnostics: diagnostics,
42453
42581
  };
42454
42582
  }
42455
42583
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42638,6 +42766,7 @@ var ts;
42638
42766
  }
42639
42767
  }
42640
42768
  var failedLookupLocations = [];
42769
+ var affectingLocations = [];
42641
42770
  var features = getDefaultNodeResolutionFeatures(options);
42642
42771
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42643
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
@@ -42656,6 +42785,7 @@ var ts;
42656
42785
  host: host,
42657
42786
  traceEnabled: traceEnabled,
42658
42787
  failedLookupLocations: failedLookupLocations,
42788
+ affectingLocations: affectingLocations,
42659
42789
  packageJsonInfoCache: cache,
42660
42790
  features: features,
42661
42791
  conditions: conditions,
@@ -42680,7 +42810,7 @@ var ts;
42680
42810
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42681
42811
  };
42682
42812
  }
42683
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42813
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42684
42814
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42685
42815
  if (traceEnabled)
42686
42816
  traceResult(result);
@@ -42760,6 +42890,7 @@ var ts;
42760
42890
  host: host,
42761
42891
  traceEnabled: isTraceEnabled(options, host),
42762
42892
  failedLookupLocations: [],
42893
+ affectingLocations: [],
42763
42894
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42764
42895
  conditions: ts.emptyArray,
42765
42896
  features: NodeResolutionFeatures.None,
@@ -43414,6 +43545,7 @@ var ts;
43414
43545
  var _a, _b;
43415
43546
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43416
43547
  var failedLookupLocations = [];
43548
+ var affectingLocations = [];
43417
43549
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43418
43550
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43419
43551
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43426,6 +43558,7 @@ var ts;
43426
43558
  host: host,
43427
43559
  traceEnabled: traceEnabled,
43428
43560
  failedLookupLocations: failedLookupLocations,
43561
+ affectingLocations: affectingLocations,
43429
43562
  packageJsonInfoCache: cache,
43430
43563
  features: features,
43431
43564
  conditions: conditions,
@@ -43433,7 +43566,7 @@ var ts;
43433
43566
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43434
43567
  };
43435
43568
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43436
- 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);
43437
43570
  function tryResolve(extensions) {
43438
43571
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43439
43572
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43728,6 +43861,7 @@ var ts;
43728
43861
  host: host,
43729
43862
  traceEnabled: isTraceEnabled(options, host),
43730
43863
  failedLookupLocations: [],
43864
+ affectingLocations: [],
43731
43865
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43732
43866
  conditions: ["node", "require", "types"],
43733
43867
  features: features,
@@ -43816,6 +43950,7 @@ var ts;
43816
43950
  compilerOptions: options,
43817
43951
  traceEnabled: isTraceEnabled(options, host),
43818
43952
  failedLookupLocations: [],
43953
+ affectingLocations: [],
43819
43954
  packageJsonInfoCache: packageJsonInfoCache,
43820
43955
  features: 0,
43821
43956
  conditions: [],
@@ -43848,6 +43983,7 @@ var ts;
43848
43983
  if (typeof existing !== "boolean") {
43849
43984
  if (traceEnabled)
43850
43985
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43986
+ state.affectingLocations.push(packageJsonPath);
43851
43987
  return existing;
43852
43988
  }
43853
43989
  else {
@@ -43866,6 +44002,7 @@ var ts;
43866
44002
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43867
44003
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43868
44004
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
44005
+ state.affectingLocations.push(packageJsonPath);
43869
44006
  return result;
43870
44007
  }
43871
44008
  else {
@@ -44529,12 +44666,25 @@ var ts;
44529
44666
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44530
44667
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44531
44668
  var failedLookupLocations = [];
44669
+ var affectingLocations = [];
44532
44670
  var containingDirectory = ts.getDirectoryPath(containingFile);
44533
44671
  var diagnostics = [];
44534
- 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
+ };
44535
44684
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44536
44685
  // No originalPath because classic resolution doesn't resolve realPath
44537
- 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);
44538
44688
  function tryResolve(extensions) {
44539
44689
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44540
44690
  if (resolvedUsingSettings) {
@@ -44577,10 +44727,23 @@ var ts;
44577
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);
44578
44728
  }
44579
44729
  var failedLookupLocations = [];
44730
+ var affectingLocations = [];
44580
44731
  var diagnostics = [];
44581
- 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
+ };
44582
44744
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44583
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44745
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44746
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44584
44747
  }
44585
44748
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44586
44749
  /**
@@ -48141,16 +48304,6 @@ var ts;
48141
48304
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
48142
48305
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
48143
48306
  })(TypeFacts || (TypeFacts = {}));
48144
- var typeofEQFacts = new ts.Map(ts.getEntries({
48145
- string: 1 /* TypeofEQString */,
48146
- number: 2 /* TypeofEQNumber */,
48147
- bigint: 4 /* TypeofEQBigInt */,
48148
- boolean: 8 /* TypeofEQBoolean */,
48149
- symbol: 16 /* TypeofEQSymbol */,
48150
- undefined: 65536 /* EQUndefined */,
48151
- object: 32 /* TypeofEQObject */,
48152
- function: 64 /* TypeofEQFunction */
48153
- }));
48154
48307
  var typeofNEFacts = new ts.Map(ts.getEntries({
48155
48308
  string: 256 /* TypeofNEString */,
48156
48309
  number: 512 /* TypeofNENumber */,
@@ -48949,14 +49102,6 @@ var ts;
48949
49102
  var awaitedTypeStack = [];
48950
49103
  var diagnostics = ts.createDiagnosticCollection();
48951
49104
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48952
- var typeofTypesByName = new ts.Map(ts.getEntries({
48953
- string: stringType,
48954
- number: numberType,
48955
- bigint: bigintType,
48956
- boolean: booleanType,
48957
- symbol: esSymbolType,
48958
- undefined: undefinedType
48959
- }));
48960
49105
  var typeofType = createTypeofType();
48961
49106
  var _jsxNamespace;
48962
49107
  var _jsxFactoryEntity;
@@ -51832,7 +51977,7 @@ var ts;
51832
51977
  return type;
51833
51978
  }
51834
51979
  function createTypeofType() {
51835
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51980
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51836
51981
  }
51837
51982
  function createTypeParameter(symbol) {
51838
51983
  var type = createType(262144 /* TypeParameter */);
@@ -52618,6 +52763,9 @@ var ts;
52618
52763
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52619
52764
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52620
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
+ }
52621
52769
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52622
52770
  }
52623
52771
  var objectFlags = ts.getObjectFlags(type);
@@ -52808,7 +52956,7 @@ var ts;
52808
52956
  // Always use 'typeof T' for type of class, enum, and module objects
52809
52957
  else if (symbol.flags & 32 /* Class */
52810
52958
  && !getBaseTypeVariableOfClass(symbol)
52811
- && !(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 */)) ||
52812
52960
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52813
52961
  shouldWriteTypeOfFunctionSymbol()) {
52814
52962
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56438,6 +56586,17 @@ var ts;
56438
56586
  });
56439
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
56440
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
+ }
56441
56600
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56442
56601
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56443
56602
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -64621,6 +64780,9 @@ var ts;
64621
64780
  }
64622
64781
  return false;
64623
64782
  }
64783
+ function containsUndefinedType(type) {
64784
+ return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
64785
+ }
64624
64786
  function isStringIndexSignatureOnlyType(type) {
64625
64787
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64626
64788
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -70043,19 +70205,17 @@ var ts;
70043
70205
  }
70044
70206
  return links.switchTypes;
70045
70207
  }
70046
- 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
+ }
70047
70214
  var witnesses = [];
70048
70215
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
70049
70216
  var clause = _a[_i];
70050
- if (clause.kind === 289 /* CaseClause */) {
70051
- if (ts.isStringLiteralLike(clause.expression)) {
70052
- witnesses.push(clause.expression.text);
70053
- continue;
70054
- }
70055
- return ts.emptyArray;
70056
- }
70057
- if (retainDefault)
70058
- 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);
70059
70219
  }
70060
70220
  return witnesses;
70061
70221
  }
@@ -71245,14 +71405,9 @@ var ts;
71245
71405
  }
71246
71406
  return type;
71247
71407
  }
71248
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71249
- return type;
71250
- }
71251
- var facts = assumeTrue ?
71252
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71253
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71254
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71255
- 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 */);
71256
71411
  }
71257
71412
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71258
71413
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71299,102 +71454,52 @@ var ts;
71299
71454
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71300
71455
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71301
71456
  }
71302
- function getImpliedTypeFromTypeofGuard(type, text) {
71303
- switch (text) {
71304
- case "object":
71305
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71306
- case "function":
71307
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71308
- default:
71309
- 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 */);
71310
71467
  }
71468
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71311
71469
  }
71312
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71313
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71314
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71315
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71316
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71317
- // filtering by type-facts.
71318
- function narrowTypeByImpliedType(type, candidate) {
71319
- if (type.flags & 3 /* AnyOrUnknown */) {
71320
- return candidate;
71321
- }
71470
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71322
71471
  return mapType(type, function (t) {
71323
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71324
- return t;
71325
- }
71326
- return mapType(candidate, function (c) {
71327
- if (!areTypesComparable(t, c)) {
71328
- return neverType;
71329
- }
71330
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71331
- return isTypeSubtypeOf(c, t) ? c : neverType;
71332
- }
71333
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71334
- return c;
71335
- }
71336
- return getIntersectionType([t, c]);
71337
- });
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;
71338
71485
  });
71339
71486
  }
71340
71487
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71341
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71342
- if (!switchWitnesses.length) {
71488
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71489
+ if (!witnesses) {
71343
71490
  return type;
71344
71491
  }
71345
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71346
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71347
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71348
- var clauseWitnesses;
71349
- var switchFacts;
71350
- if (defaultCaseLocation > -1) {
71351
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71352
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71353
- // witness array.
71354
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71355
- // The adjusted clause start and end after removing the `default` statement.
71356
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71357
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71358
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71359
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71360
- }
71361
- else {
71362
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71363
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71364
- }
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);
71365
71495
  if (hasDefaultClause) {
71366
- 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; });
71367
71499
  }
71368
- /*
71369
- The implied type is the raw type suggested by a
71370
- value being caught in this clause.
71371
-
71372
- When the clause contains a default case we ignore
71373
- the implied type and try to narrow using any facts
71374
- we can learn: see `switchFacts`.
71375
-
71376
- Example:
71377
- switch (typeof x) {
71378
- case 'number':
71379
- case 'string': break;
71380
- default: break;
71381
- case 'number':
71382
- case 'boolean': break
71383
- }
71384
-
71385
- In the first clause (case `number` and `string`) the
71386
- implied type is number | string.
71387
-
71388
- In the default clause we de not compute an implied type.
71389
-
71390
- In the third clause (case `number` and `boolean`)
71391
- the naive implied type is number | boolean, however
71392
- we use the type facts to narrow the implied type to
71393
- boolean. We know that number cannot be selected
71394
- because it is caught in the first clause.
71395
- */
71396
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71397
- 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; }));
71398
71503
  }
71399
71504
  function isMatchingConstructorReference(expr) {
71400
71505
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -72005,7 +72110,7 @@ var ts;
72005
72110
  return convertAutoToAny(flowType);
72006
72111
  }
72007
72112
  }
72008
- else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
72113
+ else if (!assumeInitialized && !containsUndefinedType(type) && containsUndefinedType(flowType)) {
72009
72114
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
72010
72115
  // Return the declared type to reduce follow-on errors
72011
72116
  return type;
@@ -75016,7 +75121,7 @@ var ts;
75016
75121
  assumeUninitialized = true;
75017
75122
  }
75018
75123
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
75019
- if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
75124
+ if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) {
75020
75125
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
75021
75126
  // Return the declared type to reduce follow-on errors
75022
75127
  return propType;
@@ -78206,45 +78311,12 @@ var ts;
78206
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
78207
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);
78208
78313
  }
78209
- /**
78210
- * Collect the TypeFacts learned from a typeof switch with
78211
- * total clauses `witnesses`, and the active clause ranging
78212
- * from `start` to `end`. Parameter `hasDefault` denotes
78213
- * whether the active clause contains a default clause.
78214
- */
78215
- 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) {
78216
78316
  var facts = 0 /* None */;
78217
- // When in the default we only collect inequality facts
78218
- // because default is 'in theory' a set of infinite
78219
- // equalities.
78220
- if (hasDefault) {
78221
- // Value is not equal to any types after the active clause.
78222
- for (var i = end; i < witnesses.length; i++) {
78223
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78224
- }
78225
- // Remove inequalities for types that appear in the
78226
- // active clause because they appear before other
78227
- // types collected so far.
78228
- for (var i = start; i < end; i++) {
78229
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78230
- }
78231
- // Add inequalities for types before the active clause unconditionally.
78232
- for (var i = 0; i < start; i++) {
78233
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78234
- }
78235
- }
78236
- // When in an active clause without default the set of
78237
- // equalities is finite.
78238
- else {
78239
- // Add equalities for all types in the active clause.
78240
- for (var i = start; i < end; i++) {
78241
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78242
- }
78243
- // Remove equalities for types that appear before the
78244
- // active clause.
78245
- for (var i = 0; i < start; i++) {
78246
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78247
- }
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;
78248
78320
  }
78249
78321
  return facts;
78250
78322
  }
@@ -78254,16 +78326,19 @@ var ts;
78254
78326
  }
78255
78327
  function computeExhaustiveSwitchStatement(node) {
78256
78328
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78257
- var operandType = getTypeOfExpression(node.expression.expression);
78258
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78259
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78260
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78261
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78262
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78263
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78264
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
78329
+ var witnesses = getSwitchClauseTypeOfWitnesses(node);
78330
+ if (!witnesses) {
78331
+ return false;
78332
+ }
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 */;
78265
78339
  }
78266
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
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; });
78267
78342
  }
78268
78343
  var type = getTypeOfExpression(node.expression);
78269
78344
  if (!isLiteralType(type)) {
@@ -82095,6 +82170,11 @@ var ts;
82095
82170
  function checkJSDocTypeTag(node) {
82096
82171
  checkSourceElement(node.typeExpression);
82097
82172
  }
82173
+ function checkJSDocLinkLikeTag(node) {
82174
+ if (node.name) {
82175
+ resolveJSDocMemberName(node.name, /*ignoreErrors*/ true);
82176
+ }
82177
+ }
82098
82178
  function checkJSDocParameterTag(node) {
82099
82179
  checkSourceElement(node.typeExpression);
82100
82180
  }
@@ -84866,7 +84946,7 @@ var ts;
84866
84946
  var propName = member.name;
84867
84947
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84868
84948
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84869
- if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84949
+ if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) {
84870
84950
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84871
84951
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84872
84952
  }
@@ -84891,7 +84971,7 @@ var ts;
84891
84971
  ts.setParent(reference, staticBlock);
84892
84972
  reference.flowNode = staticBlock.returnFlowNode;
84893
84973
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84894
- if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84974
+ if (!containsUndefinedType(flowType)) {
84895
84975
  return true;
84896
84976
  }
84897
84977
  }
@@ -84906,7 +84986,7 @@ var ts;
84906
84986
  ts.setParent(reference, constructor);
84907
84987
  reference.flowNode = constructor.returnFlowNode;
84908
84988
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84909
- return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84989
+ return !containsUndefinedType(flowType);
84910
84990
  }
84911
84991
  function checkInterfaceDeclaration(node) {
84912
84992
  // Grammar checking
@@ -85889,12 +85969,16 @@ var ts;
85889
85969
  }
85890
85970
  }
85891
85971
  function checkSourceElementWorker(node) {
85892
- if (ts.isInJSFile(node)) {
85893
- ts.forEach(node.jsDoc, function (_a) {
85894
- var tags = _a.tags;
85895
- return ts.forEach(tags, checkSourceElement);
85972
+ ts.forEach(node.jsDoc, function (_a) {
85973
+ var comment = _a.comment, tags = _a.tags;
85974
+ checkJSDocCommentWorker(comment);
85975
+ ts.forEach(tags, function (tag) {
85976
+ checkJSDocCommentWorker(tag.comment);
85977
+ if (ts.isInJSFile(node)) {
85978
+ checkSourceElement(tag);
85979
+ }
85896
85980
  });
85897
- }
85981
+ });
85898
85982
  var kind = node.kind;
85899
85983
  if (cancellationToken) {
85900
85984
  // Only bother checking on a few construct kinds. We don't want to be excessively
@@ -85980,6 +86064,10 @@ var ts;
85980
86064
  return checkJSDocTemplateTag(node);
85981
86065
  case 343 /* JSDocTypeTag */:
85982
86066
  return checkJSDocTypeTag(node);
86067
+ case 324 /* JSDocLink */:
86068
+ case 325 /* JSDocLinkCode */:
86069
+ case 326 /* JSDocLinkPlain */:
86070
+ return checkJSDocLinkLikeTag(node);
85983
86071
  case 340 /* JSDocParameterTag */:
85984
86072
  return checkJSDocParameterTag(node);
85985
86073
  case 347 /* JSDocPropertyTag */:
@@ -86074,6 +86162,15 @@ var ts;
86074
86162
  return checkMissingDeclaration(node);
86075
86163
  }
86076
86164
  }
86165
+ function checkJSDocCommentWorker(node) {
86166
+ if (ts.isArray(node)) {
86167
+ ts.forEach(node, function (tag) {
86168
+ if (ts.isJSDocLinkLike(tag)) {
86169
+ checkSourceElement(tag);
86170
+ }
86171
+ });
86172
+ }
86173
+ }
86077
86174
  function checkJSDocTypeIsInJsFile(node) {
86078
86175
  if (!ts.isInJSFile(node)) {
86079
86176
  grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
@@ -86629,7 +86726,7 @@ var ts;
86629
86726
  if (!result && isJSDoc_1) {
86630
86727
  var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
86631
86728
  if (container) {
86632
- return resolveJSDocMemberName(name, getSymbolOfNode(container));
86729
+ return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
86633
86730
  }
86634
86731
  }
86635
86732
  return result;
@@ -86675,11 +86772,11 @@ var ts;
86675
86772
  *
86676
86773
  * For unqualified names, a container K may be provided as a second argument.
86677
86774
  */
86678
- function resolveJSDocMemberName(name, container) {
86775
+ function resolveJSDocMemberName(name, ignoreErrors, container) {
86679
86776
  if (ts.isEntityName(name)) {
86680
86777
  // resolve static values first
86681
86778
  var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */;
86682
- var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86779
+ var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86683
86780
  if (!symbol && ts.isIdentifier(name) && container) {
86684
86781
  symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning));
86685
86782
  }
@@ -86687,7 +86784,7 @@ var ts;
86687
86784
  return symbol;
86688
86785
  }
86689
86786
  }
86690
- var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left);
86787
+ var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container);
86691
86788
  var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText;
86692
86789
  if (left) {
86693
86790
  var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype");
@@ -110976,7 +111073,9 @@ var ts;
110976
111073
  return;
110977
111074
  }
110978
111075
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110979
- 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 });
110980
111079
  }
110981
111080
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110982
111081
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -111130,13 +111229,20 @@ var ts;
111130
111229
  if (sourceMapFilePath) {
111131
111230
  var sourceMap = sourceMapGenerator.toString();
111132
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));
111133
111234
  }
111134
111235
  }
111135
111236
  else {
111136
111237
  writer.writeLine();
111137
111238
  }
111138
111239
  // Write the output file
111139
- 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));
111140
111246
  // Reset state
111141
111247
  writer.clear();
111142
111248
  }
@@ -111279,34 +111385,56 @@ var ts;
111279
111385
  }
111280
111386
  /*@internal*/
111281
111387
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111388
+ var createHash = ts.maybeBind(host, host.createHash);
111282
111389
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111283
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111284
- 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))
111285
111405
  return buildInfoPath;
111286
111406
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111287
111407
  if (!jsFileText)
111288
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;
111289
111412
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111290
111413
  // error if no source map or for now if inline sourcemap
111291
111414
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111292
111415
  return sourceMapFilePath || "inline sourcemap decoding";
111416
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111417
+ return sourceMapFilePath;
111293
111418
  // read declaration text
111294
111419
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111295
111420
  if (declarationFilePath && !declarationText)
111296
111421
  return declarationFilePath;
111422
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111423
+ return declarationFilePath;
111297
111424
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111298
111425
  // error if no source map or for now if inline sourcemap
111299
111426
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111300
111427
  return declarationMapPath || "inline sourcemap decoding";
111301
- var buildInfo = getBuildInfo(buildInfoText);
111302
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111303
- return buildInfoPath;
111428
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111429
+ return declarationMapPath;
111304
111430
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111305
111431
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111306
111432
  /*onlyOwnText*/ true);
111307
111433
  var outputFiles = [];
111308
111434
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111309
111435
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111436
+ var changedDtsText;
111437
+ var changedDtsData;
111310
111438
  var emitHost = {
111311
111439
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111312
111440
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111322,7 +111450,7 @@ var ts;
111322
111450
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111323
111451
  getProjectReferenceRedirect: ts.returnUndefined,
111324
111452
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111325
- writeFile: function (name, text, writeByteOrderMark) {
111453
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111326
111454
  switch (name) {
111327
111455
  case jsFilePath:
111328
111456
  if (jsFileText === text)
@@ -111333,8 +111461,13 @@ var ts;
111333
111461
  return;
111334
111462
  break;
111335
111463
  case buildInfoPath:
111336
- var newBuildInfo = getBuildInfo(text);
111464
+ var newBuildInfo = data.buildInfo;
111337
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
+ }
111338
111471
  // Update sourceFileInfo
111339
111472
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111340
111473
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111342,11 +111475,13 @@ var ts;
111342
111475
  newBuildInfo.bundle.dts.sources = dts.sources;
111343
111476
  }
111344
111477
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111345
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111478
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111346
111479
  return;
111347
111480
  case declarationFilePath:
111348
111481
  if (declarationText === text)
111349
111482
  return;
111483
+ changedDtsText = text;
111484
+ changedDtsData = data;
111350
111485
  break;
111351
111486
  case declarationMapPath:
111352
111487
  if (declarationMapText === text)
@@ -111365,6 +111500,7 @@ var ts;
111365
111500
  getSourceFileFromReference: ts.returnUndefined,
111366
111501
  redirectTargetsMap: ts.createMultiMap(),
111367
111502
  getFileIncludeReasons: ts.notImplemented,
111503
+ createHash: createHash,
111368
111504
  };
111369
111505
  emitFiles(ts.notImplementedResolver, emitHost,
111370
111506
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116449,12 +116585,10 @@ var ts;
116449
116585
  }
116450
116586
  ts.createCompilerHost = createCompilerHost;
116451
116587
  /*@internal*/
116452
- // TODO(shkamat): update this after reworking ts build API
116453
116588
  function createCompilerHostWorker(options, setParentNodes, system) {
116454
116589
  if (system === void 0) { system = ts.sys; }
116455
116590
  var existingDirectories = new ts.Map();
116456
116591
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116457
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116458
116592
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116459
116593
  var text;
116460
116594
  try {
@@ -116487,7 +116621,7 @@ var ts;
116487
116621
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116488
116622
  // the system.writeFile will do its own directory creation and
116489
116623
  // the ensureDirectoriesExist call will always be redundant.
116490
- 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); });
116491
116625
  ts.performance.mark("afterIOWrite");
116492
116626
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116493
116627
  }
@@ -116497,35 +116631,6 @@ var ts;
116497
116631
  }
116498
116632
  }
116499
116633
  }
116500
- var outputFingerprints;
116501
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116502
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116503
- system.writeFile(fileName, data, writeByteOrderMark);
116504
- return;
116505
- }
116506
- if (!outputFingerprints) {
116507
- outputFingerprints = new ts.Map();
116508
- }
116509
- var hash = computeHash(data);
116510
- var mtimeBefore = system.getModifiedTime(fileName);
116511
- if (mtimeBefore) {
116512
- var fingerprint = outputFingerprints.get(fileName);
116513
- // If output has not been changed, and the file has no external modification
116514
- if (fingerprint &&
116515
- fingerprint.byteOrderMark === writeByteOrderMark &&
116516
- fingerprint.hash === hash &&
116517
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116518
- return;
116519
- }
116520
- }
116521
- system.writeFile(fileName, data, writeByteOrderMark);
116522
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116523
- outputFingerprints.set(fileName, {
116524
- hash: hash,
116525
- byteOrderMark: writeByteOrderMark,
116526
- mtime: mtimeAfter
116527
- });
116528
- }
116529
116634
  function getDefaultLibLocation() {
116530
116635
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116531
116636
  }
@@ -118125,6 +118230,7 @@ var ts;
118125
118230
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
118126
118231
  redirectTargetsMap: redirectTargetsMap,
118127
118232
  getFileIncludeReasons: program.getFileIncludeReasons,
118233
+ createHash: ts.maybeBind(host, host.createHash),
118128
118234
  };
118129
118235
  }
118130
118236
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120238,13 +120344,9 @@ var ts;
120238
120344
  function createManyToManyPathMap() {
120239
120345
  function create(forward, reverse, deleted) {
120240
120346
  var map = {
120241
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120242
- forEach: function (fn) { return forward.forEach(fn); },
120243
120347
  getKeys: function (v) { return reverse.get(v); },
120244
120348
  getValues: function (k) { return forward.get(k); },
120245
- hasKey: function (k) { return forward.has(k); },
120246
120349
  keys: function () { return forward.keys(); },
120247
- deletedKeys: function () { return deleted; },
120248
120350
  deleteKey: function (k) {
120249
120351
  (deleted || (deleted = new ts.Set())).add(k);
120250
120352
  var set = forward.get(k);
@@ -120271,11 +120373,6 @@ var ts;
120271
120373
  });
120272
120374
  return map;
120273
120375
  },
120274
- clear: function () {
120275
- forward.clear();
120276
- reverse.clear();
120277
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120278
- }
120279
120376
  };
120280
120377
  return map;
120281
120378
  }
@@ -120403,18 +120500,21 @@ var ts;
120403
120500
  * Creates the state of file references and signature for the new program from oldState if it is safe
120404
120501
  */
120405
120502
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120503
+ var _a, _b, _c;
120406
120504
  var fileInfos = new ts.Map();
120407
120505
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120408
120506
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120409
- var hasCalledUpdateShapeSignature = new ts.Set();
120410
120507
  var useOldState = canReuseOldState(referencedMap, oldState);
120411
120508
  // Ensure source files have parent pointers set
120412
120509
  newProgram.getTypeChecker();
120413
120510
  // Create the reference map, and set the file infos
120414
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120415
- var sourceFile = _a[_i];
120511
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120512
+ var sourceFile = _d[_i];
120416
120513
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120417
- 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;
120418
120518
  if (referencedMap) {
120419
120519
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120420
120520
  if (newReferences) {
@@ -120422,19 +120522,26 @@ var ts;
120422
120522
  }
120423
120523
  // Copy old visible to outside files map
120424
120524
  if (useOldState) {
120425
- 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;
120426
120529
  if (exportedModules) {
120427
120530
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120428
120531
  }
120429
120532
  }
120430
120533
  }
120431
- 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
+ });
120432
120540
  }
120433
120541
  return {
120434
120542
  fileInfos: fileInfos,
120435
120543
  referencedMap: referencedMap,
120436
120544
  exportedModulesMap: exportedModulesMap,
120437
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120438
120545
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120439
120546
  };
120440
120547
  }
@@ -120448,71 +120555,42 @@ var ts;
120448
120555
  }
120449
120556
  BuilderState.releaseCache = releaseCache;
120450
120557
  /**
120451
- * Creates a clone of the state
120558
+ * Gets the files affected by the path from the program
120452
120559
  */
120453
- function clone(state) {
120560
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120454
120561
  var _a, _b;
120455
- // Dont need to backup allFiles info since its cache anyway
120456
- return {
120457
- fileInfos: new ts.Map(state.fileInfos),
120458
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120459
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120460
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120461
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120462
- };
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;
120463
120566
  }
120464
- BuilderState.clone = clone;
120465
- /**
120466
- * Gets the files affected by the path from the program
120467
- */
120468
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120469
- // Since the operation could be cancelled, the signatures are always stored in the cache
120470
- // They will be committed once it is safe to use them
120471
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120472
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120473
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120567
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120568
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120474
120569
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120475
120570
  if (!sourceFile) {
120476
120571
  return ts.emptyArray;
120477
120572
  }
120478
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120573
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120479
120574
  return [sourceFile];
120480
120575
  }
120481
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120482
- if (!cacheToUpdateSignature) {
120483
- // Commit all the signatures in the signature cache
120484
- updateSignaturesFromCache(state, signatureCache);
120485
- }
120486
- return result;
120487
- }
120488
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120489
- /**
120490
- * Updates the signatures from the cache into state's fileinfo signatures
120491
- * This should be called whenever it is safe to commit the state of the builder
120492
- */
120493
- function updateSignaturesFromCache(state, signatureCache) {
120494
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120576
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120495
120577
  }
120496
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120578
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120497
120579
  function updateSignatureOfFile(state, signature, path) {
120498
120580
  state.fileInfos.get(path).signature = signature;
120499
- state.hasCalledUpdateShapeSignature.add(path);
120581
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120500
120582
  }
120501
120583
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120502
120584
  /**
120503
120585
  * Returns if the shape of the signature has changed since last emit
120504
120586
  */
120505
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120587
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120588
+ var _a;
120506
120589
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120507
- ts.Debug.assert(!!sourceFile);
120508
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120509
120590
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120510
- 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))
120511
120592
  return false;
120512
- }
120513
120593
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120514
- if (!info)
120515
- return ts.Debug.fail();
120516
120594
  var prevSignature = info.signature;
120517
120595
  var latestSignature;
120518
120596
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120523,45 +120601,55 @@ var ts;
120523
120601
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120524
120602
  if (firstDts_1) {
120525
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; })); });
120526
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120527
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120528
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120604
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120605
+ if (latestSignature !== prevSignature) {
120606
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120529
120607
  }
120530
120608
  }
120531
120609
  }
120532
120610
  // Default is to use file version as signature
120533
120611
  if (latestSignature === undefined) {
120534
120612
  latestSignature = sourceFile.version;
120535
- 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);
120536
120615
  // All the references in this file are exported
120537
120616
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120538
120617
  if (references) {
120539
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120618
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120540
120619
  }
120541
120620
  else {
120542
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120621
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120543
120622
  }
120544
120623
  }
120545
120624
  }
120546
- 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;
120547
120628
  return latestSignature !== prevSignature;
120548
120629
  }
120549
120630
  BuilderState.updateShapeSignature = updateShapeSignature;
120631
+ function computeSignature(text, computeHash) {
120632
+ return (computeHash || ts.generateDjb2Hash)(text);
120633
+ }
120634
+ BuilderState.computeSignature = computeSignature;
120550
120635
  /**
120551
120636
  * Coverts the declaration emit result into exported modules map
120552
120637
  */
120553
- 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);
120554
120642
  if (!exportedModulesFromDeclarationEmit) {
120555
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120643
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120556
120644
  return;
120557
120645
  }
120558
120646
  var exportedModules;
120559
120647
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120560
120648
  if (exportedModules) {
120561
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120649
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120562
120650
  }
120563
120651
  else {
120564
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120652
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120565
120653
  }
120566
120654
  function addExportedModule(exportedModulePaths) {
120567
120655
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120573,19 +120661,6 @@ var ts;
120573
120661
  }
120574
120662
  }
120575
120663
  BuilderState.updateExportedModules = updateExportedModules;
120576
- /**
120577
- * Updates the exported modules from cache into state's exported modules map
120578
- * This should be called whenever it is safe to commit the state of the builder
120579
- */
120580
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120581
- var _a;
120582
- if (exportedModulesMapCache) {
120583
- ts.Debug.assert(!!state.exportedModulesMap);
120584
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120585
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120586
- }
120587
- }
120588
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120589
120664
  /**
120590
120665
  * Get all the dependencies of the sourceFile
120591
120666
  */
@@ -120706,7 +120781,7 @@ var ts;
120706
120781
  /**
120707
120782
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120708
120783
  */
120709
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120784
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120710
120785
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120711
120786
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120712
120787
  }
@@ -120726,7 +120801,7 @@ var ts;
120726
120801
  if (!seenFileNamesMap.has(currentPath)) {
120727
120802
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120728
120803
  seenFileNamesMap.set(currentPath, currentSourceFile);
120729
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120804
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120730
120805
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120731
120806
  }
120732
120807
  }
@@ -120752,32 +120827,33 @@ var ts;
120752
120827
  * Create the state so that we can iterate on changedFiles/affected files
120753
120828
  */
120754
120829
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120830
+ var _a, _b;
120755
120831
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120756
120832
  state.program = newProgram;
120757
120833
  var compilerOptions = newProgram.getCompilerOptions();
120758
120834
  state.compilerOptions = compilerOptions;
120835
+ var outFilePath = ts.outFile(compilerOptions);
120759
120836
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120760
- if (!ts.outFile(compilerOptions)) {
120837
+ if (!outFilePath) {
120761
120838
  state.semanticDiagnosticsPerFile = new ts.Map();
120762
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
+ }
120763
120843
  state.changedFilesSet = new ts.Set();
120844
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120764
120845
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120765
120846
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120766
120847
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120767
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);
120768
120853
  if (useOldState) {
120769
- // Verify the sanity of old state
120770
- if (!oldState.currentChangedFilePath) {
120771
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120772
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120773
- }
120774
- var changedFilesSet = oldState.changedFilesSet;
120775
- if (canCopySemanticDiagnostics) {
120776
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120777
- }
120778
120854
  // Copy old state's changed files set
120779
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120780
- 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) {
120781
120857
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120782
120858
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120783
120859
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120798,6 +120874,8 @@ var ts;
120798
120874
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120799
120875
  // versions dont match
120800
120876
  oldInfo.version !== info.version ||
120877
+ // Implied formats dont match
120878
+ oldInfo.impliedFormat !== info.impliedFormat ||
120801
120879
  // Referenced files changed
120802
120880
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120803
120881
  // Referenced file was deleted in the new program
@@ -120821,27 +120899,25 @@ var ts;
120821
120899
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120822
120900
  }
120823
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
+ }
120824
120907
  });
120825
120908
  // If the global file is removed, add all files as changed
120826
120909
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120827
120910
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120828
120911
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120829
120912
  }
120830
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120913
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120831
120914
  // Add all files to affectedFilesPendingEmit since emit changed
120832
120915
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120833
120916
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120834
120917
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120835
120918
  }
120836
- if (useOldState) {
120837
- // Any time the interpretation of a source file changes, mark it as changed
120838
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120839
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120840
- state.changedFilesSet.add(sourceFilePath);
120841
- }
120842
- });
120843
- }
120844
- 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);
120845
120921
  return state;
120846
120922
  }
120847
120923
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120877,30 +120953,35 @@ var ts;
120877
120953
  ts.BuilderState.releaseCache(state);
120878
120954
  state.program = undefined;
120879
120955
  }
120880
- /**
120881
- * Creates a clone of the state
120882
- */
120883
- function cloneBuilderProgramState(state) {
120884
- var _a;
120885
- var newState = ts.BuilderState.clone(state);
120886
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120887
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120888
- newState.affectedFiles = state.affectedFiles;
120889
- newState.affectedFilesIndex = state.affectedFilesIndex;
120890
- newState.currentChangedFilePath = state.currentChangedFilePath;
120891
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120892
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120893
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120894
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120895
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120896
- newState.program = state.program;
120897
- newState.compilerOptions = state.compilerOptions;
120898
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120899
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120900
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120901
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120902
- newState.programEmitComplete = state.programEmitComplete;
120903
- 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;
120904
120985
  }
120905
120986
  /**
120906
120987
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120915,7 +120996,7 @@ var ts;
120915
120996
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120916
120997
  */
120917
120998
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120918
- var _a;
120999
+ var _a, _b;
120919
121000
  while (true) {
120920
121001
  var affectedFiles = state.affectedFiles;
120921
121002
  if (affectedFiles) {
@@ -120935,10 +121016,8 @@ var ts;
120935
121016
  state.changedFilesSet.delete(state.currentChangedFilePath);
120936
121017
  state.currentChangedFilePath = undefined;
120937
121018
  // Commit the changes in file signature
120938
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120939
- state.currentAffectedFilesSignatures.clear();
120940
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120941
- (_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();
120942
121021
  state.affectedFiles = undefined;
120943
121022
  }
120944
121023
  // Get next changed file
@@ -120956,12 +121035,7 @@ var ts;
120956
121035
  return program;
120957
121036
  }
120958
121037
  // Get next batch of affected files
120959
- if (!state.currentAffectedFilesSignatures)
120960
- state.currentAffectedFilesSignatures = new ts.Map();
120961
- if (state.exportedModulesMap) {
120962
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120963
- }
120964
- 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);
120965
121039
  state.currentChangedFilePath = nextKey.value;
120966
121040
  state.affectedFilesIndex = 0;
120967
121041
  if (!state.seenAffectedFiles)
@@ -121013,7 +121087,6 @@ var ts;
121013
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
121014
121088
  */
121015
121089
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121016
- var _a;
121017
121090
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121018
121091
  // If affected files is everything except default library, then nothing more to do
121019
121092
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121021,10 +121094,9 @@ var ts;
121021
121094
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121022
121095
  // That means when affected file is handled, its signature can be out of date
121023
121096
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121024
- 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);
121025
121098
  return;
121026
121099
  }
121027
- 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);
121028
121100
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121029
121101
  return;
121030
121102
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -121044,7 +121116,7 @@ var ts;
121044
121116
  // This ensures that we dont later during incremental builds considering wrong signature.
121045
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
121046
121118
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121047
- 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);
121048
121120
  // If not dts emit, nothing more to do
121049
121121
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121050
121122
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121065,27 +121137,10 @@ var ts;
121065
121137
  return !state.semanticDiagnosticsFromOldState.size;
121066
121138
  }
121067
121139
  function isChangedSignature(state, path) {
121068
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
121069
- 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;
121070
121142
  return newSignature !== oldSignature;
121071
121143
  }
121072
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
121073
- // Go through exported modules from cache first
121074
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
121075
- var result = keys && ts.forEachKey(keys, fn);
121076
- if (result)
121077
- return result;
121078
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
121079
- keys = state.exportedModulesMap.getKeys(filePath);
121080
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
121081
- var _a;
121082
- // If the cache had an updated value, skip
121083
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
121084
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
121085
- fn(exportedFromPath) :
121086
- undefined;
121087
- });
121088
- }
121089
121144
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121090
121145
  var _a;
121091
121146
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -121100,6 +121155,7 @@ var ts;
121100
121155
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121101
121156
  */
121102
121157
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121158
+ var _a;
121103
121159
  // If there was change in signature (dts output) for the changed file,
121104
121160
  // then only we need to handle pending file emit
121105
121161
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -121126,11 +121182,10 @@ var ts;
121126
121182
  }
121127
121183
  }
121128
121184
  }
121129
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
121130
121185
  var seenFileAndExportsOfFile = new ts.Set();
121131
121186
  // Go through exported modules from cache first
121132
121187
  // If exported modules has path, all files referencing file exported from are affected
121133
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
121188
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121134
121189
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121135
121190
  return true;
121136
121191
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -121144,19 +121199,18 @@ var ts;
121144
121199
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121145
121200
  */
121146
121201
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121147
- var _a;
121202
+ var _a, _b;
121148
121203
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121149
121204
  return undefined;
121150
121205
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121151
121206
  return true;
121152
121207
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121153
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
121154
121208
  // If exported modules has path, all files referencing file exported from are affected
121155
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121209
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121156
121210
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121157
121211
  });
121158
121212
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121159
- (_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) {
121160
121214
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121161
121215
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121162
121216
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -121177,12 +121231,13 @@ var ts;
121177
121231
  }
121178
121232
  else {
121179
121233
  state.seenAffectedFiles.add(affected.resolvedPath);
121234
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121235
+ state.buildInfoEmitPending = true;
121180
121236
  if (emitKind !== undefined) {
121181
121237
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
121182
121238
  }
121183
121239
  if (isPendingEmit) {
121184
121240
  state.affectedFilesPendingEmitIndex++;
121185
- state.buildInfoEmitPending = true;
121186
121241
  }
121187
121242
  else {
121188
121243
  state.affectedFilesIndex++;
@@ -121230,25 +121285,62 @@ var ts;
121230
121285
  }
121231
121286
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121232
121287
  }
121288
+ function isProgramBundleEmitBuildInfo(info) {
121289
+ return !!ts.outFile(info.options || {});
121290
+ }
121291
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121233
121292
  /**
121234
121293
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121235
121294
  */
121236
- function getProgramBuildInfo(state, getCanonicalFileName) {
121237
- if (ts.outFile(state.compilerOptions))
121238
- return undefined;
121295
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121296
+ var outFilePath = ts.outFile(state.compilerOptions);
121297
+ if (outFilePath && !state.compilerOptions.composite)
121298
+ return;
121239
121299
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121240
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
+ }
121241
121322
  var fileNames = [];
121242
121323
  var fileNameToFileId = new ts.Map();
121243
121324
  var fileIdsList;
121244
121325
  var fileNamesToFileIdListId;
121326
+ var emitSignatures;
121245
121327
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121328
+ var _b, _c;
121246
121329
  var key = _a[0], value = _a[1];
121247
121330
  // Ensure fileId
121248
121331
  var fileId = toFileId(key);
121249
121332
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121250
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121251
- 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
+ }
121252
121344
  return value.version === actualSignature ?
121253
121345
  value.affectsGlobalScope || value.impliedFormat ?
121254
121346
  // If file version is same as signature, dont serialize signature
@@ -121256,11 +121348,11 @@ var ts;
121256
121348
  // If file info only contains version and signature and both are same we can just write string
121257
121349
  value.version :
121258
121350
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121259
- signature === undefined ?
121351
+ oldSignature === undefined ?
121260
121352
  // If we havent computed signature, use fileInfo as is
121261
121353
  value :
121262
121354
  // Serialize fileInfo with new updated signature
121263
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121355
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121264
121356
  // Signature of the FileInfo is undefined, serialize it as false
121265
121357
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121266
121358
  });
@@ -121275,17 +121367,13 @@ var ts;
121275
121367
  if (state.exportedModulesMap) {
121276
121368
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121277
121369
  var _a;
121278
- if (state.currentAffectedFilesExportedModulesMap) {
121279
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121280
- return undefined;
121281
- }
121282
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121283
- if (newValue) {
121284
- return [toFileId(key), toFileIdListId(newValue)];
121285
- }
121286
- }
121370
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121287
121371
  // Not in temporary cache, use existing value
121288
- 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;
121289
121377
  });
121290
121378
  }
121291
121379
  var semanticDiagnosticsPerFile;
@@ -121296,9 +121384,7 @@ var ts;
121296
121384
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121297
121385
  [
121298
121386
  toFileId(key),
121299
- state.hasReusableDiagnostic ?
121300
- value :
121301
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121387
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121302
121388
  ] :
121303
121389
  toFileId(key));
121304
121390
  }
@@ -121313,16 +121399,27 @@ var ts;
121313
121399
  }
121314
121400
  }
121315
121401
  }
121316
- 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 = {
121317
121410
  fileNames: fileNames,
121318
121411
  fileInfos: fileInfos,
121319
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121412
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121320
121413
  fileIdsList: fileIdsList,
121321
121414
  referencedMap: referencedMap,
121322
121415
  exportedModulesMap: exportedModulesMap,
121323
121416
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121324
121417
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121418
+ changeFileSet: changeFileSet,
121419
+ emitSignatures: emitSignatures,
121420
+ dtsChangeTime: state.dtsChangeTime,
121325
121421
  };
121422
+ return result;
121326
121423
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121327
121424
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121328
121425
  }
@@ -121347,24 +121444,21 @@ var ts;
121347
121444
  }
121348
121445
  return fileIdListId;
121349
121446
  }
121350
- }
121351
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121352
- var result;
121353
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121354
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121355
- var name = _a[_i];
121356
- var optionKey = name.toLowerCase();
121357
- var optionInfo = optionsNameMap.get(optionKey);
121358
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121359
- // We need to store `strict`, even though it won't be examined directly, so that the
121360
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121361
- optionKey === "strict" ||
121362
- // We need to store these to determine whether `lib` files need to be rechecked.
121363
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121364
- (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
+ }
121365
121459
  }
121460
+ return result;
121366
121461
  }
121367
- return result;
121368
121462
  }
121369
121463
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121370
121464
  if (option) {
@@ -121438,6 +121532,10 @@ var ts;
121438
121532
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121439
121533
  }
121440
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;
121441
121539
  function createBuilderProgram(kind, _a) {
121442
121540
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121443
121541
  // Return same program if underlying program doesnt change
@@ -121456,8 +121554,7 @@ var ts;
121456
121554
  */
121457
121555
  var computeHash = ts.maybeBind(host, host.createHash);
121458
121556
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121459
- var backupState;
121460
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121557
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121461
121558
  // To ensure that we arent storing any references to old program or new program without state
121462
121559
  newProgram = undefined; // TODO: GH#18217
121463
121560
  oldProgram = undefined;
@@ -121465,21 +121562,12 @@ var ts;
121465
121562
  var getState = function () { return state; };
121466
121563
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121467
121564
  builderProgram.getState = getState;
121468
- builderProgram.backupState = function () {
121469
- ts.Debug.assert(backupState === undefined);
121470
- backupState = cloneBuilderProgramState(state);
121471
- };
121472
- builderProgram.restoreState = function () {
121473
- state = ts.Debug.checkDefined(backupState);
121474
- backupState = undefined;
121475
- };
121565
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121566
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121476
121567
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121477
121568
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121478
121569
  builderProgram.emit = emit;
121479
- builderProgram.releaseProgram = function () {
121480
- releaseCache(state);
121481
- backupState = undefined;
121482
- };
121570
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121483
121571
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121484
121572
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121485
121573
  }
@@ -121537,35 +121625,62 @@ var ts;
121537
121625
  return toAffectedFileEmitResult(state,
121538
121626
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121539
121627
  // Otherwise just affected file
121540
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121541
- getWriteFileUpdatingSignatureCallback(writeFile) :
121628
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121629
+ getWriteFileCallback(writeFile, customTransformers) :
121542
121630
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121543
121631
  }
121544
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121632
+ function getWriteFileCallback(writeFile, customTransformers) {
121545
121633
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121546
- var _a;
121634
+ var _a, _b, _c;
121547
121635
  if (ts.isDeclarationFileName(fileName)) {
121548
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121549
- var file = sourceFiles[0];
121550
- var info = state.fileInfos.get(file.resolvedPath);
121551
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121552
- if (signature === file.version) {
121553
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121554
- if (newSignature !== file.version) { // Update it
121555
- if (host.storeFilesChangingSignatureDuringEmit)
121556
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121557
- if (state.exportedModulesMap)
121558
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121559
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121560
- 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
+ }
121561
121662
  }
121562
- else {
121563
- info.signature = newSignature;
121564
- if (state.exportedModulesMap)
121565
- 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;
121566
121674
  }
121567
121675
  }
121568
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
+ }
121569
121684
  }
121570
121685
  if (writeFile)
121571
121686
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121630,8 +121745,8 @@ var ts;
121630
121745
  }
121631
121746
  }
121632
121747
  }
121633
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121634
- getWriteFileUpdatingSignatureCallback(writeFile) :
121748
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121749
+ getWriteFileCallback(writeFile, customTransformers) :
121635
121750
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121636
121751
  }
121637
121752
  /**
@@ -121720,29 +121835,58 @@ var ts;
121720
121835
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121721
121836
  }
121722
121837
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121723
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121724
- var _a;
121838
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121839
+ var _a, _b, _c, _d;
121725
121840
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121726
121841
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121727
- var filePaths = program.fileNames.map(toPath);
121728
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121729
- var fileInfos = new ts.Map();
121730
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121731
- var state = {
121732
- fileInfos: fileInfos,
121733
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121734
- referencedMap: toManyToManyPathMap(program.referencedMap),
121735
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121736
- 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]; }),
121737
- hasReusableDiagnostic: true,
121738
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121739
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121740
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121741
- };
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
+ }
121742
121886
  return {
121743
121887
  getState: function () { return state; },
121744
- backupState: ts.noop,
121745
- restoreState: ts.noop,
121888
+ saveEmitState: ts.noop,
121889
+ restoreEmitState: ts.noop,
121746
121890
  getProgram: ts.notImplemented,
121747
121891
  getProgramOrUndefined: ts.returnUndefined,
121748
121892
  releaseProgram: ts.noop,
@@ -121787,12 +121931,24 @@ var ts;
121787
121931
  return map;
121788
121932
  }
121789
121933
  }
121790
- 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;
121791
121947
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121792
121948
  return {
121793
121949
  getState: ts.notImplemented,
121794
- backupState: ts.noop,
121795
- restoreState: ts.noop,
121950
+ saveEmitState: ts.noop,
121951
+ restoreEmitState: ts.noop,
121796
121952
  getProgram: getProgram,
121797
121953
  getProgramOrUndefined: function () { return getState().program; },
121798
121954
  releaseProgram: function () { return getState().program = undefined; },
@@ -121896,8 +122052,10 @@ var ts;
121896
122052
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121897
122053
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121898
122054
  var resolutionsWithFailedLookups = [];
122055
+ var resolutionsWithOnlyAffectingLocations = [];
121899
122056
  var resolvedFileToResolution = ts.createMultiMap();
121900
122057
  var hasChangedAutomaticTypeDirectiveNames = false;
122058
+ var affectingPathChecks;
121901
122059
  var failedLookupChecks;
121902
122060
  var startsWithPathChecks;
121903
122061
  var isInDirectoryChecks;
@@ -121924,6 +122082,7 @@ var ts;
121924
122082
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121925
122083
  var customFailedLookupPaths = new ts.Map();
121926
122084
  var directoryWatchesOfFailedLookups = new ts.Map();
122085
+ var fileWatchesOfAffectingLocations = new ts.Map();
121927
122086
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121928
122087
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121929
122088
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121966,6 +122125,7 @@ var ts;
121966
122125
  }
121967
122126
  function clear() {
121968
122127
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
122128
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121969
122129
  customFailedLookupPaths.clear();
121970
122130
  nonRelativeExternalModuleResolutions.clear();
121971
122131
  closeTypeRootsWatch();
@@ -121973,9 +122133,11 @@ var ts;
121973
122133
  resolvedTypeReferenceDirectives.clear();
121974
122134
  resolvedFileToResolution.clear();
121975
122135
  resolutionsWithFailedLookups.length = 0;
122136
+ resolutionsWithOnlyAffectingLocations.length = 0;
121976
122137
  failedLookupChecks = undefined;
121977
122138
  startsWithPathChecks = undefined;
121978
122139
  isInDirectoryChecks = undefined;
122140
+ affectingPathChecks = undefined;
121979
122141
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
121980
122142
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
121981
122143
  clearPerDirectoryResolutions();
@@ -122025,10 +122187,18 @@ var ts;
122025
122187
  watcher.watcher.close();
122026
122188
  }
122027
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
+ });
122028
122198
  hasChangedAutomaticTypeDirectiveNames = false;
122029
122199
  }
122030
122200
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
122031
- var _a;
122201
+ var _a, _b;
122032
122202
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
122033
122203
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
122034
122204
  if (!resolutionHost.getGlobalCache) {
@@ -122039,11 +122209,12 @@ var ts;
122039
122209
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
122040
122210
  // create different collection of failed lookup locations for second pass
122041
122211
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
122042
- 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;
122043
122213
  if (resolvedModule) {
122044
122214
  // Modify existing resolution so its saved in the directory cache as well
122045
122215
  primaryResult.resolvedModule = resolvedModule;
122046
122216
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122217
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
122047
122218
  return primaryResult;
122048
122219
  }
122049
122220
  }
@@ -122294,10 +122465,11 @@ var ts;
122294
122465
  }
122295
122466
  function watchFailedLookupLocationOfResolution(resolution) {
122296
122467
  ts.Debug.assert(!!resolution.refCount);
122297
- var failedLookupLocations = resolution.failedLookupLocations;
122298
- if (!failedLookupLocations.length)
122468
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122469
+ if (!failedLookupLocations.length && !affectingLocations.length)
122299
122470
  return;
122300
- resolutionsWithFailedLookups.push(resolution);
122471
+ if (failedLookupLocations.length)
122472
+ resolutionsWithFailedLookups.push(resolution);
122301
122473
  var setAtRoot = false;
122302
122474
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122303
122475
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122324,12 +122496,66 @@ var ts;
122324
122496
  // This is always non recursive
122325
122497
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122326
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
+ }
122327
122550
  }
122328
122551
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122329
122552
  var program = resolutionHost.getCurrentProgram();
122330
122553
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122331
122554
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122332
122555
  }
122556
+ else {
122557
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122558
+ }
122333
122559
  }
122334
122560
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122335
122561
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122351,38 +122577,44 @@ var ts;
122351
122577
  if (resolved && resolved.resolvedFileName) {
122352
122578
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122353
122579
  }
122354
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122355
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122356
- return;
122357
- }
122358
- var failedLookupLocations = resolution.failedLookupLocations;
122359
- var removeAtRoot = false;
122360
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122361
- var failedLookupLocation = failedLookupLocations_2[_i];
122362
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122363
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122364
- if (toWatch) {
122365
- var dirPath = toWatch.dirPath;
122366
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122367
- if (refCount) {
122368
- if (refCount === 1) {
122369
- 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;
122370
122601
  }
122371
122602
  else {
122372
- ts.Debug.assert(refCount > 1);
122373
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122603
+ removeDirectoryWatcher(dirPath);
122374
122604
  }
122375
122605
  }
122376
- if (dirPath === rootPath) {
122377
- removeAtRoot = true;
122378
- }
122379
- else {
122380
- removeDirectoryWatcher(dirPath);
122381
- }
122606
+ }
122607
+ if (removeAtRoot) {
122608
+ removeDirectoryWatcher(rootPath);
122382
122609
  }
122383
122610
  }
122384
- if (removeAtRoot) {
122385
- 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--;
122386
122618
  }
122387
122619
  }
122388
122620
  function removeDirectoryWatcher(dirPath) {
@@ -122461,7 +122693,7 @@ var ts;
122461
122693
  if (isCreatingWatchedDirectory) {
122462
122694
  // Watching directory is created
122463
122695
  // Invalidate any resolution has failed lookup in this directory
122464
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122696
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122465
122697
  }
122466
122698
  else {
122467
122699
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122479,7 +122711,7 @@ var ts;
122479
122711
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122480
122712
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122481
122713
  // Invalidate any resolution from this directory
122482
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122714
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122483
122715
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122484
122716
  }
122485
122717
  else {
@@ -122491,7 +122723,7 @@ var ts;
122491
122723
  return false;
122492
122724
  }
122493
122725
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122494
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122726
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122495
122727
  // If the invalidated file is from a node_modules package, invalidate everything else
122496
122728
  // in the package since we might not get notifications for other files in the package.
122497
122729
  // This hardens our logic against unreliable file watchers.
@@ -122503,21 +122735,32 @@ var ts;
122503
122735
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122504
122736
  }
122505
122737
  function invalidateResolutionsOfFailedLookupLocations() {
122506
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122738
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122507
122739
  return false;
122508
122740
  }
122509
122741
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122510
122742
  failedLookupChecks = undefined;
122511
122743
  startsWithPathChecks = undefined;
122512
122744
  isInDirectoryChecks = undefined;
122745
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122746
+ affectingPathChecks = undefined;
122513
122747
  return invalidated;
122514
122748
  }
122515
122749
  function canInvalidateFailedLookupResolution(resolution) {
122750
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122751
+ return true;
122752
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122753
+ return false;
122516
122754
  return resolution.failedLookupLocations.some(function (location) {
122517
122755
  var locationPath = resolutionHost.toPath(location);
122518
- return ts.contains(failedLookupChecks, locationPath) ||
122756
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122519
122757
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122520
- (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));
122521
122764
  });
122522
122765
  }
122523
122766
  function closeTypeRootsWatch() {
@@ -122908,9 +123151,9 @@ var ts;
122908
123151
  if (!preferSymlinks) {
122909
123152
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122910
123153
  // so we only need to remove them from the realpath filenames.
122911
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122912
- if (result_15)
122913
- 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;
122914
123157
  }
122915
123158
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122916
123159
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122930,10 +123173,10 @@ var ts;
122930
123173
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122931
123174
  var symlinkDirectory = symlinkDirectories_1[_i];
122932
123175
  var option = ts.resolvePath(symlinkDirectory, relative);
122933
- var result_16 = cb(option, target === referenceRedirect);
123176
+ var result_17 = cb(option, target === referenceRedirect);
122934
123177
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122935
- if (result_16)
122936
- return result_16;
123178
+ if (result_17)
123179
+ return result_17;
122937
123180
  }
122938
123181
  });
122939
123182
  });
@@ -123843,6 +124086,7 @@ var ts;
123843
124086
  readDirectory: ts.maybeBind(host, host.readDirectory),
123844
124087
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123845
124088
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
124089
+ now: ts.maybeBind(host, host.now),
123846
124090
  };
123847
124091
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123848
124092
  try {
@@ -123903,6 +124147,7 @@ var ts;
123903
124147
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123904
124148
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123905
124149
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
124150
+ now: ts.maybeBind(system, system.now),
123906
124151
  };
123907
124152
  }
123908
124153
  ts.createProgramHost = createProgramHost;
@@ -123970,20 +124215,27 @@ var ts;
123970
124215
  var ts;
123971
124216
  (function (ts) {
123972
124217
  function readBuilderProgram(compilerOptions, host) {
123973
- if (ts.outFile(compilerOptions))
123974
- return undefined;
123975
124218
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123976
124219
  if (!buildInfoPath)
123977
124220
  return undefined;
123978
- var content = host.readFile(buildInfoPath);
123979
- if (!content)
123980
- return undefined;
123981
- 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
+ }
123982
124234
  if (buildInfo.version !== ts.version)
123983
124235
  return undefined;
123984
124236
  if (!buildInfo.program)
123985
124237
  return undefined;
123986
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124238
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123987
124239
  }
123988
124240
  ts.readBuilderProgram = readBuilderProgram;
123989
124241
  function createIncrementalCompilerHost(options, system) {
@@ -123992,6 +124244,7 @@ var ts;
123992
124244
  host.createHash = ts.maybeBind(system, system.createHash);
123993
124245
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123994
124246
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124247
+ host.now = ts.maybeBind(system, system.now);
123995
124248
  ts.setGetSourceFileAsHashVersioned(host, system);
123996
124249
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123997
124250
  return host;
@@ -124036,7 +124289,6 @@ var ts;
124036
124289
  var builderProgram;
124037
124290
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
124038
124291
  var missingFilesMap; // Map of file watchers for the missing files
124039
- var packageJsonMap; // map of watchers for package json files used in module resolution
124040
124292
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
124041
124293
  var timerToUpdateProgram; // timer callback to recompile the program
124042
124294
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -124100,6 +124352,7 @@ var ts;
124100
124352
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
124101
124353
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
124102
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); };
124103
124356
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
124104
124357
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
124105
124358
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -124182,10 +124435,6 @@ var ts;
124182
124435
  });
124183
124436
  parsedConfigs = undefined;
124184
124437
  }
124185
- if (packageJsonMap) {
124186
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
124187
- packageJsonMap = undefined;
124188
- }
124189
124438
  }
124190
124439
  function getCurrentBuilderProgram() {
124191
124440
  return builderProgram;
@@ -124241,15 +124490,9 @@ var ts;
124241
124490
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124242
124491
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124243
124492
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124244
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124245
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124246
- var path = _a[0], data = _a[1];
124247
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124248
- });
124249
124493
  resolutionCache.finishCachingPerDirectoryResolution();
124250
124494
  // Update watches
124251
124495
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124252
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124253
124496
  if (needsUpdateInTypeRootWatch) {
124254
124497
  resolutionCache.updateTypeRootsWatch();
124255
124498
  }
@@ -124555,21 +124798,6 @@ var ts;
124555
124798
  ts.noopFileWatcher :
124556
124799
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124557
124800
  }
124558
- function watchPackageJsonLookupPath(packageJsonPath) {
124559
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124560
- return sourceFilesCache.has(packageJsonPath) ?
124561
- ts.noopFileWatcher :
124562
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124563
- }
124564
- function onPackageJsonChange(fileName, eventKind, path) {
124565
- updateCachedSystemWithFile(fileName, path, eventKind);
124566
- // package.json changes invalidate module resolution and can change the set of loaded files
124567
- // so if we witness a change to one, we have to do a full reload
124568
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124569
- changesAffectResolution = true;
124570
- // Update the program
124571
- scheduleProgramUpdate();
124572
- }
124573
124801
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124574
124802
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124575
124803
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124727,14 +124955,17 @@ var ts;
124727
124955
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124728
124956
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124729
124957
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124730
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124731
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124732
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124733
- 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";
124734
124964
  /**
124735
124965
  * Projects with no outputs (i.e. "solution" files)
124736
124966
  */
124737
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124967
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124968
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124738
124969
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124739
124970
  function resolveConfigFileProjectName(project) {
124740
124971
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124779,9 +125010,12 @@ var ts;
124779
125010
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124780
125011
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124781
125012
  }
124782
- function newer(date1, date2) {
124783
- 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();
124784
125017
  }
125018
+ ts.getCurrentTime = getCurrentTime;
124785
125019
  /*@internal*/
124786
125020
  function isCircularBuildOrder(buildOrder) {
124787
125021
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124871,6 +125105,7 @@ var ts;
124871
125105
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124872
125106
  };
124873
125107
  }
125108
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124874
125109
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124875
125110
  var state = {
124876
125111
  host: host,
@@ -124887,8 +125122,9 @@ var ts;
124887
125122
  resolvedConfigFilePaths: new ts.Map(),
124888
125123
  configFileCache: new ts.Map(),
124889
125124
  projectStatus: new ts.Map(),
124890
- buildInfoChecked: new ts.Map(),
124891
125125
  extendedConfigCache: new ts.Map(),
125126
+ buildInfoCache: new ts.Map(),
125127
+ outputTimeStamps: new ts.Map(),
124892
125128
  builderPrograms: new ts.Map(),
124893
125129
  diagnostics: new ts.Map(),
124894
125130
  projectPendingBuild: new ts.Map(),
@@ -124911,6 +125147,7 @@ var ts;
124911
125147
  allWatchedConfigFiles: new ts.Map(),
124912
125148
  allWatchedExtendedConfigFiles: new ts.Map(),
124913
125149
  allWatchedPackageJsonFiles: new ts.Map(),
125150
+ filesWatched: new ts.Map(),
124914
125151
  lastCachedPackageJsonLookups: new ts.Map(),
124915
125152
  timerToBuildInvalidatedProject: undefined,
124916
125153
  reportFileChangeDetected: false,
@@ -125017,11 +125254,12 @@ var ts;
125017
125254
  // Config file cache
125018
125255
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
125019
125256
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
125020
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
125021
125257
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
125022
125258
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
125023
125259
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
125024
125260
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125261
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125262
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
125025
125263
  // Remove watches for the program no longer in the solution
125026
125264
  if (state.watch) {
125027
125265
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125311,21 +125549,21 @@ var ts;
125311
125549
  }
125312
125550
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125313
125551
  var _a;
125314
- var _b, _c;
125552
+ var _b, _c, _d;
125315
125553
  ts.Debug.assertIsDefined(program);
125316
125554
  ts.Debug.assert(step === BuildStep.Emit);
125317
125555
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125318
- program.backupState();
125556
+ var saved = program.saveEmitState();
125319
125557
  var declDiagnostics;
125320
125558
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125321
125559
  var outputFiles = [];
125322
125560
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125323
125561
  /*write*/ undefined,
125324
- /*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,
125325
125563
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125326
125564
  // Don't emit .d.ts if there are decl file errors
125327
125565
  if (declDiagnostics) {
125328
- program.restoreState();
125566
+ program.restoreEmitState(saved);
125329
125567
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125330
125568
  return {
125331
125569
  emitSkipped: true,
@@ -125335,37 +125573,44 @@ var ts;
125335
125573
  // Actual Emit
125336
125574
  var host = state.host, compilerHost = state.compilerHost;
125337
125575
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125338
- var newestDeclarationFileContentChangedTime = minimumDate;
125339
- var anyDtsChanged = false;
125576
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125340
125577
  var emitterDiagnostics = ts.createDiagnosticCollection();
125341
125578
  var emittedOutputs = new ts.Map();
125579
+ var options = program.getCompilerOptions();
125580
+ var isIncremental = ts.isIncrementalCompilation(options);
125581
+ var outputTimeStampMap;
125582
+ var now;
125342
125583
  outputFiles.forEach(function (_a) {
125343
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125344
- var priorChangeTime;
125345
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125346
- // Check for unchanged .d.ts files
125347
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125348
- priorChangeTime = host.getModifiedTime(name);
125349
- }
125350
- 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)) {
125351
125592
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125352
- anyDtsChanged = true;
125353
125593
  }
125354
125594
  }
125355
- emittedOutputs.set(toPath(state, name), name);
125356
125595
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125357
- if (priorChangeTime !== undefined) {
125358
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125596
+ if (!isIncremental && state.watch) {
125597
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125359
125598
  }
125360
125599
  });
125361
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125362
- /*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);
125363
125601
  return emitResult;
125364
125602
  }
125365
125603
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125366
125604
  ts.Debug.assertIsDefined(program);
125367
125605
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125368
- 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);
125369
125614
  if (emitResult.diagnostics.length) {
125370
125615
  reportErrors(state, emitResult.diagnostics);
125371
125616
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125378,7 +125623,7 @@ var ts;
125378
125623
  step = BuildStep.QueueReferencingProjects;
125379
125624
  return emitResult;
125380
125625
  }
125381
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125626
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125382
125627
  var _a;
125383
125628
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125384
125629
  if (emitDiagnostics.length) {
@@ -125389,13 +125634,11 @@ var ts;
125389
125634
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125390
125635
  }
125391
125636
  // Update time stamps for rest of the outputs
125392
- 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);
125393
125638
  state.diagnostics.delete(projectPath);
125394
125639
  state.projectStatus.set(projectPath, {
125395
125640
  type: ts.UpToDateStatusType.UpToDate,
125396
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125397
- maximumDate :
125398
- newestDeclarationFileContentChangedTime,
125641
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125399
125642
  oldestOutputFileName: oldestOutputFileName
125400
125643
  });
125401
125644
  afterProgramDone(state, program, config);
@@ -125430,13 +125673,21 @@ var ts;
125430
125673
  ts.Debug.assert(!!outputFiles.length);
125431
125674
  var emitterDiagnostics = ts.createDiagnosticCollection();
125432
125675
  var emittedOutputs = new ts.Map();
125676
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125677
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125433
125678
  outputFiles.forEach(function (_a) {
125434
- 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;
125435
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
+ }
125436
125688
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125437
125689
  });
125438
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125439
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125690
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125440
125691
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125441
125692
  }
125442
125693
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125535,7 +125786,7 @@ var ts;
125535
125786
  }
125536
125787
  continue;
125537
125788
  }
125538
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125789
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125539
125790
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125540
125791
  return {
125541
125792
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125620,7 +125871,8 @@ var ts;
125620
125871
  state.projectCompilerOptions = state.baseCompilerOptions;
125621
125872
  }
125622
125873
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125623
- 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());
125624
125876
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125625
125877
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125626
125878
  if (canEmitBuildInfo)
@@ -125628,9 +125880,99 @@ var ts;
125628
125880
  afterProgramDone(state, program, config);
125629
125881
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125630
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
+ }
125631
125973
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125632
125974
  // Check tsconfig time
125633
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125975
+ var tsconfigTime = getModifiedTime(state, configFile);
125634
125976
  if (oldestOutputFileTime < tsconfigTime) {
125635
125977
  return {
125636
125978
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125640,88 +125982,24 @@ var ts;
125640
125982
  }
125641
125983
  }
125642
125984
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125643
- var force = !!state.options.force;
125644
- var newestInputFileName = undefined;
125645
- var newestInputFileTime = minimumDate;
125646
- var host = state.host;
125647
- // Get timestamps of input files
125648
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125649
- var inputFile = _a[_i];
125650
- if (!host.fileExists(inputFile)) {
125651
- return {
125652
- type: ts.UpToDateStatusType.Unbuildable,
125653
- reason: inputFile + " does not exist"
125654
- };
125655
- }
125656
- if (!force) {
125657
- var inputTime = ts.getModifiedTime(host, inputFile);
125658
- if (inputTime > newestInputFileTime) {
125659
- newestInputFileName = inputFile;
125660
- newestInputFileTime = inputTime;
125661
- }
125662
- }
125663
- }
125985
+ var _a, _b, _c;
125664
125986
  // Container if no files are specified in the project
125665
125987
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125666
125988
  return {
125667
125989
  type: ts.UpToDateStatusType.ContainerOnly
125668
125990
  };
125669
125991
  }
125670
- // Collect the expected outputs of this project
125671
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125672
- // Now see if all outputs are newer than the newest input
125673
- var oldestOutputFileName = "(none)";
125674
- var oldestOutputFileTime = maximumDate;
125675
- var newestOutputFileName = "(none)";
125676
- var newestOutputFileTime = minimumDate;
125677
- var missingOutputFileName;
125678
- var newestDeclarationFileContentChangedTime = minimumDate;
125679
- var isOutOfDateWithInputs = false;
125680
- if (!force) {
125681
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125682
- var output = outputs_1[_b];
125683
- // Output is missing; can stop checking
125684
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125685
- if (!host.fileExists(output)) {
125686
- missingOutputFileName = output;
125687
- break;
125688
- }
125689
- var outputTime = ts.getModifiedTime(host, output);
125690
- if (outputTime < oldestOutputFileTime) {
125691
- oldestOutputFileTime = outputTime;
125692
- oldestOutputFileName = output;
125693
- }
125694
- // If an output is older than the newest input, we can stop checking
125695
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125696
- if (outputTime < newestInputFileTime) {
125697
- isOutOfDateWithInputs = true;
125698
- break;
125699
- }
125700
- if (outputTime > newestOutputFileTime) {
125701
- newestOutputFileTime = outputTime;
125702
- newestOutputFileName = output;
125703
- }
125704
- // Keep track of when the most recent time a .d.ts file was changed.
125705
- // In addition to file timestamps, we also keep track of when a .d.ts file
125706
- // had its file touched but not had its contents changed - this allows us
125707
- // to skip a downstream typecheck
125708
- if (ts.isDeclarationFileName(output)) {
125709
- var outputModifiedTime = ts.getModifiedTime(host, output);
125710
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125711
- }
125712
- }
125713
- }
125714
- var pseudoUpToDate = false;
125715
- var usesPrepend = false;
125716
- 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;
125717
125995
  if (project.projectReferences) {
125718
125996
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125719
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125720
- var ref = _d[_c];
125721
- usesPrepend = usesPrepend || !!(ref.prepend);
125997
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125998
+ var ref = _d[_i];
125722
125999
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125723
126000
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125724
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
126001
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
126002
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125725
126003
  // Its a circular reference ignore the status of this project
125726
126004
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125727
126005
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125743,75 +126021,194 @@ var ts;
125743
126021
  upstreamProjectName: ref.path
125744
126022
  };
125745
126023
  }
125746
- // Check oldest output file name only if there is no missing output file name
125747
- // (a check we will have skipped if this is a forced build)
125748
- if (!force && !missingOutputFileName) {
125749
- // If the upstream project's newest file is older than our oldest output, we
125750
- // can't be out of date because of it
125751
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125752
- continue;
125753
- }
125754
- // If the upstream project has only change .d.ts files, and we've built
125755
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125756
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125757
- pseudoUpToDate = true;
125758
- upstreamChangedProject = ref.path;
125759
- continue;
125760
- }
125761
- // We have an output older than an upstream output - we are out of date
125762
- 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))) {
125763
126066
  return {
125764
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125765
- outOfDateOutputFileName: oldestOutputFileName,
125766
- newerProjectName: ref.path
126067
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
126068
+ buildInfoFile: buildInfoPath
125767
126069
  };
125768
126070
  }
126071
+ buildInfoProgram = buildInfo.program;
125769
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;
125770
126077
  }
125771
- if (missingOutputFileName !== undefined) {
125772
- return {
125773
- type: ts.UpToDateStatusType.OutputMissing,
125774
- missingOutputFileName: missingOutputFileName
125775
- };
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
+ }
125776
126119
  }
125777
- if (isOutOfDateWithInputs) {
125778
- return {
125779
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125780
- outOfDateOutputFileName: oldestOutputFileName,
125781
- newerInputFileName: newestInputFileName
125782
- };
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
+ }
125783
126156
  }
125784
- else {
125785
- // Check tsconfig time
125786
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125787
- if (configStatus)
125788
- return configStatus;
125789
- // Check extended config time
125790
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125791
- if (extendedConfigStatus)
125792
- return extendedConfigStatus;
125793
- // Check package file time
125794
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125795
- var path = _a[0];
125796
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125797
- });
125798
- if (dependentPackageFileStatus)
125799
- return dependentPackageFileStatus;
125800
- }
125801
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125802
- state.buildInfoChecked.set(resolvedPath, true);
125803
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125804
- if (buildInfoPath) {
125805
- var value = state.readFileWithCache(buildInfoPath);
125806
- var buildInfo = value && ts.getBuildInfo(value);
125807
- 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)) {
125808
126175
  return {
125809
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125810
- version: buildInfo.version
126176
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
126177
+ outOfDateOutputFileName: buildInfoPath,
126178
+ newerProjectName: ref.path
125811
126179
  };
125812
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
+ };
125813
126195
  }
125814
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;
125815
126212
  if (usesPrepend && pseudoUpToDate) {
125816
126213
  return {
125817
126214
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125821,15 +126218,37 @@ var ts;
125821
126218
  }
125822
126219
  // Up to date
125823
126220
  return {
125824
- 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,
125825
126226
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125826
126227
  newestInputFileTime: newestInputFileTime,
125827
- newestOutputFileTime: newestOutputFileTime,
125828
126228
  newestInputFileName: newestInputFileName,
125829
- newestOutputFileName: newestOutputFileName,
125830
126229
  oldestOutputFileName: oldestOutputFileName
125831
126230
  };
125832
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
+ }
125833
126252
  function getUpToDateStatus(state, project, resolvedPath) {
125834
126253
  if (project === undefined) {
125835
126254
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125842,39 +126261,68 @@ var ts;
125842
126261
  state.projectStatus.set(resolvedPath, actual);
125843
126262
  return actual;
125844
126263
  }
125845
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126264
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125846
126265
  if (proj.options.noEmit)
125847
- 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
+ }
125848
126281
  var host = state.host;
125849
126282
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126283
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126284
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125850
126285
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125851
126286
  var reportVerbose = !!state.options.verbose;
125852
- var now = host.now ? host.now() : new Date();
125853
126287
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125854
126288
  var file = outputs_2[_i];
125855
- 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))
125856
126291
  continue;
125857
- }
125858
126292
  if (reportVerbose) {
125859
126293
  reportVerbose = false;
125860
126294
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125861
126295
  }
125862
- if (ts.isDeclarationFileName(file)) {
125863
- 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);
125864
126301
  }
125865
- host.setModifiedTime(file, now);
125866
126302
  }
125867
126303
  }
125868
- 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;
125869
126317
  }
125870
126318
  function updateOutputTimestamps(state, proj, resolvedPath) {
125871
126319
  if (state.options.dry) {
125872
126320
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125873
126321
  }
125874
- 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);
125875
126323
  state.projectStatus.set(resolvedPath, {
125876
126324
  type: ts.UpToDateStatusType.UpToDate,
125877
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126325
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125878
126326
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125879
126327
  });
125880
126328
  }
@@ -125920,6 +126368,7 @@ var ts;
125920
126368
  break;
125921
126369
  }
125922
126370
  // falls through
126371
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125923
126372
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125924
126373
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125925
126374
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -126080,12 +126529,10 @@ var ts;
126080
126529
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
126081
126530
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
126082
126531
  return;
126083
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
126084
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
126085
- }, 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));
126086
126533
  }
126087
126534
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
126088
- 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 () {
126089
126536
  var _a;
126090
126537
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
126091
126538
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -126117,7 +126564,7 @@ var ts;
126117
126564
  if (!state.watch)
126118
126565
  return;
126119
126566
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
126120
- 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); },
126121
126568
  onDeleteValue: ts.closeFileWatcher,
126122
126569
  });
126123
126570
  }
@@ -126125,7 +126572,7 @@ var ts;
126125
126572
  if (!state.watch || !state.lastCachedPackageJsonLookups)
126126
126573
  return;
126127
126574
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
126128
- 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); },
126129
126576
  onDeleteValue: ts.closeFileWatcher,
126130
126577
  });
126131
126578
  }
@@ -126255,19 +126702,18 @@ var ts;
126255
126702
  }
126256
126703
  }
126257
126704
  function reportUpToDateStatus(state, configFileName, status) {
126258
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126259
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126260
- }
126261
126705
  switch (status.type) {
126262
126706
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126263
- 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));
126264
126708
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126265
- 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));
126266
126710
  case ts.UpToDateStatusType.OutputMissing:
126267
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));
126268
126714
  case ts.UpToDateStatusType.UpToDate:
126269
126715
  if (status.newestInputFileTime !== undefined) {
126270
- 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 || ""));
126271
126717
  }
126272
126718
  // Don't report anything for "up to date because it was already built" -- too verbose
126273
126719
  break;
@@ -126275,6 +126721,8 @@ var ts;
126275
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));
126276
126722
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126277
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));
126278
126726
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126279
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));
126280
126728
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126285,6 +126733,8 @@ var ts;
126285
126733
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126286
126734
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126287
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));
126288
126738
  case ts.UpToDateStatusType.ContainerOnly:
126289
126739
  // Don't report status on "solution" projects
126290
126740
  // falls through
@@ -136981,7 +137431,7 @@ var ts;
136981
137431
  }
136982
137432
  var str = "{";
136983
137433
  for (var key in value) {
136984
- if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
137434
+ if (ts.hasProperty(value, key)) {
136985
137435
  str += key + ": " + compilerOptionValueToString(value[key]);
136986
137436
  }
136987
137437
  }
@@ -159909,14 +160359,14 @@ var ts;
159909
160359
  if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) {
159910
160360
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) };
159911
160361
  }
159912
- var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol;
160362
+ var checker = program.getTypeChecker();
160363
+ var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker);
159913
160364
  var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */);
159914
160365
  var wasDefault = !!(flags & 512 /* Default */);
159915
160366
  // If source file already has a default export, don't offer refactor.
159916
160367
  if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) {
159917
160368
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) };
159918
160369
  }
159919
- var checker = program.getTypeChecker();
159920
160370
  var noSymbolError = function (id) {
159921
160371
  return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined
159922
160372
  : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) };
@@ -160008,6 +160458,8 @@ var ts;
160008
160458
  var checker = program.getTypeChecker();
160009
160459
  var exportSymbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol");
160010
160460
  ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) {
160461
+ if (exportName === ref)
160462
+ return;
160011
160463
  var importingSourceFile = ref.getSourceFile();
160012
160464
  if (wasDefault) {
160013
160465
  changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text);
@@ -160100,6 +160552,17 @@ var ts;
160100
160552
  function makeExportSpecifier(propertyName, name) {
160101
160553
  return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name));
160102
160554
  }
160555
+ function getExportingModuleSymbol(node, checker) {
160556
+ var parent = node.parent;
160557
+ if (ts.isSourceFile(parent)) {
160558
+ return parent.symbol;
160559
+ }
160560
+ var symbol = parent.parent.symbol;
160561
+ if (symbol.valueDeclaration && ts.isExternalModuleAugmentation(symbol.valueDeclaration)) {
160562
+ return checker.getMergedSymbol(symbol);
160563
+ }
160564
+ return symbol;
160565
+ }
160103
160566
  })(refactor = ts.refactor || (ts.refactor = {}));
160104
160567
  })(ts || (ts = {}));
160105
160568
  /* @internal */
@@ -168396,7 +168859,8 @@ var ts;
168396
168859
  }
168397
168860
  return {
168398
168861
  resolvedFileName: resolvedFileName,
168399
- failedLookupLocations: result.failedLookupLocations
168862
+ failedLookupLocations: result.failedLookupLocations,
168863
+ affectingLocations: result.affectingLocations,
168400
168864
  };
168401
168865
  });
168402
168866
  };