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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220605";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220609";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -6198,7 +6198,7 @@ var ts;
6198
6198
  };
6199
6199
  }
6200
6200
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6201
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6201
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6202
6202
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6203
6203
  if (!ts.isString(relativeFileName))
6204
6204
  return;
@@ -6208,7 +6208,7 @@ var ts;
6208
6208
  if (callbacks) {
6209
6209
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6210
6210
  var fileCallback = callbacks_1[_i];
6211
- fileCallback(fileName, FileWatcherEventKind.Changed);
6211
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6212
6212
  }
6213
6213
  }
6214
6214
  },
@@ -6262,7 +6262,7 @@ var ts;
6262
6262
  }
6263
6263
  else {
6264
6264
  cache.set(path, {
6265
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6265
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6266
6266
  refCount: 1
6267
6267
  });
6268
6268
  }
@@ -6290,7 +6290,8 @@ var ts;
6290
6290
  var newTime = modifiedTime.getTime();
6291
6291
  if (oldTime !== newTime) {
6292
6292
  watchedFile.mtime = modifiedTime;
6293
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6293
+ // Pass modified times so tsc --build can use it
6294
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6294
6295
  return true;
6295
6296
  }
6296
6297
  return false;
@@ -6325,7 +6326,7 @@ var ts;
6325
6326
  */
6326
6327
  /*@internal*/
6327
6328
  function createDirectoryWatcherSupportingRecursive(_a) {
6328
- var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, directoryExists = _a.directoryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6329
+ var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, fileSystemEntryExists = _a.fileSystemEntryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6329
6330
  var cache = new ts.Map();
6330
6331
  var callbackCache = ts.createMultiMap();
6331
6332
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6425,7 +6426,7 @@ var ts;
6425
6426
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6426
6427
  // Iterate through existing children and update the watches if needed
6427
6428
  var parentWatcher = cache.get(dirPath);
6428
- if (parentWatcher && directoryExists(dirName)) {
6429
+ if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6429
6430
  // Schedule the update and postpone invoke for callbacks
6430
6431
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6431
6432
  return;
@@ -6498,7 +6499,7 @@ var ts;
6498
6499
  if (!parentWatcher)
6499
6500
  return false;
6500
6501
  var newChildWatches;
6501
- var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6502
+ var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6502
6503
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6503
6504
  // Filter our the symbolic link directories since those arent included in recursive watch
6504
6505
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6541,17 +6542,19 @@ var ts;
6541
6542
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6542
6543
  /*@internal*/
6543
6544
  function createFileWatcherCallback(callback) {
6544
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6545
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6545
6546
  }
6546
6547
  ts.createFileWatcherCallback = createFileWatcherCallback;
6547
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6548
- return function (eventName) {
6548
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6549
+ return function (eventName, _relativeFileName, modifiedTime) {
6549
6550
  if (eventName === "rename") {
6550
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6551
+ // Check time stamps rather than file system entry checks
6552
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6553
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6551
6554
  }
6552
6555
  else {
6553
6556
  // Change
6554
- callback(fileName, FileWatcherEventKind.Changed);
6557
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6555
6558
  }
6556
6559
  };
6557
6560
  }
@@ -6575,11 +6578,12 @@ var ts;
6575
6578
  }
6576
6579
  /*@internal*/
6577
6580
  function createSystemWatchFunctions(_a) {
6578
- var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6581
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6579
6582
  var dynamicPollingWatchFile;
6580
6583
  var fixedChunkSizePollingWatchFile;
6581
6584
  var nonPollingWatchFile;
6582
6585
  var hostRecursiveDirectoryWatcher;
6586
+ var hitSystemWatcherLimit = false;
6583
6587
  return {
6584
6588
  watchFile: watchFile,
6585
6589
  watchDirectory: watchDirectory
@@ -6597,7 +6601,7 @@ var ts;
6597
6601
  case ts.WatchFileKind.FixedChunkSizePolling:
6598
6602
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6599
6603
  case ts.WatchFileKind.UseFsEvents:
6600
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6604
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6601
6605
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6602
6606
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6603
6607
  if (!nonPollingWatchFile) {
@@ -6658,7 +6662,7 @@ var ts;
6658
6662
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6659
6663
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6660
6664
  getCurrentDirectory: getCurrentDirectory,
6661
- directoryExists: directoryExists,
6665
+ fileSystemEntryExists: fileSystemEntryExists,
6662
6666
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6663
6667
  watchDirectory: nonRecursiveWatchDirectory,
6664
6668
  realpath: realpath,
@@ -6709,6 +6713,122 @@ var ts;
6709
6713
  };
6710
6714
  }
6711
6715
  }
6716
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6717
+ var lastDirectoryPartWithDirectorySeparator;
6718
+ var lastDirectoryPart;
6719
+ if (inodeWatching) {
6720
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6721
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6722
+ }
6723
+ /** Watcher for the file system entry depending on whether it is missing or present */
6724
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6725
+ watchMissingFileSystemEntry() :
6726
+ watchPresentFileSystemEntry();
6727
+ return {
6728
+ close: function () {
6729
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6730
+ watcher.close();
6731
+ watcher = undefined;
6732
+ }
6733
+ };
6734
+ function updateWatcher(createWatcher) {
6735
+ // If watcher is not closed, update it
6736
+ if (watcher) {
6737
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6738
+ watcher.close();
6739
+ watcher = createWatcher();
6740
+ }
6741
+ }
6742
+ /**
6743
+ * Watch the file or directory that is currently present
6744
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
6745
+ */
6746
+ function watchPresentFileSystemEntry() {
6747
+ if (hitSystemWatcherLimit) {
6748
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6749
+ return watchPresentFileSystemEntryWithFsWatchFile();
6750
+ }
6751
+ try {
6752
+ var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6753
+ callbackChangingToMissingFileSystemEntry :
6754
+ callback);
6755
+ // Watch the missing file or directory or error
6756
+ presentWatcher.on("error", function () {
6757
+ callback("rename", "");
6758
+ updateWatcher(watchMissingFileSystemEntry);
6759
+ });
6760
+ return presentWatcher;
6761
+ }
6762
+ catch (e) {
6763
+ // Catch the exception and use polling instead
6764
+ // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6765
+ // so instead of throwing error, use fs.watchFile
6766
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6767
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6768
+ return watchPresentFileSystemEntryWithFsWatchFile();
6769
+ }
6770
+ }
6771
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6772
+ // In some scenarios, file save operation fires event with fileName.ext~ instead of fileName.ext
6773
+ // To ensure we see the file going missing and coming back up (file delete and then recreated)
6774
+ // and watches being updated correctly we are calling back with fileName.ext as well as fileName.ext~
6775
+ // The worst is we have fired event that was not needed but we wont miss any changes
6776
+ // especially in cases where file goes missing and watches wrong inode
6777
+ var originalRelativeName;
6778
+ if (relativeName && ts.endsWith(relativeName, "~")) {
6779
+ originalRelativeName = relativeName;
6780
+ relativeName = relativeName.slice(0, relativeName.length - 1);
6781
+ }
6782
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6783
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6784
+ if (event === "rename" &&
6785
+ (!relativeName ||
6786
+ relativeName === lastDirectoryPart ||
6787
+ ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6788
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
6789
+ if (originalRelativeName)
6790
+ callback(event, originalRelativeName, modifiedTime);
6791
+ callback(event, relativeName, modifiedTime);
6792
+ if (inodeWatching) {
6793
+ // If this was rename event, inode has changed means we need to update watcher
6794
+ updateWatcher(modifiedTime === ts.missingFileModifiedTime ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6795
+ }
6796
+ else if (modifiedTime === ts.missingFileModifiedTime) {
6797
+ updateWatcher(watchMissingFileSystemEntry);
6798
+ }
6799
+ }
6800
+ else {
6801
+ if (originalRelativeName)
6802
+ callback(event, originalRelativeName);
6803
+ callback(event, relativeName);
6804
+ }
6805
+ }
6806
+ /**
6807
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
6808
+ * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6809
+ */
6810
+ function watchPresentFileSystemEntryWithFsWatchFile() {
6811
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
6812
+ }
6813
+ /**
6814
+ * Watch the file or directory that is missing
6815
+ * and switch to existing file or directory when the missing filesystem entry is created
6816
+ */
6817
+ function watchMissingFileSystemEntry() {
6818
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
6819
+ if (eventKind === FileWatcherEventKind.Created) {
6820
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
6821
+ if (modifiedTime !== ts.missingFileModifiedTime) {
6822
+ callback("rename", "", modifiedTime);
6823
+ // Call the callback for current file or directory
6824
+ // For now it could be callback for the inner directory creation,
6825
+ // but just return current directory, better than current no-op
6826
+ updateWatcher(watchPresentFileSystemEntry);
6827
+ }
6828
+ }
6829
+ }, fallbackPollingInterval, fallbackOptions);
6830
+ }
6831
+ }
6712
6832
  }
6713
6833
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6714
6834
  /**
@@ -6761,7 +6881,6 @@ var ts;
6761
6881
  }
6762
6882
  var activeSession;
6763
6883
  var profilePath = "./profile.cpuprofile";
6764
- var hitSystemWatcherLimit = false;
6765
6884
  var Buffer = require("buffer").Buffer;
6766
6885
  var nodeVersion = getNodeMajorVersion();
6767
6886
  var isNode4OrLater = nodeVersion >= 4;
@@ -6776,20 +6895,21 @@ var ts;
6776
6895
  getModifiedTime: getModifiedTime,
6777
6896
  setTimeout: setTimeout,
6778
6897
  clearTimeout: clearTimeout,
6779
- fsWatch: fsWatch,
6898
+ fsWatchWorker: fsWatchWorker,
6780
6899
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6781
6900
  getCurrentDirectory: getCurrentDirectory,
6782
- fileExists: fileExists,
6901
+ fileSystemEntryExists: fileSystemEntryExists,
6783
6902
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6784
6903
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6785
6904
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6786
- directoryExists: directoryExists,
6787
6905
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6788
6906
  realpath: realpath,
6789
6907
  tscWatchFile: process.env.TSC_WATCHFILE,
6790
6908
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6791
6909
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6792
6910
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
6911
+ inodeWatching: isLinuxOrMacOs,
6912
+ sysLog: sysLog,
6793
6913
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6794
6914
  var nodeSystem = {
6795
6915
  args: process.argv.slice(2),
@@ -7039,110 +7159,14 @@ var ts;
7039
7159
  // File changed
7040
7160
  eventKind = FileWatcherEventKind.Changed;
7041
7161
  }
7042
- callback(fileName, eventKind);
7162
+ callback(fileName, eventKind, curr.mtime);
7043
7163
  }
7044
7164
  }
7045
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7046
- var options;
7047
- var lastDirectoryPartWithDirectorySeparator;
7048
- var lastDirectoryPart;
7049
- if (isLinuxOrMacOs) {
7050
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7051
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7052
- }
7053
- /** Watcher for the file system entry depending on whether it is missing or present */
7054
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7055
- watchMissingFileSystemEntry() :
7056
- watchPresentFileSystemEntry();
7057
- return {
7058
- close: function () {
7059
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7060
- watcher.close();
7061
- watcher = undefined;
7062
- }
7063
- };
7064
- /**
7065
- * Invoke the callback with rename and update the watcher if not closed
7066
- * @param createWatcher
7067
- */
7068
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7069
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7070
- // Call the callback for current directory
7071
- callback("rename", "");
7072
- // If watcher is not closed, update it
7073
- if (watcher) {
7074
- watcher.close();
7075
- watcher = createWatcher();
7076
- }
7077
- }
7078
- /**
7079
- * Watch the file or directory that is currently present
7080
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
7081
- */
7082
- function watchPresentFileSystemEntry() {
7083
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7084
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7085
- if (options === undefined) {
7086
- if (fsSupportsRecursiveFsWatch) {
7087
- options = { persistent: true, recursive: !!recursive };
7088
- }
7089
- else {
7090
- options = { persistent: true };
7091
- }
7092
- }
7093
- if (hitSystemWatcherLimit) {
7094
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7095
- return watchPresentFileSystemEntryWithFsWatchFile();
7096
- }
7097
- try {
7098
- var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7099
- callbackChangingToMissingFileSystemEntry :
7100
- callback);
7101
- // Watch the missing file or directory or error
7102
- presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7103
- return presentWatcher;
7104
- }
7105
- catch (e) {
7106
- // Catch the exception and use polling instead
7107
- // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7108
- // so instead of throwing error, use fs.watchFile
7109
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7110
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7111
- return watchPresentFileSystemEntryWithFsWatchFile();
7112
- }
7113
- }
7114
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7115
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7116
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7117
- return event === "rename" &&
7118
- (!relativeName ||
7119
- relativeName === lastDirectoryPart ||
7120
- (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7121
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7122
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7123
- callback(event, relativeName);
7124
- }
7125
- /**
7126
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
7127
- * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7128
- */
7129
- function watchPresentFileSystemEntryWithFsWatchFile() {
7130
- return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7131
- }
7132
- /**
7133
- * Watch the file or directory that is missing
7134
- * and switch to existing file or directory when the missing filesystem entry is created
7135
- */
7136
- function watchMissingFileSystemEntry() {
7137
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7138
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7139
- // Call the callback for current file or directory
7140
- // For now it could be callback for the inner directory creation,
7141
- // but just return current directory, better than current no-op
7142
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7143
- }
7144
- }, fallbackPollingInterval, fallbackOptions);
7145
- }
7165
+ function fsWatchWorker(fileOrDirectory, recursive, callback) {
7166
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7167
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7168
+ return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7169
+ { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7146
7170
  }
7147
7171
  function readFileWorker(fileName, _encoding) {
7148
7172
  var buffer;
@@ -7289,12 +7313,19 @@ var ts;
7289
7313
  }
7290
7314
  function getModifiedTime(path) {
7291
7315
  var _a;
7316
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7317
+ // the CPU time performance.
7318
+ var originalStackTraceLimit = Error.stackTraceLimit;
7319
+ Error.stackTraceLimit = 0;
7292
7320
  try {
7293
7321
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7294
7322
  }
7295
7323
  catch (e) {
7296
7324
  return undefined;
7297
7325
  }
7326
+ finally {
7327
+ Error.stackTraceLimit = originalStackTraceLimit;
7328
+ }
7298
7329
  }
7299
7330
  function setModifiedTime(path, time) {
7300
7331
  try {
@@ -9319,8 +9350,8 @@ var ts;
9319
9350
  Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, ts.DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"),
9320
9351
  Output_file_0_from_project_1_does_not_exist: diag(6309, ts.DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"),
9321
9352
  Referenced_project_0_may_not_disable_emit: diag(6310, ts.DiagnosticCategory.Error, "Referenced_project_0_may_not_disable_emit_6310", "Referenced project '{0}' may not disable emit."),
9322
- Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2_6350", "Project '{0}' is out of date because oldest output '{1}' is older than newest input '{2}'"),
9323
- Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than oldest output '{2}'"),
9353
+ Project_0_is_out_of_date_because_output_1_is_older_than_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_1_is_older_than_input_2_6350", "Project '{0}' is out of date because output '{1}' is older than input '{2}'"),
9354
+ Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than output '{2}'"),
9324
9355
  Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"),
9325
9356
  Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"),
9326
9357
  Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"),
@@ -9364,6 +9395,8 @@ var ts;
9364
9395
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."),
9365
9396
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."),
9366
9397
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."),
9398
+ Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
9399
+ Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
9367
9400
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
9368
9401
  The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
9369
9402
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -20201,6 +20234,10 @@ var ts;
20201
20234
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20202
20235
  }
20203
20236
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20237
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20238
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20239
+ }
20240
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20204
20241
  function getCompilerOptionValue(options, option) {
20205
20242
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20206
20243
  }
@@ -39044,6 +39081,7 @@ var ts;
39044
39081
  ["es2022.error", "lib.es2022.error.d.ts"],
39045
39082
  ["es2022.intl", "lib.es2022.intl.d.ts"],
39046
39083
  ["es2022.object", "lib.es2022.object.d.ts"],
39084
+ ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
39047
39085
  ["es2022.string", "lib.es2022.string.d.ts"],
39048
39086
  ["esnext.array", "lib.es2022.array.d.ts"],
39049
39087
  ["esnext.symbol", "lib.es2019.symbol.d.ts"],
@@ -39257,6 +39295,7 @@ var ts;
39257
39295
  type: "boolean",
39258
39296
  affectsSemanticDiagnostics: true,
39259
39297
  affectsEmit: true,
39298
+ affectsMultiFileEmitBuildInfo: true,
39260
39299
  category: ts.Diagnostics.Watch_and_Build_Modes,
39261
39300
  description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
39262
39301
  defaultValueDescription: false,
@@ -39291,12 +39330,40 @@ var ts;
39291
39330
  affectsSourceFile: true,
39292
39331
  affectsModuleResolution: true,
39293
39332
  affectsEmit: true,
39333
+ affectsMultiFileEmitBuildInfo: true,
39294
39334
  paramType: ts.Diagnostics.VERSION,
39295
39335
  showInSimplifiedHelpView: true,
39296
39336
  category: ts.Diagnostics.Language_and_Environment,
39297
39337
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39298
39338
  defaultValueDescription: 0 /* ES3 */,
39299
39339
  };
39340
+ /*@internal*/
39341
+ ts.moduleOptionDeclaration = {
39342
+ name: "module",
39343
+ shortName: "m",
39344
+ type: new ts.Map(ts.getEntries({
39345
+ none: ts.ModuleKind.None,
39346
+ commonjs: ts.ModuleKind.CommonJS,
39347
+ amd: ts.ModuleKind.AMD,
39348
+ system: ts.ModuleKind.System,
39349
+ umd: ts.ModuleKind.UMD,
39350
+ es6: ts.ModuleKind.ES2015,
39351
+ es2015: ts.ModuleKind.ES2015,
39352
+ es2020: ts.ModuleKind.ES2020,
39353
+ es2022: ts.ModuleKind.ES2022,
39354
+ esnext: ts.ModuleKind.ESNext,
39355
+ node16: ts.ModuleKind.Node16,
39356
+ nodenext: ts.ModuleKind.NodeNext,
39357
+ })),
39358
+ affectsModuleResolution: true,
39359
+ affectsEmit: true,
39360
+ affectsMultiFileEmitBuildInfo: true,
39361
+ paramType: ts.Diagnostics.KIND,
39362
+ showInSimplifiedHelpView: true,
39363
+ category: ts.Diagnostics.Modules,
39364
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39365
+ defaultValueDescription: undefined,
39366
+ };
39300
39367
  var commandOptionsWithoutBuild = [
39301
39368
  // CommandLine only options
39302
39369
  {
@@ -39358,37 +39425,14 @@ var ts;
39358
39425
  category: ts.Diagnostics.Command_line_Options,
39359
39426
  affectsSemanticDiagnostics: true,
39360
39427
  affectsEmit: true,
39428
+ affectsMultiFileEmitBuildInfo: true,
39361
39429
  isCommandLineOnly: true,
39362
39430
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39363
39431
  defaultValueDescription: false,
39364
39432
  },
39365
39433
  // Basic
39366
39434
  ts.targetOptionDeclaration,
39367
- {
39368
- name: "module",
39369
- shortName: "m",
39370
- type: new ts.Map(ts.getEntries({
39371
- none: ts.ModuleKind.None,
39372
- commonjs: ts.ModuleKind.CommonJS,
39373
- amd: ts.ModuleKind.AMD,
39374
- system: ts.ModuleKind.System,
39375
- umd: ts.ModuleKind.UMD,
39376
- es6: ts.ModuleKind.ES2015,
39377
- es2015: ts.ModuleKind.ES2015,
39378
- es2020: ts.ModuleKind.ES2020,
39379
- es2022: ts.ModuleKind.ES2022,
39380
- esnext: ts.ModuleKind.ESNext,
39381
- node16: ts.ModuleKind.Node16,
39382
- nodenext: ts.ModuleKind.NodeNext,
39383
- })),
39384
- affectsModuleResolution: true,
39385
- affectsEmit: true,
39386
- paramType: ts.Diagnostics.KIND,
39387
- showInSimplifiedHelpView: true,
39388
- category: ts.Diagnostics.Modules,
39389
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39390
- defaultValueDescription: undefined,
39391
- },
39435
+ ts.moduleOptionDeclaration,
39392
39436
  {
39393
39437
  name: "lib",
39394
39438
  type: "list",
@@ -39425,6 +39469,7 @@ var ts;
39425
39469
  type: jsxOptionMap,
39426
39470
  affectsSourceFile: true,
39427
39471
  affectsEmit: true,
39472
+ affectsMultiFileEmitBuildInfo: true,
39428
39473
  affectsModuleResolution: true,
39429
39474
  paramType: ts.Diagnostics.KIND,
39430
39475
  showInSimplifiedHelpView: true,
@@ -39437,6 +39482,7 @@ var ts;
39437
39482
  shortName: "d",
39438
39483
  type: "boolean",
39439
39484
  affectsEmit: true,
39485
+ affectsMultiFileEmitBuildInfo: true,
39440
39486
  showInSimplifiedHelpView: true,
39441
39487
  category: ts.Diagnostics.Emit,
39442
39488
  transpileOptionValue: undefined,
@@ -39447,6 +39493,7 @@ var ts;
39447
39493
  name: "declarationMap",
39448
39494
  type: "boolean",
39449
39495
  affectsEmit: true,
39496
+ affectsMultiFileEmitBuildInfo: true,
39450
39497
  showInSimplifiedHelpView: true,
39451
39498
  category: ts.Diagnostics.Emit,
39452
39499
  transpileOptionValue: undefined,
@@ -39457,6 +39504,7 @@ var ts;
39457
39504
  name: "emitDeclarationOnly",
39458
39505
  type: "boolean",
39459
39506
  affectsEmit: true,
39507
+ affectsMultiFileEmitBuildInfo: true,
39460
39508
  showInSimplifiedHelpView: true,
39461
39509
  category: ts.Diagnostics.Emit,
39462
39510
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39467,6 +39515,7 @@ var ts;
39467
39515
  name: "sourceMap",
39468
39516
  type: "boolean",
39469
39517
  affectsEmit: true,
39518
+ affectsMultiFileEmitBuildInfo: true,
39470
39519
  showInSimplifiedHelpView: true,
39471
39520
  category: ts.Diagnostics.Emit,
39472
39521
  defaultValueDescription: false,
@@ -39476,6 +39525,9 @@ var ts;
39476
39525
  name: "outFile",
39477
39526
  type: "string",
39478
39527
  affectsEmit: true,
39528
+ affectsMultiFileEmitBuildInfo: true,
39529
+ affectsDeclarationPath: true,
39530
+ affectsBundleEmitBuildInfo: true,
39479
39531
  isFilePath: true,
39480
39532
  paramType: ts.Diagnostics.FILE,
39481
39533
  showInSimplifiedHelpView: true,
@@ -39487,6 +39539,8 @@ var ts;
39487
39539
  name: "outDir",
39488
39540
  type: "string",
39489
39541
  affectsEmit: true,
39542
+ affectsMultiFileEmitBuildInfo: true,
39543
+ affectsDeclarationPath: true,
39490
39544
  isFilePath: true,
39491
39545
  paramType: ts.Diagnostics.DIRECTORY,
39492
39546
  showInSimplifiedHelpView: true,
@@ -39497,6 +39551,8 @@ var ts;
39497
39551
  name: "rootDir",
39498
39552
  type: "string",
39499
39553
  affectsEmit: true,
39554
+ affectsMultiFileEmitBuildInfo: true,
39555
+ affectsDeclarationPath: true,
39500
39556
  isFilePath: true,
39501
39557
  paramType: ts.Diagnostics.LOCATION,
39502
39558
  category: ts.Diagnostics.Modules,
@@ -39507,6 +39563,8 @@ var ts;
39507
39563
  name: "composite",
39508
39564
  type: "boolean",
39509
39565
  affectsEmit: true,
39566
+ affectsMultiFileEmitBuildInfo: true,
39567
+ affectsBundleEmitBuildInfo: true,
39510
39568
  isTSConfigOnly: true,
39511
39569
  category: ts.Diagnostics.Projects,
39512
39570
  transpileOptionValue: undefined,
@@ -39517,6 +39575,8 @@ var ts;
39517
39575
  name: "tsBuildInfoFile",
39518
39576
  type: "string",
39519
39577
  affectsEmit: true,
39578
+ affectsMultiFileEmitBuildInfo: true,
39579
+ affectsBundleEmitBuildInfo: true,
39520
39580
  isFilePath: true,
39521
39581
  paramType: ts.Diagnostics.FILE,
39522
39582
  category: ts.Diagnostics.Projects,
@@ -39528,6 +39588,7 @@ var ts;
39528
39588
  name: "removeComments",
39529
39589
  type: "boolean",
39530
39590
  affectsEmit: true,
39591
+ affectsMultiFileEmitBuildInfo: true,
39531
39592
  showInSimplifiedHelpView: true,
39532
39593
  category: ts.Diagnostics.Emit,
39533
39594
  defaultValueDescription: false,
@@ -39546,6 +39607,7 @@ var ts;
39546
39607
  name: "importHelpers",
39547
39608
  type: "boolean",
39548
39609
  affectsEmit: true,
39610
+ affectsMultiFileEmitBuildInfo: true,
39549
39611
  category: ts.Diagnostics.Emit,
39550
39612
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39551
39613
  defaultValueDescription: false,
@@ -39559,6 +39621,7 @@ var ts;
39559
39621
  })),
39560
39622
  affectsEmit: true,
39561
39623
  affectsSemanticDiagnostics: true,
39624
+ affectsMultiFileEmitBuildInfo: true,
39562
39625
  category: ts.Diagnostics.Emit,
39563
39626
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39564
39627
  defaultValueDescription: 0 /* Remove */,
@@ -39567,6 +39630,7 @@ var ts;
39567
39630
  name: "downlevelIteration",
39568
39631
  type: "boolean",
39569
39632
  affectsEmit: true,
39633
+ affectsMultiFileEmitBuildInfo: true,
39570
39634
  category: ts.Diagnostics.Emit,
39571
39635
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39572
39636
  defaultValueDescription: false,
@@ -39585,6 +39649,9 @@ var ts;
39585
39649
  type: "boolean",
39586
39650
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39587
39651
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39652
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39653
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39654
+ affectsMultiFileEmitBuildInfo: true,
39588
39655
  showInSimplifiedHelpView: true,
39589
39656
  category: ts.Diagnostics.Type_Checking,
39590
39657
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39594,6 +39661,7 @@ var ts;
39594
39661
  name: "noImplicitAny",
39595
39662
  type: "boolean",
39596
39663
  affectsSemanticDiagnostics: true,
39664
+ affectsMultiFileEmitBuildInfo: true,
39597
39665
  strictFlag: true,
39598
39666
  category: ts.Diagnostics.Type_Checking,
39599
39667
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39603,6 +39671,7 @@ var ts;
39603
39671
  name: "strictNullChecks",
39604
39672
  type: "boolean",
39605
39673
  affectsSemanticDiagnostics: true,
39674
+ affectsMultiFileEmitBuildInfo: true,
39606
39675
  strictFlag: true,
39607
39676
  category: ts.Diagnostics.Type_Checking,
39608
39677
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39611,6 +39680,8 @@ var ts;
39611
39680
  {
39612
39681
  name: "strictFunctionTypes",
39613
39682
  type: "boolean",
39683
+ affectsSemanticDiagnostics: true,
39684
+ affectsMultiFileEmitBuildInfo: true,
39614
39685
  strictFlag: true,
39615
39686
  category: ts.Diagnostics.Type_Checking,
39616
39687
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39619,6 +39690,8 @@ var ts;
39619
39690
  {
39620
39691
  name: "strictBindCallApply",
39621
39692
  type: "boolean",
39693
+ affectsSemanticDiagnostics: true,
39694
+ affectsMultiFileEmitBuildInfo: true,
39622
39695
  strictFlag: true,
39623
39696
  category: ts.Diagnostics.Type_Checking,
39624
39697
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39628,6 +39701,7 @@ var ts;
39628
39701
  name: "strictPropertyInitialization",
39629
39702
  type: "boolean",
39630
39703
  affectsSemanticDiagnostics: true,
39704
+ affectsMultiFileEmitBuildInfo: true,
39631
39705
  strictFlag: true,
39632
39706
  category: ts.Diagnostics.Type_Checking,
39633
39707
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39637,6 +39711,7 @@ var ts;
39637
39711
  name: "noImplicitThis",
39638
39712
  type: "boolean",
39639
39713
  affectsSemanticDiagnostics: true,
39714
+ affectsMultiFileEmitBuildInfo: true,
39640
39715
  strictFlag: true,
39641
39716
  category: ts.Diagnostics.Type_Checking,
39642
39717
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39646,6 +39721,7 @@ var ts;
39646
39721
  name: "useUnknownInCatchVariables",
39647
39722
  type: "boolean",
39648
39723
  affectsSemanticDiagnostics: true,
39724
+ affectsMultiFileEmitBuildInfo: true,
39649
39725
  strictFlag: true,
39650
39726
  category: ts.Diagnostics.Type_Checking,
39651
39727
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39655,6 +39731,8 @@ var ts;
39655
39731
  name: "alwaysStrict",
39656
39732
  type: "boolean",
39657
39733
  affectsSourceFile: true,
39734
+ affectsEmit: true,
39735
+ affectsMultiFileEmitBuildInfo: true,
39658
39736
  strictFlag: true,
39659
39737
  category: ts.Diagnostics.Type_Checking,
39660
39738
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39665,6 +39743,7 @@ var ts;
39665
39743
  name: "noUnusedLocals",
39666
39744
  type: "boolean",
39667
39745
  affectsSemanticDiagnostics: true,
39746
+ affectsMultiFileEmitBuildInfo: true,
39668
39747
  category: ts.Diagnostics.Type_Checking,
39669
39748
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39670
39749
  defaultValueDescription: false,
@@ -39673,6 +39752,7 @@ var ts;
39673
39752
  name: "noUnusedParameters",
39674
39753
  type: "boolean",
39675
39754
  affectsSemanticDiagnostics: true,
39755
+ affectsMultiFileEmitBuildInfo: true,
39676
39756
  category: ts.Diagnostics.Type_Checking,
39677
39757
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39678
39758
  defaultValueDescription: false,
@@ -39681,6 +39761,7 @@ var ts;
39681
39761
  name: "exactOptionalPropertyTypes",
39682
39762
  type: "boolean",
39683
39763
  affectsSemanticDiagnostics: true,
39764
+ affectsMultiFileEmitBuildInfo: true,
39684
39765
  category: ts.Diagnostics.Type_Checking,
39685
39766
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39686
39767
  defaultValueDescription: false,
@@ -39689,6 +39770,7 @@ var ts;
39689
39770
  name: "noImplicitReturns",
39690
39771
  type: "boolean",
39691
39772
  affectsSemanticDiagnostics: true,
39773
+ affectsMultiFileEmitBuildInfo: true,
39692
39774
  category: ts.Diagnostics.Type_Checking,
39693
39775
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39694
39776
  defaultValueDescription: false,
@@ -39698,6 +39780,7 @@ var ts;
39698
39780
  type: "boolean",
39699
39781
  affectsBindDiagnostics: true,
39700
39782
  affectsSemanticDiagnostics: true,
39783
+ affectsMultiFileEmitBuildInfo: true,
39701
39784
  category: ts.Diagnostics.Type_Checking,
39702
39785
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39703
39786
  defaultValueDescription: false,
@@ -39706,6 +39789,7 @@ var ts;
39706
39789
  name: "noUncheckedIndexedAccess",
39707
39790
  type: "boolean",
39708
39791
  affectsSemanticDiagnostics: true,
39792
+ affectsMultiFileEmitBuildInfo: true,
39709
39793
  category: ts.Diagnostics.Type_Checking,
39710
39794
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39711
39795
  defaultValueDescription: false,
@@ -39714,6 +39798,7 @@ var ts;
39714
39798
  name: "noImplicitOverride",
39715
39799
  type: "boolean",
39716
39800
  affectsSemanticDiagnostics: true,
39801
+ affectsMultiFileEmitBuildInfo: true,
39717
39802
  category: ts.Diagnostics.Type_Checking,
39718
39803
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39719
39804
  defaultValueDescription: false,
@@ -39721,6 +39806,8 @@ var ts;
39721
39806
  {
39722
39807
  name: "noPropertyAccessFromIndexSignature",
39723
39808
  type: "boolean",
39809
+ affectsSemanticDiagnostics: true,
39810
+ affectsMultiFileEmitBuildInfo: true,
39724
39811
  showInSimplifiedHelpView: false,
39725
39812
  category: ts.Diagnostics.Type_Checking,
39726
39813
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39806,6 +39893,7 @@ var ts;
39806
39893
  name: "allowSyntheticDefaultImports",
39807
39894
  type: "boolean",
39808
39895
  affectsSemanticDiagnostics: true,
39896
+ affectsMultiFileEmitBuildInfo: true,
39809
39897
  category: ts.Diagnostics.Interop_Constraints,
39810
39898
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39811
39899
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39815,6 +39903,7 @@ var ts;
39815
39903
  type: "boolean",
39816
39904
  affectsSemanticDiagnostics: true,
39817
39905
  affectsEmit: true,
39906
+ affectsMultiFileEmitBuildInfo: true,
39818
39907
  showInSimplifiedHelpView: true,
39819
39908
  category: ts.Diagnostics.Interop_Constraints,
39820
39909
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39831,6 +39920,7 @@ var ts;
39831
39920
  name: "allowUmdGlobalAccess",
39832
39921
  type: "boolean",
39833
39922
  affectsSemanticDiagnostics: true,
39923
+ affectsMultiFileEmitBuildInfo: true,
39834
39924
  category: ts.Diagnostics.Modules,
39835
39925
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39836
39926
  defaultValueDescription: false,
@@ -39852,6 +39942,7 @@ var ts;
39852
39942
  name: "sourceRoot",
39853
39943
  type: "string",
39854
39944
  affectsEmit: true,
39945
+ affectsMultiFileEmitBuildInfo: true,
39855
39946
  paramType: ts.Diagnostics.LOCATION,
39856
39947
  category: ts.Diagnostics.Emit,
39857
39948
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39860,6 +39951,7 @@ var ts;
39860
39951
  name: "mapRoot",
39861
39952
  type: "string",
39862
39953
  affectsEmit: true,
39954
+ affectsMultiFileEmitBuildInfo: true,
39863
39955
  paramType: ts.Diagnostics.LOCATION,
39864
39956
  category: ts.Diagnostics.Emit,
39865
39957
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39868,6 +39960,7 @@ var ts;
39868
39960
  name: "inlineSourceMap",
39869
39961
  type: "boolean",
39870
39962
  affectsEmit: true,
39963
+ affectsMultiFileEmitBuildInfo: true,
39871
39964
  category: ts.Diagnostics.Emit,
39872
39965
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39873
39966
  defaultValueDescription: false,
@@ -39876,6 +39969,7 @@ var ts;
39876
39969
  name: "inlineSources",
39877
39970
  type: "boolean",
39878
39971
  affectsEmit: true,
39972
+ affectsMultiFileEmitBuildInfo: true,
39879
39973
  category: ts.Diagnostics.Emit,
39880
39974
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39881
39975
  defaultValueDescription: false,
@@ -39885,6 +39979,7 @@ var ts;
39885
39979
  name: "experimentalDecorators",
39886
39980
  type: "boolean",
39887
39981
  affectsSemanticDiagnostics: true,
39982
+ affectsMultiFileEmitBuildInfo: true,
39888
39983
  category: ts.Diagnostics.Language_and_Environment,
39889
39984
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39890
39985
  defaultValueDescription: false,
@@ -39894,6 +39989,7 @@ var ts;
39894
39989
  type: "boolean",
39895
39990
  affectsSemanticDiagnostics: true,
39896
39991
  affectsEmit: true,
39992
+ affectsMultiFileEmitBuildInfo: true,
39897
39993
  category: ts.Diagnostics.Language_and_Environment,
39898
39994
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39899
39995
  defaultValueDescription: false,
@@ -39918,6 +40014,7 @@ var ts;
39918
40014
  type: "string",
39919
40015
  affectsSemanticDiagnostics: true,
39920
40016
  affectsEmit: true,
40017
+ affectsMultiFileEmitBuildInfo: true,
39921
40018
  affectsModuleResolution: true,
39922
40019
  category: ts.Diagnostics.Language_and_Environment,
39923
40020
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39935,6 +40032,9 @@ var ts;
39935
40032
  name: "out",
39936
40033
  type: "string",
39937
40034
  affectsEmit: true,
40035
+ affectsMultiFileEmitBuildInfo: true,
40036
+ affectsDeclarationPath: true,
40037
+ affectsBundleEmitBuildInfo: true,
39938
40038
  isFilePath: false,
39939
40039
  // for correct behaviour, please use outFile
39940
40040
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39946,6 +40046,7 @@ var ts;
39946
40046
  name: "reactNamespace",
39947
40047
  type: "string",
39948
40048
  affectsEmit: true,
40049
+ affectsMultiFileEmitBuildInfo: true,
39949
40050
  category: ts.Diagnostics.Language_and_Environment,
39950
40051
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39951
40052
  defaultValueDescription: "`React`",
@@ -39953,6 +40054,8 @@ var ts;
39953
40054
  {
39954
40055
  name: "skipDefaultLibCheck",
39955
40056
  type: "boolean",
40057
+ // We need to store these to determine whether `lib` files need to be rechecked
40058
+ affectsMultiFileEmitBuildInfo: true,
39956
40059
  category: ts.Diagnostics.Completeness,
39957
40060
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39958
40061
  defaultValueDescription: false,
@@ -39968,6 +40071,7 @@ var ts;
39968
40071
  name: "emitBOM",
39969
40072
  type: "boolean",
39970
40073
  affectsEmit: true,
40074
+ affectsMultiFileEmitBuildInfo: true,
39971
40075
  category: ts.Diagnostics.Emit,
39972
40076
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39973
40077
  defaultValueDescription: false,
@@ -39979,6 +40083,7 @@ var ts;
39979
40083
  lf: 1 /* LineFeed */
39980
40084
  })),
39981
40085
  affectsEmit: true,
40086
+ affectsMultiFileEmitBuildInfo: true,
39982
40087
  paramType: ts.Diagnostics.NEWLINE,
39983
40088
  category: ts.Diagnostics.Emit,
39984
40089
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39988,6 +40093,7 @@ var ts;
39988
40093
  name: "noErrorTruncation",
39989
40094
  type: "boolean",
39990
40095
  affectsSemanticDiagnostics: true,
40096
+ affectsMultiFileEmitBuildInfo: true,
39991
40097
  category: ts.Diagnostics.Output_Formatting,
39992
40098
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39993
40099
  defaultValueDescription: false,
@@ -40018,6 +40124,7 @@ var ts;
40018
40124
  name: "stripInternal",
40019
40125
  type: "boolean",
40020
40126
  affectsEmit: true,
40127
+ affectsMultiFileEmitBuildInfo: true,
40021
40128
  category: ts.Diagnostics.Emit,
40022
40129
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40023
40130
  defaultValueDescription: false,
@@ -40058,6 +40165,7 @@ var ts;
40058
40165
  name: "noImplicitUseStrict",
40059
40166
  type: "boolean",
40060
40167
  affectsSemanticDiagnostics: true,
40168
+ affectsMultiFileEmitBuildInfo: true,
40061
40169
  category: ts.Diagnostics.Backwards_Compatibility,
40062
40170
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40063
40171
  defaultValueDescription: false,
@@ -40066,6 +40174,7 @@ var ts;
40066
40174
  name: "noEmitHelpers",
40067
40175
  type: "boolean",
40068
40176
  affectsEmit: true,
40177
+ affectsMultiFileEmitBuildInfo: true,
40069
40178
  category: ts.Diagnostics.Emit,
40070
40179
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40071
40180
  defaultValueDescription: false,
@@ -40074,6 +40183,7 @@ var ts;
40074
40183
  name: "noEmitOnError",
40075
40184
  type: "boolean",
40076
40185
  affectsEmit: true,
40186
+ affectsMultiFileEmitBuildInfo: true,
40077
40187
  category: ts.Diagnostics.Emit,
40078
40188
  transpileOptionValue: undefined,
40079
40189
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40083,6 +40193,7 @@ var ts;
40083
40193
  name: "preserveConstEnums",
40084
40194
  type: "boolean",
40085
40195
  affectsEmit: true,
40196
+ affectsMultiFileEmitBuildInfo: true,
40086
40197
  category: ts.Diagnostics.Emit,
40087
40198
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40088
40199
  defaultValueDescription: false,
@@ -40091,6 +40202,8 @@ var ts;
40091
40202
  name: "declarationDir",
40092
40203
  type: "string",
40093
40204
  affectsEmit: true,
40205
+ affectsMultiFileEmitBuildInfo: true,
40206
+ affectsDeclarationPath: true,
40094
40207
  isFilePath: true,
40095
40208
  paramType: ts.Diagnostics.DIRECTORY,
40096
40209
  category: ts.Diagnostics.Emit,
@@ -40100,6 +40213,8 @@ var ts;
40100
40213
  {
40101
40214
  name: "skipLibCheck",
40102
40215
  type: "boolean",
40216
+ // We need to store these to determine whether `lib` files need to be rechecked
40217
+ affectsMultiFileEmitBuildInfo: true,
40103
40218
  category: ts.Diagnostics.Completeness,
40104
40219
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40105
40220
  defaultValueDescription: false,
@@ -40109,6 +40224,7 @@ var ts;
40109
40224
  type: "boolean",
40110
40225
  affectsBindDiagnostics: true,
40111
40226
  affectsSemanticDiagnostics: true,
40227
+ affectsMultiFileEmitBuildInfo: true,
40112
40228
  category: ts.Diagnostics.Type_Checking,
40113
40229
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40114
40230
  defaultValueDescription: undefined,
@@ -40118,6 +40234,7 @@ var ts;
40118
40234
  type: "boolean",
40119
40235
  affectsBindDiagnostics: true,
40120
40236
  affectsSemanticDiagnostics: true,
40237
+ affectsMultiFileEmitBuildInfo: true,
40121
40238
  category: ts.Diagnostics.Type_Checking,
40122
40239
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40123
40240
  defaultValueDescription: undefined,
@@ -40126,6 +40243,7 @@ var ts;
40126
40243
  name: "suppressExcessPropertyErrors",
40127
40244
  type: "boolean",
40128
40245
  affectsSemanticDiagnostics: true,
40246
+ affectsMultiFileEmitBuildInfo: true,
40129
40247
  category: ts.Diagnostics.Backwards_Compatibility,
40130
40248
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40131
40249
  defaultValueDescription: false,
@@ -40134,6 +40252,7 @@ var ts;
40134
40252
  name: "suppressImplicitAnyIndexErrors",
40135
40253
  type: "boolean",
40136
40254
  affectsSemanticDiagnostics: true,
40255
+ affectsMultiFileEmitBuildInfo: true,
40137
40256
  category: ts.Diagnostics.Backwards_Compatibility,
40138
40257
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40139
40258
  defaultValueDescription: false,
@@ -40158,6 +40277,7 @@ var ts;
40158
40277
  name: "noStrictGenericChecks",
40159
40278
  type: "boolean",
40160
40279
  affectsSemanticDiagnostics: true,
40280
+ affectsMultiFileEmitBuildInfo: true,
40161
40281
  category: ts.Diagnostics.Backwards_Compatibility,
40162
40282
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40163
40283
  defaultValueDescription: false,
@@ -40167,6 +40287,7 @@ var ts;
40167
40287
  type: "boolean",
40168
40288
  affectsSemanticDiagnostics: true,
40169
40289
  affectsEmit: true,
40290
+ affectsMultiFileEmitBuildInfo: true,
40170
40291
  category: ts.Diagnostics.Language_and_Environment,
40171
40292
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40172
40293
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40175,6 +40296,7 @@ var ts;
40175
40296
  name: "preserveValueImports",
40176
40297
  type: "boolean",
40177
40298
  affectsEmit: true,
40299
+ affectsMultiFileEmitBuildInfo: true,
40178
40300
  category: ts.Diagnostics.Emit,
40179
40301
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40180
40302
  defaultValueDescription: false,
@@ -40218,6 +40340,8 @@ var ts;
40218
40340
  /* @internal */
40219
40341
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40220
40342
  /* @internal */
40343
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40344
+ /* @internal */
40221
40345
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40222
40346
  /* @internal */
40223
40347
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41073,6 +41197,7 @@ var ts;
41073
41197
  return optionDefinition.type;
41074
41198
  }
41075
41199
  }
41200
+ /* @internal */
41076
41201
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41077
41202
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41078
41203
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41081,6 +41206,7 @@ var ts;
41081
41206
  }
41082
41207
  });
41083
41208
  }
41209
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41084
41210
  function serializeCompilerOptions(options, pathOptions) {
41085
41211
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41086
41212
  }
@@ -42246,16 +42372,18 @@ var ts;
42246
42372
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42247
42373
  return { fileName: resolved.path, packageId: resolved.packageId };
42248
42374
  }
42249
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42250
- var _a;
42375
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42376
+ var _a, _b;
42251
42377
  if (resultFromCache) {
42252
42378
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42379
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42253
42380
  return resultFromCache;
42254
42381
  }
42255
42382
  return {
42256
42383
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42257
42384
  failedLookupLocations: failedLookupLocations,
42258
- resolutionDiagnostics: diagnostics
42385
+ affectingLocations: affectingLocations,
42386
+ resolutionDiagnostics: diagnostics,
42259
42387
  };
42260
42388
  }
42261
42389
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42444,6 +42572,7 @@ var ts;
42444
42572
  }
42445
42573
  }
42446
42574
  var failedLookupLocations = [];
42575
+ var affectingLocations = [];
42447
42576
  var features = getDefaultNodeResolutionFeatures(options);
42448
42577
  // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
42449
42578
  // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
@@ -42462,6 +42591,7 @@ var ts;
42462
42591
  host: host,
42463
42592
  traceEnabled: traceEnabled,
42464
42593
  failedLookupLocations: failedLookupLocations,
42594
+ affectingLocations: affectingLocations,
42465
42595
  packageJsonInfoCache: cache,
42466
42596
  features: features,
42467
42597
  conditions: conditions,
@@ -42486,7 +42616,7 @@ var ts;
42486
42616
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42487
42617
  };
42488
42618
  }
42489
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42619
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
42490
42620
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42491
42621
  if (traceEnabled)
42492
42622
  traceResult(result);
@@ -42566,6 +42696,7 @@ var ts;
42566
42696
  host: host,
42567
42697
  traceEnabled: isTraceEnabled(options, host),
42568
42698
  failedLookupLocations: [],
42699
+ affectingLocations: [],
42569
42700
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42570
42701
  conditions: ts.emptyArray,
42571
42702
  features: NodeResolutionFeatures.None,
@@ -43220,6 +43351,7 @@ var ts;
43220
43351
  var _a, _b;
43221
43352
  var traceEnabled = isTraceEnabled(compilerOptions, host);
43222
43353
  var failedLookupLocations = [];
43354
+ var affectingLocations = [];
43223
43355
  // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
43224
43356
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43225
43357
  var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
@@ -43232,6 +43364,7 @@ var ts;
43232
43364
  host: host,
43233
43365
  traceEnabled: traceEnabled,
43234
43366
  failedLookupLocations: failedLookupLocations,
43367
+ affectingLocations: affectingLocations,
43235
43368
  packageJsonInfoCache: cache,
43236
43369
  features: features,
43237
43370
  conditions: conditions,
@@ -43239,7 +43372,7 @@ var ts;
43239
43372
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43240
43373
  };
43241
43374
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43242
- return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
43375
+ return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
43243
43376
  function tryResolve(extensions) {
43244
43377
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43245
43378
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43534,6 +43667,7 @@ var ts;
43534
43667
  host: host,
43535
43668
  traceEnabled: isTraceEnabled(options, host),
43536
43669
  failedLookupLocations: [],
43670
+ affectingLocations: [],
43537
43671
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43538
43672
  conditions: ["node", "require", "types"],
43539
43673
  features: features,
@@ -43622,6 +43756,7 @@ var ts;
43622
43756
  compilerOptions: options,
43623
43757
  traceEnabled: isTraceEnabled(options, host),
43624
43758
  failedLookupLocations: [],
43759
+ affectingLocations: [],
43625
43760
  packageJsonInfoCache: packageJsonInfoCache,
43626
43761
  features: 0,
43627
43762
  conditions: [],
@@ -43654,6 +43789,7 @@ var ts;
43654
43789
  if (typeof existing !== "boolean") {
43655
43790
  if (traceEnabled)
43656
43791
  trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43792
+ state.affectingLocations.push(packageJsonPath);
43657
43793
  return existing;
43658
43794
  }
43659
43795
  else {
@@ -43672,6 +43808,7 @@ var ts;
43672
43808
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
43673
43809
  var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
43674
43810
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
43811
+ state.affectingLocations.push(packageJsonPath);
43675
43812
  return result;
43676
43813
  }
43677
43814
  else {
@@ -44335,12 +44472,25 @@ var ts;
44335
44472
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44336
44473
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44337
44474
  var failedLookupLocations = [];
44475
+ var affectingLocations = [];
44338
44476
  var containingDirectory = ts.getDirectoryPath(containingFile);
44339
44477
  var diagnostics = [];
44340
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44478
+ var state = {
44479
+ compilerOptions: compilerOptions,
44480
+ host: host,
44481
+ traceEnabled: traceEnabled,
44482
+ failedLookupLocations: failedLookupLocations,
44483
+ affectingLocations: affectingLocations,
44484
+ packageJsonInfoCache: cache,
44485
+ features: NodeResolutionFeatures.None,
44486
+ conditions: [],
44487
+ requestContainingDirectory: containingDirectory,
44488
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44489
+ };
44341
44490
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44342
44491
  // No originalPath because classic resolution doesn't resolve realPath
44343
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44492
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
44493
+ /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44344
44494
  function tryResolve(extensions) {
44345
44495
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44346
44496
  if (resolvedUsingSettings) {
@@ -44383,10 +44533,23 @@ var ts;
44383
44533
  trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
44384
44534
  }
44385
44535
  var failedLookupLocations = [];
44536
+ var affectingLocations = [];
44386
44537
  var diagnostics = [];
44387
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44538
+ var state = {
44539
+ compilerOptions: compilerOptions,
44540
+ host: host,
44541
+ traceEnabled: traceEnabled,
44542
+ failedLookupLocations: failedLookupLocations,
44543
+ affectingLocations: affectingLocations,
44544
+ packageJsonInfoCache: packageJsonInfoCache,
44545
+ features: NodeResolutionFeatures.None,
44546
+ conditions: [],
44547
+ requestContainingDirectory: undefined,
44548
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44549
+ };
44388
44550
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44389
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44551
+ return createResolvedModuleWithFailedLookupLocations(resolved,
44552
+ /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44390
44553
  }
44391
44554
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44392
44555
  /**
@@ -47947,16 +48110,6 @@ var ts;
47947
48110
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47948
48111
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47949
48112
  })(TypeFacts || (TypeFacts = {}));
47950
- var typeofEQFacts = new ts.Map(ts.getEntries({
47951
- string: 1 /* TypeofEQString */,
47952
- number: 2 /* TypeofEQNumber */,
47953
- bigint: 4 /* TypeofEQBigInt */,
47954
- boolean: 8 /* TypeofEQBoolean */,
47955
- symbol: 16 /* TypeofEQSymbol */,
47956
- undefined: 65536 /* EQUndefined */,
47957
- object: 32 /* TypeofEQObject */,
47958
- function: 64 /* TypeofEQFunction */
47959
- }));
47960
48113
  var typeofNEFacts = new ts.Map(ts.getEntries({
47961
48114
  string: 256 /* TypeofNEString */,
47962
48115
  number: 512 /* TypeofNENumber */,
@@ -48755,14 +48908,6 @@ var ts;
48755
48908
  var awaitedTypeStack = [];
48756
48909
  var diagnostics = ts.createDiagnosticCollection();
48757
48910
  var suggestionDiagnostics = ts.createDiagnosticCollection();
48758
- var typeofTypesByName = new ts.Map(ts.getEntries({
48759
- string: stringType,
48760
- number: numberType,
48761
- bigint: bigintType,
48762
- boolean: booleanType,
48763
- symbol: esSymbolType,
48764
- undefined: undefinedType
48765
- }));
48766
48911
  var typeofType = createTypeofType();
48767
48912
  var _jsxNamespace;
48768
48913
  var _jsxFactoryEntity;
@@ -51638,7 +51783,7 @@ var ts;
51638
51783
  return type;
51639
51784
  }
51640
51785
  function createTypeofType() {
51641
- return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
51786
+ return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
51642
51787
  }
51643
51788
  function createTypeParameter(symbol) {
51644
51789
  var type = createType(262144 /* TypeParameter */);
@@ -52424,6 +52569,9 @@ var ts;
52424
52569
  var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
52425
52570
  if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
52426
52571
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
52572
+ if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
52573
+ return ts.factory.createArrayTypeNode(typeArgumentNodes[0]);
52574
+ }
52427
52575
  return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
52428
52576
  }
52429
52577
  var objectFlags = ts.getObjectFlags(type);
@@ -52614,7 +52762,7 @@ var ts;
52614
52762
  // Always use 'typeof T' for type of class, enum, and module objects
52615
52763
  else if (symbol.flags & 32 /* Class */
52616
52764
  && !getBaseTypeVariableOfClass(symbol)
52617
- && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) ||
52765
+ && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) ||
52618
52766
  symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
52619
52767
  shouldWriteTypeOfFunctionSymbol()) {
52620
52768
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -56244,6 +56392,17 @@ var ts;
56244
56392
  });
56245
56393
  var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type
56246
56394
  members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
56395
+ if (initialSize === members_4.size) {
56396
+ if (type.aliasSymbol) {
56397
+ result.aliasSymbol = type.aliasSymbol;
56398
+ result.aliasTypeArguments = type.aliasTypeArguments;
56399
+ }
56400
+ if (ts.getObjectFlags(type) & 4 /* Reference */) {
56401
+ result.aliasSymbol = type.symbol;
56402
+ var args = getTypeArguments(type);
56403
+ result.aliasTypeArguments = ts.length(args) ? args : undefined;
56404
+ }
56405
+ }
56247
56406
  result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag
56248
56407
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
56249
56408
  result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
@@ -64427,6 +64586,9 @@ var ts;
64427
64586
  }
64428
64587
  return false;
64429
64588
  }
64589
+ function containsUndefinedType(type) {
64590
+ return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
64591
+ }
64430
64592
  function isStringIndexSignatureOnlyType(type) {
64431
64593
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64432
64594
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -69849,19 +70011,17 @@ var ts;
69849
70011
  }
69850
70012
  return links.switchTypes;
69851
70013
  }
69852
- function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
70014
+ // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are
70015
+ // represented as undefined. Return undefined if one or more case clause expressions are not string literals.
70016
+ function getSwitchClauseTypeOfWitnesses(switchStatement) {
70017
+ if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) {
70018
+ return undefined;
70019
+ }
69853
70020
  var witnesses = [];
69854
70021
  for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
69855
70022
  var clause = _a[_i];
69856
- if (clause.kind === 289 /* CaseClause */) {
69857
- if (ts.isStringLiteralLike(clause.expression)) {
69858
- witnesses.push(clause.expression.text);
69859
- continue;
69860
- }
69861
- return ts.emptyArray;
69862
- }
69863
- if (retainDefault)
69864
- witnesses.push(/*explicitDefaultStatement*/ undefined);
70023
+ var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined;
70024
+ witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined);
69865
70025
  }
69866
70026
  return witnesses;
69867
70027
  }
@@ -71051,14 +71211,9 @@ var ts;
71051
71211
  }
71052
71212
  return type;
71053
71213
  }
71054
- if (type.flags & 1 /* Any */ && literal.text === "function") {
71055
- return type;
71056
- }
71057
- var facts = assumeTrue ?
71058
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71059
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71060
- var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71061
- return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71214
+ return assumeTrue ?
71215
+ narrowTypeByTypeName(type, literal.text) :
71216
+ getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */);
71062
71217
  }
71063
71218
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71064
71219
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71105,102 +71260,52 @@ var ts;
71105
71260
  var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
71106
71261
  return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
71107
71262
  }
71108
- function getImpliedTypeFromTypeofGuard(type, text) {
71109
- switch (text) {
71110
- case "object":
71111
- return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71112
- case "function":
71113
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
71114
- default:
71115
- return typeofTypesByName.get(text);
71263
+ function narrowTypeByTypeName(type, typeName) {
71264
+ switch (typeName) {
71265
+ case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */);
71266
+ case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */);
71267
+ case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */);
71268
+ case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */);
71269
+ case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */);
71270
+ case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]);
71271
+ case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */);
71272
+ case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */);
71116
71273
  }
71274
+ return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
71117
71275
  }
71118
- // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71119
- // super-types of the implied guard will be retained in the final type: this is because type-facts only
71120
- // filter. Instead, we would like to replace those union constituents with the more precise type implied by
71121
- // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71122
- // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71123
- // filtering by type-facts.
71124
- function narrowTypeByImpliedType(type, candidate) {
71125
- if (type.flags & 3 /* AnyOrUnknown */) {
71126
- return candidate;
71127
- }
71276
+ function narrowTypeByTypeFacts(type, impliedType, facts) {
71128
71277
  return mapType(type, function (t) {
71129
- if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71130
- return t;
71131
- }
71132
- return mapType(candidate, function (c) {
71133
- if (!areTypesComparable(t, c)) {
71134
- return neverType;
71135
- }
71136
- if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71137
- return isTypeSubtypeOf(c, t) ? c : neverType;
71138
- }
71139
- if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71140
- return c;
71141
- }
71142
- return getIntersectionType([t, c]);
71143
- });
71278
+ // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
71279
+ // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
71280
+ // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
71281
+ // but are classified as "function" according to `typeof`.
71282
+ return isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType :
71283
+ // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
71284
+ // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
71285
+ isTypeSubtypeOf(impliedType, t) ? impliedType :
71286
+ // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
71287
+ // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
71288
+ // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
71289
+ getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) :
71290
+ neverType;
71144
71291
  });
71145
71292
  }
71146
71293
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71147
- var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
71148
- if (!switchWitnesses.length) {
71294
+ var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
71295
+ if (!witnesses) {
71149
71296
  return type;
71150
71297
  }
71151
- // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause
71152
- var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
71153
- var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
71154
- var clauseWitnesses;
71155
- var switchFacts;
71156
- if (defaultCaseLocation > -1) {
71157
- // We no longer need the undefined denoting an explicit default case. Remove the undefined and
71158
- // fix-up clauseStart and clauseEnd. This means that we don't have to worry about undefined in the
71159
- // witness array.
71160
- var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
71161
- // The adjusted clause start and end after removing the `default` statement.
71162
- var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
71163
- var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
71164
- clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
71165
- switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
71166
- }
71167
- else {
71168
- clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
71169
- switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
71170
- }
71298
+ // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause.
71299
+ var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; });
71300
+ var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd);
71171
71301
  if (hasDefaultClause) {
71172
- return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
71302
+ // In the default clause we filter constituents down to those that are not-equal to all handled cases.
71303
+ var notEqualFacts_1 = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses);
71304
+ return filterType(type, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; });
71173
71305
  }
71174
- /*
71175
- The implied type is the raw type suggested by a
71176
- value being caught in this clause.
71177
-
71178
- When the clause contains a default case we ignore
71179
- the implied type and try to narrow using any facts
71180
- we can learn: see `switchFacts`.
71181
-
71182
- Example:
71183
- switch (typeof x) {
71184
- case 'number':
71185
- case 'string': break;
71186
- default: break;
71187
- case 'number':
71188
- case 'boolean': break
71189
- }
71190
-
71191
- In the first clause (case `number` and `string`) the
71192
- implied type is number | string.
71193
-
71194
- In the default clause we de not compute an implied type.
71195
-
71196
- In the third clause (case `number` and `boolean`)
71197
- the naive implied type is number | boolean, however
71198
- we use the type facts to narrow the implied type to
71199
- boolean. We know that number cannot be selected
71200
- because it is caught in the first clause.
71201
- */
71202
- var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71203
- return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71306
+ // In the non-default cause we create a union of the type narrowed by each of the listed cases.
71307
+ var clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71308
+ return getUnionType(ts.map(clauseWitnesses, function (text) { return text ? narrowTypeByTypeName(type, text) : neverType; }));
71204
71309
  }
71205
71310
  function isMatchingConstructorReference(expr) {
71206
71311
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71811,7 +71916,7 @@ var ts;
71811
71916
  return convertAutoToAny(flowType);
71812
71917
  }
71813
71918
  }
71814
- else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
71919
+ else if (!assumeInitialized && !containsUndefinedType(type) && containsUndefinedType(flowType)) {
71815
71920
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
71816
71921
  // Return the declared type to reduce follow-on errors
71817
71922
  return type;
@@ -74822,7 +74927,7 @@ var ts;
74822
74927
  assumeUninitialized = true;
74823
74928
  }
74824
74929
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
74825
- if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
74930
+ if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) {
74826
74931
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
74827
74932
  // Return the declared type to reduce follow-on errors
74828
74933
  return propType;
@@ -78012,45 +78117,12 @@ var ts;
78012
78117
  ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
78013
78118
  : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
78014
78119
  }
78015
- /**
78016
- * Collect the TypeFacts learned from a typeof switch with
78017
- * total clauses `witnesses`, and the active clause ranging
78018
- * from `start` to `end`. Parameter `hasDefault` denotes
78019
- * whether the active clause contains a default clause.
78020
- */
78021
- function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
78120
+ // Return the combined not-equal type facts for all cases except those between the start and end indices.
78121
+ function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) {
78022
78122
  var facts = 0 /* None */;
78023
- // When in the default we only collect inequality facts
78024
- // because default is 'in theory' a set of infinite
78025
- // equalities.
78026
- if (hasDefault) {
78027
- // Value is not equal to any types after the active clause.
78028
- for (var i = end; i < witnesses.length; i++) {
78029
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78030
- }
78031
- // Remove inequalities for types that appear in the
78032
- // active clause because they appear before other
78033
- // types collected so far.
78034
- for (var i = start; i < end; i++) {
78035
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
78036
- }
78037
- // Add inequalities for types before the active clause unconditionally.
78038
- for (var i = 0; i < start; i++) {
78039
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
78040
- }
78041
- }
78042
- // When in an active clause without default the set of
78043
- // equalities is finite.
78044
- else {
78045
- // Add equalities for all types in the active clause.
78046
- for (var i = start; i < end; i++) {
78047
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
78048
- }
78049
- // Remove equalities for types that appear before the
78050
- // active clause.
78051
- for (var i = 0; i < start; i++) {
78052
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
78053
- }
78123
+ for (var i = 0; i < witnesses.length; i++) {
78124
+ var witness = i < start || i >= end ? witnesses[i] : undefined;
78125
+ facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0;
78054
78126
  }
78055
78127
  return facts;
78056
78128
  }
@@ -78060,16 +78132,19 @@ var ts;
78060
78132
  }
78061
78133
  function computeExhaustiveSwitchStatement(node) {
78062
78134
  if (node.expression.kind === 216 /* TypeOfExpression */) {
78063
- var operandType = getTypeOfExpression(node.expression.expression);
78064
- var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
78065
- // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
78066
- var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
78067
- var type_6 = getBaseConstraintOfType(operandType) || operandType;
78068
- // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
78069
- if (type_6.flags & 3 /* AnyOrUnknown */) {
78070
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
78135
+ var witnesses = getSwitchClauseTypeOfWitnesses(node);
78136
+ if (!witnesses) {
78137
+ return false;
78071
78138
  }
78072
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
78139
+ var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
78140
+ // Get the not-equal flags for all handled cases.
78141
+ var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
78142
+ if (operandConstraint.flags & 3 /* AnyOrUnknown */) {
78143
+ // We special case the top types to be exhaustive when all cases are handled.
78144
+ return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */;
78145
+ }
78146
+ // A missing not-equal flag indicates that the type wasn't handled by some case.
78147
+ return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
78073
78148
  }
78074
78149
  var type = getTypeOfExpression(node.expression);
78075
78150
  if (!isLiteralType(type)) {
@@ -81901,6 +81976,11 @@ var ts;
81901
81976
  function checkJSDocTypeTag(node) {
81902
81977
  checkSourceElement(node.typeExpression);
81903
81978
  }
81979
+ function checkJSDocLinkLikeTag(node) {
81980
+ if (node.name) {
81981
+ resolveJSDocMemberName(node.name, /*ignoreErrors*/ true);
81982
+ }
81983
+ }
81904
81984
  function checkJSDocParameterTag(node) {
81905
81985
  checkSourceElement(node.typeExpression);
81906
81986
  }
@@ -84672,7 +84752,7 @@ var ts;
84672
84752
  var propName = member.name;
84673
84753
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84674
84754
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84675
- if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84755
+ if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) {
84676
84756
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84677
84757
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84678
84758
  }
@@ -84697,7 +84777,7 @@ var ts;
84697
84777
  ts.setParent(reference, staticBlock);
84698
84778
  reference.flowNode = staticBlock.returnFlowNode;
84699
84779
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84700
- if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84780
+ if (!containsUndefinedType(flowType)) {
84701
84781
  return true;
84702
84782
  }
84703
84783
  }
@@ -84712,7 +84792,7 @@ var ts;
84712
84792
  ts.setParent(reference, constructor);
84713
84793
  reference.flowNode = constructor.returnFlowNode;
84714
84794
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84715
- return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84795
+ return !containsUndefinedType(flowType);
84716
84796
  }
84717
84797
  function checkInterfaceDeclaration(node) {
84718
84798
  // Grammar checking
@@ -85695,12 +85775,16 @@ var ts;
85695
85775
  }
85696
85776
  }
85697
85777
  function checkSourceElementWorker(node) {
85698
- if (ts.isInJSFile(node)) {
85699
- ts.forEach(node.jsDoc, function (_a) {
85700
- var tags = _a.tags;
85701
- return ts.forEach(tags, checkSourceElement);
85778
+ ts.forEach(node.jsDoc, function (_a) {
85779
+ var comment = _a.comment, tags = _a.tags;
85780
+ checkJSDocCommentWorker(comment);
85781
+ ts.forEach(tags, function (tag) {
85782
+ checkJSDocCommentWorker(tag.comment);
85783
+ if (ts.isInJSFile(node)) {
85784
+ checkSourceElement(tag);
85785
+ }
85702
85786
  });
85703
- }
85787
+ });
85704
85788
  var kind = node.kind;
85705
85789
  if (cancellationToken) {
85706
85790
  // Only bother checking on a few construct kinds. We don't want to be excessively
@@ -85786,6 +85870,10 @@ var ts;
85786
85870
  return checkJSDocTemplateTag(node);
85787
85871
  case 343 /* JSDocTypeTag */:
85788
85872
  return checkJSDocTypeTag(node);
85873
+ case 324 /* JSDocLink */:
85874
+ case 325 /* JSDocLinkCode */:
85875
+ case 326 /* JSDocLinkPlain */:
85876
+ return checkJSDocLinkLikeTag(node);
85789
85877
  case 340 /* JSDocParameterTag */:
85790
85878
  return checkJSDocParameterTag(node);
85791
85879
  case 347 /* JSDocPropertyTag */:
@@ -85880,6 +85968,15 @@ var ts;
85880
85968
  return checkMissingDeclaration(node);
85881
85969
  }
85882
85970
  }
85971
+ function checkJSDocCommentWorker(node) {
85972
+ if (ts.isArray(node)) {
85973
+ ts.forEach(node, function (tag) {
85974
+ if (ts.isJSDocLinkLike(tag)) {
85975
+ checkSourceElement(tag);
85976
+ }
85977
+ });
85978
+ }
85979
+ }
85883
85980
  function checkJSDocTypeIsInJsFile(node) {
85884
85981
  if (!ts.isInJSFile(node)) {
85885
85982
  grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
@@ -86435,7 +86532,7 @@ var ts;
86435
86532
  if (!result && isJSDoc_1) {
86436
86533
  var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
86437
86534
  if (container) {
86438
- return resolveJSDocMemberName(name, getSymbolOfNode(container));
86535
+ return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
86439
86536
  }
86440
86537
  }
86441
86538
  return result;
@@ -86481,11 +86578,11 @@ var ts;
86481
86578
  *
86482
86579
  * For unqualified names, a container K may be provided as a second argument.
86483
86580
  */
86484
- function resolveJSDocMemberName(name, container) {
86581
+ function resolveJSDocMemberName(name, ignoreErrors, container) {
86485
86582
  if (ts.isEntityName(name)) {
86486
86583
  // resolve static values first
86487
86584
  var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */;
86488
- var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86585
+ var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
86489
86586
  if (!symbol && ts.isIdentifier(name) && container) {
86490
86587
  symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning));
86491
86588
  }
@@ -86493,7 +86590,7 @@ var ts;
86493
86590
  return symbol;
86494
86591
  }
86495
86592
  }
86496
- var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left);
86593
+ var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container);
86497
86594
  var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText;
86498
86595
  if (left) {
86499
86596
  var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype");
@@ -110782,7 +110879,9 @@ var ts;
110782
110879
  return;
110783
110880
  }
110784
110881
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110785
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110882
+ var buildInfo = { bundle: bundle, program: program, version: version };
110883
+ // Pass buildinfo as additional data to avoid having to reparse
110884
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110786
110885
  }
110787
110886
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110788
110887
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110936,13 +111035,20 @@ var ts;
110936
111035
  if (sourceMapFilePath) {
110937
111036
  var sourceMap = sourceMapGenerator.toString();
110938
111037
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111038
+ if (printer.bundleFileInfo)
111039
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110939
111040
  }
110940
111041
  }
110941
111042
  else {
110942
111043
  writer.writeLine();
110943
111044
  }
110944
111045
  // Write the output file
110945
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111046
+ var text = writer.getText();
111047
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111048
+ // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
111049
+ // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
111050
+ if (printer.bundleFileInfo)
111051
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110946
111052
  // Reset state
110947
111053
  writer.clear();
110948
111054
  }
@@ -111085,34 +111191,56 @@ var ts;
111085
111191
  }
111086
111192
  /*@internal*/
111087
111193
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111194
+ var createHash = ts.maybeBind(host, host.createHash);
111088
111195
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
111089
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
111090
- if (!buildInfoText)
111196
+ var buildInfo;
111197
+ if (host.getBuildInfo) {
111198
+ // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111199
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111200
+ if (!hostBuildInfo)
111201
+ return buildInfoPath;
111202
+ buildInfo = hostBuildInfo;
111203
+ }
111204
+ else {
111205
+ var buildInfoText = host.readFile(buildInfoPath);
111206
+ if (!buildInfoText)
111207
+ return buildInfoPath;
111208
+ buildInfo = getBuildInfo(buildInfoText);
111209
+ }
111210
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111091
111211
  return buildInfoPath;
111092
111212
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
111093
111213
  if (!jsFileText)
111094
111214
  return jsFilePath;
111215
+ // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111216
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111217
+ return jsFilePath;
111095
111218
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111096
111219
  // error if no source map or for now if inline sourcemap
111097
111220
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111098
111221
  return sourceMapFilePath || "inline sourcemap decoding";
111222
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111223
+ return sourceMapFilePath;
111099
111224
  // read declaration text
111100
111225
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111101
111226
  if (declarationFilePath && !declarationText)
111102
111227
  return declarationFilePath;
111228
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111229
+ return declarationFilePath;
111103
111230
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111104
111231
  // error if no source map or for now if inline sourcemap
111105
111232
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111106
111233
  return declarationMapPath || "inline sourcemap decoding";
111107
- var buildInfo = getBuildInfo(buildInfoText);
111108
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
111109
- return buildInfoPath;
111234
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111235
+ return declarationMapPath;
111110
111236
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111111
111237
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
111112
111238
  /*onlyOwnText*/ true);
111113
111239
  var outputFiles = [];
111114
111240
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
111115
111241
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
111242
+ var changedDtsText;
111243
+ var changedDtsData;
111116
111244
  var emitHost = {
111117
111245
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
111118
111246
  getCanonicalFileName: host.getCanonicalFileName,
@@ -111128,7 +111256,7 @@ var ts;
111128
111256
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
111129
111257
  getProjectReferenceRedirect: ts.returnUndefined,
111130
111258
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
111131
- writeFile: function (name, text, writeByteOrderMark) {
111259
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
111132
111260
  switch (name) {
111133
111261
  case jsFilePath:
111134
111262
  if (jsFileText === text)
@@ -111139,8 +111267,13 @@ var ts;
111139
111267
  return;
111140
111268
  break;
111141
111269
  case buildInfoPath:
111142
- var newBuildInfo = getBuildInfo(text);
111270
+ var newBuildInfo = data.buildInfo;
111143
111271
  newBuildInfo.program = buildInfo.program;
111272
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111273
+ // Update the output signature
111274
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111275
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111276
+ }
111144
111277
  // Update sourceFileInfo
111145
111278
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
111146
111279
  newBuildInfo.bundle.js.sources = js.sources;
@@ -111148,11 +111281,13 @@ var ts;
111148
111281
  newBuildInfo.bundle.dts.sources = dts.sources;
111149
111282
  }
111150
111283
  newBuildInfo.bundle.sourceFiles = sourceFiles;
111151
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
111284
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
111152
111285
  return;
111153
111286
  case declarationFilePath:
111154
111287
  if (declarationText === text)
111155
111288
  return;
111289
+ changedDtsText = text;
111290
+ changedDtsData = data;
111156
111291
  break;
111157
111292
  case declarationMapPath:
111158
111293
  if (declarationMapText === text)
@@ -111171,6 +111306,7 @@ var ts;
111171
111306
  getSourceFileFromReference: ts.returnUndefined,
111172
111307
  redirectTargetsMap: ts.createMultiMap(),
111173
111308
  getFileIncludeReasons: ts.notImplemented,
111309
+ createHash: createHash,
111174
111310
  };
111175
111311
  emitFiles(ts.notImplementedResolver, emitHost,
111176
111312
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116255,12 +116391,10 @@ var ts;
116255
116391
  }
116256
116392
  ts.createCompilerHost = createCompilerHost;
116257
116393
  /*@internal*/
116258
- // TODO(shkamat): update this after reworking ts build API
116259
116394
  function createCompilerHostWorker(options, setParentNodes, system) {
116260
116395
  if (system === void 0) { system = ts.sys; }
116261
116396
  var existingDirectories = new ts.Map();
116262
116397
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116263
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116264
116398
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116265
116399
  var text;
116266
116400
  try {
@@ -116293,7 +116427,7 @@ var ts;
116293
116427
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116294
116428
  // the system.writeFile will do its own directory creation and
116295
116429
  // the ensureDirectoriesExist call will always be redundant.
116296
- ts.writeFileEnsuringDirectories(fileName, data, writeByteOrderMark, function (path, data, writeByteOrderMark) { return writeFileWorker(path, data, writeByteOrderMark); }, function (path) { return (compilerHost.createDirectory || system.createDirectory)(path); }, function (path) { return directoryExists(path); });
116430
+ ts.writeFileEnsuringDirectories(fileName, data, writeByteOrderMark, function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, function (path) { return (compilerHost.createDirectory || system.createDirectory)(path); }, function (path) { return directoryExists(path); });
116297
116431
  ts.performance.mark("afterIOWrite");
116298
116432
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116299
116433
  }
@@ -116303,35 +116437,6 @@ var ts;
116303
116437
  }
116304
116438
  }
116305
116439
  }
116306
- var outputFingerprints;
116307
- function writeFileWorker(fileName, data, writeByteOrderMark) {
116308
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116309
- system.writeFile(fileName, data, writeByteOrderMark);
116310
- return;
116311
- }
116312
- if (!outputFingerprints) {
116313
- outputFingerprints = new ts.Map();
116314
- }
116315
- var hash = computeHash(data);
116316
- var mtimeBefore = system.getModifiedTime(fileName);
116317
- if (mtimeBefore) {
116318
- var fingerprint = outputFingerprints.get(fileName);
116319
- // If output has not been changed, and the file has no external modification
116320
- if (fingerprint &&
116321
- fingerprint.byteOrderMark === writeByteOrderMark &&
116322
- fingerprint.hash === hash &&
116323
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116324
- return;
116325
- }
116326
- }
116327
- system.writeFile(fileName, data, writeByteOrderMark);
116328
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116329
- outputFingerprints.set(fileName, {
116330
- hash: hash,
116331
- byteOrderMark: writeByteOrderMark,
116332
- mtime: mtimeAfter
116333
- });
116334
- }
116335
116440
  function getDefaultLibLocation() {
116336
116441
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116337
116442
  }
@@ -117931,6 +118036,7 @@ var ts;
117931
118036
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117932
118037
  redirectTargetsMap: redirectTargetsMap,
117933
118038
  getFileIncludeReasons: program.getFileIncludeReasons,
118039
+ createHash: ts.maybeBind(host, host.createHash),
117934
118040
  };
117935
118041
  }
117936
118042
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -120044,13 +120150,9 @@ var ts;
120044
120150
  function createManyToManyPathMap() {
120045
120151
  function create(forward, reverse, deleted) {
120046
120152
  var map = {
120047
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
120048
- forEach: function (fn) { return forward.forEach(fn); },
120049
120153
  getKeys: function (v) { return reverse.get(v); },
120050
120154
  getValues: function (k) { return forward.get(k); },
120051
- hasKey: function (k) { return forward.has(k); },
120052
120155
  keys: function () { return forward.keys(); },
120053
- deletedKeys: function () { return deleted; },
120054
120156
  deleteKey: function (k) {
120055
120157
  (deleted || (deleted = new ts.Set())).add(k);
120056
120158
  var set = forward.get(k);
@@ -120077,11 +120179,6 @@ var ts;
120077
120179
  });
120078
120180
  return map;
120079
120181
  },
120080
- clear: function () {
120081
- forward.clear();
120082
- reverse.clear();
120083
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
120084
- }
120085
120182
  };
120086
120183
  return map;
120087
120184
  }
@@ -120209,18 +120306,21 @@ var ts;
120209
120306
  * Creates the state of file references and signature for the new program from oldState if it is safe
120210
120307
  */
120211
120308
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120309
+ var _a, _b, _c;
120212
120310
  var fileInfos = new ts.Map();
120213
120311
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
120214
120312
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
120215
- var hasCalledUpdateShapeSignature = new ts.Set();
120216
120313
  var useOldState = canReuseOldState(referencedMap, oldState);
120217
120314
  // Ensure source files have parent pointers set
120218
120315
  newProgram.getTypeChecker();
120219
120316
  // Create the reference map, and set the file infos
120220
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
120221
- var sourceFile = _a[_i];
120317
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
120318
+ var sourceFile = _d[_i];
120222
120319
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120223
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120320
+ var oldUncommittedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120321
+ var signature = oldUncommittedSignature === undefined ?
120322
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120323
+ oldUncommittedSignature || undefined;
120224
120324
  if (referencedMap) {
120225
120325
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120226
120326
  if (newReferences) {
@@ -120228,19 +120328,26 @@ var ts;
120228
120328
  }
120229
120329
  // Copy old visible to outside files map
120230
120330
  if (useOldState) {
120231
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120331
+ var oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120332
+ var exportedModules = oldUncommittedExportedModules === undefined ?
120333
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120334
+ oldUncommittedExportedModules || undefined;
120232
120335
  if (exportedModules) {
120233
120336
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120234
120337
  }
120235
120338
  }
120236
120339
  }
120237
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120340
+ fileInfos.set(sourceFile.resolvedPath, {
120341
+ version: version_2,
120342
+ signature: signature,
120343
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120344
+ impliedFormat: sourceFile.impliedNodeFormat
120345
+ });
120238
120346
  }
120239
120347
  return {
120240
120348
  fileInfos: fileInfos,
120241
120349
  referencedMap: referencedMap,
120242
120350
  exportedModulesMap: exportedModulesMap,
120243
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120244
120351
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120245
120352
  };
120246
120353
  }
@@ -120254,71 +120361,42 @@ var ts;
120254
120361
  }
120255
120362
  BuilderState.releaseCache = releaseCache;
120256
120363
  /**
120257
- * Creates a clone of the state
120364
+ * Gets the files affected by the path from the program
120258
120365
  */
120259
- function clone(state) {
120366
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120260
120367
  var _a, _b;
120261
- // Dont need to backup allFiles info since its cache anyway
120262
- return {
120263
- fileInfos: new ts.Map(state.fileInfos),
120264
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120265
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120266
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120267
- useFileVersionAsSignature: state.useFileVersionAsSignature,
120268
- };
120368
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120369
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120370
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120371
+ return result;
120269
120372
  }
120270
- BuilderState.clone = clone;
120271
- /**
120272
- * Gets the files affected by the path from the program
120273
- */
120274
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120275
- // Since the operation could be cancelled, the signatures are always stored in the cache
120276
- // They will be committed once it is safe to use them
120277
- // eg when calling this api from tsserver, if there is no cancellation of the operation
120278
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120279
- var signatureCache = cacheToUpdateSignature || new ts.Map();
120373
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120374
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120280
120375
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120281
120376
  if (!sourceFile) {
120282
120377
  return ts.emptyArray;
120283
120378
  }
120284
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120379
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120285
120380
  return [sourceFile];
120286
120381
  }
120287
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120288
- if (!cacheToUpdateSignature) {
120289
- // Commit all the signatures in the signature cache
120290
- updateSignaturesFromCache(state, signatureCache);
120291
- }
120292
- return result;
120382
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120293
120383
  }
120294
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120295
- /**
120296
- * Updates the signatures from the cache into state's fileinfo signatures
120297
- * This should be called whenever it is safe to commit the state of the builder
120298
- */
120299
- function updateSignaturesFromCache(state, signatureCache) {
120300
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120301
- }
120302
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120384
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120303
120385
  function updateSignatureOfFile(state, signature, path) {
120304
120386
  state.fileInfos.get(path).signature = signature;
120305
- state.hasCalledUpdateShapeSignature.add(path);
120387
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120306
120388
  }
120307
120389
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120308
120390
  /**
120309
120391
  * Returns if the shape of the signature has changed since last emit
120310
120392
  */
120311
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120393
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120394
+ var _a;
120312
120395
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120313
- ts.Debug.assert(!!sourceFile);
120314
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120315
120396
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120316
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120397
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
120317
120398
  return false;
120318
- }
120319
120399
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120320
- if (!info)
120321
- return ts.Debug.fail();
120322
120400
  var prevSignature = info.signature;
120323
120401
  var latestSignature;
120324
120402
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120329,45 +120407,55 @@ var ts;
120329
120407
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120330
120408
  if (firstDts_1) {
120331
120409
  ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
120332
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120333
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120334
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120410
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
120411
+ if (latestSignature !== prevSignature) {
120412
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120335
120413
  }
120336
120414
  }
120337
120415
  }
120338
120416
  // Default is to use file version as signature
120339
120417
  if (latestSignature === undefined) {
120340
120418
  latestSignature = sourceFile.version;
120341
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
120419
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
120420
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120342
120421
  // All the references in this file are exported
120343
120422
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120344
120423
  if (references) {
120345
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120424
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120346
120425
  }
120347
120426
  else {
120348
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120427
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120349
120428
  }
120350
120429
  }
120351
120430
  }
120352
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120431
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120432
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120433
+ info.signature = latestSignature;
120353
120434
  return latestSignature !== prevSignature;
120354
120435
  }
120355
120436
  BuilderState.updateShapeSignature = updateShapeSignature;
120437
+ function computeSignature(text, computeHash) {
120438
+ return (computeHash || ts.generateDjb2Hash)(text);
120439
+ }
120440
+ BuilderState.computeSignature = computeSignature;
120356
120441
  /**
120357
120442
  * Coverts the declaration emit result into exported modules map
120358
120443
  */
120359
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120444
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120445
+ if (!state.exportedModulesMap)
120446
+ return;
120447
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120360
120448
  if (!exportedModulesFromDeclarationEmit) {
120361
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120449
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120362
120450
  return;
120363
120451
  }
120364
120452
  var exportedModules;
120365
120453
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120366
120454
  if (exportedModules) {
120367
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120455
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120368
120456
  }
120369
120457
  else {
120370
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120458
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120371
120459
  }
120372
120460
  function addExportedModule(exportedModulePaths) {
120373
120461
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120379,19 +120467,6 @@ var ts;
120379
120467
  }
120380
120468
  }
120381
120469
  BuilderState.updateExportedModules = updateExportedModules;
120382
- /**
120383
- * Updates the exported modules from cache into state's exported modules map
120384
- * This should be called whenever it is safe to commit the state of the builder
120385
- */
120386
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120387
- var _a;
120388
- if (exportedModulesMapCache) {
120389
- ts.Debug.assert(!!state.exportedModulesMap);
120390
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120391
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120392
- }
120393
- }
120394
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120395
120470
  /**
120396
120471
  * Get all the dependencies of the sourceFile
120397
120472
  */
@@ -120512,7 +120587,7 @@ var ts;
120512
120587
  /**
120513
120588
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120514
120589
  */
120515
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120590
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120516
120591
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120517
120592
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120518
120593
  }
@@ -120532,7 +120607,7 @@ var ts;
120532
120607
  if (!seenFileNamesMap.has(currentPath)) {
120533
120608
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120534
120609
  seenFileNamesMap.set(currentPath, currentSourceFile);
120535
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120610
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120536
120611
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120537
120612
  }
120538
120613
  }
@@ -120558,32 +120633,33 @@ var ts;
120558
120633
  * Create the state so that we can iterate on changedFiles/affected files
120559
120634
  */
120560
120635
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120636
+ var _a, _b;
120561
120637
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120562
120638
  state.program = newProgram;
120563
120639
  var compilerOptions = newProgram.getCompilerOptions();
120564
120640
  state.compilerOptions = compilerOptions;
120641
+ var outFilePath = ts.outFile(compilerOptions);
120565
120642
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120566
- if (!ts.outFile(compilerOptions)) {
120643
+ if (!outFilePath) {
120567
120644
  state.semanticDiagnosticsPerFile = new ts.Map();
120568
120645
  }
120646
+ else if (compilerOptions.composite && (oldState === null || oldState === void 0 ? void 0 : oldState.outSignature) && outFilePath === ts.outFile(oldState === null || oldState === void 0 ? void 0 : oldState.compilerOptions)) {
120647
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120648
+ }
120569
120649
  state.changedFilesSet = new ts.Set();
120650
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120570
120651
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120571
120652
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120572
120653
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120573
120654
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120655
+ var canCopyEmitSignatures = compilerOptions.composite &&
120656
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120657
+ !outFilePath &&
120658
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120574
120659
  if (useOldState) {
120575
- // Verify the sanity of old state
120576
- if (!oldState.currentChangedFilePath) {
120577
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
120578
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120579
- }
120580
- var changedFilesSet = oldState.changedFilesSet;
120581
- if (canCopySemanticDiagnostics) {
120582
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120583
- }
120584
120660
  // Copy old state's changed files set
120585
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120586
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120661
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120662
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
120587
120663
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120588
120664
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120589
120665
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120604,6 +120680,8 @@ var ts;
120604
120680
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120605
120681
  // versions dont match
120606
120682
  oldInfo.version !== info.version ||
120683
+ // Implied formats dont match
120684
+ oldInfo.impliedFormat !== info.impliedFormat ||
120607
120685
  // Referenced files changed
120608
120686
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120609
120687
  // Referenced file was deleted in the new program
@@ -120627,27 +120705,25 @@ var ts;
120627
120705
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120628
120706
  }
120629
120707
  }
120708
+ if (canCopyEmitSignatures) {
120709
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120710
+ if (oldEmitSignature)
120711
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120712
+ }
120630
120713
  });
120631
120714
  // If the global file is removed, add all files as changed
120632
120715
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120633
120716
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120634
120717
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120635
120718
  }
120636
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120719
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120637
120720
  // Add all files to affectedFilesPendingEmit since emit changed
120638
120721
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120639
120722
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120640
120723
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120641
120724
  }
120642
- if (useOldState) {
120643
- // Any time the interpretation of a source file changes, mark it as changed
120644
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120645
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120646
- state.changedFilesSet.add(sourceFilePath);
120647
- }
120648
- });
120649
- }
120650
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120725
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120726
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120651
120727
  return state;
120652
120728
  }
120653
120729
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120683,30 +120759,35 @@ var ts;
120683
120759
  ts.BuilderState.releaseCache(state);
120684
120760
  state.program = undefined;
120685
120761
  }
120686
- /**
120687
- * Creates a clone of the state
120688
- */
120689
- function cloneBuilderProgramState(state) {
120690
- var _a;
120691
- var newState = ts.BuilderState.clone(state);
120692
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120693
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120694
- newState.affectedFiles = state.affectedFiles;
120695
- newState.affectedFilesIndex = state.affectedFilesIndex;
120696
- newState.currentChangedFilePath = state.currentChangedFilePath;
120697
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120698
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120699
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120700
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120701
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120702
- newState.program = state.program;
120703
- newState.compilerOptions = state.compilerOptions;
120704
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120705
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120706
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120707
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120708
- newState.programEmitComplete = state.programEmitComplete;
120709
- return newState;
120762
+ function backupBuilderProgramEmitState(state) {
120763
+ var outFilePath = ts.outFile(state.compilerOptions);
120764
+ // Only in --out changeFileSet is kept around till emit
120765
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120766
+ return {
120767
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120768
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120769
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120770
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120771
+ programEmitComplete: state.programEmitComplete,
120772
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120773
+ outSignature: state.outSignature,
120774
+ dtsChangeTime: state.dtsChangeTime,
120775
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120776
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120777
+ };
120778
+ }
120779
+ function restoreBuilderProgramEmitState(state, savedEmitState) {
120780
+ state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
120781
+ state.affectedFilesPendingEmitKind = savedEmitState.affectedFilesPendingEmitKind;
120782
+ state.affectedFilesPendingEmitIndex = savedEmitState.affectedFilesPendingEmitIndex;
120783
+ state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
120784
+ state.programEmitComplete = savedEmitState.programEmitComplete;
120785
+ state.emitSignatures = savedEmitState.emitSignatures;
120786
+ state.outSignature = savedEmitState.outSignature;
120787
+ state.dtsChangeTime = savedEmitState.dtsChangeTime;
120788
+ state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
120789
+ if (savedEmitState.changedFilesSet)
120790
+ state.changedFilesSet = savedEmitState.changedFilesSet;
120710
120791
  }
120711
120792
  /**
120712
120793
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120721,7 +120802,7 @@ var ts;
120721
120802
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120722
120803
  */
120723
120804
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120724
- var _a;
120805
+ var _a, _b;
120725
120806
  while (true) {
120726
120807
  var affectedFiles = state.affectedFiles;
120727
120808
  if (affectedFiles) {
@@ -120741,10 +120822,8 @@ var ts;
120741
120822
  state.changedFilesSet.delete(state.currentChangedFilePath);
120742
120823
  state.currentChangedFilePath = undefined;
120743
120824
  // Commit the changes in file signature
120744
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120745
- state.currentAffectedFilesSignatures.clear();
120746
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120747
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120825
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120826
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120748
120827
  state.affectedFiles = undefined;
120749
120828
  }
120750
120829
  // Get next changed file
@@ -120762,12 +120841,7 @@ var ts;
120762
120841
  return program;
120763
120842
  }
120764
120843
  // Get next batch of affected files
120765
- if (!state.currentAffectedFilesSignatures)
120766
- state.currentAffectedFilesSignatures = new ts.Map();
120767
- if (state.exportedModulesMap) {
120768
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120769
- }
120770
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120844
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120771
120845
  state.currentChangedFilePath = nextKey.value;
120772
120846
  state.affectedFilesIndex = 0;
120773
120847
  if (!state.seenAffectedFiles)
@@ -120819,7 +120893,6 @@ var ts;
120819
120893
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120820
120894
  */
120821
120895
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120822
- var _a;
120823
120896
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120824
120897
  // If affected files is everything except default library, then nothing more to do
120825
120898
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120827,10 +120900,9 @@ var ts;
120827
120900
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120828
120901
  // That means when affected file is handled, its signature can be out of date
120829
120902
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120830
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120903
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120831
120904
  return;
120832
120905
  }
120833
- 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);
120834
120906
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120835
120907
  return;
120836
120908
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120850,7 +120922,7 @@ var ts;
120850
120922
  // This ensures that we dont later during incremental builds considering wrong signature.
120851
120923
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120852
120924
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120853
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120925
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120854
120926
  // If not dts emit, nothing more to do
120855
120927
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120856
120928
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120871,27 +120943,10 @@ var ts;
120871
120943
  return !state.semanticDiagnosticsFromOldState.size;
120872
120944
  }
120873
120945
  function isChangedSignature(state, path) {
120874
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120875
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120946
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120947
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120876
120948
  return newSignature !== oldSignature;
120877
120949
  }
120878
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120879
- // Go through exported modules from cache first
120880
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120881
- var result = keys && ts.forEachKey(keys, fn);
120882
- if (result)
120883
- return result;
120884
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120885
- keys = state.exportedModulesMap.getKeys(filePath);
120886
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120887
- var _a;
120888
- // If the cache had an updated value, skip
120889
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120890
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120891
- fn(exportedFromPath) :
120892
- undefined;
120893
- });
120894
- }
120895
120950
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120896
120951
  var _a;
120897
120952
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120906,6 +120961,7 @@ var ts;
120906
120961
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120907
120962
  */
120908
120963
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120964
+ var _a;
120909
120965
  // If there was change in signature (dts output) for the changed file,
120910
120966
  // then only we need to handle pending file emit
120911
120967
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120932,11 +120988,10 @@ var ts;
120932
120988
  }
120933
120989
  }
120934
120990
  }
120935
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120936
120991
  var seenFileAndExportsOfFile = new ts.Set();
120937
120992
  // Go through exported modules from cache first
120938
120993
  // If exported modules has path, all files referencing file exported from are affected
120939
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120994
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120940
120995
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120941
120996
  return true;
120942
120997
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120950,19 +121005,18 @@ var ts;
120950
121005
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120951
121006
  */
120952
121007
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120953
- var _a;
121008
+ var _a, _b;
120954
121009
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120955
121010
  return undefined;
120956
121011
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120957
121012
  return true;
120958
121013
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120959
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120960
121014
  // If exported modules has path, all files referencing file exported from are affected
120961
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
121015
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120962
121016
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120963
121017
  });
120964
121018
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120965
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
121019
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120966
121020
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120967
121021
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120968
121022
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120983,12 +121037,13 @@ var ts;
120983
121037
  }
120984
121038
  else {
120985
121039
  state.seenAffectedFiles.add(affected.resolvedPath);
121040
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
121041
+ state.buildInfoEmitPending = true;
120986
121042
  if (emitKind !== undefined) {
120987
121043
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120988
121044
  }
120989
121045
  if (isPendingEmit) {
120990
121046
  state.affectedFilesPendingEmitIndex++;
120991
- state.buildInfoEmitPending = true;
120992
121047
  }
120993
121048
  else {
120994
121049
  state.affectedFilesIndex++;
@@ -121036,25 +121091,62 @@ var ts;
121036
121091
  }
121037
121092
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
121038
121093
  }
121094
+ function isProgramBundleEmitBuildInfo(info) {
121095
+ return !!ts.outFile(info.options || {});
121096
+ }
121097
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
121039
121098
  /**
121040
121099
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121041
121100
  */
121042
- function getProgramBuildInfo(state, getCanonicalFileName) {
121043
- if (ts.outFile(state.compilerOptions))
121044
- return undefined;
121101
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
121102
+ var outFilePath = ts.outFile(state.compilerOptions);
121103
+ if (outFilePath && !state.compilerOptions.composite)
121104
+ return;
121045
121105
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121046
121106
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
121107
+ // Update the dtsChange time in buildInfo
121108
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
121109
+ if (outFilePath) {
121110
+ var fileNames_1 = [];
121111
+ var fileInfos_1 = [];
121112
+ state.program.getRootFileNames().forEach(function (f) {
121113
+ var sourceFile = state.program.getSourceFile(f);
121114
+ if (!sourceFile)
121115
+ return;
121116
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121117
+ fileInfos_1.push(sourceFile.version);
121118
+ });
121119
+ var result_15 = {
121120
+ fileNames: fileNames_1,
121121
+ fileInfos: fileInfos_1,
121122
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
121123
+ outSignature: state.outSignature,
121124
+ dtsChangeTime: state.dtsChangeTime,
121125
+ };
121126
+ return result_15;
121127
+ }
121047
121128
  var fileNames = [];
121048
121129
  var fileNameToFileId = new ts.Map();
121049
121130
  var fileIdsList;
121050
121131
  var fileNamesToFileIdListId;
121132
+ var emitSignatures;
121051
121133
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
121134
+ var _b, _c;
121052
121135
  var key = _a[0], value = _a[1];
121053
121136
  // Ensure fileId
121054
121137
  var fileId = toFileId(key);
121055
121138
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
121056
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
121057
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
121139
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
121140
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
121141
+ if (state.compilerOptions.composite) {
121142
+ var file = state.program.getSourceFileByPath(key);
121143
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
121144
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
121145
+ if (emitSignature !== actualSignature) {
121146
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
121147
+ }
121148
+ }
121149
+ }
121058
121150
  return value.version === actualSignature ?
121059
121151
  value.affectsGlobalScope || value.impliedFormat ?
121060
121152
  // If file version is same as signature, dont serialize signature
@@ -121062,11 +121154,11 @@ var ts;
121062
121154
  // If file info only contains version and signature and both are same we can just write string
121063
121155
  value.version :
121064
121156
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
121065
- signature === undefined ?
121157
+ oldSignature === undefined ?
121066
121158
  // If we havent computed signature, use fileInfo as is
121067
121159
  value :
121068
121160
  // Serialize fileInfo with new updated signature
121069
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121161
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
121070
121162
  // Signature of the FileInfo is undefined, serialize it as false
121071
121163
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
121072
121164
  });
@@ -121081,17 +121173,13 @@ var ts;
121081
121173
  if (state.exportedModulesMap) {
121082
121174
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
121083
121175
  var _a;
121084
- if (state.currentAffectedFilesExportedModulesMap) {
121085
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
121086
- return undefined;
121087
- }
121088
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
121089
- if (newValue) {
121090
- return [toFileId(key), toFileIdListId(newValue)];
121091
- }
121092
- }
121176
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
121093
121177
  // Not in temporary cache, use existing value
121094
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121178
+ if (oldValue === undefined)
121179
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
121180
+ if (oldValue)
121181
+ return [toFileId(key), toFileIdListId(oldValue)];
121182
+ return undefined;
121095
121183
  });
121096
121184
  }
121097
121185
  var semanticDiagnosticsPerFile;
@@ -121102,9 +121190,7 @@ var ts;
121102
121190
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
121103
121191
  [
121104
121192
  toFileId(key),
121105
- state.hasReusableDiagnostic ?
121106
- value :
121107
- convertToReusableDiagnostics(value, relativeToBuildInfo)
121193
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
121108
121194
  ] :
121109
121195
  toFileId(key));
121110
121196
  }
@@ -121119,16 +121205,27 @@ var ts;
121119
121205
  }
121120
121206
  }
121121
121207
  }
121122
- return {
121208
+ var changeFileSet;
121209
+ if (state.changedFilesSet.size) {
121210
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
121211
+ var path = _e[_d];
121212
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
121213
+ }
121214
+ }
121215
+ var result = {
121123
121216
  fileNames: fileNames,
121124
121217
  fileInfos: fileInfos,
121125
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
121218
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
121126
121219
  fileIdsList: fileIdsList,
121127
121220
  referencedMap: referencedMap,
121128
121221
  exportedModulesMap: exportedModulesMap,
121129
121222
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
121130
121223
  affectedFilesPendingEmit: affectedFilesPendingEmit,
121224
+ changeFileSet: changeFileSet,
121225
+ emitSignatures: emitSignatures,
121226
+ dtsChangeTime: state.dtsChangeTime,
121131
121227
  };
121228
+ return result;
121132
121229
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
121133
121230
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
121134
121231
  }
@@ -121153,24 +121250,21 @@ var ts;
121153
121250
  }
121154
121251
  return fileIdListId;
121155
121252
  }
121156
- }
121157
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
121158
- var result;
121159
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121160
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121161
- var name = _a[_i];
121162
- var optionKey = name.toLowerCase();
121163
- var optionInfo = optionsNameMap.get(optionKey);
121164
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
121165
- // We need to store `strict`, even though it won't be examined directly, so that the
121166
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
121167
- optionKey === "strict" ||
121168
- // We need to store these to determine whether `lib` files need to be rechecked.
121169
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
121170
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
121253
+ /**
121254
+ * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
121255
+ */
121256
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
121257
+ var result;
121258
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
121259
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
121260
+ var name = _a[_i];
121261
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
121262
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
121263
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
121264
+ }
121171
121265
  }
121266
+ return result;
121172
121267
  }
121173
- return result;
121174
121268
  }
121175
121269
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
121176
121270
  if (option) {
@@ -121244,6 +121338,10 @@ var ts;
121244
121338
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121245
121339
  }
121246
121340
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121341
+ function computeSignature(text, data, computeHash) {
121342
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121343
+ }
121344
+ ts.computeSignature = computeSignature;
121247
121345
  function createBuilderProgram(kind, _a) {
121248
121346
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121249
121347
  // Return same program if underlying program doesnt change
@@ -121262,8 +121360,7 @@ var ts;
121262
121360
  */
121263
121361
  var computeHash = ts.maybeBind(host, host.createHash);
121264
121362
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121265
- var backupState;
121266
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121363
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121267
121364
  // To ensure that we arent storing any references to old program or new program without state
121268
121365
  newProgram = undefined; // TODO: GH#18217
121269
121366
  oldProgram = undefined;
@@ -121271,21 +121368,12 @@ var ts;
121271
121368
  var getState = function () { return state; };
121272
121369
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121273
121370
  builderProgram.getState = getState;
121274
- builderProgram.backupState = function () {
121275
- ts.Debug.assert(backupState === undefined);
121276
- backupState = cloneBuilderProgramState(state);
121277
- };
121278
- builderProgram.restoreState = function () {
121279
- state = ts.Debug.checkDefined(backupState);
121280
- backupState = undefined;
121281
- };
121371
+ builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); };
121372
+ builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); };
121282
121373
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121283
121374
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121284
121375
  builderProgram.emit = emit;
121285
- builderProgram.releaseProgram = function () {
121286
- releaseCache(state);
121287
- backupState = undefined;
121288
- };
121376
+ builderProgram.releaseProgram = function () { return releaseCache(state); };
121289
121377
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121290
121378
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
121291
121379
  }
@@ -121343,35 +121431,62 @@ var ts;
121343
121431
  return toAffectedFileEmitResult(state,
121344
121432
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121345
121433
  // Otherwise just affected file
121346
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121347
- getWriteFileUpdatingSignatureCallback(writeFile) :
121434
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121435
+ getWriteFileCallback(writeFile, customTransformers) :
121348
121436
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121349
121437
  }
121350
- function getWriteFileUpdatingSignatureCallback(writeFile) {
121438
+ function getWriteFileCallback(writeFile, customTransformers) {
121351
121439
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121352
- var _a;
121440
+ var _a, _b, _c;
121353
121441
  if (ts.isDeclarationFileName(fileName)) {
121354
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121355
- var file = sourceFiles[0];
121356
- var info = state.fileInfos.get(file.resolvedPath);
121357
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121358
- if (signature === file.version) {
121359
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121360
- if (newSignature !== file.version) { // Update it
121361
- if (host.storeFilesChangingSignatureDuringEmit)
121362
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121363
- if (state.exportedModulesMap)
121364
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121365
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121366
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121442
+ if (!ts.outFile(state.compilerOptions)) {
121443
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121444
+ var newSignature = void 0;
121445
+ if (!customTransformers) {
121446
+ var file = sourceFiles[0];
121447
+ var info = state.fileInfos.get(file.resolvedPath);
121448
+ if (info.signature === file.version) {
121449
+ newSignature = computeSignature(text, data, computeHash);
121450
+ if (newSignature !== file.version) { // Update it
121451
+ if (host.storeFilesChangingSignatureDuringEmit)
121452
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121453
+ if (state.exportedModulesMap)
121454
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121455
+ if (state.affectedFiles) {
121456
+ // Keep old signature so we know what to undo if cancellation happens
121457
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121458
+ if (existing === undefined)
121459
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121460
+ info.signature = newSignature;
121461
+ }
121462
+ else {
121463
+ // These are directly commited
121464
+ info.signature = newSignature;
121465
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121466
+ }
121467
+ }
121367
121468
  }
121368
- else {
121369
- info.signature = newSignature;
121370
- if (state.exportedModulesMap)
121371
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121469
+ }
121470
+ // Store d.ts emit hash so later can be compared to check if d.ts has changed.
121471
+ // Currently we do this only for composite projects since these are the only projects that can be referenced by other projects
121472
+ // and would need their d.ts change time in --build mode
121473
+ if (state.compilerOptions.composite) {
121474
+ var filePath = sourceFiles[0].resolvedPath;
121475
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121476
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
121477
+ if (newSignature !== oldSignature) {
121478
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121479
+ state.hasChangedEmitSignature = true;
121372
121480
  }
121373
121481
  }
121374
121482
  }
121483
+ else if (state.compilerOptions.composite) {
121484
+ var newSignature = computeSignature(text, data, computeHash);
121485
+ if (newSignature !== state.outSignature) {
121486
+ state.outSignature = newSignature;
121487
+ state.hasChangedEmitSignature = true;
121488
+ }
121489
+ }
121375
121490
  }
121376
121491
  if (writeFile)
121377
121492
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121436,8 +121551,8 @@ var ts;
121436
121551
  }
121437
121552
  }
121438
121553
  }
121439
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121440
- getWriteFileUpdatingSignatureCallback(writeFile) :
121554
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121555
+ getWriteFileCallback(writeFile, customTransformers) :
121441
121556
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121442
121557
  }
121443
121558
  /**
@@ -121526,29 +121641,58 @@ var ts;
121526
121641
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121527
121642
  }
121528
121643
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121529
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121530
- var _a;
121644
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121645
+ var _a, _b, _c, _d;
121531
121646
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121532
121647
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121533
- var filePaths = program.fileNames.map(toPath);
121534
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121535
- var fileInfos = new ts.Map();
121536
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121537
- var state = {
121538
- fileInfos: fileInfos,
121539
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121540
- referencedMap: toManyToManyPathMap(program.referencedMap),
121541
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121542
- 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]; }),
121543
- hasReusableDiagnostic: true,
121544
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121545
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121546
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121547
- };
121648
+ var state;
121649
+ var filePaths;
121650
+ var filePathsSetList;
121651
+ if (isProgramBundleEmitBuildInfo(program)) {
121652
+ state = {
121653
+ fileInfos: new ts.Map(),
121654
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121655
+ dtsChangeTime: program.dtsChangeTime,
121656
+ outSignature: program.outSignature,
121657
+ };
121658
+ }
121659
+ else {
121660
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121661
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121662
+ var fileInfos_2 = new ts.Map();
121663
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121664
+ program.fileInfos.forEach(function (fileInfo, index) {
121665
+ var path = toFilePath(index + 1);
121666
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121667
+ fileInfos_2.set(path, stateFileInfo);
121668
+ if (emitSignatures_1 && stateFileInfo.signature)
121669
+ emitSignatures_1.set(path, stateFileInfo.signature);
121670
+ });
121671
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121672
+ if (ts.isNumber(value))
121673
+ emitSignatures_1.delete(toFilePath(value));
121674
+ else
121675
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121676
+ });
121677
+ state = {
121678
+ fileInfos: fileInfos_2,
121679
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121680
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121681
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121682
+ semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }),
121683
+ hasReusableDiagnostic: true,
121684
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121685
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121686
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121687
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121688
+ dtsChangeTime: program.dtsChangeTime,
121689
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121690
+ };
121691
+ }
121548
121692
  return {
121549
121693
  getState: function () { return state; },
121550
- backupState: ts.noop,
121551
- restoreState: ts.noop,
121694
+ saveEmitState: ts.noop,
121695
+ restoreEmitState: ts.noop,
121552
121696
  getProgram: ts.notImplemented,
121553
121697
  getProgramOrUndefined: ts.returnUndefined,
121554
121698
  releaseProgram: ts.noop,
@@ -121593,12 +121737,24 @@ var ts;
121593
121737
  return map;
121594
121738
  }
121595
121739
  }
121596
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121740
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121741
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121742
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121743
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121744
+ var fileInfos = new ts.Map();
121745
+ program.fileInfos.forEach(function (fileInfo, index) {
121746
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121747
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121748
+ fileInfos.set(path, version);
121749
+ });
121750
+ return fileInfos;
121751
+ }
121752
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121597
121753
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121598
121754
  return {
121599
121755
  getState: ts.notImplemented,
121600
- backupState: ts.noop,
121601
- restoreState: ts.noop,
121756
+ saveEmitState: ts.noop,
121757
+ restoreEmitState: ts.noop,
121602
121758
  getProgram: getProgram,
121603
121759
  getProgramOrUndefined: function () { return getState().program; },
121604
121760
  releaseProgram: function () { return getState().program = undefined; },
@@ -121702,8 +121858,10 @@ var ts;
121702
121858
  var filesWithInvalidatedNonRelativeUnresolvedImports;
121703
121859
  var nonRelativeExternalModuleResolutions = ts.createMultiMap();
121704
121860
  var resolutionsWithFailedLookups = [];
121861
+ var resolutionsWithOnlyAffectingLocations = [];
121705
121862
  var resolvedFileToResolution = ts.createMultiMap();
121706
121863
  var hasChangedAutomaticTypeDirectiveNames = false;
121864
+ var affectingPathChecks;
121707
121865
  var failedLookupChecks;
121708
121866
  var startsWithPathChecks;
121709
121867
  var isInDirectoryChecks;
@@ -121730,6 +121888,7 @@ var ts;
121730
121888
  var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
121731
121889
  var customFailedLookupPaths = new ts.Map();
121732
121890
  var directoryWatchesOfFailedLookups = new ts.Map();
121891
+ var fileWatchesOfAffectingLocations = new ts.Map();
121733
121892
  var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121734
121893
  var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217
121735
121894
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
@@ -121772,6 +121931,7 @@ var ts;
121772
121931
  }
121773
121932
  function clear() {
121774
121933
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
121934
+ ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
121775
121935
  customFailedLookupPaths.clear();
121776
121936
  nonRelativeExternalModuleResolutions.clear();
121777
121937
  closeTypeRootsWatch();
@@ -121779,9 +121939,11 @@ var ts;
121779
121939
  resolvedTypeReferenceDirectives.clear();
121780
121940
  resolvedFileToResolution.clear();
121781
121941
  resolutionsWithFailedLookups.length = 0;
121942
+ resolutionsWithOnlyAffectingLocations.length = 0;
121782
121943
  failedLookupChecks = undefined;
121783
121944
  startsWithPathChecks = undefined;
121784
121945
  isInDirectoryChecks = undefined;
121946
+ affectingPathChecks = undefined;
121785
121947
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
121786
121948
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
121787
121949
  clearPerDirectoryResolutions();
@@ -121831,10 +121993,18 @@ var ts;
121831
121993
  watcher.watcher.close();
121832
121994
  }
121833
121995
  });
121996
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
121997
+ if (watcher.refCount === 0) {
121998
+ fileWatchesOfAffectingLocations.delete(path);
121999
+ watcher.watcher.close();
122000
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122001
+ watcher.watcher = ts.noopFileWatcher;
122002
+ }
122003
+ });
121834
122004
  hasChangedAutomaticTypeDirectiveNames = false;
121835
122005
  }
121836
122006
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
121837
- var _a;
122007
+ var _a, _b;
121838
122008
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
121839
122009
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
121840
122010
  if (!resolutionHost.getGlobalCache) {
@@ -121845,11 +122015,12 @@ var ts;
121845
122015
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
121846
122016
  // create different collection of failed lookup locations for second pass
121847
122017
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
121848
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
122018
+ var _c = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _c.resolvedModule, failedLookupLocations = _c.failedLookupLocations, affectingLocations = _c.affectingLocations;
121849
122019
  if (resolvedModule) {
121850
122020
  // Modify existing resolution so its saved in the directory cache as well
121851
122021
  primaryResult.resolvedModule = resolvedModule;
121852
122022
  (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122023
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
121853
122024
  return primaryResult;
121854
122025
  }
121855
122026
  }
@@ -122100,10 +122271,11 @@ var ts;
122100
122271
  }
122101
122272
  function watchFailedLookupLocationOfResolution(resolution) {
122102
122273
  ts.Debug.assert(!!resolution.refCount);
122103
- var failedLookupLocations = resolution.failedLookupLocations;
122104
- if (!failedLookupLocations.length)
122274
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122275
+ if (!failedLookupLocations.length && !affectingLocations.length)
122105
122276
  return;
122106
- resolutionsWithFailedLookups.push(resolution);
122277
+ if (failedLookupLocations.length)
122278
+ resolutionsWithFailedLookups.push(resolution);
122107
122279
  var setAtRoot = false;
122108
122280
  for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
122109
122281
  var failedLookupLocation = failedLookupLocations_1[_i];
@@ -122130,12 +122302,66 @@ var ts;
122130
122302
  // This is always non recursive
122131
122303
  setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
122132
122304
  }
122305
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
122306
+ }
122307
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
122308
+ ts.Debug.assert(!!resolution.refCount);
122309
+ if (addToResolutionsWithOnlyAffectingLocations)
122310
+ resolutionsWithOnlyAffectingLocations.push(resolution);
122311
+ var affectingLocations = resolution.affectingLocations;
122312
+ // Watch package json
122313
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122314
+ var affectingLocation = affectingLocations_1[_i];
122315
+ createFileWatcherOfAffectingLocation(affectingLocation);
122316
+ }
122317
+ }
122318
+ function createFileWatcherOfAffectingLocation(affectingLocation) {
122319
+ var path = resolutionHost.toPath(affectingLocation);
122320
+ var fileWatcher = fileWatchesOfAffectingLocations.get(path);
122321
+ if (fileWatcher) {
122322
+ fileWatcher.refCount++;
122323
+ return;
122324
+ }
122325
+ var locationToWatch = affectingLocation;
122326
+ var locationToWatchPath = path;
122327
+ if (resolutionHost.realpath) {
122328
+ locationToWatch = resolutionHost.realpath(affectingLocation);
122329
+ locationToWatchPath = resolutionHost.toPath(locationToWatch);
122330
+ if (path !== locationToWatchPath) {
122331
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
122332
+ if (fileWatcher_1) {
122333
+ fileWatcher_1.refCount++;
122334
+ fileWatcher_1.paths.add(path);
122335
+ fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
122336
+ return;
122337
+ }
122338
+ }
122339
+ }
122340
+ var paths = new ts.Set();
122341
+ paths.add(locationToWatchPath);
122342
+ var watcher = {
122343
+ watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
122344
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
122345
+ paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
122346
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122347
+ }),
122348
+ refCount: 1,
122349
+ paths: paths,
122350
+ };
122351
+ fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
122352
+ if (path !== locationToWatchPath) {
122353
+ fileWatchesOfAffectingLocations.set(path, watcher);
122354
+ paths.add(path);
122355
+ }
122133
122356
  }
122134
122357
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122135
122358
  var program = resolutionHost.getCurrentProgram();
122136
122359
  if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122137
122360
  resolutions.forEach(watchFailedLookupLocationOfResolution);
122138
122361
  }
122362
+ else {
122363
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
122364
+ }
122139
122365
  }
122140
122366
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122141
122367
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -122157,38 +122383,44 @@ var ts;
122157
122383
  if (resolved && resolved.resolvedFileName) {
122158
122384
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
122159
122385
  }
122160
- if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122161
- // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
122162
- return;
122163
- }
122164
- var failedLookupLocations = resolution.failedLookupLocations;
122165
- var removeAtRoot = false;
122166
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122167
- var failedLookupLocation = failedLookupLocations_2[_i];
122168
- var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122169
- var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122170
- if (toWatch) {
122171
- var dirPath = toWatch.dirPath;
122172
- var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122173
- if (refCount) {
122174
- if (refCount === 1) {
122175
- customFailedLookupPaths.delete(failedLookupLocationPath);
122386
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
122387
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
122388
+ var removeAtRoot = false;
122389
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
122390
+ var failedLookupLocation = failedLookupLocations_2[_i];
122391
+ var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
122392
+ var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
122393
+ if (toWatch) {
122394
+ var dirPath = toWatch.dirPath;
122395
+ var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
122396
+ if (refCount) {
122397
+ if (refCount === 1) {
122398
+ customFailedLookupPaths.delete(failedLookupLocationPath);
122399
+ }
122400
+ else {
122401
+ ts.Debug.assert(refCount > 1);
122402
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122403
+ }
122404
+ }
122405
+ if (dirPath === rootPath) {
122406
+ removeAtRoot = true;
122176
122407
  }
122177
122408
  else {
122178
- ts.Debug.assert(refCount > 1);
122179
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
122409
+ removeDirectoryWatcher(dirPath);
122180
122410
  }
122181
122411
  }
122182
- if (dirPath === rootPath) {
122183
- removeAtRoot = true;
122184
- }
122185
- else {
122186
- removeDirectoryWatcher(dirPath);
122187
- }
122188
122412
  }
122413
+ if (removeAtRoot) {
122414
+ removeDirectoryWatcher(rootPath);
122415
+ }
122416
+ }
122417
+ else if (affectingLocations.length) {
122418
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
122189
122419
  }
122190
- if (removeAtRoot) {
122191
- removeDirectoryWatcher(rootPath);
122420
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
122421
+ var affectingLocation = affectingLocations_2[_a];
122422
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
122423
+ watcher.refCount--;
122192
122424
  }
122193
122425
  }
122194
122426
  function removeDirectoryWatcher(dirPath) {
@@ -122267,7 +122499,7 @@ var ts;
122267
122499
  if (isCreatingWatchedDirectory) {
122268
122500
  // Watching directory is created
122269
122501
  // Invalidate any resolution has failed lookup in this directory
122270
- (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath);
122502
+ (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath);
122271
122503
  }
122272
122504
  else {
122273
122505
  // If something to do with folder/file starting with "." in node_modules folder, skip it
@@ -122285,7 +122517,7 @@ var ts;
122285
122517
  if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
122286
122518
  isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
122287
122519
  // Invalidate any resolution from this directory
122288
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122520
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122289
122521
  (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath);
122290
122522
  }
122291
122523
  else {
@@ -122297,7 +122529,7 @@ var ts;
122297
122529
  return false;
122298
122530
  }
122299
122531
  // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
122300
- (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath);
122532
+ (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath);
122301
122533
  // If the invalidated file is from a node_modules package, invalidate everything else
122302
122534
  // in the package since we might not get notifications for other files in the package.
122303
122535
  // This hardens our logic against unreliable file watchers.
@@ -122309,21 +122541,32 @@ var ts;
122309
122541
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122310
122542
  }
122311
122543
  function invalidateResolutionsOfFailedLookupLocations() {
122312
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) {
122544
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
122313
122545
  return false;
122314
122546
  }
122315
122547
  var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
122316
122548
  failedLookupChecks = undefined;
122317
122549
  startsWithPathChecks = undefined;
122318
122550
  isInDirectoryChecks = undefined;
122551
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
122552
+ affectingPathChecks = undefined;
122319
122553
  return invalidated;
122320
122554
  }
122321
122555
  function canInvalidateFailedLookupResolution(resolution) {
122556
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
122557
+ return true;
122558
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
122559
+ return false;
122322
122560
  return resolution.failedLookupLocations.some(function (location) {
122323
122561
  var locationPath = resolutionHost.toPath(location);
122324
- return ts.contains(failedLookupChecks, locationPath) ||
122562
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
122325
122563
  ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
122326
- (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }));
122564
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
122565
+ });
122566
+ }
122567
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
122568
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
122569
+ return affectingPathChecks.has(resolutionHost.toPath(location));
122327
122570
  });
122328
122571
  }
122329
122572
  function closeTypeRootsWatch() {
@@ -122714,9 +122957,9 @@ var ts;
122714
122957
  if (!preferSymlinks) {
122715
122958
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122716
122959
  // so we only need to remove them from the realpath filenames.
122717
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122718
- if (result_15)
122719
- return result_15;
122960
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122961
+ if (result_16)
122962
+ return result_16;
122720
122963
  }
122721
122964
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122722
122965
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122736,10 +122979,10 @@ var ts;
122736
122979
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122737
122980
  var symlinkDirectory = symlinkDirectories_1[_i];
122738
122981
  var option = ts.resolvePath(symlinkDirectory, relative);
122739
- var result_16 = cb(option, target === referenceRedirect);
122982
+ var result_17 = cb(option, target === referenceRedirect);
122740
122983
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122741
- if (result_16)
122742
- return result_16;
122984
+ if (result_17)
122985
+ return result_17;
122743
122986
  }
122744
122987
  });
122745
122988
  });
@@ -123649,6 +123892,7 @@ var ts;
123649
123892
  readDirectory: ts.maybeBind(host, host.readDirectory),
123650
123893
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123651
123894
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123895
+ now: ts.maybeBind(host, host.now),
123652
123896
  };
123653
123897
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123654
123898
  try {
@@ -123709,6 +123953,7 @@ var ts;
123709
123953
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123710
123954
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123711
123955
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123956
+ now: ts.maybeBind(system, system.now),
123712
123957
  };
123713
123958
  }
123714
123959
  ts.createProgramHost = createProgramHost;
@@ -123776,20 +124021,27 @@ var ts;
123776
124021
  var ts;
123777
124022
  (function (ts) {
123778
124023
  function readBuilderProgram(compilerOptions, host) {
123779
- if (ts.outFile(compilerOptions))
123780
- return undefined;
123781
124024
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123782
124025
  if (!buildInfoPath)
123783
124026
  return undefined;
123784
- var content = host.readFile(buildInfoPath);
123785
- if (!content)
123786
- return undefined;
123787
- var buildInfo = ts.getBuildInfo(content);
124027
+ var buildInfo;
124028
+ if (host.getBuildInfo) {
124029
+ // host provides buildinfo, get it from there. This allows host to cache it
124030
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
124031
+ if (!buildInfo)
124032
+ return undefined;
124033
+ }
124034
+ else {
124035
+ var content = host.readFile(buildInfoPath);
124036
+ if (!content)
124037
+ return undefined;
124038
+ buildInfo = ts.getBuildInfo(content);
124039
+ }
123788
124040
  if (buildInfo.version !== ts.version)
123789
124041
  return undefined;
123790
124042
  if (!buildInfo.program)
123791
124043
  return undefined;
123792
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
124044
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123793
124045
  }
123794
124046
  ts.readBuilderProgram = readBuilderProgram;
123795
124047
  function createIncrementalCompilerHost(options, system) {
@@ -123798,6 +124050,7 @@ var ts;
123798
124050
  host.createHash = ts.maybeBind(system, system.createHash);
123799
124051
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123800
124052
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
124053
+ host.now = ts.maybeBind(system, system.now);
123801
124054
  ts.setGetSourceFileAsHashVersioned(host, system);
123802
124055
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123803
124056
  return host;
@@ -123842,7 +124095,6 @@ var ts;
123842
124095
  var builderProgram;
123843
124096
  var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
123844
124097
  var missingFilesMap; // Map of file watchers for the missing files
123845
- var packageJsonMap; // map of watchers for package json files used in module resolution
123846
124098
  var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file
123847
124099
  var timerToUpdateProgram; // timer callback to recompile the program
123848
124100
  var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations
@@ -123906,6 +124158,7 @@ var ts;
123906
124158
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
123907
124159
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
123908
124160
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124161
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
123909
124162
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
123910
124163
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
123911
124164
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -123988,10 +124241,6 @@ var ts;
123988
124241
  });
123989
124242
  parsedConfigs = undefined;
123990
124243
  }
123991
- if (packageJsonMap) {
123992
- ts.clearMap(packageJsonMap, ts.closeFileWatcher);
123993
- packageJsonMap = undefined;
123994
- }
123995
124244
  }
123996
124245
  function getCurrentBuilderProgram() {
123997
124246
  return builderProgram;
@@ -124047,15 +124296,9 @@ var ts;
124047
124296
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124048
124297
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124049
124298
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124050
- // map package json cache entries to their realpaths so we don't try to watch across symlinks
124051
- var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) {
124052
- var path = _a[0], data = _a[1];
124053
- return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data];
124054
- });
124055
124299
  resolutionCache.finishCachingPerDirectoryResolution();
124056
124300
  // Update watches
124057
124301
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124058
- ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath);
124059
124302
  if (needsUpdateInTypeRootWatch) {
124060
124303
  resolutionCache.updateTypeRootsWatch();
124061
124304
  }
@@ -124361,21 +124604,6 @@ var ts;
124361
124604
  ts.noopFileWatcher :
124362
124605
  watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
124363
124606
  }
124364
- function watchPackageJsonLookupPath(packageJsonPath) {
124365
- // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here
124366
- return sourceFilesCache.has(packageJsonPath) ?
124367
- ts.noopFileWatcher :
124368
- watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson);
124369
- }
124370
- function onPackageJsonChange(fileName, eventKind, path) {
124371
- updateCachedSystemWithFile(fileName, path, eventKind);
124372
- // package.json changes invalidate module resolution and can change the set of loaded files
124373
- // so if we witness a change to one, we have to do a full reload
124374
- reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
124375
- changesAffectResolution = true;
124376
- // Update the program
124377
- scheduleProgramUpdate();
124378
- }
124379
124607
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
124380
124608
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
124381
124609
  if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
@@ -124533,14 +124761,17 @@ var ts;
124533
124761
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124534
124762
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124535
124763
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124536
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124537
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124538
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124539
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124764
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124765
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124766
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124767
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124768
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124769
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124540
124770
  /**
124541
124771
  * Projects with no outputs (i.e. "solution" files)
124542
124772
  */
124543
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124773
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124774
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124544
124775
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124545
124776
  function resolveConfigFileProjectName(project) {
124546
124777
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124585,9 +124816,12 @@ var ts;
124585
124816
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124586
124817
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124587
124818
  }
124588
- function newer(date1, date2) {
124589
- return date2 > date1 ? date2 : date1;
124819
+ /*@internal*/
124820
+ /** Helper to use now method instead of current date for testing purposes to get consistent baselines */
124821
+ function getCurrentTime(host) {
124822
+ return host.now ? host.now() : new Date();
124590
124823
  }
124824
+ ts.getCurrentTime = getCurrentTime;
124591
124825
  /*@internal*/
124592
124826
  function isCircularBuildOrder(buildOrder) {
124593
124827
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124677,6 +124911,7 @@ var ts;
124677
124911
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124678
124912
  };
124679
124913
  }
124914
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124680
124915
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124681
124916
  var state = {
124682
124917
  host: host,
@@ -124693,8 +124928,9 @@ var ts;
124693
124928
  resolvedConfigFilePaths: new ts.Map(),
124694
124929
  configFileCache: new ts.Map(),
124695
124930
  projectStatus: new ts.Map(),
124696
- buildInfoChecked: new ts.Map(),
124697
124931
  extendedConfigCache: new ts.Map(),
124932
+ buildInfoCache: new ts.Map(),
124933
+ outputTimeStamps: new ts.Map(),
124698
124934
  builderPrograms: new ts.Map(),
124699
124935
  diagnostics: new ts.Map(),
124700
124936
  projectPendingBuild: new ts.Map(),
@@ -124717,6 +124953,7 @@ var ts;
124717
124953
  allWatchedConfigFiles: new ts.Map(),
124718
124954
  allWatchedExtendedConfigFiles: new ts.Map(),
124719
124955
  allWatchedPackageJsonFiles: new ts.Map(),
124956
+ filesWatched: new ts.Map(),
124720
124957
  lastCachedPackageJsonLookups: new ts.Map(),
124721
124958
  timerToBuildInvalidatedProject: undefined,
124722
124959
  reportFileChangeDetected: false,
@@ -124823,11 +125060,12 @@ var ts;
124823
125060
  // Config file cache
124824
125061
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124825
125062
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124826
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124827
125063
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124828
125064
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124829
125065
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124830
125066
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
125067
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
125068
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124831
125069
  // Remove watches for the program no longer in the solution
124832
125070
  if (state.watch) {
124833
125071
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -125117,21 +125355,21 @@ var ts;
125117
125355
  }
125118
125356
  function emit(writeFileCallback, cancellationToken, customTransformers) {
125119
125357
  var _a;
125120
- var _b, _c;
125358
+ var _b, _c, _d;
125121
125359
  ts.Debug.assertIsDefined(program);
125122
125360
  ts.Debug.assert(step === BuildStep.Emit);
125123
125361
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
125124
- program.backupState();
125362
+ var saved = program.saveEmitState();
125125
125363
  var declDiagnostics;
125126
125364
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
125127
125365
  var outputFiles = [];
125128
125366
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
125129
125367
  /*write*/ undefined,
125130
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
125368
+ /*reportSummary*/ undefined, function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark, buildInfo: data === null || data === void 0 ? void 0 : data.buildInfo }); }, cancellationToken,
125131
125369
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125132
125370
  // Don't emit .d.ts if there are decl file errors
125133
125371
  if (declDiagnostics) {
125134
- program.restoreState();
125372
+ program.restoreEmitState(saved);
125135
125373
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125136
125374
  return {
125137
125375
  emitSkipped: true,
@@ -125141,37 +125379,44 @@ var ts;
125141
125379
  // Actual Emit
125142
125380
  var host = state.host, compilerHost = state.compilerHost;
125143
125381
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125144
- var newestDeclarationFileContentChangedTime = minimumDate;
125145
- var anyDtsChanged = false;
125382
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
125146
125383
  var emitterDiagnostics = ts.createDiagnosticCollection();
125147
125384
  var emittedOutputs = new ts.Map();
125385
+ var options = program.getCompilerOptions();
125386
+ var isIncremental = ts.isIncrementalCompilation(options);
125387
+ var outputTimeStampMap;
125388
+ var now;
125148
125389
  outputFiles.forEach(function (_a) {
125149
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125150
- var priorChangeTime;
125151
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
125152
- // Check for unchanged .d.ts files
125153
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
125154
- priorChangeTime = host.getModifiedTime(name);
125155
- }
125156
- else {
125390
+ var _b, _c;
125391
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125392
+ var path = toPath(state, name);
125393
+ emittedOutputs.set(toPath(state, name), name);
125394
+ if (buildInfo) {
125395
+ setBuildInfo(state, buildInfo, projectPath, options);
125396
+ // Buildinfo has information on when last dts change time
125397
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125157
125398
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125158
- anyDtsChanged = true;
125159
125399
  }
125160
125400
  }
125161
- emittedOutputs.set(toPath(state, name), name);
125162
125401
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125163
- if (priorChangeTime !== undefined) {
125164
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125402
+ if (!isIncremental && state.watch) {
125403
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
125165
125404
  }
125166
125405
  });
125167
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
125168
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125406
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125169
125407
  return emitResult;
125170
125408
  }
125171
125409
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125172
125410
  ts.Debug.assertIsDefined(program);
125173
125411
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125174
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125412
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125413
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
125414
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125415
+ if (writeFileCallback)
125416
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125417
+ else
125418
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125419
+ }, cancellationToken);
125175
125420
  if (emitResult.diagnostics.length) {
125176
125421
  reportErrors(state, emitResult.diagnostics);
125177
125422
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125184,7 +125429,7 @@ var ts;
125184
125429
  step = BuildStep.QueueReferencingProjects;
125185
125430
  return emitResult;
125186
125431
  }
125187
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125432
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
125188
125433
  var _a;
125189
125434
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125190
125435
  if (emitDiagnostics.length) {
@@ -125195,13 +125440,11 @@ var ts;
125195
125440
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125196
125441
  }
125197
125442
  // Update time stamps for rest of the outputs
125198
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125443
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125199
125444
  state.diagnostics.delete(projectPath);
125200
125445
  state.projectStatus.set(projectPath, {
125201
125446
  type: ts.UpToDateStatusType.UpToDate,
125202
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
125203
- maximumDate :
125204
- newestDeclarationFileContentChangedTime,
125447
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
125205
125448
  oldestOutputFileName: oldestOutputFileName
125206
125449
  });
125207
125450
  afterProgramDone(state, program, config);
@@ -125236,13 +125479,21 @@ var ts;
125236
125479
  ts.Debug.assert(!!outputFiles.length);
125237
125480
  var emitterDiagnostics = ts.createDiagnosticCollection();
125238
125481
  var emittedOutputs = new ts.Map();
125482
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125483
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125239
125484
  outputFiles.forEach(function (_a) {
125240
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125485
+ var _b, _c;
125486
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125241
125487
  emittedOutputs.set(toPath(state, name), name);
125488
+ if (buildInfo) {
125489
+ setBuildInfo(state, buildInfo, projectPath, config.options);
125490
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125491
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125492
+ }
125493
+ }
125242
125494
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125243
125495
  });
125244
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
125245
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125496
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
125246
125497
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125247
125498
  }
125248
125499
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125341,7 +125592,7 @@ var ts;
125341
125592
  }
125342
125593
  continue;
125343
125594
  }
125344
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125595
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125345
125596
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125346
125597
  return {
125347
125598
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125426,7 +125677,8 @@ var ts;
125426
125677
  state.projectCompilerOptions = state.baseCompilerOptions;
125427
125678
  }
125428
125679
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125429
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125680
+ // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors
125681
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125430
125682
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125431
125683
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125432
125684
  if (canEmitBuildInfo)
@@ -125434,9 +125686,99 @@ var ts;
125434
125686
  afterProgramDone(state, program, config);
125435
125687
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125436
125688
  }
125689
+ function isFileWatcherWithModifiedTime(value) {
125690
+ return !!value.watcher;
125691
+ }
125692
+ function getModifiedTime(state, fileName) {
125693
+ var path = toPath(state, fileName);
125694
+ var existing = state.filesWatched.get(path);
125695
+ if (state.watch && !!existing) {
125696
+ if (!isFileWatcherWithModifiedTime(existing))
125697
+ return existing;
125698
+ if (existing.modifiedTime)
125699
+ return existing.modifiedTime;
125700
+ }
125701
+ // In watch mode we store the modified times in the cache
125702
+ // This is either Date | FileWatcherWithModifiedTime because we query modified times first and
125703
+ // then after complete compilation of the project, watch the files so we dont want to loose these modified times.
125704
+ var result = ts.getModifiedTime(state.host, fileName);
125705
+ if (state.watch) {
125706
+ if (existing)
125707
+ existing.modifiedTime = result;
125708
+ else
125709
+ state.filesWatched.set(path, result);
125710
+ }
125711
+ return result;
125712
+ }
125713
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125714
+ var path = toPath(state, file);
125715
+ var existing = state.filesWatched.get(path);
125716
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125717
+ existing.callbacks.push(callback);
125718
+ }
125719
+ else {
125720
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125721
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125722
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125723
+ existing.modifiedTime = modifiedTime;
125724
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125725
+ }, pollingInterval, options, watchType, project);
125726
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125727
+ }
125728
+ return {
125729
+ close: function () {
125730
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125731
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125732
+ if (existing.callbacks.length === 1) {
125733
+ state.filesWatched.delete(path);
125734
+ ts.closeFileWatcherOf(existing);
125735
+ }
125736
+ else {
125737
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125738
+ }
125739
+ }
125740
+ };
125741
+ }
125742
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125743
+ // Output timestamps are stored only in watch mode
125744
+ if (!state.watch)
125745
+ return undefined;
125746
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125747
+ if (!result)
125748
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125749
+ return result;
125750
+ }
125751
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125752
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125753
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125754
+ if (existing) {
125755
+ existing.buildInfo = buildInfo;
125756
+ existing.modifiedTime = getCurrentTime(state.host);
125757
+ }
125758
+ else {
125759
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125760
+ }
125761
+ }
125762
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125763
+ var path = toPath(state, buildInfoPath);
125764
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125765
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125766
+ }
125767
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125768
+ var path = toPath(state, buildInfoPath);
125769
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125770
+ if (existing !== undefined && existing.path === path) {
125771
+ return existing.buildInfo || undefined;
125772
+ }
125773
+ var value = state.readFileWithCache(buildInfoPath);
125774
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125775
+ ts.Debug.assert(modifiedTime || !buildInfo);
125776
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125777
+ return buildInfo;
125778
+ }
125437
125779
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125438
125780
  // Check tsconfig time
125439
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125781
+ var tsconfigTime = getModifiedTime(state, configFile);
125440
125782
  if (oldestOutputFileTime < tsconfigTime) {
125441
125783
  return {
125442
125784
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125446,88 +125788,24 @@ var ts;
125446
125788
  }
125447
125789
  }
125448
125790
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125449
- var force = !!state.options.force;
125450
- var newestInputFileName = undefined;
125451
- var newestInputFileTime = minimumDate;
125452
- var host = state.host;
125453
- // Get timestamps of input files
125454
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125455
- var inputFile = _a[_i];
125456
- if (!host.fileExists(inputFile)) {
125457
- return {
125458
- type: ts.UpToDateStatusType.Unbuildable,
125459
- reason: inputFile + " does not exist"
125460
- };
125461
- }
125462
- if (!force) {
125463
- var inputTime = ts.getModifiedTime(host, inputFile);
125464
- if (inputTime > newestInputFileTime) {
125465
- newestInputFileName = inputFile;
125466
- newestInputFileTime = inputTime;
125467
- }
125468
- }
125469
- }
125791
+ var _a, _b, _c;
125470
125792
  // Container if no files are specified in the project
125471
125793
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125472
125794
  return {
125473
125795
  type: ts.UpToDateStatusType.ContainerOnly
125474
125796
  };
125475
125797
  }
125476
- // Collect the expected outputs of this project
125477
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125478
- // Now see if all outputs are newer than the newest input
125479
- var oldestOutputFileName = "(none)";
125480
- var oldestOutputFileTime = maximumDate;
125481
- var newestOutputFileName = "(none)";
125482
- var newestOutputFileTime = minimumDate;
125483
- var missingOutputFileName;
125484
- var newestDeclarationFileContentChangedTime = minimumDate;
125485
- var isOutOfDateWithInputs = false;
125486
- if (!force) {
125487
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125488
- var output = outputs_1[_b];
125489
- // Output is missing; can stop checking
125490
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125491
- if (!host.fileExists(output)) {
125492
- missingOutputFileName = output;
125493
- break;
125494
- }
125495
- var outputTime = ts.getModifiedTime(host, output);
125496
- if (outputTime < oldestOutputFileTime) {
125497
- oldestOutputFileTime = outputTime;
125498
- oldestOutputFileName = output;
125499
- }
125500
- // If an output is older than the newest input, we can stop checking
125501
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125502
- if (outputTime < newestInputFileTime) {
125503
- isOutOfDateWithInputs = true;
125504
- break;
125505
- }
125506
- if (outputTime > newestOutputFileTime) {
125507
- newestOutputFileTime = outputTime;
125508
- newestOutputFileName = output;
125509
- }
125510
- // Keep track of when the most recent time a .d.ts file was changed.
125511
- // In addition to file timestamps, we also keep track of when a .d.ts file
125512
- // had its file touched but not had its contents changed - this allows us
125513
- // to skip a downstream typecheck
125514
- if (ts.isDeclarationFileName(output)) {
125515
- var outputModifiedTime = ts.getModifiedTime(host, output);
125516
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125517
- }
125518
- }
125519
- }
125520
- var pseudoUpToDate = false;
125521
- var usesPrepend = false;
125522
- var upstreamChangedProject;
125798
+ // Fast check to see if reference projects are upto date and error free
125799
+ var referenceStatuses;
125800
+ var force = !!state.options.force;
125523
125801
  if (project.projectReferences) {
125524
125802
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125525
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125526
- var ref = _d[_c];
125527
- usesPrepend = usesPrepend || !!(ref.prepend);
125803
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125804
+ var ref = _d[_i];
125528
125805
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125529
125806
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125530
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125807
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125808
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125531
125809
  // Its a circular reference ignore the status of this project
125532
125810
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125533
125811
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125549,75 +125827,194 @@ var ts;
125549
125827
  upstreamProjectName: ref.path
125550
125828
  };
125551
125829
  }
125552
- // Check oldest output file name only if there is no missing output file name
125553
- // (a check we will have skipped if this is a forced build)
125554
- if (!force && !missingOutputFileName) {
125555
- // If the upstream project's newest file is older than our oldest output, we
125556
- // can't be out of date because of it
125557
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125558
- continue;
125559
- }
125560
- // If the upstream project has only change .d.ts files, and we've built
125561
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125562
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125563
- pseudoUpToDate = true;
125564
- upstreamChangedProject = ref.path;
125565
- continue;
125566
- }
125567
- // We have an output older than an upstream output - we are out of date
125568
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125830
+ if (!force)
125831
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125832
+ }
125833
+ }
125834
+ if (force)
125835
+ return { type: ts.UpToDateStatusType.ForceBuild };
125836
+ // Check buildinfo first
125837
+ var host = state.host;
125838
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125839
+ var oldestOutputFileName;
125840
+ var oldestOutputFileTime = maximumDate;
125841
+ var buildInfoTime;
125842
+ var buildInfoProgram;
125843
+ var buildInfoVersionMap;
125844
+ var newestDeclarationFileContentChangedTime;
125845
+ if (buildInfoPath) {
125846
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125847
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125848
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125849
+ if (!buildInfoCacheEntry_1) {
125850
+ state.buildInfoCache.set(resolvedPath, {
125851
+ path: toPath(state, buildInfoPath),
125852
+ buildInfo: false,
125853
+ modifiedTime: buildInfoTime
125854
+ });
125855
+ }
125856
+ return {
125857
+ type: ts.UpToDateStatusType.OutputMissing,
125858
+ missingOutputFileName: buildInfoPath
125859
+ };
125860
+ }
125861
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125862
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125863
+ return {
125864
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125865
+ version: buildInfo.version
125866
+ };
125867
+ }
125868
+ if (buildInfo.program) {
125869
+ // If there are pending changes that are not emitted, project is out of date
125870
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125871
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125569
125872
  return {
125570
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125571
- outOfDateOutputFileName: oldestOutputFileName,
125572
- newerProjectName: ref.path
125873
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125874
+ buildInfoFile: buildInfoPath
125573
125875
  };
125574
125876
  }
125877
+ buildInfoProgram = buildInfo.program;
125575
125878
  }
125879
+ oldestOutputFileTime = buildInfoTime;
125880
+ oldestOutputFileName = buildInfoPath;
125881
+ // Get the last dtsChange time from build info
125882
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125576
125883
  }
125577
- if (missingOutputFileName !== undefined) {
125578
- return {
125579
- type: ts.UpToDateStatusType.OutputMissing,
125580
- missingOutputFileName: missingOutputFileName
125581
- };
125884
+ // Check input files
125885
+ var newestInputFileName = undefined;
125886
+ var newestInputFileTime = minimumDate;
125887
+ /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */
125888
+ var pseudoInputUpToDate = false;
125889
+ // Get timestamps of input files
125890
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125891
+ var inputFile = _f[_e];
125892
+ var inputTime = getModifiedTime(state, inputFile);
125893
+ if (inputTime === ts.missingFileModifiedTime) {
125894
+ return {
125895
+ type: ts.UpToDateStatusType.Unbuildable,
125896
+ reason: inputFile + " does not exist"
125897
+ };
125898
+ }
125899
+ // If an buildInfo is older than the newest input, we can stop checking
125900
+ if (buildInfoTime && buildInfoTime < inputTime) {
125901
+ var version_3 = void 0;
125902
+ var currentVersion = void 0;
125903
+ if (buildInfoProgram) {
125904
+ // Read files and see if they are same, read is anyways cached
125905
+ if (!buildInfoVersionMap)
125906
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125907
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125908
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125909
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125910
+ if (version_3 && version_3 === currentVersion)
125911
+ pseudoInputUpToDate = true;
125912
+ }
125913
+ if (!version_3 || version_3 !== currentVersion) {
125914
+ return {
125915
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125916
+ outOfDateOutputFileName: buildInfoPath,
125917
+ newerInputFileName: inputFile
125918
+ };
125919
+ }
125920
+ }
125921
+ if (inputTime > newestInputFileTime) {
125922
+ newestInputFileName = inputFile;
125923
+ newestInputFileTime = inputTime;
125924
+ }
125582
125925
  }
125583
- if (isOutOfDateWithInputs) {
125584
- return {
125585
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125586
- outOfDateOutputFileName: oldestOutputFileName,
125587
- newerInputFileName: newestInputFileName
125588
- };
125926
+ // Now see if all outputs are newer than the newest input
125927
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125928
+ if (!buildInfoPath) {
125929
+ // Collect the expected outputs of this project
125930
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125931
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125932
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125933
+ var output = outputs_1[_g];
125934
+ var path = toPath(state, output);
125935
+ // Output is missing; can stop checking
125936
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125937
+ if (!outputTime) {
125938
+ outputTime = ts.getModifiedTime(state.host, output);
125939
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125940
+ }
125941
+ if (outputTime === ts.missingFileModifiedTime) {
125942
+ return {
125943
+ type: ts.UpToDateStatusType.OutputMissing,
125944
+ missingOutputFileName: output
125945
+ };
125946
+ }
125947
+ // If an output is older than the newest input, we can stop checking
125948
+ if (outputTime < newestInputFileTime) {
125949
+ return {
125950
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125951
+ outOfDateOutputFileName: output,
125952
+ newerInputFileName: newestInputFileName
125953
+ };
125954
+ }
125955
+ // No need to get newestDeclarationFileContentChangedTime since thats needed only for composite projects
125956
+ // And composite projects are the only ones that can be referenced
125957
+ if (outputTime < oldestOutputFileTime) {
125958
+ oldestOutputFileTime = outputTime;
125959
+ oldestOutputFileName = output;
125960
+ }
125961
+ }
125589
125962
  }
125590
- else {
125591
- // Check tsconfig time
125592
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125593
- if (configStatus)
125594
- return configStatus;
125595
- // Check extended config time
125596
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125597
- if (extendedConfigStatus)
125598
- return extendedConfigStatus;
125599
- // Check package file time
125600
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125601
- var path = _a[0];
125602
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125603
- });
125604
- if (dependentPackageFileStatus)
125605
- return dependentPackageFileStatus;
125606
- }
125607
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125608
- state.buildInfoChecked.set(resolvedPath, true);
125609
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125610
- if (buildInfoPath) {
125611
- var value = state.readFileWithCache(buildInfoPath);
125612
- var buildInfo = value && ts.getBuildInfo(value);
125613
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125963
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125964
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125965
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125966
+ /** Inputs are up-to-date, just need either timestamp update or bundle prepend manipulation to make it look up-to-date */
125967
+ var pseudoUpToDate = false;
125968
+ var usesPrepend = false;
125969
+ var upstreamChangedProject;
125970
+ if (referenceStatuses) {
125971
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125972
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125973
+ usesPrepend = usesPrepend || !!(ref.prepend);
125974
+ // If the upstream project's newest file is older than our oldest output, we
125975
+ // can't be out of date because of it
125976
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125977
+ continue;
125978
+ }
125979
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125980
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125614
125981
  return {
125615
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125616
- version: buildInfo.version
125982
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125983
+ outOfDateOutputFileName: buildInfoPath,
125984
+ newerProjectName: ref.path
125617
125985
  };
125618
125986
  }
125987
+ // If the upstream project has only change .d.ts files, and we've built
125988
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125989
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125990
+ pseudoUpToDate = true;
125991
+ upstreamChangedProject = ref.path;
125992
+ continue;
125993
+ }
125994
+ // We have an output older than an upstream output - we are out of date
125995
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125996
+ return {
125997
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125998
+ outOfDateOutputFileName: oldestOutputFileName,
125999
+ newerProjectName: ref.path
126000
+ };
125619
126001
  }
125620
126002
  }
126003
+ // Check tsconfig time
126004
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
126005
+ if (configStatus)
126006
+ return configStatus;
126007
+ // Check extended config time
126008
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
126009
+ if (extendedConfigStatus)
126010
+ return extendedConfigStatus;
126011
+ // Check package file time
126012
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
126013
+ var path = _a[0];
126014
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
126015
+ });
126016
+ if (dependentPackageFileStatus)
126017
+ return dependentPackageFileStatus;
125621
126018
  if (usesPrepend && pseudoUpToDate) {
125622
126019
  return {
125623
126020
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125627,15 +126024,37 @@ var ts;
125627
126024
  }
125628
126025
  // Up to date
125629
126026
  return {
125630
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
126027
+ type: pseudoUpToDate ?
126028
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
126029
+ pseudoInputUpToDate ?
126030
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
126031
+ ts.UpToDateStatusType.UpToDate,
125631
126032
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125632
126033
  newestInputFileTime: newestInputFileTime,
125633
- newestOutputFileTime: newestOutputFileTime,
125634
126034
  newestInputFileName: newestInputFileName,
125635
- newestOutputFileName: newestOutputFileName,
125636
126035
  oldestOutputFileName: oldestOutputFileName
125637
126036
  };
125638
126037
  }
126038
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
126039
+ if (seenRefs.has(resolvedRefPath))
126040
+ return false;
126041
+ seenRefs.add(resolvedRefPath);
126042
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
126043
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
126044
+ return true;
126045
+ if (resolvedConfig.projectReferences) {
126046
+ // Check references
126047
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
126048
+ var ref = _a[_i];
126049
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
126050
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
126051
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
126052
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
126053
+ return true;
126054
+ }
126055
+ }
126056
+ return false;
126057
+ }
125639
126058
  function getUpToDateStatus(state, project, resolvedPath) {
125640
126059
  if (project === undefined) {
125641
126060
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125648,39 +126067,68 @@ var ts;
125648
126067
  state.projectStatus.set(resolvedPath, actual);
125649
126068
  return actual;
125650
126069
  }
125651
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
126070
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125652
126071
  if (proj.options.noEmit)
125653
- return priorNewestUpdateTime;
126072
+ return;
126073
+ var now;
126074
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
126075
+ if (buildInfoPath) {
126076
+ // For incremental projects, only buildinfo needs to be upto date with timestamp check
126077
+ // as we dont check output files for up-to-date ness
126078
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
126079
+ if (!!state.options.verbose)
126080
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
126081
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
126082
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
126083
+ }
126084
+ state.outputTimeStamps.delete(projectPath);
126085
+ return;
126086
+ }
125654
126087
  var host = state.host;
125655
126088
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
126089
+ var outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
126090
+ var modifiedOutputs = outputTimeStampMap ? new ts.Set() : undefined;
125656
126091
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
125657
126092
  var reportVerbose = !!state.options.verbose;
125658
- var now = host.now ? host.now() : new Date();
125659
126093
  for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125660
126094
  var file = outputs_2[_i];
125661
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
126095
+ var path = toPath(state, file);
126096
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125662
126097
  continue;
125663
- }
125664
126098
  if (reportVerbose) {
125665
126099
  reportVerbose = false;
125666
126100
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125667
126101
  }
125668
- if (ts.isDeclarationFileName(file)) {
125669
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
126102
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
126103
+ // Store output timestamps in a map because non incremental build will need to check them to determine up-to-dateness
126104
+ if (outputTimeStampMap) {
126105
+ outputTimeStampMap.set(path, now);
126106
+ modifiedOutputs.add(path);
125670
126107
  }
125671
- host.setModifiedTime(file, now);
125672
126108
  }
125673
126109
  }
125674
- return priorNewestUpdateTime;
126110
+ // Clear out timestamps not in output list any more
126111
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.forEach(function (_value, key) {
126112
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs.has(key))
126113
+ outputTimeStampMap.delete(key);
126114
+ });
126115
+ }
126116
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
126117
+ var _a;
126118
+ if (!options.composite)
126119
+ return undefined;
126120
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
126121
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
126122
+ return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125675
126123
  }
125676
126124
  function updateOutputTimestamps(state, proj, resolvedPath) {
125677
126125
  if (state.options.dry) {
125678
126126
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125679
126127
  }
125680
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
126128
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125681
126129
  state.projectStatus.set(resolvedPath, {
125682
126130
  type: ts.UpToDateStatusType.UpToDate,
125683
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
126131
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125684
126132
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125685
126133
  });
125686
126134
  }
@@ -125726,6 +126174,7 @@ var ts;
125726
126174
  break;
125727
126175
  }
125728
126176
  // falls through
126177
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125729
126178
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125730
126179
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125731
126180
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125886,12 +126335,10 @@ var ts;
125886
126335
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125887
126336
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125888
126337
  return;
125889
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125890
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125891
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126338
+ state.allWatchedConfigFiles.set(resolvedPath, watchFile(state, resolved, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
125892
126339
  }
125893
126340
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125894
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126341
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125895
126342
  var _a;
125896
126343
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125897
126344
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125923,7 +126370,7 @@ var ts;
125923
126370
  if (!state.watch)
125924
126371
  return;
125925
126372
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125926
- createNewValue: function (_path, input) { return state.watchFile(input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.SourceFile, resolved); },
126373
+ createNewValue: function (_path, input) { return watchFile(state, input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.SourceFile, resolved); },
125927
126374
  onDeleteValue: ts.closeFileWatcher,
125928
126375
  });
125929
126376
  }
@@ -125931,7 +126378,7 @@ var ts;
125931
126378
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125932
126379
  return;
125933
126380
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125934
- createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
126381
+ createNewValue: function (path, _input) { return watchFile(state, path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
125935
126382
  onDeleteValue: ts.closeFileWatcher,
125936
126383
  });
125937
126384
  }
@@ -126061,19 +126508,18 @@ var ts;
126061
126508
  }
126062
126509
  }
126063
126510
  function reportUpToDateStatus(state, configFileName, status) {
126064
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
126065
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126066
- }
126067
126511
  switch (status.type) {
126068
126512
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126069
- return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
126513
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_1_is_older_than_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
126070
126514
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126071
- return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
126515
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_1_is_older_than_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
126072
126516
  case ts.UpToDateStatusType.OutputMissing:
126073
126517
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(state, configFileName), relName(state, status.missingOutputFileName));
126518
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
126519
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted, relName(state, configFileName), relName(state, status.buildInfoFile));
126074
126520
  case ts.UpToDateStatusType.UpToDate:
126075
126521
  if (status.newestInputFileTime !== undefined) {
126076
- return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(state, configFileName), relName(state, status.newestInputFileName || ""), relName(state, status.oldestOutputFileName || ""));
126522
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2, relName(state, configFileName), relName(state, status.newestInputFileName || ""), relName(state, status.oldestOutputFileName || ""));
126077
126523
  }
126078
126524
  // Don't report anything for "up to date because it was already built" -- too verbose
126079
126525
  break;
@@ -126081,6 +126527,8 @@ var ts;
126081
126527
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(state, configFileName), relName(state, status.newerProjectName));
126082
126528
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126083
126529
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126530
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
126531
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files, relName(state, configFileName));
126084
126532
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126085
126533
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName));
126086
126534
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126091,6 +126539,8 @@ var ts;
126091
126539
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126092
126540
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126093
126541
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version);
126542
+ case ts.UpToDateStatusType.ForceBuild:
126543
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126094
126544
  case ts.UpToDateStatusType.ContainerOnly:
126095
126545
  // Don't report status on "solution" projects
126096
126546
  // falls through
@@ -136368,7 +136818,7 @@ var ts;
136368
136818
  }
136369
136819
  var str = "{";
136370
136820
  for (var key in value) {
136371
- if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
136821
+ if (ts.hasProperty(value, key)) {
136372
136822
  str += key + ": " + compilerOptionValueToString(value[key]);
136373
136823
  }
136374
136824
  }
@@ -159296,14 +159746,14 @@ var ts;
159296
159746
  if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) {
159297
159747
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) };
159298
159748
  }
159299
- var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol;
159749
+ var checker = program.getTypeChecker();
159750
+ var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker);
159300
159751
  var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */);
159301
159752
  var wasDefault = !!(flags & 512 /* Default */);
159302
159753
  // If source file already has a default export, don't offer refactor.
159303
159754
  if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) {
159304
159755
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) };
159305
159756
  }
159306
- var checker = program.getTypeChecker();
159307
159757
  var noSymbolError = function (id) {
159308
159758
  return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined
159309
159759
  : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) };
@@ -159395,6 +159845,8 @@ var ts;
159395
159845
  var checker = program.getTypeChecker();
159396
159846
  var exportSymbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol");
159397
159847
  ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) {
159848
+ if (exportName === ref)
159849
+ return;
159398
159850
  var importingSourceFile = ref.getSourceFile();
159399
159851
  if (wasDefault) {
159400
159852
  changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text);
@@ -159487,6 +159939,17 @@ var ts;
159487
159939
  function makeExportSpecifier(propertyName, name) {
159488
159940
  return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name));
159489
159941
  }
159942
+ function getExportingModuleSymbol(node, checker) {
159943
+ var parent = node.parent;
159944
+ if (ts.isSourceFile(parent)) {
159945
+ return parent.symbol;
159946
+ }
159947
+ var symbol = parent.parent.symbol;
159948
+ if (symbol.valueDeclaration && ts.isExternalModuleAugmentation(symbol.valueDeclaration)) {
159949
+ return checker.getMergedSymbol(symbol);
159950
+ }
159951
+ return symbol;
159952
+ }
159490
159953
  })(refactor = ts.refactor || (ts.refactor = {}));
159491
159954
  })(ts || (ts = {}));
159492
159955
  /* @internal */
@@ -167783,7 +168246,8 @@ var ts;
167783
168246
  }
167784
168247
  return {
167785
168248
  resolvedFileName: resolvedFileName,
167786
- failedLookupLocations: result.failedLookupLocations
168249
+ failedLookupLocations: result.failedLookupLocations,
168250
+ affectingLocations: result.affectingLocations,
167787
168251
  };
167788
168252
  });
167789
168253
  };
@@ -169919,6 +170383,10 @@ var ts;
169919
170383
  return this.projectService.watchFactory.watchDirectory(directory, cb, flags, this.projectService.getWatchOptions(this), ts.WatchType.FailedLookupLocations, this);
169920
170384
  };
169921
170385
  /*@internal*/
170386
+ Project.prototype.watchAffectingFileLocation = function (file, cb) {
170387
+ return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this);
170388
+ };
170389
+ /*@internal*/
169922
170390
  Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () {
169923
170391
  return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation");
169924
170392
  };