@typescript-deploys/pr-build 4.8.0-pr-49233-9 → 4.8.0-pr-48784-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
92
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220527";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -3499,16 +3499,34 @@ var ts;
3499
3499
  /** Performance measurements for the compiler. */
3500
3500
  var ts;
3501
3501
  (function (ts) {
3502
- var performance;
3503
- (function (performance) {
3502
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3503
+ ts.performance = createPerformanceTracker();
3504
+ ts.solutionPerformance = createPerformanceTracker();
3505
+ function createPerformanceTracker() {
3504
3506
  var perfHooks;
3505
3507
  // when set, indicates the implementation of `Performance` to use for user timing.
3506
3508
  // when unset, indicates user timing is unavailable or disabled.
3507
3509
  var performanceImpl;
3510
+ var enabled = false;
3511
+ var timeorigin = ts.timestamp();
3512
+ var marks = new ts.Map();
3513
+ var counts = new ts.Map();
3514
+ var durations = new ts.Map();
3515
+ return {
3516
+ createTimerIf: createTimerIf,
3517
+ createTimer: createTimer,
3518
+ mark: mark,
3519
+ measure: measure,
3520
+ getCount: getCount,
3521
+ getDuration: getDuration,
3522
+ forEachMeasure: forEachMeasure,
3523
+ isEnabled: isEnabled,
3524
+ enable: enable,
3525
+ disable: disable,
3526
+ };
3508
3527
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3509
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3528
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3510
3529
  }
3511
- performance.createTimerIf = createTimerIf;
3512
3530
  function createTimer(measureName, startMarkName, endMarkName) {
3513
3531
  var enterCount = 0;
3514
3532
  return {
@@ -3530,13 +3548,6 @@ var ts;
3530
3548
  }
3531
3549
  }
3532
3550
  }
3533
- performance.createTimer = createTimer;
3534
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3535
- var enabled = false;
3536
- var timeorigin = ts.timestamp();
3537
- var marks = new ts.Map();
3538
- var counts = new ts.Map();
3539
- var durations = new ts.Map();
3540
3551
  /**
3541
3552
  * Marks a performance event.
3542
3553
  *
@@ -3551,7 +3562,6 @@ var ts;
3551
3562
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3552
3563
  }
3553
3564
  }
3554
- performance.mark = mark;
3555
3565
  /**
3556
3566
  * Adds a performance measurement with the specified name.
3557
3567
  *
@@ -3564,14 +3574,13 @@ var ts;
3564
3574
  function measure(measureName, startMarkName, endMarkName) {
3565
3575
  var _a, _b;
3566
3576
  if (enabled) {
3567
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3568
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3577
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3578
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3569
3579
  var previousDuration = durations.get(measureName) || 0;
3570
3580
  durations.set(measureName, previousDuration + (end - start));
3571
3581
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3572
3582
  }
3573
3583
  }
3574
- performance.measure = measure;
3575
3584
  /**
3576
3585
  * Gets the number of times a marker was encountered.
3577
3586
  *
@@ -3580,7 +3589,6 @@ var ts;
3580
3589
  function getCount(markName) {
3581
3590
  return counts.get(markName) || 0;
3582
3591
  }
3583
- performance.getCount = getCount;
3584
3592
  /**
3585
3593
  * Gets the total duration of all measurements with the supplied name.
3586
3594
  *
@@ -3589,7 +3597,6 @@ var ts;
3589
3597
  function getDuration(measureName) {
3590
3598
  return durations.get(measureName) || 0;
3591
3599
  }
3592
- performance.getDuration = getDuration;
3593
3600
  /**
3594
3601
  * Iterate over each measure, performing some action
3595
3602
  *
@@ -3598,14 +3605,12 @@ var ts;
3598
3605
  function forEachMeasure(cb) {
3599
3606
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3600
3607
  }
3601
- performance.forEachMeasure = forEachMeasure;
3602
3608
  /**
3603
3609
  * Indicates whether the performance API is enabled.
3604
3610
  */
3605
3611
  function isEnabled() {
3606
3612
  return enabled;
3607
3613
  }
3608
- performance.isEnabled = isEnabled;
3609
3614
  /** Enables (and resets) performance measurements for the compiler. */
3610
3615
  function enable(system) {
3611
3616
  var _a;
@@ -3626,7 +3631,6 @@ var ts;
3626
3631
  }
3627
3632
  return true;
3628
3633
  }
3629
- performance.enable = enable;
3630
3634
  /** Disables performance measurements for the compiler. */
3631
3635
  function disable() {
3632
3636
  if (enabled) {
@@ -3637,8 +3641,7 @@ var ts;
3637
3641
  enabled = false;
3638
3642
  }
3639
3643
  }
3640
- performance.disable = disable;
3641
- })(performance = ts.performance || (ts.performance = {}));
3644
+ }
3642
3645
  })(ts || (ts = {}));
3643
3646
  /* @internal */
3644
3647
  var ts;
@@ -6181,7 +6184,7 @@ var ts;
6181
6184
  };
6182
6185
  }
6183
6186
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6184
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6187
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6185
6188
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6186
6189
  if (!ts.isString(relativeFileName))
6187
6190
  return;
@@ -6191,7 +6194,7 @@ var ts;
6191
6194
  if (callbacks) {
6192
6195
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6193
6196
  var fileCallback = callbacks_1[_i];
6194
- fileCallback(fileName, FileWatcherEventKind.Changed);
6197
+ fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6195
6198
  }
6196
6199
  }
6197
6200
  },
@@ -6245,7 +6248,7 @@ var ts;
6245
6248
  }
6246
6249
  else {
6247
6250
  cache.set(path, {
6248
- watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6251
+ watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6249
6252
  refCount: 1
6250
6253
  });
6251
6254
  }
@@ -6273,7 +6276,7 @@ var ts;
6273
6276
  var newTime = modifiedTime.getTime();
6274
6277
  if (oldTime !== newTime) {
6275
6278
  watchedFile.mtime = modifiedTime;
6276
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6279
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6277
6280
  return true;
6278
6281
  }
6279
6282
  return false;
@@ -6524,17 +6527,18 @@ var ts;
6524
6527
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6525
6528
  /*@internal*/
6526
6529
  function createFileWatcherCallback(callback) {
6527
- return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6530
+ return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6528
6531
  }
6529
6532
  ts.createFileWatcherCallback = createFileWatcherCallback;
6530
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6531
- return function (eventName) {
6533
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6534
+ return function (eventName, _relativeFileName, modifiedTime) {
6532
6535
  if (eventName === "rename") {
6533
- callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6536
+ modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6537
+ callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6534
6538
  }
6535
6539
  else {
6536
6540
  // Change
6537
- callback(fileName, FileWatcherEventKind.Changed);
6541
+ callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6538
6542
  }
6539
6543
  };
6540
6544
  }
@@ -6558,7 +6562,7 @@ var ts;
6558
6562
  }
6559
6563
  /*@internal*/
6560
6564
  function createSystemWatchFunctions(_a) {
6561
- 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;
6565
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, 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;
6562
6566
  var dynamicPollingWatchFile;
6563
6567
  var fixedChunkSizePollingWatchFile;
6564
6568
  var nonPollingWatchFile;
@@ -6580,7 +6584,7 @@ var ts;
6580
6584
  case ts.WatchFileKind.FixedChunkSizePolling:
6581
6585
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6582
6586
  case ts.WatchFileKind.UseFsEvents:
6583
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6587
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6584
6588
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6585
6589
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6586
6590
  if (!nonPollingWatchFile) {
@@ -6762,7 +6766,6 @@ var ts;
6762
6766
  fsWatch: fsWatch,
6763
6767
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6764
6768
  getCurrentDirectory: getCurrentDirectory,
6765
- fileExists: fileExists,
6766
6769
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6767
6770
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6768
6771
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
@@ -7022,7 +7025,7 @@ var ts;
7022
7025
  // File changed
7023
7026
  eventKind = FileWatcherEventKind.Changed;
7024
7027
  }
7025
- callback(fileName, eventKind);
7028
+ callback(fileName, eventKind, curr.mtime);
7026
7029
  }
7027
7030
  }
7028
7031
  function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
@@ -7048,10 +7051,10 @@ var ts;
7048
7051
  * Invoke the callback with rename and update the watcher if not closed
7049
7052
  * @param createWatcher
7050
7053
  */
7051
- function invokeCallbackAndUpdateWatcher(createWatcher) {
7054
+ function invokeCallbackAndUpdateWatcher(createWatcher, modifiedTime) {
7052
7055
  sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7053
7056
  // Call the callback for current directory
7054
- callback("rename", "");
7057
+ callback("rename", "", modifiedTime);
7055
7058
  // If watcher is not closed, update it
7056
7059
  if (watcher) {
7057
7060
  watcher.close();
@@ -7097,13 +7100,14 @@ var ts;
7097
7100
  function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7098
7101
  // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7099
7102
  // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7103
+ var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
7100
7104
  return event === "rename" &&
7101
7105
  (!relativeName ||
7102
7106
  relativeName === lastDirectoryPart ||
7103
7107
  (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7104
- !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7105
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7106
- callback(event, relativeName);
7108
+ modifiedTime === ts.missingFileModifiedTime ?
7109
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry, modifiedTime) :
7110
+ callback(event, relativeName, modifiedTime);
7107
7111
  }
7108
7112
  /**
7109
7113
  * Watch the file or directory using fs.watchFile since fs.watch threw exception
@@ -7117,12 +7121,15 @@ var ts;
7117
7121
  * and switch to existing file or directory when the missing filesystem entry is created
7118
7122
  */
7119
7123
  function watchMissingFileSystemEntry() {
7120
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7121
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7122
- // Call the callback for current file or directory
7123
- // For now it could be callback for the inner directory creation,
7124
- // but just return current directory, better than current no-op
7125
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7124
+ return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7125
+ if (eventKind === FileWatcherEventKind.Created) {
7126
+ modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7127
+ if (modifiedTime !== ts.missingFileModifiedTime) {
7128
+ // Call the callback for current file or directory
7129
+ // For now it could be callback for the inner directory creation,
7130
+ // but just return current directory, better than current no-op
7131
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry, modifiedTime);
7132
+ }
7126
7133
  }
7127
7134
  }, fallbackPollingInterval, fallbackOptions);
7128
7135
  }
@@ -7272,12 +7279,19 @@ var ts;
7272
7279
  }
7273
7280
  function getModifiedTime(path) {
7274
7281
  var _a;
7282
+ // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7283
+ // the CPU time performance.
7284
+ var originalStackTraceLimit = Error.stackTraceLimit;
7285
+ Error.stackTraceLimit = 0;
7275
7286
  try {
7276
7287
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7277
7288
  }
7278
7289
  catch (e) {
7279
7290
  return undefined;
7280
7291
  }
7292
+ finally {
7293
+ Error.stackTraceLimit = originalStackTraceLimit;
7294
+ }
7281
7295
  }
7282
7296
  function setModifiedTime(path, time) {
7283
7297
  try {
@@ -9298,8 +9312,8 @@ var ts;
9298
9312
  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"),
9299
9313
  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"),
9300
9314
  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."),
9301
- 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}'"),
9302
- 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}'"),
9315
+ 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}'"),
9316
+ 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}'"),
9303
9317
  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"),
9304
9318
  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"),
9305
9319
  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"),
@@ -9343,6 +9357,8 @@ var ts;
9343
9357
  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}'."),
9344
9358
  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}'."),
9345
9359
  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."),
9360
+ Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes are not emitted"),
9361
+ Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs update to timestamps of output files that are older than input files"),
9346
9362
  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}'"),
9347
9363
  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."),
9348
9364
  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."),
@@ -16207,9 +16223,6 @@ var ts;
16207
16223
  }
16208
16224
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16209
16225
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16210
- if (node.kind === 203 /* BindingElement */) {
16211
- node = node.parent.parent;
16212
- }
16213
16226
  return ts.isVariableDeclaration(node) &&
16214
16227
  !!node.initializer &&
16215
16228
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20021,8 +20034,9 @@ var ts;
20021
20034
  */
20022
20035
  function isFileForcedToBeModuleByFormat(file) {
20023
20036
  // Excludes declaration files - they still require an explicit `export {}` or the like
20024
- // for back compat purposes.
20025
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20037
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20038
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20039
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20026
20040
  }
20027
20041
  function getSetExternalModuleIndicator(options) {
20028
20042
  // TODO: Should this callback be cached?
@@ -20030,7 +20044,7 @@ var ts;
20030
20044
  case ts.ModuleDetectionKind.Force:
20031
20045
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20032
20046
  return function (file) {
20033
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20047
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20034
20048
  };
20035
20049
  case ts.ModuleDetectionKind.Legacy:
20036
20050
  // Files are modules if they have imports, exports, or import.meta
@@ -20090,7 +20104,8 @@ var ts;
20090
20104
  }
20091
20105
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20092
20106
  function getEmitModuleDetectionKind(options) {
20093
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20107
+ return options.moduleDetection ||
20108
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20094
20109
  }
20095
20110
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20096
20111
  function hasJsonModuleEmitEnabled(options) {
@@ -20173,6 +20188,10 @@ var ts;
20173
20188
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20174
20189
  }
20175
20190
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20191
+ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20192
+ return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20193
+ }
20194
+ ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20176
20195
  function getCompilerOptionValue(options, option) {
20177
20196
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20178
20197
  }
@@ -39213,6 +39232,7 @@ var ts;
39213
39232
  type: "boolean",
39214
39233
  affectsSemanticDiagnostics: true,
39215
39234
  affectsEmit: true,
39235
+ affectsMultiFileEmitBuildInfo: true,
39216
39236
  category: ts.Diagnostics.Watch_and_Build_Modes,
39217
39237
  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,
39218
39238
  defaultValueDescription: false,
@@ -39247,12 +39267,40 @@ var ts;
39247
39267
  affectsSourceFile: true,
39248
39268
  affectsModuleResolution: true,
39249
39269
  affectsEmit: true,
39270
+ affectsMultiFileEmitBuildInfo: true,
39250
39271
  paramType: ts.Diagnostics.VERSION,
39251
39272
  showInSimplifiedHelpView: true,
39252
39273
  category: ts.Diagnostics.Language_and_Environment,
39253
39274
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39254
39275
  defaultValueDescription: 0 /* ES3 */,
39255
39276
  };
39277
+ /*@internal*/
39278
+ ts.moduleOptionDeclaration = {
39279
+ name: "module",
39280
+ shortName: "m",
39281
+ type: new ts.Map(ts.getEntries({
39282
+ none: ts.ModuleKind.None,
39283
+ commonjs: ts.ModuleKind.CommonJS,
39284
+ amd: ts.ModuleKind.AMD,
39285
+ system: ts.ModuleKind.System,
39286
+ umd: ts.ModuleKind.UMD,
39287
+ es6: ts.ModuleKind.ES2015,
39288
+ es2015: ts.ModuleKind.ES2015,
39289
+ es2020: ts.ModuleKind.ES2020,
39290
+ es2022: ts.ModuleKind.ES2022,
39291
+ esnext: ts.ModuleKind.ESNext,
39292
+ node16: ts.ModuleKind.Node16,
39293
+ nodenext: ts.ModuleKind.NodeNext,
39294
+ })),
39295
+ affectsModuleResolution: true,
39296
+ affectsEmit: true,
39297
+ affectsMultiFileEmitBuildInfo: true,
39298
+ paramType: ts.Diagnostics.KIND,
39299
+ showInSimplifiedHelpView: true,
39300
+ category: ts.Diagnostics.Modules,
39301
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39302
+ defaultValueDescription: undefined,
39303
+ };
39256
39304
  var commandOptionsWithoutBuild = [
39257
39305
  // CommandLine only options
39258
39306
  {
@@ -39314,37 +39362,14 @@ var ts;
39314
39362
  category: ts.Diagnostics.Command_line_Options,
39315
39363
  affectsSemanticDiagnostics: true,
39316
39364
  affectsEmit: true,
39365
+ affectsMultiFileEmitBuildInfo: true,
39317
39366
  isCommandLineOnly: true,
39318
39367
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39319
39368
  defaultValueDescription: false,
39320
39369
  },
39321
39370
  // Basic
39322
39371
  ts.targetOptionDeclaration,
39323
- {
39324
- name: "module",
39325
- shortName: "m",
39326
- type: new ts.Map(ts.getEntries({
39327
- none: ts.ModuleKind.None,
39328
- commonjs: ts.ModuleKind.CommonJS,
39329
- amd: ts.ModuleKind.AMD,
39330
- system: ts.ModuleKind.System,
39331
- umd: ts.ModuleKind.UMD,
39332
- es6: ts.ModuleKind.ES2015,
39333
- es2015: ts.ModuleKind.ES2015,
39334
- es2020: ts.ModuleKind.ES2020,
39335
- es2022: ts.ModuleKind.ES2022,
39336
- esnext: ts.ModuleKind.ESNext,
39337
- node16: ts.ModuleKind.Node16,
39338
- nodenext: ts.ModuleKind.NodeNext,
39339
- })),
39340
- affectsModuleResolution: true,
39341
- affectsEmit: true,
39342
- paramType: ts.Diagnostics.KIND,
39343
- showInSimplifiedHelpView: true,
39344
- category: ts.Diagnostics.Modules,
39345
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39346
- defaultValueDescription: undefined,
39347
- },
39372
+ ts.moduleOptionDeclaration,
39348
39373
  {
39349
39374
  name: "lib",
39350
39375
  type: "list",
@@ -39381,6 +39406,7 @@ var ts;
39381
39406
  type: jsxOptionMap,
39382
39407
  affectsSourceFile: true,
39383
39408
  affectsEmit: true,
39409
+ affectsMultiFileEmitBuildInfo: true,
39384
39410
  affectsModuleResolution: true,
39385
39411
  paramType: ts.Diagnostics.KIND,
39386
39412
  showInSimplifiedHelpView: true,
@@ -39393,6 +39419,7 @@ var ts;
39393
39419
  shortName: "d",
39394
39420
  type: "boolean",
39395
39421
  affectsEmit: true,
39422
+ affectsMultiFileEmitBuildInfo: true,
39396
39423
  showInSimplifiedHelpView: true,
39397
39424
  category: ts.Diagnostics.Emit,
39398
39425
  transpileOptionValue: undefined,
@@ -39403,6 +39430,7 @@ var ts;
39403
39430
  name: "declarationMap",
39404
39431
  type: "boolean",
39405
39432
  affectsEmit: true,
39433
+ affectsMultiFileEmitBuildInfo: true,
39406
39434
  showInSimplifiedHelpView: true,
39407
39435
  category: ts.Diagnostics.Emit,
39408
39436
  transpileOptionValue: undefined,
@@ -39413,6 +39441,7 @@ var ts;
39413
39441
  name: "emitDeclarationOnly",
39414
39442
  type: "boolean",
39415
39443
  affectsEmit: true,
39444
+ affectsMultiFileEmitBuildInfo: true,
39416
39445
  showInSimplifiedHelpView: true,
39417
39446
  category: ts.Diagnostics.Emit,
39418
39447
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39423,6 +39452,7 @@ var ts;
39423
39452
  name: "sourceMap",
39424
39453
  type: "boolean",
39425
39454
  affectsEmit: true,
39455
+ affectsMultiFileEmitBuildInfo: true,
39426
39456
  showInSimplifiedHelpView: true,
39427
39457
  category: ts.Diagnostics.Emit,
39428
39458
  defaultValueDescription: false,
@@ -39432,6 +39462,9 @@ var ts;
39432
39462
  name: "outFile",
39433
39463
  type: "string",
39434
39464
  affectsEmit: true,
39465
+ affectsMultiFileEmitBuildInfo: true,
39466
+ affectsDeclarationPath: true,
39467
+ affectsBundleEmitBuildInfo: true,
39435
39468
  isFilePath: true,
39436
39469
  paramType: ts.Diagnostics.FILE,
39437
39470
  showInSimplifiedHelpView: true,
@@ -39443,6 +39476,8 @@ var ts;
39443
39476
  name: "outDir",
39444
39477
  type: "string",
39445
39478
  affectsEmit: true,
39479
+ affectsMultiFileEmitBuildInfo: true,
39480
+ affectsDeclarationPath: true,
39446
39481
  isFilePath: true,
39447
39482
  paramType: ts.Diagnostics.DIRECTORY,
39448
39483
  showInSimplifiedHelpView: true,
@@ -39453,6 +39488,8 @@ var ts;
39453
39488
  name: "rootDir",
39454
39489
  type: "string",
39455
39490
  affectsEmit: true,
39491
+ affectsMultiFileEmitBuildInfo: true,
39492
+ affectsDeclarationPath: true,
39456
39493
  isFilePath: true,
39457
39494
  paramType: ts.Diagnostics.LOCATION,
39458
39495
  category: ts.Diagnostics.Modules,
@@ -39463,6 +39500,8 @@ var ts;
39463
39500
  name: "composite",
39464
39501
  type: "boolean",
39465
39502
  affectsEmit: true,
39503
+ affectsMultiFileEmitBuildInfo: true,
39504
+ affectsBundleEmitBuildInfo: true,
39466
39505
  isTSConfigOnly: true,
39467
39506
  category: ts.Diagnostics.Projects,
39468
39507
  transpileOptionValue: undefined,
@@ -39473,6 +39512,8 @@ var ts;
39473
39512
  name: "tsBuildInfoFile",
39474
39513
  type: "string",
39475
39514
  affectsEmit: true,
39515
+ affectsMultiFileEmitBuildInfo: true,
39516
+ affectsBundleEmitBuildInfo: true,
39476
39517
  isFilePath: true,
39477
39518
  paramType: ts.Diagnostics.FILE,
39478
39519
  category: ts.Diagnostics.Projects,
@@ -39484,6 +39525,7 @@ var ts;
39484
39525
  name: "removeComments",
39485
39526
  type: "boolean",
39486
39527
  affectsEmit: true,
39528
+ affectsMultiFileEmitBuildInfo: true,
39487
39529
  showInSimplifiedHelpView: true,
39488
39530
  category: ts.Diagnostics.Emit,
39489
39531
  defaultValueDescription: false,
@@ -39502,6 +39544,7 @@ var ts;
39502
39544
  name: "importHelpers",
39503
39545
  type: "boolean",
39504
39546
  affectsEmit: true,
39547
+ affectsMultiFileEmitBuildInfo: true,
39505
39548
  category: ts.Diagnostics.Emit,
39506
39549
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39507
39550
  defaultValueDescription: false,
@@ -39515,6 +39558,7 @@ var ts;
39515
39558
  })),
39516
39559
  affectsEmit: true,
39517
39560
  affectsSemanticDiagnostics: true,
39561
+ affectsMultiFileEmitBuildInfo: true,
39518
39562
  category: ts.Diagnostics.Emit,
39519
39563
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39520
39564
  defaultValueDescription: 0 /* Remove */,
@@ -39523,6 +39567,7 @@ var ts;
39523
39567
  name: "downlevelIteration",
39524
39568
  type: "boolean",
39525
39569
  affectsEmit: true,
39570
+ affectsMultiFileEmitBuildInfo: true,
39526
39571
  category: ts.Diagnostics.Emit,
39527
39572
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39528
39573
  defaultValueDescription: false,
@@ -39541,6 +39586,9 @@ var ts;
39541
39586
  type: "boolean",
39542
39587
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39543
39588
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39589
+ // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39590
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39591
+ affectsMultiFileEmitBuildInfo: true,
39544
39592
  showInSimplifiedHelpView: true,
39545
39593
  category: ts.Diagnostics.Type_Checking,
39546
39594
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39550,6 +39598,7 @@ var ts;
39550
39598
  name: "noImplicitAny",
39551
39599
  type: "boolean",
39552
39600
  affectsSemanticDiagnostics: true,
39601
+ affectsMultiFileEmitBuildInfo: true,
39553
39602
  strictFlag: true,
39554
39603
  category: ts.Diagnostics.Type_Checking,
39555
39604
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39559,6 +39608,7 @@ var ts;
39559
39608
  name: "strictNullChecks",
39560
39609
  type: "boolean",
39561
39610
  affectsSemanticDiagnostics: true,
39611
+ affectsMultiFileEmitBuildInfo: true,
39562
39612
  strictFlag: true,
39563
39613
  category: ts.Diagnostics.Type_Checking,
39564
39614
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39567,6 +39617,8 @@ var ts;
39567
39617
  {
39568
39618
  name: "strictFunctionTypes",
39569
39619
  type: "boolean",
39620
+ affectsSemanticDiagnostics: true,
39621
+ affectsMultiFileEmitBuildInfo: true,
39570
39622
  strictFlag: true,
39571
39623
  category: ts.Diagnostics.Type_Checking,
39572
39624
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39575,6 +39627,8 @@ var ts;
39575
39627
  {
39576
39628
  name: "strictBindCallApply",
39577
39629
  type: "boolean",
39630
+ affectsSemanticDiagnostics: true,
39631
+ affectsMultiFileEmitBuildInfo: true,
39578
39632
  strictFlag: true,
39579
39633
  category: ts.Diagnostics.Type_Checking,
39580
39634
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39584,6 +39638,7 @@ var ts;
39584
39638
  name: "strictPropertyInitialization",
39585
39639
  type: "boolean",
39586
39640
  affectsSemanticDiagnostics: true,
39641
+ affectsMultiFileEmitBuildInfo: true,
39587
39642
  strictFlag: true,
39588
39643
  category: ts.Diagnostics.Type_Checking,
39589
39644
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39593,6 +39648,7 @@ var ts;
39593
39648
  name: "noImplicitThis",
39594
39649
  type: "boolean",
39595
39650
  affectsSemanticDiagnostics: true,
39651
+ affectsMultiFileEmitBuildInfo: true,
39596
39652
  strictFlag: true,
39597
39653
  category: ts.Diagnostics.Type_Checking,
39598
39654
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39602,6 +39658,7 @@ var ts;
39602
39658
  name: "useUnknownInCatchVariables",
39603
39659
  type: "boolean",
39604
39660
  affectsSemanticDiagnostics: true,
39661
+ affectsMultiFileEmitBuildInfo: true,
39605
39662
  strictFlag: true,
39606
39663
  category: ts.Diagnostics.Type_Checking,
39607
39664
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39611,6 +39668,8 @@ var ts;
39611
39668
  name: "alwaysStrict",
39612
39669
  type: "boolean",
39613
39670
  affectsSourceFile: true,
39671
+ affectsEmit: true,
39672
+ affectsMultiFileEmitBuildInfo: true,
39614
39673
  strictFlag: true,
39615
39674
  category: ts.Diagnostics.Type_Checking,
39616
39675
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39621,6 +39680,7 @@ var ts;
39621
39680
  name: "noUnusedLocals",
39622
39681
  type: "boolean",
39623
39682
  affectsSemanticDiagnostics: true,
39683
+ affectsMultiFileEmitBuildInfo: true,
39624
39684
  category: ts.Diagnostics.Type_Checking,
39625
39685
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39626
39686
  defaultValueDescription: false,
@@ -39629,6 +39689,7 @@ var ts;
39629
39689
  name: "noUnusedParameters",
39630
39690
  type: "boolean",
39631
39691
  affectsSemanticDiagnostics: true,
39692
+ affectsMultiFileEmitBuildInfo: true,
39632
39693
  category: ts.Diagnostics.Type_Checking,
39633
39694
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39634
39695
  defaultValueDescription: false,
@@ -39637,6 +39698,7 @@ var ts;
39637
39698
  name: "exactOptionalPropertyTypes",
39638
39699
  type: "boolean",
39639
39700
  affectsSemanticDiagnostics: true,
39701
+ affectsMultiFileEmitBuildInfo: true,
39640
39702
  category: ts.Diagnostics.Type_Checking,
39641
39703
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39642
39704
  defaultValueDescription: false,
@@ -39645,6 +39707,7 @@ var ts;
39645
39707
  name: "noImplicitReturns",
39646
39708
  type: "boolean",
39647
39709
  affectsSemanticDiagnostics: true,
39710
+ affectsMultiFileEmitBuildInfo: true,
39648
39711
  category: ts.Diagnostics.Type_Checking,
39649
39712
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39650
39713
  defaultValueDescription: false,
@@ -39654,6 +39717,7 @@ var ts;
39654
39717
  type: "boolean",
39655
39718
  affectsBindDiagnostics: true,
39656
39719
  affectsSemanticDiagnostics: true,
39720
+ affectsMultiFileEmitBuildInfo: true,
39657
39721
  category: ts.Diagnostics.Type_Checking,
39658
39722
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39659
39723
  defaultValueDescription: false,
@@ -39662,6 +39726,7 @@ var ts;
39662
39726
  name: "noUncheckedIndexedAccess",
39663
39727
  type: "boolean",
39664
39728
  affectsSemanticDiagnostics: true,
39729
+ affectsMultiFileEmitBuildInfo: true,
39665
39730
  category: ts.Diagnostics.Type_Checking,
39666
39731
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39667
39732
  defaultValueDescription: false,
@@ -39670,6 +39735,7 @@ var ts;
39670
39735
  name: "noImplicitOverride",
39671
39736
  type: "boolean",
39672
39737
  affectsSemanticDiagnostics: true,
39738
+ affectsMultiFileEmitBuildInfo: true,
39673
39739
  category: ts.Diagnostics.Type_Checking,
39674
39740
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39675
39741
  defaultValueDescription: false,
@@ -39677,6 +39743,8 @@ var ts;
39677
39743
  {
39678
39744
  name: "noPropertyAccessFromIndexSignature",
39679
39745
  type: "boolean",
39746
+ affectsSemanticDiagnostics: true,
39747
+ affectsMultiFileEmitBuildInfo: true,
39680
39748
  showInSimplifiedHelpView: false,
39681
39749
  category: ts.Diagnostics.Type_Checking,
39682
39750
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39762,6 +39830,7 @@ var ts;
39762
39830
  name: "allowSyntheticDefaultImports",
39763
39831
  type: "boolean",
39764
39832
  affectsSemanticDiagnostics: true,
39833
+ affectsMultiFileEmitBuildInfo: true,
39765
39834
  category: ts.Diagnostics.Interop_Constraints,
39766
39835
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39767
39836
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39771,6 +39840,7 @@ var ts;
39771
39840
  type: "boolean",
39772
39841
  affectsSemanticDiagnostics: true,
39773
39842
  affectsEmit: true,
39843
+ affectsMultiFileEmitBuildInfo: true,
39774
39844
  showInSimplifiedHelpView: true,
39775
39845
  category: ts.Diagnostics.Interop_Constraints,
39776
39846
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39787,6 +39857,7 @@ var ts;
39787
39857
  name: "allowUmdGlobalAccess",
39788
39858
  type: "boolean",
39789
39859
  affectsSemanticDiagnostics: true,
39860
+ affectsMultiFileEmitBuildInfo: true,
39790
39861
  category: ts.Diagnostics.Modules,
39791
39862
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39792
39863
  defaultValueDescription: false,
@@ -39808,6 +39879,7 @@ var ts;
39808
39879
  name: "sourceRoot",
39809
39880
  type: "string",
39810
39881
  affectsEmit: true,
39882
+ affectsMultiFileEmitBuildInfo: true,
39811
39883
  paramType: ts.Diagnostics.LOCATION,
39812
39884
  category: ts.Diagnostics.Emit,
39813
39885
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39816,6 +39888,7 @@ var ts;
39816
39888
  name: "mapRoot",
39817
39889
  type: "string",
39818
39890
  affectsEmit: true,
39891
+ affectsMultiFileEmitBuildInfo: true,
39819
39892
  paramType: ts.Diagnostics.LOCATION,
39820
39893
  category: ts.Diagnostics.Emit,
39821
39894
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39824,6 +39897,7 @@ var ts;
39824
39897
  name: "inlineSourceMap",
39825
39898
  type: "boolean",
39826
39899
  affectsEmit: true,
39900
+ affectsMultiFileEmitBuildInfo: true,
39827
39901
  category: ts.Diagnostics.Emit,
39828
39902
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39829
39903
  defaultValueDescription: false,
@@ -39832,6 +39906,7 @@ var ts;
39832
39906
  name: "inlineSources",
39833
39907
  type: "boolean",
39834
39908
  affectsEmit: true,
39909
+ affectsMultiFileEmitBuildInfo: true,
39835
39910
  category: ts.Diagnostics.Emit,
39836
39911
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39837
39912
  defaultValueDescription: false,
@@ -39841,6 +39916,7 @@ var ts;
39841
39916
  name: "experimentalDecorators",
39842
39917
  type: "boolean",
39843
39918
  affectsSemanticDiagnostics: true,
39919
+ affectsMultiFileEmitBuildInfo: true,
39844
39920
  category: ts.Diagnostics.Language_and_Environment,
39845
39921
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39846
39922
  defaultValueDescription: false,
@@ -39850,6 +39926,7 @@ var ts;
39850
39926
  type: "boolean",
39851
39927
  affectsSemanticDiagnostics: true,
39852
39928
  affectsEmit: true,
39929
+ affectsMultiFileEmitBuildInfo: true,
39853
39930
  category: ts.Diagnostics.Language_and_Environment,
39854
39931
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39855
39932
  defaultValueDescription: false,
@@ -39874,6 +39951,7 @@ var ts;
39874
39951
  type: "string",
39875
39952
  affectsSemanticDiagnostics: true,
39876
39953
  affectsEmit: true,
39954
+ affectsMultiFileEmitBuildInfo: true,
39877
39955
  affectsModuleResolution: true,
39878
39956
  category: ts.Diagnostics.Language_and_Environment,
39879
39957
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39891,6 +39969,9 @@ var ts;
39891
39969
  name: "out",
39892
39970
  type: "string",
39893
39971
  affectsEmit: true,
39972
+ affectsMultiFileEmitBuildInfo: true,
39973
+ affectsDeclarationPath: true,
39974
+ affectsBundleEmitBuildInfo: true,
39894
39975
  isFilePath: false,
39895
39976
  // for correct behaviour, please use outFile
39896
39977
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39902,6 +39983,7 @@ var ts;
39902
39983
  name: "reactNamespace",
39903
39984
  type: "string",
39904
39985
  affectsEmit: true,
39986
+ affectsMultiFileEmitBuildInfo: true,
39905
39987
  category: ts.Diagnostics.Language_and_Environment,
39906
39988
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
39907
39989
  defaultValueDescription: "`React`",
@@ -39909,6 +39991,8 @@ var ts;
39909
39991
  {
39910
39992
  name: "skipDefaultLibCheck",
39911
39993
  type: "boolean",
39994
+ // We need to store these to determine whether `lib` files need to be rechecked
39995
+ affectsMultiFileEmitBuildInfo: true,
39912
39996
  category: ts.Diagnostics.Completeness,
39913
39997
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
39914
39998
  defaultValueDescription: false,
@@ -39924,6 +40008,7 @@ var ts;
39924
40008
  name: "emitBOM",
39925
40009
  type: "boolean",
39926
40010
  affectsEmit: true,
40011
+ affectsMultiFileEmitBuildInfo: true,
39927
40012
  category: ts.Diagnostics.Emit,
39928
40013
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
39929
40014
  defaultValueDescription: false,
@@ -39935,6 +40020,7 @@ var ts;
39935
40020
  lf: 1 /* LineFeed */
39936
40021
  })),
39937
40022
  affectsEmit: true,
40023
+ affectsMultiFileEmitBuildInfo: true,
39938
40024
  paramType: ts.Diagnostics.NEWLINE,
39939
40025
  category: ts.Diagnostics.Emit,
39940
40026
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -39944,6 +40030,7 @@ var ts;
39944
40030
  name: "noErrorTruncation",
39945
40031
  type: "boolean",
39946
40032
  affectsSemanticDiagnostics: true,
40033
+ affectsMultiFileEmitBuildInfo: true,
39947
40034
  category: ts.Diagnostics.Output_Formatting,
39948
40035
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
39949
40036
  defaultValueDescription: false,
@@ -39974,6 +40061,7 @@ var ts;
39974
40061
  name: "stripInternal",
39975
40062
  type: "boolean",
39976
40063
  affectsEmit: true,
40064
+ affectsMultiFileEmitBuildInfo: true,
39977
40065
  category: ts.Diagnostics.Emit,
39978
40066
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
39979
40067
  defaultValueDescription: false,
@@ -40014,6 +40102,7 @@ var ts;
40014
40102
  name: "noImplicitUseStrict",
40015
40103
  type: "boolean",
40016
40104
  affectsSemanticDiagnostics: true,
40105
+ affectsMultiFileEmitBuildInfo: true,
40017
40106
  category: ts.Diagnostics.Backwards_Compatibility,
40018
40107
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40019
40108
  defaultValueDescription: false,
@@ -40022,6 +40111,7 @@ var ts;
40022
40111
  name: "noEmitHelpers",
40023
40112
  type: "boolean",
40024
40113
  affectsEmit: true,
40114
+ affectsMultiFileEmitBuildInfo: true,
40025
40115
  category: ts.Diagnostics.Emit,
40026
40116
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40027
40117
  defaultValueDescription: false,
@@ -40030,6 +40120,7 @@ var ts;
40030
40120
  name: "noEmitOnError",
40031
40121
  type: "boolean",
40032
40122
  affectsEmit: true,
40123
+ affectsMultiFileEmitBuildInfo: true,
40033
40124
  category: ts.Diagnostics.Emit,
40034
40125
  transpileOptionValue: undefined,
40035
40126
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40039,6 +40130,7 @@ var ts;
40039
40130
  name: "preserveConstEnums",
40040
40131
  type: "boolean",
40041
40132
  affectsEmit: true,
40133
+ affectsMultiFileEmitBuildInfo: true,
40042
40134
  category: ts.Diagnostics.Emit,
40043
40135
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40044
40136
  defaultValueDescription: false,
@@ -40047,6 +40139,8 @@ var ts;
40047
40139
  name: "declarationDir",
40048
40140
  type: "string",
40049
40141
  affectsEmit: true,
40142
+ affectsMultiFileEmitBuildInfo: true,
40143
+ affectsDeclarationPath: true,
40050
40144
  isFilePath: true,
40051
40145
  paramType: ts.Diagnostics.DIRECTORY,
40052
40146
  category: ts.Diagnostics.Emit,
@@ -40056,6 +40150,8 @@ var ts;
40056
40150
  {
40057
40151
  name: "skipLibCheck",
40058
40152
  type: "boolean",
40153
+ // We need to store these to determine whether `lib` files need to be rechecked
40154
+ affectsMultiFileEmitBuildInfo: true,
40059
40155
  category: ts.Diagnostics.Completeness,
40060
40156
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40061
40157
  defaultValueDescription: false,
@@ -40065,6 +40161,7 @@ var ts;
40065
40161
  type: "boolean",
40066
40162
  affectsBindDiagnostics: true,
40067
40163
  affectsSemanticDiagnostics: true,
40164
+ affectsMultiFileEmitBuildInfo: true,
40068
40165
  category: ts.Diagnostics.Type_Checking,
40069
40166
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40070
40167
  defaultValueDescription: undefined,
@@ -40074,6 +40171,7 @@ var ts;
40074
40171
  type: "boolean",
40075
40172
  affectsBindDiagnostics: true,
40076
40173
  affectsSemanticDiagnostics: true,
40174
+ affectsMultiFileEmitBuildInfo: true,
40077
40175
  category: ts.Diagnostics.Type_Checking,
40078
40176
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40079
40177
  defaultValueDescription: undefined,
@@ -40082,6 +40180,7 @@ var ts;
40082
40180
  name: "suppressExcessPropertyErrors",
40083
40181
  type: "boolean",
40084
40182
  affectsSemanticDiagnostics: true,
40183
+ affectsMultiFileEmitBuildInfo: true,
40085
40184
  category: ts.Diagnostics.Backwards_Compatibility,
40086
40185
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40087
40186
  defaultValueDescription: false,
@@ -40090,6 +40189,7 @@ var ts;
40090
40189
  name: "suppressImplicitAnyIndexErrors",
40091
40190
  type: "boolean",
40092
40191
  affectsSemanticDiagnostics: true,
40192
+ affectsMultiFileEmitBuildInfo: true,
40093
40193
  category: ts.Diagnostics.Backwards_Compatibility,
40094
40194
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40095
40195
  defaultValueDescription: false,
@@ -40114,6 +40214,7 @@ var ts;
40114
40214
  name: "noStrictGenericChecks",
40115
40215
  type: "boolean",
40116
40216
  affectsSemanticDiagnostics: true,
40217
+ affectsMultiFileEmitBuildInfo: true,
40117
40218
  category: ts.Diagnostics.Backwards_Compatibility,
40118
40219
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40119
40220
  defaultValueDescription: false,
@@ -40123,6 +40224,7 @@ var ts;
40123
40224
  type: "boolean",
40124
40225
  affectsSemanticDiagnostics: true,
40125
40226
  affectsEmit: true,
40227
+ affectsMultiFileEmitBuildInfo: true,
40126
40228
  category: ts.Diagnostics.Language_and_Environment,
40127
40229
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40128
40230
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40131,6 +40233,7 @@ var ts;
40131
40233
  name: "preserveValueImports",
40132
40234
  type: "boolean",
40133
40235
  affectsEmit: true,
40236
+ affectsMultiFileEmitBuildInfo: true,
40134
40237
  category: ts.Diagnostics.Emit,
40135
40238
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40136
40239
  defaultValueDescription: false,
@@ -40174,6 +40277,8 @@ var ts;
40174
40277
  /* @internal */
40175
40278
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40176
40279
  /* @internal */
40280
+ ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40281
+ /* @internal */
40177
40282
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40178
40283
  /* @internal */
40179
40284
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41029,6 +41134,7 @@ var ts;
41029
41134
  return optionDefinition.type;
41030
41135
  }
41031
41136
  }
41137
+ /* @internal */
41032
41138
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41033
41139
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41034
41140
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41037,6 +41143,7 @@ var ts;
41037
41143
  }
41038
41144
  });
41039
41145
  }
41146
+ ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41040
41147
  function serializeCompilerOptions(options, pathOptions) {
41041
41148
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41042
41149
  }
@@ -42032,7 +42139,7 @@ var ts;
42032
42139
  }
42033
42140
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42034
42141
  return {
42035
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42142
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42036
42143
  flags: 1 /* Recursive */
42037
42144
  };
42038
42145
  }
@@ -46935,12 +47042,14 @@ var ts;
46935
47042
  }
46936
47043
  }
46937
47044
  function setCommonJsModuleIndicator(node) {
46938
- if (file.externalModuleIndicator) {
47045
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46939
47046
  return false;
46940
47047
  }
46941
47048
  if (!file.commonJsModuleIndicator) {
46942
47049
  file.commonJsModuleIndicator = node;
46943
- bindSourceFileAsExternalModule();
47050
+ if (!file.externalModuleIndicator) {
47051
+ bindSourceFileAsExternalModule();
47052
+ }
46944
47053
  }
46945
47054
  return true;
46946
47055
  }
@@ -47354,7 +47463,11 @@ var ts;
47354
47463
  checkStrictModeEvalOrArguments(node, node.name);
47355
47464
  }
47356
47465
  if (!ts.isBindingPattern(node.name)) {
47357
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47466
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47467
+ if (ts.isInJSFile(node) &&
47468
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47469
+ !ts.getJSDocTypeTag(node) &&
47470
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47358
47471
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47359
47472
  }
47360
47473
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50181,7 +50294,8 @@ var ts;
50181
50294
  && isAliasableOrJsExpression(node.parent.right)
50182
50295
  || node.kind === 297 /* ShorthandPropertyAssignment */
50183
50296
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50184
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50297
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50298
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50185
50299
  }
50186
50300
  function isAliasableOrJsExpression(e) {
50187
50301
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50274,7 +50388,7 @@ var ts;
50274
50388
  return hasExportAssignmentSymbol(moduleSymbol);
50275
50389
  }
50276
50390
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50277
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50391
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50278
50392
  }
50279
50393
  function getTargetOfImportClause(node, dontResolveAlias) {
50280
50394
  var _a;
@@ -68138,13 +68252,40 @@ var ts;
68138
68252
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68139
68253
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68140
68254
  }
68141
- function isValidBigIntString(s) {
68255
+ /**
68256
+ * Tests whether the provided string can be parsed as a number.
68257
+ * @param s The string to test.
68258
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68259
+ */
68260
+ function isValidNumberString(s, roundTripOnly) {
68261
+ if (s === "")
68262
+ return false;
68263
+ var n = +s;
68264
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68265
+ }
68266
+ /**
68267
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68268
+ */
68269
+ function parseBigIntLiteralType(text) {
68270
+ var negative = text.startsWith("-");
68271
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68272
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68273
+ }
68274
+ /**
68275
+ * Tests whether the provided string can be parsed as a bigint.
68276
+ * @param s The string to test.
68277
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68278
+ */
68279
+ function isValidBigIntString(s, roundTripOnly) {
68280
+ if (s === "")
68281
+ return false;
68142
68282
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68143
68283
  var success = true;
68144
68284
  scanner.setOnError(function () { return success = false; });
68145
68285
  scanner.setText(s + "n");
68146
68286
  var result = scanner.scan();
68147
- if (result === 40 /* MinusToken */) {
68287
+ var negative = result === 40 /* MinusToken */;
68288
+ if (negative) {
68148
68289
  result = scanner.scan();
68149
68290
  }
68150
68291
  var flags = scanner.getTokenFlags();
@@ -68153,7 +68294,8 @@ var ts;
68153
68294
  // * a bigint can be scanned, and that when it is scanned, it is
68154
68295
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68155
68296
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68156
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68297
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68298
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68157
68299
  }
68158
68300
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68159
68301
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68161,8 +68303,8 @@ var ts;
68161
68303
  }
68162
68304
  if (source.flags & 128 /* StringLiteral */) {
68163
68305
  var value = source.value;
68164
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68165
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68306
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68307
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68166
68308
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68167
68309
  }
68168
68310
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68735,8 +68877,57 @@ var ts;
68735
68877
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68736
68878
  // succeed. That would be a pointless and confusing outcome.
68737
68879
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68880
+ var _loop_23 = function (i) {
68881
+ var source_1 = matches ? matches[i] : neverType;
68882
+ var target_3 = types[i];
68883
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68884
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68885
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68886
+ var inferenceContext = getInferenceInfoForType(target_3);
68887
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68888
+ if (constraint && !isTypeAny(constraint)) {
68889
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68890
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68891
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68892
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68893
+ var str_1 = source_1.value;
68894
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68895
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68896
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68897
+ }
68898
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68899
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68900
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68901
+ }
68902
+ // for each type in the constraint, find the highest priority matching type
68903
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68904
+ return !(right.flags & allTypeFlags_1) ? left :
68905
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68906
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68907
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68908
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68909
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68910
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68911
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68912
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68913
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68914
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68915
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68916
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68917
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68918
+ left;
68919
+ }, neverType);
68920
+ if (!(matchingType.flags & 131072 /* Never */)) {
68921
+ inferFromTypes(matchingType, target_3);
68922
+ return "continue";
68923
+ }
68924
+ }
68925
+ }
68926
+ }
68927
+ inferFromTypes(source_1, target_3);
68928
+ };
68738
68929
  for (var i = 0; i < types.length; i++) {
68739
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68930
+ _loop_23(i);
68740
68931
  }
68741
68932
  }
68742
68933
  }
@@ -69254,7 +69445,7 @@ var ts;
69254
69445
  function mapTypesByKeyProperty(types, name) {
69255
69446
  var map = new ts.Map();
69256
69447
  var count = 0;
69257
- var _loop_23 = function (type) {
69448
+ var _loop_24 = function (type) {
69258
69449
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69259
69450
  var discriminant = getTypeOfPropertyOfType(type, name);
69260
69451
  if (discriminant) {
@@ -69280,7 +69471,7 @@ var ts;
69280
69471
  };
69281
69472
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69282
69473
  var type = types_16[_i];
69283
- var state_9 = _loop_23(type);
69474
+ var state_9 = _loop_24(type);
69284
69475
  if (typeof state_9 === "object")
69285
69476
  return state_9.value;
69286
69477
  }
@@ -75668,7 +75859,7 @@ var ts;
75668
75859
  if (spreadIndex >= 0) {
75669
75860
  // Create synthetic arguments from spreads of tuple types.
75670
75861
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75671
- var _loop_24 = function (i) {
75862
+ var _loop_25 = function (i) {
75672
75863
  var arg = args[i];
75673
75864
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75674
75865
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75685,7 +75876,7 @@ var ts;
75685
75876
  }
75686
75877
  };
75687
75878
  for (var i = spreadIndex; i < args.length; i++) {
75688
- _loop_24(i);
75879
+ _loop_25(i);
75689
75880
  }
75690
75881
  return effectiveArgs_1;
75691
75882
  }
@@ -76005,7 +76196,7 @@ var ts;
76005
76196
  var min_3 = Number.MAX_VALUE;
76006
76197
  var minIndex = 0;
76007
76198
  var i_1 = 0;
76008
- var _loop_25 = function (c) {
76199
+ var _loop_26 = function (c) {
76009
76200
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76010
76201
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76011
76202
  if (diags_2) {
@@ -76023,7 +76214,7 @@ var ts;
76023
76214
  };
76024
76215
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76025
76216
  var c = candidatesForArgumentError_1[_a];
76026
- _loop_25(c);
76217
+ _loop_26(c);
76027
76218
  }
76028
76219
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76029
76220
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76181,7 +76372,7 @@ var ts;
76181
76372
  }
76182
76373
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76183
76374
  var parameters = [];
76184
- var _loop_26 = function (i) {
76375
+ var _loop_27 = function (i) {
76185
76376
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76186
76377
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76187
76378
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76189,7 +76380,7 @@ var ts;
76189
76380
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76190
76381
  };
76191
76382
  for (var i = 0; i < maxNonRestParam; i++) {
76192
- _loop_26(i);
76383
+ _loop_27(i);
76193
76384
  }
76194
76385
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76195
76386
  var flags = 0 /* None */;
@@ -80246,7 +80437,7 @@ var ts;
80246
80437
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80247
80438
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80248
80439
  var indexSignatureMap_1 = new ts.Map();
80249
- var _loop_27 = function (declaration) {
80440
+ var _loop_28 = function (declaration) {
80250
80441
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80251
80442
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80252
80443
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80261,7 +80452,7 @@ var ts;
80261
80452
  };
80262
80453
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80263
80454
  var declaration = _a[_i];
80264
- _loop_27(declaration);
80455
+ _loop_28(declaration);
80265
80456
  }
80266
80457
  indexSignatureMap_1.forEach(function (entry) {
80267
80458
  if (entry.declarations.length > 1) {
@@ -82457,7 +82648,7 @@ var ts;
82457
82648
  }
82458
82649
  // For a commonjs `const x = require`, validate the alias and exit
82459
82650
  var symbol = getSymbolOfNode(node);
82460
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82651
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82461
82652
  checkAliasSymbol(node);
82462
82653
  return;
82463
82654
  }
@@ -83722,7 +83913,7 @@ var ts;
83722
83913
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83723
83914
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83724
83915
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83725
- var _loop_28 = function (info) {
83916
+ var _loop_29 = function (info) {
83726
83917
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83727
83918
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83728
83919
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83735,7 +83926,7 @@ var ts;
83735
83926
  };
83736
83927
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83737
83928
  var info = indexInfos_9[_i];
83738
- _loop_28(info);
83929
+ _loop_29(info);
83739
83930
  }
83740
83931
  }
83741
83932
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83743,7 +83934,7 @@ var ts;
83743
83934
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83744
83935
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83745
83936
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83746
- var _loop_29 = function (info) {
83937
+ var _loop_30 = function (info) {
83747
83938
  if (info === checkInfo)
83748
83939
  return "continue";
83749
83940
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83758,7 +83949,7 @@ var ts;
83758
83949
  };
83759
83950
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83760
83951
  var info = indexInfos_10[_i];
83761
- _loop_29(info);
83952
+ _loop_30(info);
83762
83953
  }
83763
83954
  }
83764
83955
  function checkTypeNameIsReserved(name, message) {
@@ -84077,7 +84268,7 @@ var ts;
84077
84268
  var baseTypes = baseTypeNode && getBaseTypes(type);
84078
84269
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84079
84270
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84080
- var _loop_30 = function (member) {
84271
+ var _loop_31 = function (member) {
84081
84272
  if (ts.hasAmbientModifier(member)) {
84082
84273
  return "continue";
84083
84274
  }
@@ -84094,7 +84285,7 @@ var ts;
84094
84285
  };
84095
84286
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84096
84287
  var member = _a[_i];
84097
- _loop_30(member);
84288
+ _loop_31(member);
84098
84289
  }
84099
84290
  }
84100
84291
  /**
@@ -84182,7 +84373,7 @@ var ts;
84182
84373
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84183
84374
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84184
84375
  var issuedMemberError = false;
84185
- var _loop_31 = function (member) {
84376
+ var _loop_32 = function (member) {
84186
84377
  if (ts.isStatic(member)) {
84187
84378
  return "continue";
84188
84379
  }
@@ -84201,7 +84392,7 @@ var ts;
84201
84392
  };
84202
84393
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84203
84394
  var member = _a[_i];
84204
- _loop_31(member);
84395
+ _loop_32(member);
84205
84396
  }
84206
84397
  if (!issuedMemberError) {
84207
84398
  // check again with diagnostics to generate a less-specific error
@@ -89861,9 +90052,7 @@ var ts;
89861
90052
  var ts;
89862
90053
  (function (ts) {
89863
90054
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
89864
- var _a = generatorOptions.extendedDiagnostics
89865
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
89866
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90055
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
89867
90056
  // Current source map file and its index in the sources list
89868
90057
  var rawSources = [];
89869
90058
  var sources = [];
@@ -110180,7 +110369,8 @@ var ts;
110180
110369
  return;
110181
110370
  }
110182
110371
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110183
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110372
+ var buildInfo = { bundle: bundle, program: program, version: version };
110373
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110184
110374
  }
110185
110375
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110186
110376
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110334,13 +110524,18 @@ var ts;
110334
110524
  if (sourceMapFilePath) {
110335
110525
  var sourceMap = sourceMapGenerator.toString();
110336
110526
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
110527
+ if (printer.bundleFileInfo)
110528
+ printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110337
110529
  }
110338
110530
  }
110339
110531
  else {
110340
110532
  writer.writeLine();
110341
110533
  }
110342
110534
  // Write the output file
110343
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110535
+ var text = writer.getText();
110536
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110537
+ if (printer.bundleFileInfo)
110538
+ printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110344
110539
  // Reset state
110345
110540
  writer.clear();
110346
110541
  }
@@ -110483,34 +110678,54 @@ var ts;
110483
110678
  }
110484
110679
  /*@internal*/
110485
110680
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
110681
+ var createHash = ts.maybeBind(host, host.createHash);
110486
110682
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
110487
- var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
110488
- if (!buildInfoText)
110683
+ var buildInfo;
110684
+ if (host.getBuildInfo) {
110685
+ var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
110686
+ if (!hostBuildInfo)
110687
+ return buildInfoPath;
110688
+ buildInfo = hostBuildInfo;
110689
+ }
110690
+ else {
110691
+ var buildInfoText = host.readFile(buildInfoPath);
110692
+ if (!buildInfoText)
110693
+ return buildInfoPath;
110694
+ buildInfo = getBuildInfo(buildInfoText);
110695
+ }
110696
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
110489
110697
  return buildInfoPath;
110490
110698
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
110491
110699
  if (!jsFileText)
110492
110700
  return jsFilePath;
110701
+ if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
110702
+ return jsFilePath;
110493
110703
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
110494
110704
  // error if no source map or for now if inline sourcemap
110495
110705
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
110496
110706
  return sourceMapFilePath || "inline sourcemap decoding";
110707
+ if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
110708
+ return sourceMapFilePath;
110497
110709
  // read declaration text
110498
110710
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
110499
110711
  if (declarationFilePath && !declarationText)
110500
110712
  return declarationFilePath;
110713
+ if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
110714
+ return declarationFilePath;
110501
110715
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
110502
110716
  // error if no source map or for now if inline sourcemap
110503
110717
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
110504
110718
  return declarationMapPath || "inline sourcemap decoding";
110505
- var buildInfo = getBuildInfo(buildInfoText);
110506
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
110507
- return buildInfoPath;
110719
+ if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
110720
+ return declarationMapPath;
110508
110721
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110509
110722
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
110510
110723
  /*onlyOwnText*/ true);
110511
110724
  var outputFiles = [];
110512
110725
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
110513
110726
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
110727
+ var changedDtsText;
110728
+ var changedDtsData;
110514
110729
  var emitHost = {
110515
110730
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
110516
110731
  getCanonicalFileName: host.getCanonicalFileName,
@@ -110526,7 +110741,7 @@ var ts;
110526
110741
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
110527
110742
  getProjectReferenceRedirect: ts.returnUndefined,
110528
110743
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
110529
- writeFile: function (name, text, writeByteOrderMark) {
110744
+ writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
110530
110745
  switch (name) {
110531
110746
  case jsFilePath:
110532
110747
  if (jsFileText === text)
@@ -110537,8 +110752,13 @@ var ts;
110537
110752
  return;
110538
110753
  break;
110539
110754
  case buildInfoPath:
110540
- var newBuildInfo = getBuildInfo(text);
110755
+ var newBuildInfo = data.buildInfo;
110541
110756
  newBuildInfo.program = buildInfo.program;
110757
+ if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
110758
+ // Update the output signature
110759
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
110760
+ newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
110761
+ }
110542
110762
  // Update sourceFileInfo
110543
110763
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
110544
110764
  newBuildInfo.bundle.js.sources = js.sources;
@@ -110546,11 +110766,13 @@ var ts;
110546
110766
  newBuildInfo.bundle.dts.sources = dts.sources;
110547
110767
  }
110548
110768
  newBuildInfo.bundle.sourceFiles = sourceFiles;
110549
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
110769
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
110550
110770
  return;
110551
110771
  case declarationFilePath:
110552
110772
  if (declarationText === text)
110553
110773
  return;
110774
+ changedDtsText = text;
110775
+ changedDtsData = data;
110554
110776
  break;
110555
110777
  case declarationMapPath:
110556
110778
  if (declarationMapText === text)
@@ -110569,6 +110791,7 @@ var ts;
110569
110791
  getSourceFileFromReference: ts.returnUndefined,
110570
110792
  redirectTargetsMap: ts.createMultiMap(),
110571
110793
  getFileIncludeReasons: ts.notImplemented,
110794
+ createHash: createHash,
110572
110795
  };
110573
110796
  emitFiles(ts.notImplementedResolver, emitHost,
110574
110797
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -115653,12 +115876,10 @@ var ts;
115653
115876
  }
115654
115877
  ts.createCompilerHost = createCompilerHost;
115655
115878
  /*@internal*/
115656
- // TODO(shkamat): update this after reworking ts build API
115657
115879
  function createCompilerHostWorker(options, setParentNodes, system) {
115658
115880
  if (system === void 0) { system = ts.sys; }
115659
115881
  var existingDirectories = new ts.Map();
115660
115882
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
115661
- var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
115662
115883
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
115663
115884
  var text;
115664
115885
  try {
@@ -115691,7 +115912,7 @@ var ts;
115691
115912
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
115692
115913
  // the system.writeFile will do its own directory creation and
115693
115914
  // the ensureDirectoriesExist call will always be redundant.
115694
- 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); });
115915
+ 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); });
115695
115916
  ts.performance.mark("afterIOWrite");
115696
115917
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
115697
115918
  }
@@ -115701,35 +115922,6 @@ var ts;
115701
115922
  }
115702
115923
  }
115703
115924
  }
115704
- var outputFingerprints;
115705
- function writeFileWorker(fileName, data, writeByteOrderMark) {
115706
- if (!ts.isWatchSet(options) || !system.getModifiedTime) {
115707
- system.writeFile(fileName, data, writeByteOrderMark);
115708
- return;
115709
- }
115710
- if (!outputFingerprints) {
115711
- outputFingerprints = new ts.Map();
115712
- }
115713
- var hash = computeHash(data);
115714
- var mtimeBefore = system.getModifiedTime(fileName);
115715
- if (mtimeBefore) {
115716
- var fingerprint = outputFingerprints.get(fileName);
115717
- // If output has not been changed, and the file has no external modification
115718
- if (fingerprint &&
115719
- fingerprint.byteOrderMark === writeByteOrderMark &&
115720
- fingerprint.hash === hash &&
115721
- fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
115722
- return;
115723
- }
115724
- }
115725
- system.writeFile(fileName, data, writeByteOrderMark);
115726
- var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
115727
- outputFingerprints.set(fileName, {
115728
- hash: hash,
115729
- byteOrderMark: writeByteOrderMark,
115730
- mtime: mtimeAfter
115731
- });
115732
- }
115733
115925
  function getDefaultLibLocation() {
115734
115926
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
115735
115927
  }
@@ -117319,6 +117511,7 @@ var ts;
117319
117511
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117320
117512
  redirectTargetsMap: redirectTargetsMap,
117321
117513
  getFileIncludeReasons: program.getFileIncludeReasons,
117514
+ createHash: ts.maybeBind(host, host.createHash),
117322
117515
  };
117323
117516
  }
117324
117517
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -119432,13 +119625,9 @@ var ts;
119432
119625
  function createManyToManyPathMap() {
119433
119626
  function create(forward, reverse, deleted) {
119434
119627
  var map = {
119435
- clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
119436
- forEach: function (fn) { return forward.forEach(fn); },
119437
119628
  getKeys: function (v) { return reverse.get(v); },
119438
119629
  getValues: function (k) { return forward.get(k); },
119439
- hasKey: function (k) { return forward.has(k); },
119440
119630
  keys: function () { return forward.keys(); },
119441
- deletedKeys: function () { return deleted; },
119442
119631
  deleteKey: function (k) {
119443
119632
  (deleted || (deleted = new ts.Set())).add(k);
119444
119633
  var set = forward.get(k);
@@ -119465,11 +119654,6 @@ var ts;
119465
119654
  });
119466
119655
  return map;
119467
119656
  },
119468
- clear: function () {
119469
- forward.clear();
119470
- reverse.clear();
119471
- deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119472
- }
119473
119657
  };
119474
119658
  return map;
119475
119659
  }
@@ -119597,18 +119781,21 @@ var ts;
119597
119781
  * Creates the state of file references and signature for the new program from oldState if it is safe
119598
119782
  */
119599
119783
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
119784
+ var _a, _b, _c;
119600
119785
  var fileInfos = new ts.Map();
119601
119786
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
119602
119787
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
119603
- var hasCalledUpdateShapeSignature = new ts.Set();
119604
119788
  var useOldState = canReuseOldState(referencedMap, oldState);
119605
119789
  // Ensure source files have parent pointers set
119606
119790
  newProgram.getTypeChecker();
119607
119791
  // Create the reference map, and set the file infos
119608
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
119609
- var sourceFile = _a[_i];
119792
+ for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
119793
+ var sourceFile = _d[_i];
119610
119794
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
119611
- var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
119795
+ var oldUncommitedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
119796
+ var signature = oldUncommitedSignature === undefined ?
119797
+ useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
119798
+ oldUncommitedSignature || undefined;
119612
119799
  if (referencedMap) {
119613
119800
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
119614
119801
  if (newReferences) {
@@ -119616,19 +119803,26 @@ var ts;
119616
119803
  }
119617
119804
  // Copy old visible to outside files map
119618
119805
  if (useOldState) {
119619
- var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
119806
+ var oldUncommitedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
119807
+ var exportedModules = oldUncommitedExportedModules === undefined ?
119808
+ oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
119809
+ oldUncommitedExportedModules || undefined;
119620
119810
  if (exportedModules) {
119621
119811
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119622
119812
  }
119623
119813
  }
119624
119814
  }
119625
- fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
119815
+ fileInfos.set(sourceFile.resolvedPath, {
119816
+ version: version_2,
119817
+ signature: signature,
119818
+ affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
119819
+ impliedFormat: sourceFile.impliedNodeFormat
119820
+ });
119626
119821
  }
119627
119822
  return {
119628
119823
  fileInfos: fileInfos,
119629
119824
  referencedMap: referencedMap,
119630
119825
  exportedModulesMap: exportedModulesMap,
119631
- hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
119632
119826
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
119633
119827
  };
119634
119828
  }
@@ -119642,71 +119836,42 @@ var ts;
119642
119836
  }
119643
119837
  BuilderState.releaseCache = releaseCache;
119644
119838
  /**
119645
- * Creates a clone of the state
119839
+ * Gets the files affected by the path from the program
119646
119840
  */
119647
- function clone(state) {
119841
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
119648
119842
  var _a, _b;
119649
- // Dont need to backup allFiles info since its cache anyway
119650
- return {
119651
- fileInfos: new ts.Map(state.fileInfos),
119652
- referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
119653
- exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
119654
- hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
119655
- useFileVersionAsSignature: state.useFileVersionAsSignature,
119656
- };
119843
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
119844
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
119845
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
119846
+ return result;
119657
119847
  }
119658
- BuilderState.clone = clone;
119659
- /**
119660
- * Gets the files affected by the path from the program
119661
- */
119662
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
119663
- // Since the operation could be cancelled, the signatures are always stored in the cache
119664
- // They will be committed once it is safe to use them
119665
- // eg when calling this api from tsserver, if there is no cancellation of the operation
119666
- // In the other cases the affected files signatures are committed only after the iteration through the result is complete
119667
- var signatureCache = cacheToUpdateSignature || new ts.Map();
119848
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119849
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
119668
119850
  var sourceFile = programOfThisState.getSourceFileByPath(path);
119669
119851
  if (!sourceFile) {
119670
119852
  return ts.emptyArray;
119671
119853
  }
119672
- if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
119854
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
119673
119855
  return [sourceFile];
119674
119856
  }
119675
- var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
119676
- if (!cacheToUpdateSignature) {
119677
- // Commit all the signatures in the signature cache
119678
- updateSignaturesFromCache(state, signatureCache);
119679
- }
119680
- return result;
119681
- }
119682
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119683
- /**
119684
- * Updates the signatures from the cache into state's fileinfo signatures
119685
- * This should be called whenever it is safe to commit the state of the builder
119686
- */
119687
- function updateSignaturesFromCache(state, signatureCache) {
119688
- signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
119857
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
119689
119858
  }
119690
- BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
119859
+ BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
119691
119860
  function updateSignatureOfFile(state, signature, path) {
119692
119861
  state.fileInfos.get(path).signature = signature;
119693
- state.hasCalledUpdateShapeSignature.add(path);
119862
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
119694
119863
  }
119695
119864
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
119696
119865
  /**
119697
119866
  * Returns if the shape of the signature has changed since last emit
119698
119867
  */
119699
- function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
119868
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
119869
+ var _a;
119700
119870
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
119701
- ts.Debug.assert(!!sourceFile);
119702
- ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
119703
119871
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
119704
- if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
119872
+ if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
119705
119873
  return false;
119706
- }
119707
119874
  var info = state.fileInfos.get(sourceFile.resolvedPath);
119708
- if (!info)
119709
- return ts.Debug.fail();
119710
119875
  var prevSignature = info.signature;
119711
119876
  var latestSignature;
119712
119877
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -119717,45 +119882,55 @@ var ts;
119717
119882
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119718
119883
  if (firstDts_1) {
119719
119884
  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; })); });
119720
- latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119721
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
119722
- updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
119885
+ latestSignature = computeSignature(firstDts_1.text, computeHash);
119886
+ if (latestSignature !== prevSignature) {
119887
+ updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
119723
119888
  }
119724
119889
  }
119725
119890
  }
119726
119891
  // Default is to use file version as signature
119727
119892
  if (latestSignature === undefined) {
119728
119893
  latestSignature = sourceFile.version;
119729
- if (exportedModulesMapCache && latestSignature !== prevSignature) {
119894
+ if (state.exportedModulesMap && latestSignature !== prevSignature) {
119895
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119730
119896
  // All the references in this file are exported
119731
119897
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
119732
119898
  if (references) {
119733
- exportedModulesMapCache.set(sourceFile.resolvedPath, references);
119899
+ state.exportedModulesMap.set(sourceFile.resolvedPath, references);
119734
119900
  }
119735
119901
  else {
119736
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119902
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119737
119903
  }
119738
119904
  }
119739
119905
  }
119740
- cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
119906
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
119907
+ (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
119908
+ info.signature = latestSignature;
119741
119909
  return latestSignature !== prevSignature;
119742
119910
  }
119743
119911
  BuilderState.updateShapeSignature = updateShapeSignature;
119912
+ function computeSignature(text, computeHash) {
119913
+ return (computeHash || ts.generateDjb2Hash)(text);
119914
+ }
119915
+ BuilderState.computeSignature = computeSignature;
119744
119916
  /**
119745
119917
  * Coverts the declaration emit result into exported modules map
119746
119918
  */
119747
- function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
119919
+ function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
119920
+ if (!state.exportedModulesMap)
119921
+ return;
119922
+ (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119748
119923
  if (!exportedModulesFromDeclarationEmit) {
119749
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119924
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119750
119925
  return;
119751
119926
  }
119752
119927
  var exportedModules;
119753
119928
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
119754
119929
  if (exportedModules) {
119755
- exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
119930
+ state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119756
119931
  }
119757
119932
  else {
119758
- exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119933
+ state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119759
119934
  }
119760
119935
  function addExportedModule(exportedModulePaths) {
119761
119936
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -119767,19 +119942,6 @@ var ts;
119767
119942
  }
119768
119943
  }
119769
119944
  BuilderState.updateExportedModules = updateExportedModules;
119770
- /**
119771
- * Updates the exported modules from cache into state's exported modules map
119772
- * This should be called whenever it is safe to commit the state of the builder
119773
- */
119774
- function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
119775
- var _a;
119776
- if (exportedModulesMapCache) {
119777
- ts.Debug.assert(!!state.exportedModulesMap);
119778
- (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119779
- exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119780
- }
119781
- }
119782
- BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
119783
119945
  /**
119784
119946
  * Get all the dependencies of the sourceFile
119785
119947
  */
@@ -119900,7 +120062,7 @@ var ts;
119900
120062
  /**
119901
120063
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
119902
120064
  */
119903
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120065
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
119904
120066
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
119905
120067
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
119906
120068
  }
@@ -119920,7 +120082,7 @@ var ts;
119920
120082
  if (!seenFileNamesMap.has(currentPath)) {
119921
120083
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
119922
120084
  seenFileNamesMap.set(currentPath, currentSourceFile);
119923
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120085
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
119924
120086
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
119925
120087
  }
119926
120088
  }
@@ -119946,32 +120108,33 @@ var ts;
119946
120108
  * Create the state so that we can iterate on changedFiles/affected files
119947
120109
  */
119948
120110
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120111
+ var _a, _b;
119949
120112
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
119950
120113
  state.program = newProgram;
119951
120114
  var compilerOptions = newProgram.getCompilerOptions();
119952
120115
  state.compilerOptions = compilerOptions;
120116
+ var outFilePath = ts.outFile(compilerOptions);
119953
120117
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
119954
- if (!ts.outFile(compilerOptions)) {
120118
+ if (!outFilePath) {
119955
120119
  state.semanticDiagnosticsPerFile = new ts.Map();
119956
120120
  }
120121
+ 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)) {
120122
+ state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120123
+ }
119957
120124
  state.changedFilesSet = new ts.Set();
120125
+ state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
119958
120126
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
119959
120127
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
119960
120128
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
119961
120129
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120130
+ var canCopyEmitSignatures = compilerOptions.composite &&
120131
+ (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120132
+ !outFilePath &&
120133
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
119962
120134
  if (useOldState) {
119963
- // Verify the sanity of old state
119964
- if (!oldState.currentChangedFilePath) {
119965
- var affectedSignatures = oldState.currentAffectedFilesSignatures;
119966
- ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
119967
- }
119968
- var changedFilesSet = oldState.changedFilesSet;
119969
- if (canCopySemanticDiagnostics) {
119970
- ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
119971
- }
119972
120135
  // Copy old state's changed files set
119973
- changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
119974
- if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120136
+ (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120137
+ if (!outFilePath && oldState.affectedFilesPendingEmit) {
119975
120138
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
119976
120139
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
119977
120140
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -119992,6 +120155,8 @@ var ts;
119992
120155
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
119993
120156
  // versions dont match
119994
120157
  oldInfo.version !== info.version ||
120158
+ // Implied formats dont match
120159
+ oldInfo.impliedFormat !== info.impliedFormat ||
119995
120160
  // Referenced files changed
119996
120161
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
119997
120162
  // Referenced file was deleted in the new program
@@ -120015,27 +120180,25 @@ var ts;
120015
120180
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120016
120181
  }
120017
120182
  }
120183
+ if (canCopyEmitSignatures) {
120184
+ var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120185
+ if (oldEmitSignature)
120186
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120187
+ }
120018
120188
  });
120019
120189
  // If the global file is removed, add all files as changed
120020
120190
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120021
120191
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120022
120192
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120023
120193
  }
120024
- else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120194
+ else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120025
120195
  // Add all files to affectedFilesPendingEmit since emit changed
120026
120196
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120027
120197
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120028
120198
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120029
120199
  }
120030
- if (useOldState) {
120031
- // Any time the interpretation of a source file changes, mark it as changed
120032
- ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120033
- if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120034
- state.changedFilesSet.add(sourceFilePath);
120035
- }
120036
- });
120037
- }
120038
- state.buildInfoEmitPending = !!state.changedFilesSet.size;
120200
+ // Since old states change files set is copied, any additional change means we would need to emit build info
120201
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120039
120202
  return state;
120040
120203
  }
120041
120204
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120071,30 +120234,35 @@ var ts;
120071
120234
  ts.BuilderState.releaseCache(state);
120072
120235
  state.program = undefined;
120073
120236
  }
120074
- /**
120075
- * Creates a clone of the state
120076
- */
120077
- function cloneBuilderProgramState(state) {
120078
- var _a;
120079
- var newState = ts.BuilderState.clone(state);
120080
- newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120081
- newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120082
- newState.affectedFiles = state.affectedFiles;
120083
- newState.affectedFilesIndex = state.affectedFilesIndex;
120084
- newState.currentChangedFilePath = state.currentChangedFilePath;
120085
- newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120086
- newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120087
- newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120088
- newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120089
- newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120090
- newState.program = state.program;
120091
- newState.compilerOptions = state.compilerOptions;
120092
- newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120093
- newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120094
- newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120095
- newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120096
- newState.programEmitComplete = state.programEmitComplete;
120097
- return newState;
120237
+ function backupEmitBuilderProgramState(state) {
120238
+ var outFilePath = ts.outFile(state.compilerOptions);
120239
+ // Only in --out changeFileSet is kept around till emit
120240
+ ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120241
+ return {
120242
+ affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120243
+ affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120244
+ affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120245
+ seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120246
+ programEmitComplete: state.programEmitComplete,
120247
+ emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120248
+ outSignature: state.outSignature,
120249
+ dtsChangeTime: state.dtsChangeTime,
120250
+ hasChangedEmitSignature: state.hasChangedEmitSignature,
120251
+ changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120252
+ };
120253
+ }
120254
+ function restoreEmitBuilderProgramState(state, backupEmitState) {
120255
+ state.affectedFilesPendingEmit = backupEmitState.affectedFilesPendingEmit;
120256
+ state.affectedFilesPendingEmitKind = backupEmitState.affectedFilesPendingEmitKind;
120257
+ state.affectedFilesPendingEmitIndex = backupEmitState.affectedFilesPendingEmitIndex;
120258
+ state.seenEmittedFiles = backupEmitState.seenEmittedFiles;
120259
+ state.programEmitComplete = backupEmitState.programEmitComplete;
120260
+ state.emitSignatures = backupEmitState.emitSignatures;
120261
+ state.outSignature = backupEmitState.outSignature;
120262
+ state.dtsChangeTime = backupEmitState.dtsChangeTime;
120263
+ state.hasChangedEmitSignature = backupEmitState.hasChangedEmitSignature;
120264
+ if (backupEmitState.changedFilesSet)
120265
+ state.changedFilesSet = backupEmitState.changedFilesSet;
120098
120266
  }
120099
120267
  /**
120100
120268
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120109,7 +120277,7 @@ var ts;
120109
120277
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120110
120278
  */
120111
120279
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120112
- var _a;
120280
+ var _a, _b;
120113
120281
  while (true) {
120114
120282
  var affectedFiles = state.affectedFiles;
120115
120283
  if (affectedFiles) {
@@ -120129,10 +120297,8 @@ var ts;
120129
120297
  state.changedFilesSet.delete(state.currentChangedFilePath);
120130
120298
  state.currentChangedFilePath = undefined;
120131
120299
  // Commit the changes in file signature
120132
- ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120133
- state.currentAffectedFilesSignatures.clear();
120134
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120135
- (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120300
+ (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120301
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120136
120302
  state.affectedFiles = undefined;
120137
120303
  }
120138
120304
  // Get next changed file
@@ -120150,12 +120316,7 @@ var ts;
120150
120316
  return program;
120151
120317
  }
120152
120318
  // Get next batch of affected files
120153
- if (!state.currentAffectedFilesSignatures)
120154
- state.currentAffectedFilesSignatures = new ts.Map();
120155
- if (state.exportedModulesMap) {
120156
- state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120157
- }
120158
- state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120319
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120159
120320
  state.currentChangedFilePath = nextKey.value;
120160
120321
  state.affectedFilesIndex = 0;
120161
120322
  if (!state.seenAffectedFiles)
@@ -120207,7 +120368,6 @@ var ts;
120207
120368
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120208
120369
  */
120209
120370
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120210
- var _a;
120211
120371
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120212
120372
  // If affected files is everything except default library, then nothing more to do
120213
120373
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120215,10 +120375,9 @@ var ts;
120215
120375
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120216
120376
  // That means when affected file is handled, its signature can be out of date
120217
120377
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120218
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120378
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120219
120379
  return;
120220
120380
  }
120221
- 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);
120222
120381
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120223
120382
  return;
120224
120383
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120238,7 +120397,7 @@ var ts;
120238
120397
  // This ensures that we dont later during incremental builds considering wrong signature.
120239
120398
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120240
120399
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120241
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120400
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120242
120401
  // If not dts emit, nothing more to do
120243
120402
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120244
120403
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120259,27 +120418,10 @@ var ts;
120259
120418
  return !state.semanticDiagnosticsFromOldState.size;
120260
120419
  }
120261
120420
  function isChangedSignature(state, path) {
120262
- var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120263
- var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120421
+ var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120422
+ var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120264
120423
  return newSignature !== oldSignature;
120265
120424
  }
120266
- function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120267
- // Go through exported modules from cache first
120268
- var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120269
- var result = keys && ts.forEachKey(keys, fn);
120270
- if (result)
120271
- return result;
120272
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120273
- keys = state.exportedModulesMap.getKeys(filePath);
120274
- return keys && ts.forEachKey(keys, function (exportedFromPath) {
120275
- var _a;
120276
- // If the cache had an updated value, skip
120277
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120278
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120279
- fn(exportedFromPath) :
120280
- undefined;
120281
- });
120282
- }
120283
120425
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120284
120426
  var _a;
120285
120427
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120294,6 +120436,7 @@ var ts;
120294
120436
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120295
120437
  */
120296
120438
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120439
+ var _a;
120297
120440
  // If there was change in signature (dts output) for the changed file,
120298
120441
  // then only we need to handle pending file emit
120299
120442
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120320,11 +120463,10 @@ var ts;
120320
120463
  }
120321
120464
  }
120322
120465
  }
120323
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120324
120466
  var seenFileAndExportsOfFile = new ts.Set();
120325
120467
  // Go through exported modules from cache first
120326
120468
  // If exported modules has path, all files referencing file exported from are affected
120327
- forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120469
+ (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120328
120470
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120329
120471
  return true;
120330
120472
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120338,19 +120480,18 @@ var ts;
120338
120480
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120339
120481
  */
120340
120482
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120341
- var _a;
120483
+ var _a, _b;
120342
120484
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120343
120485
  return undefined;
120344
120486
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120345
120487
  return true;
120346
120488
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120347
- ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120348
120489
  // If exported modules has path, all files referencing file exported from are affected
120349
- forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120490
+ (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120350
120491
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120351
120492
  });
120352
120493
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120353
- (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120494
+ (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120354
120495
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120355
120496
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120356
120497
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120371,12 +120512,13 @@ var ts;
120371
120512
  }
120372
120513
  else {
120373
120514
  state.seenAffectedFiles.add(affected.resolvedPath);
120515
+ // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
120516
+ state.buildInfoEmitPending = true;
120374
120517
  if (emitKind !== undefined) {
120375
120518
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120376
120519
  }
120377
120520
  if (isPendingEmit) {
120378
120521
  state.affectedFilesPendingEmitIndex++;
120379
- state.buildInfoEmitPending = true;
120380
120522
  }
120381
120523
  else {
120382
120524
  state.affectedFilesIndex++;
@@ -120424,25 +120566,61 @@ var ts;
120424
120566
  }
120425
120567
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
120426
120568
  }
120569
+ function isProgramBundleEmitBuildInfo(info) {
120570
+ return !!ts.outFile(info.options || {});
120571
+ }
120572
+ ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
120427
120573
  /**
120428
120574
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
120429
120575
  */
120430
- function getProgramBuildInfo(state, getCanonicalFileName) {
120431
- if (ts.outFile(state.compilerOptions))
120432
- return undefined;
120576
+ function getProgramBuildInfo(state, getCanonicalFileName, host) {
120577
+ var outFilePath = ts.outFile(state.compilerOptions);
120578
+ if (outFilePath && !state.compilerOptions.composite)
120579
+ return;
120433
120580
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
120434
120581
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
120582
+ state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
120583
+ if (outFilePath) {
120584
+ var fileNames_1 = [];
120585
+ var fileInfos_1 = [];
120586
+ state.program.getRootFileNames().forEach(function (f) {
120587
+ var sourceFile = state.program.getSourceFile(f);
120588
+ if (!sourceFile)
120589
+ return;
120590
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
120591
+ fileInfos_1.push(sourceFile.version);
120592
+ });
120593
+ var result_15 = {
120594
+ fileNames: fileNames_1,
120595
+ fileInfos: fileInfos_1,
120596
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
120597
+ outSignature: state.outSignature,
120598
+ dtsChangeTime: state.dtsChangeTime,
120599
+ };
120600
+ return result_15;
120601
+ }
120435
120602
  var fileNames = [];
120436
120603
  var fileNameToFileId = new ts.Map();
120437
120604
  var fileIdsList;
120438
120605
  var fileNamesToFileIdListId;
120606
+ var emitSignatures;
120439
120607
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
120608
+ var _b, _c;
120440
120609
  var key = _a[0], value = _a[1];
120441
120610
  // Ensure fileId
120442
120611
  var fileId = toFileId(key);
120443
120612
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
120444
- var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120445
- var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120613
+ var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
120614
+ var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
120615
+ if (state.compilerOptions.composite) {
120616
+ var file = state.program.getSourceFileByPath(key);
120617
+ if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
120618
+ var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
120619
+ if (emitSignature !== actualSignature) {
120620
+ (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
120621
+ }
120622
+ }
120623
+ }
120446
120624
  return value.version === actualSignature ?
120447
120625
  value.affectsGlobalScope || value.impliedFormat ?
120448
120626
  // If file version is same as signature, dont serialize signature
@@ -120450,11 +120628,11 @@ var ts;
120450
120628
  // If file info only contains version and signature and both are same we can just write string
120451
120629
  value.version :
120452
120630
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120453
- signature === undefined ?
120631
+ oldSignature === undefined ?
120454
120632
  // If we havent computed signature, use fileInfo as is
120455
120633
  value :
120456
120634
  // Serialize fileInfo with new updated signature
120457
- { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120635
+ { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120458
120636
  // Signature of the FileInfo is undefined, serialize it as false
120459
120637
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120460
120638
  });
@@ -120469,17 +120647,13 @@ var ts;
120469
120647
  if (state.exportedModulesMap) {
120470
120648
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
120471
120649
  var _a;
120472
- if (state.currentAffectedFilesExportedModulesMap) {
120473
- if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
120474
- return undefined;
120475
- }
120476
- var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
120477
- if (newValue) {
120478
- return [toFileId(key), toFileIdListId(newValue)];
120479
- }
120480
- }
120650
+ var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
120481
120651
  // Not in temporary cache, use existing value
120482
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120652
+ if (oldValue === undefined)
120653
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120654
+ if (oldValue)
120655
+ return [toFileId(key), toFileIdListId(oldValue)];
120656
+ return undefined;
120483
120657
  });
120484
120658
  }
120485
120659
  var semanticDiagnosticsPerFile;
@@ -120490,9 +120664,7 @@ var ts;
120490
120664
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
120491
120665
  [
120492
120666
  toFileId(key),
120493
- state.hasReusableDiagnostic ?
120494
- value :
120495
- convertToReusableDiagnostics(value, relativeToBuildInfo)
120667
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
120496
120668
  ] :
120497
120669
  toFileId(key));
120498
120670
  }
@@ -120507,16 +120679,27 @@ var ts;
120507
120679
  }
120508
120680
  }
120509
120681
  }
120510
- return {
120682
+ var changeFileSet;
120683
+ if (state.changedFilesSet.size) {
120684
+ for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
120685
+ var path = _e[_d];
120686
+ (changeFileSet || (changeFileSet = [])).push(toFileId(path));
120687
+ }
120688
+ }
120689
+ var result = {
120511
120690
  fileNames: fileNames,
120512
120691
  fileInfos: fileInfos,
120513
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
120692
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
120514
120693
  fileIdsList: fileIdsList,
120515
120694
  referencedMap: referencedMap,
120516
120695
  exportedModulesMap: exportedModulesMap,
120517
120696
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
120518
120697
  affectedFilesPendingEmit: affectedFilesPendingEmit,
120698
+ changeFileSet: changeFileSet,
120699
+ emitSignatures: emitSignatures,
120700
+ dtsChangeTime: state.dtsChangeTime,
120519
120701
  };
120702
+ return result;
120520
120703
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
120521
120704
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
120522
120705
  }
@@ -120541,24 +120724,18 @@ var ts;
120541
120724
  }
120542
120725
  return fileIdListId;
120543
120726
  }
120544
- }
120545
- function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
120546
- var result;
120547
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120548
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120549
- var name = _a[_i];
120550
- var optionKey = name.toLowerCase();
120551
- var optionInfo = optionsNameMap.get(optionKey);
120552
- if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
120553
- // We need to store `strict`, even though it won't be examined directly, so that the
120554
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
120555
- optionKey === "strict" ||
120556
- // We need to store these to determine whether `lib` files need to be rechecked.
120557
- optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
120558
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
120727
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
120728
+ var result;
120729
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120730
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120731
+ var name = _a[_i];
120732
+ var optionInfo = optionsNameMap.get(name.toLowerCase());
120733
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
120734
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
120735
+ }
120559
120736
  }
120737
+ return result;
120560
120738
  }
120561
- return result;
120562
120739
  }
120563
120740
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
120564
120741
  if (option) {
@@ -120632,6 +120809,10 @@ var ts;
120632
120809
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
120633
120810
  }
120634
120811
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
120812
+ function computeSignature(text, data, computeHash) {
120813
+ return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
120814
+ }
120815
+ ts.computeSignature = computeSignature;
120635
120816
  function createBuilderProgram(kind, _a) {
120636
120817
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
120637
120818
  // Return same program if underlying program doesnt change
@@ -120650,8 +120831,8 @@ var ts;
120650
120831
  */
120651
120832
  var computeHash = ts.maybeBind(host, host.createHash);
120652
120833
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
120653
- var backupState;
120654
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
120834
+ var backupEmitState;
120835
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
120655
120836
  // To ensure that we arent storing any references to old program or new program without state
120656
120837
  newProgram = undefined; // TODO: GH#18217
120657
120838
  oldProgram = undefined;
@@ -120659,20 +120840,20 @@ var ts;
120659
120840
  var getState = function () { return state; };
120660
120841
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
120661
120842
  builderProgram.getState = getState;
120662
- builderProgram.backupState = function () {
120663
- ts.Debug.assert(backupState === undefined);
120664
- backupState = cloneBuilderProgramState(state);
120843
+ builderProgram.backupEmitState = function () {
120844
+ ts.Debug.assert(backupEmitState === undefined);
120845
+ backupEmitState = backupEmitBuilderProgramState(state);
120665
120846
  };
120666
- builderProgram.restoreState = function () {
120667
- state = ts.Debug.checkDefined(backupState);
120668
- backupState = undefined;
120847
+ builderProgram.restoreEmitState = function () {
120848
+ restoreEmitBuilderProgramState(state, ts.Debug.checkDefined(backupEmitState));
120849
+ backupEmitState = undefined;
120669
120850
  };
120670
120851
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
120671
120852
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
120672
120853
  builderProgram.emit = emit;
120673
120854
  builderProgram.releaseProgram = function () {
120674
120855
  releaseCache(state);
120675
- backupState = undefined;
120856
+ backupEmitState = undefined;
120676
120857
  };
120677
120858
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
120678
120859
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
@@ -120731,35 +120912,59 @@ var ts;
120731
120912
  return toAffectedFileEmitResult(state,
120732
120913
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120733
120914
  // Otherwise just affected file
120734
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120735
- getWriteFileUpdatingSignatureCallback(writeFile) :
120915
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
120916
+ getWriteFileCallback(writeFile, customTransformers) :
120736
120917
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120737
120918
  }
120738
- function getWriteFileUpdatingSignatureCallback(writeFile) {
120919
+ function getWriteFileCallback(writeFile, customTransformers) {
120739
120920
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120740
- var _a;
120921
+ var _a, _b, _c;
120741
120922
  if (ts.isDeclarationFileName(fileName)) {
120742
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120743
- var file = sourceFiles[0];
120744
- var info = state.fileInfos.get(file.resolvedPath);
120745
- var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120746
- if (signature === file.version) {
120747
- var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120748
- if (newSignature !== file.version) { // Update it
120749
- if (host.storeFilesChangingSignatureDuringEmit)
120750
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120751
- if (state.exportedModulesMap)
120752
- ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120753
- if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120754
- state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120923
+ if (!ts.outFile(state.compilerOptions)) {
120924
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120925
+ var newSignature = void 0;
120926
+ if (!customTransformers) {
120927
+ var file = sourceFiles[0];
120928
+ var info = state.fileInfos.get(file.resolvedPath);
120929
+ if (info.signature === file.version) {
120930
+ newSignature = computeSignature(text, data, computeHash);
120931
+ if (newSignature !== file.version) { // Update it
120932
+ if (host.storeFilesChangingSignatureDuringEmit)
120933
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120934
+ if (state.exportedModulesMap)
120935
+ ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
120936
+ if (state.affectedFiles) {
120937
+ // Keep old signature so we know what to undo if cancellation happens
120938
+ var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
120939
+ if (existing === undefined)
120940
+ (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
120941
+ info.signature = newSignature;
120942
+ }
120943
+ else {
120944
+ // These are directly commited
120945
+ info.signature = newSignature;
120946
+ (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120947
+ }
120948
+ }
120755
120949
  }
120756
- else {
120757
- info.signature = newSignature;
120758
- if (state.exportedModulesMap)
120759
- ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120950
+ }
120951
+ if (state.compilerOptions.composite) {
120952
+ var filePath = sourceFiles[0].resolvedPath;
120953
+ var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
120954
+ newSignature || (newSignature = computeSignature(text, data, computeHash));
120955
+ if (newSignature !== oldSignature) {
120956
+ (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
120957
+ state.hasChangedEmitSignature = true;
120760
120958
  }
120761
120959
  }
120762
120960
  }
120961
+ else if (state.compilerOptions.composite) {
120962
+ var newSignature = computeSignature(text, data, computeHash);
120963
+ if (newSignature !== state.outSignature) {
120964
+ state.outSignature = newSignature;
120965
+ state.hasChangedEmitSignature = true;
120966
+ }
120967
+ }
120763
120968
  }
120764
120969
  if (writeFile)
120765
120970
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -120824,8 +121029,8 @@ var ts;
120824
121029
  }
120825
121030
  }
120826
121031
  }
120827
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120828
- getWriteFileUpdatingSignatureCallback(writeFile) :
121032
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121033
+ getWriteFileCallback(writeFile, customTransformers) :
120829
121034
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120830
121035
  }
120831
121036
  /**
@@ -120914,29 +121119,58 @@ var ts;
120914
121119
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
120915
121120
  }
120916
121121
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
120917
- function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
120918
- var _a;
121122
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121123
+ var _a, _b, _c, _d;
120919
121124
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
120920
121125
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
120921
- var filePaths = program.fileNames.map(toPath);
120922
- var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
120923
- var fileInfos = new ts.Map();
120924
- program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
120925
- var state = {
120926
- fileInfos: fileInfos,
120927
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
120928
- referencedMap: toManyToManyPathMap(program.referencedMap),
120929
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
120930
- 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]; }),
120931
- hasReusableDiagnostic: true,
120932
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
120933
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
120934
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
120935
- };
121126
+ var state;
121127
+ var filePaths;
121128
+ var filePathsSetList;
121129
+ if (isProgramBundleEmitBuildInfo(program)) {
121130
+ state = {
121131
+ fileInfos: new ts.Map(),
121132
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121133
+ dtsChangeTime: program.dtsChangeTime,
121134
+ outSignature: program.outSignature,
121135
+ };
121136
+ }
121137
+ else {
121138
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121139
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121140
+ var fileInfos_2 = new ts.Map();
121141
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121142
+ program.fileInfos.forEach(function (fileInfo, index) {
121143
+ var path = toFilePath(index + 1);
121144
+ var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121145
+ fileInfos_2.set(path, stateFileInfo);
121146
+ if (emitSignatures_1 && stateFileInfo.signature)
121147
+ emitSignatures_1.set(path, stateFileInfo.signature);
121148
+ });
121149
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121150
+ if (ts.isNumber(value))
121151
+ emitSignatures_1.delete(toFilePath(value));
121152
+ else
121153
+ emitSignatures_1.set(toFilePath(value[0]), value[1]);
121154
+ });
121155
+ state = {
121156
+ fileInfos: fileInfos_2,
121157
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121158
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121159
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121160
+ 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]; }),
121161
+ hasReusableDiagnostic: true,
121162
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121163
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121164
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121165
+ changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121166
+ dtsChangeTime: program.dtsChangeTime,
121167
+ emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121168
+ };
121169
+ }
120936
121170
  return {
120937
121171
  getState: function () { return state; },
120938
- backupState: ts.noop,
120939
- restoreState: ts.noop,
121172
+ backupEmitState: ts.noop,
121173
+ restoreEmitState: ts.noop,
120940
121174
  getProgram: ts.notImplemented,
120941
121175
  getProgramOrUndefined: ts.returnUndefined,
120942
121176
  releaseProgram: ts.noop,
@@ -120981,12 +121215,24 @@ var ts;
120981
121215
  return map;
120982
121216
  }
120983
121217
  }
120984
- ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121218
+ ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121219
+ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121220
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121221
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121222
+ var fileInfos = new ts.Map();
121223
+ program.fileInfos.forEach(function (fileInfo, index) {
121224
+ var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121225
+ var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121226
+ fileInfos.set(path, version);
121227
+ });
121228
+ return fileInfos;
121229
+ }
121230
+ ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
120985
121231
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
120986
121232
  return {
120987
121233
  getState: ts.notImplemented,
120988
- backupState: ts.noop,
120989
- restoreState: ts.noop,
121234
+ backupEmitState: ts.noop,
121235
+ restoreEmitState: ts.noop,
120990
121236
  getProgram: getProgram,
120991
121237
  getProgramOrUndefined: function () { return getState().program; },
120992
121238
  releaseProgram: function () { return getState().program = undefined; },
@@ -122102,9 +122348,9 @@ var ts;
122102
122348
  if (!preferSymlinks) {
122103
122349
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122104
122350
  // so we only need to remove them from the realpath filenames.
122105
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122106
- if (result_15)
122107
- return result_15;
122351
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122352
+ if (result_16)
122353
+ return result_16;
122108
122354
  }
122109
122355
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122110
122356
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122124,10 +122370,10 @@ var ts;
122124
122370
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122125
122371
  var symlinkDirectory = symlinkDirectories_1[_i];
122126
122372
  var option = ts.resolvePath(symlinkDirectory, relative);
122127
- var result_16 = cb(option, target === referenceRedirect);
122373
+ var result_17 = cb(option, target === referenceRedirect);
122128
122374
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122129
- if (result_16)
122130
- return result_16;
122375
+ if (result_17)
122376
+ return result_17;
122131
122377
  }
122132
122378
  });
122133
122379
  });
@@ -122169,7 +122415,7 @@ var ts;
122169
122415
  });
122170
122416
  // Sort by paths closest to importing file Name directory
122171
122417
  var sortedPaths = [];
122172
- var _loop_32 = function (directory) {
122418
+ var _loop_33 = function (directory) {
122173
122419
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122174
122420
  var pathsInDirectory;
122175
122421
  allFileNames.forEach(function (_a, fileName) {
@@ -122193,7 +122439,7 @@ var ts;
122193
122439
  };
122194
122440
  var out_directory_1;
122195
122441
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122196
- var state_10 = _loop_32(directory);
122442
+ var state_10 = _loop_33(directory);
122197
122443
  directory = out_directory_1;
122198
122444
  if (state_10 === "break")
122199
122445
  break;
@@ -123037,6 +123283,7 @@ var ts;
123037
123283
  readDirectory: ts.maybeBind(host, host.readDirectory),
123038
123284
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123039
123285
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123286
+ now: ts.maybeBind(host, host.now),
123040
123287
  };
123041
123288
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123042
123289
  try {
@@ -123097,6 +123344,7 @@ var ts;
123097
123344
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123098
123345
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123099
123346
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123347
+ now: ts.maybeBind(system, system.now),
123100
123348
  };
123101
123349
  }
123102
123350
  ts.createProgramHost = createProgramHost;
@@ -123164,20 +123412,26 @@ var ts;
123164
123412
  var ts;
123165
123413
  (function (ts) {
123166
123414
  function readBuilderProgram(compilerOptions, host) {
123167
- if (ts.outFile(compilerOptions))
123168
- return undefined;
123169
123415
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123170
123416
  if (!buildInfoPath)
123171
123417
  return undefined;
123172
- var content = host.readFile(buildInfoPath);
123173
- if (!content)
123174
- return undefined;
123175
- var buildInfo = ts.getBuildInfo(content);
123418
+ var buildInfo;
123419
+ if (host.getBuildInfo) {
123420
+ buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
123421
+ if (!buildInfo)
123422
+ return undefined;
123423
+ }
123424
+ else {
123425
+ var content = host.readFile(buildInfoPath);
123426
+ if (!content)
123427
+ return undefined;
123428
+ buildInfo = ts.getBuildInfo(content);
123429
+ }
123176
123430
  if (buildInfo.version !== ts.version)
123177
123431
  return undefined;
123178
123432
  if (!buildInfo.program)
123179
123433
  return undefined;
123180
- return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123434
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123181
123435
  }
123182
123436
  ts.readBuilderProgram = readBuilderProgram;
123183
123437
  function createIncrementalCompilerHost(options, system) {
@@ -123186,6 +123440,7 @@ var ts;
123186
123440
  host.createHash = ts.maybeBind(system, system.createHash);
123187
123441
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123188
123442
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
123443
+ host.now = ts.maybeBind(system, system.now);
123189
123444
  ts.setGetSourceFileAsHashVersioned(host, system);
123190
123445
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123191
123446
  return host;
@@ -123640,6 +123895,7 @@ var ts;
123640
123895
  }
123641
123896
  function reloadFileNamesFromConfigFile() {
123642
123897
  writeLog("Reloading new file names and options");
123898
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123643
123899
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123644
123900
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123645
123901
  hasChangedConfigFileParsingErrors = true;
@@ -123920,14 +124176,17 @@ var ts;
123920
124176
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
123921
124177
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
123922
124178
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
123923
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
123924
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
123925
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
123926
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124179
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124180
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124181
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124182
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124183
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124184
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
123927
124185
  /**
123928
124186
  * Projects with no outputs (i.e. "solution" files)
123929
124187
  */
123930
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124188
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124189
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
123931
124190
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
123932
124191
  function resolveConfigFileProjectName(project) {
123933
124192
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -123972,9 +124231,11 @@ var ts;
123972
124231
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
123973
124232
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
123974
124233
  }
123975
- function newer(date1, date2) {
123976
- return date2 > date1 ? date2 : date1;
124234
+ /*@internal*/
124235
+ function getCurrentTime(host) {
124236
+ return host.now ? host.now() : new Date();
123977
124237
  }
124238
+ ts.getCurrentTime = getCurrentTime;
123978
124239
  /*@internal*/
123979
124240
  function isCircularBuildOrder(buildOrder) {
123980
124241
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124064,6 +124325,7 @@ var ts;
124064
124325
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124065
124326
  };
124066
124327
  }
124328
+ compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124067
124329
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124068
124330
  var state = {
124069
124331
  host: host,
@@ -124080,8 +124342,9 @@ var ts;
124080
124342
  resolvedConfigFilePaths: new ts.Map(),
124081
124343
  configFileCache: new ts.Map(),
124082
124344
  projectStatus: new ts.Map(),
124083
- buildInfoChecked: new ts.Map(),
124084
124345
  extendedConfigCache: new ts.Map(),
124346
+ buildInfoCache: new ts.Map(),
124347
+ outputTimeStamps: new ts.Map(),
124085
124348
  builderPrograms: new ts.Map(),
124086
124349
  diagnostics: new ts.Map(),
124087
124350
  projectPendingBuild: new ts.Map(),
@@ -124104,6 +124367,7 @@ var ts;
124104
124367
  allWatchedConfigFiles: new ts.Map(),
124105
124368
  allWatchedExtendedConfigFiles: new ts.Map(),
124106
124369
  allWatchedPackageJsonFiles: new ts.Map(),
124370
+ filesWatched: new ts.Map(),
124107
124371
  lastCachedPackageJsonLookups: new ts.Map(),
124108
124372
  timerToBuildInvalidatedProject: undefined,
124109
124373
  reportFileChangeDetected: false,
@@ -124138,6 +124402,7 @@ var ts;
124138
124402
  if (value) {
124139
124403
  return isParsedCommandLine(value) ? value : undefined;
124140
124404
  }
124405
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124141
124406
  var diagnostic;
124142
124407
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124143
124408
  var parsed;
@@ -124152,6 +124417,8 @@ var ts;
124152
124417
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124153
124418
  }
124154
124419
  configFileCache.set(configFilePath, parsed || diagnostic);
124420
+ ts.solutionPerformance.mark("afterParseConfigFile");
124421
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124155
124422
  return parsed;
124156
124423
  }
124157
124424
  function resolveProjectName(state, name) {
@@ -124201,6 +124468,7 @@ var ts;
124201
124468
  return state.buildOrder || createStateBuildOrder(state);
124202
124469
  }
124203
124470
  function createStateBuildOrder(state) {
124471
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124204
124472
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124205
124473
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124206
124474
  state.resolvedConfigFilePaths.clear();
@@ -124210,11 +124478,12 @@ var ts;
124210
124478
  // Config file cache
124211
124479
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124212
124480
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124213
- ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124214
124481
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124215
124482
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124216
124483
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124217
124484
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124485
+ ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124486
+ ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124218
124487
  // Remove watches for the program no longer in the solution
124219
124488
  if (state.watch) {
124220
124489
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -124230,6 +124499,8 @@ var ts;
124230
124499
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124231
124500
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124232
124501
  }
124502
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124503
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124233
124504
  return state.buildOrder = buildOrder;
124234
124505
  }
124235
124506
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124350,6 +124621,7 @@ var ts;
124350
124621
  if (updateOutputFileStampsPending) {
124351
124622
  updateOutputTimestamps(state, config, projectPath);
124352
124623
  }
124624
+ ts.solutionPerformance.mark("timestampUpdated");
124353
124625
  return doneInvalidatedProject(state, projectPath);
124354
124626
  }
124355
124627
  };
@@ -124443,6 +124715,10 @@ var ts;
124443
124715
  };
124444
124716
  function done(cancellationToken, writeFile, customTransformers) {
124445
124717
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124718
+ if (kind === InvalidatedProjectKind.Build)
124719
+ ts.solutionPerformance.mark("projectsBuilt");
124720
+ else
124721
+ ts.solutionPerformance.mark("bundlesUpdated");
124446
124722
  return doneInvalidatedProject(state, projectPath);
124447
124723
  }
124448
124724
  function withProgramOrUndefined(action) {
@@ -124504,21 +124780,21 @@ var ts;
124504
124780
  }
124505
124781
  function emit(writeFileCallback, cancellationToken, customTransformers) {
124506
124782
  var _a;
124507
- var _b, _c;
124783
+ var _b, _c, _d;
124508
124784
  ts.Debug.assertIsDefined(program);
124509
124785
  ts.Debug.assert(step === BuildStep.Emit);
124510
124786
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
124511
- program.backupState();
124787
+ program.backupEmitState();
124512
124788
  var declDiagnostics;
124513
124789
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
124514
124790
  var outputFiles = [];
124515
124791
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
124516
124792
  /*write*/ undefined,
124517
- /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
124793
+ /*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,
124518
124794
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
124519
124795
  // Don't emit .d.ts if there are decl file errors
124520
124796
  if (declDiagnostics) {
124521
- program.restoreState();
124797
+ program.restoreEmitState();
124522
124798
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
124523
124799
  return {
124524
124800
  emitSkipped: true,
@@ -124528,37 +124804,46 @@ var ts;
124528
124804
  // Actual Emit
124529
124805
  var host = state.host, compilerHost = state.compilerHost;
124530
124806
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124531
- var newestDeclarationFileContentChangedTime = minimumDate;
124532
- var anyDtsChanged = false;
124807
+ var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
124533
124808
  var emitterDiagnostics = ts.createDiagnosticCollection();
124534
124809
  var emittedOutputs = new ts.Map();
124810
+ var options = program.getCompilerOptions();
124811
+ var isIncremental = ts.isIncrementalCompilation(options);
124812
+ var outputTimeStampMap;
124813
+ var now;
124814
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124535
124815
  outputFiles.forEach(function (_a) {
124536
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124537
- var priorChangeTime;
124538
- if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124539
- // Check for unchanged .d.ts files
124540
- if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124541
- priorChangeTime = host.getModifiedTime(name);
124542
- }
124543
- else {
124816
+ var _b, _c;
124817
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124818
+ var path = toPath(state, name);
124819
+ emittedOutputs.set(toPath(state, name), name);
124820
+ if (buildInfo) {
124821
+ setBuildInfo(state, buildInfo, projectPath, options);
124822
+ 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)) {
124544
124823
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124545
- anyDtsChanged = true;
124546
124824
  }
124547
124825
  }
124548
- emittedOutputs.set(toPath(state, name), name);
124549
124826
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124550
- if (priorChangeTime !== undefined) {
124551
- newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124827
+ if (!isIncremental && state.watch) {
124828
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
124552
124829
  }
124553
124830
  });
124554
- finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124555
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124831
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124832
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124833
+ finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124556
124834
  return emitResult;
124557
124835
  }
124558
124836
  function emitBuildInfo(writeFileCallback, cancellationToken) {
124559
124837
  ts.Debug.assertIsDefined(program);
124560
124838
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
124561
- var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
124839
+ var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
124840
+ if (data === null || data === void 0 ? void 0 : data.buildInfo)
124841
+ setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
124842
+ if (writeFileCallback)
124843
+ writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
124844
+ else
124845
+ state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
124846
+ }, cancellationToken);
124562
124847
  if (emitResult.diagnostics.length) {
124563
124848
  reportErrors(state, emitResult.diagnostics);
124564
124849
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -124571,7 +124856,7 @@ var ts;
124571
124856
  step = BuildStep.QueueReferencingProjects;
124572
124857
  return emitResult;
124573
124858
  }
124574
- function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
124859
+ function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
124575
124860
  var _a;
124576
124861
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
124577
124862
  if (emitDiagnostics.length) {
@@ -124582,13 +124867,11 @@ var ts;
124582
124867
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
124583
124868
  }
124584
124869
  // Update time stamps for rest of the outputs
124585
- var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124870
+ updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124586
124871
  state.diagnostics.delete(projectPath);
124587
124872
  state.projectStatus.set(projectPath, {
124588
124873
  type: ts.UpToDateStatusType.UpToDate,
124589
- newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
124590
- maximumDate :
124591
- newestDeclarationFileContentChangedTime,
124874
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
124592
124875
  oldestOutputFileName: oldestOutputFileName
124593
124876
  });
124594
124877
  afterProgramDone(state, program, config);
@@ -124623,13 +124906,21 @@ var ts;
124623
124906
  ts.Debug.assert(!!outputFiles.length);
124624
124907
  var emitterDiagnostics = ts.createDiagnosticCollection();
124625
124908
  var emittedOutputs = new ts.Map();
124909
+ var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124910
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
124626
124911
  outputFiles.forEach(function (_a) {
124627
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124912
+ var _b, _c;
124913
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124628
124914
  emittedOutputs.set(toPath(state, name), name);
124915
+ if (buildInfo) {
124916
+ setBuildInfo(state, buildInfo, projectPath, config.options);
124917
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
124918
+ resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124919
+ }
124920
+ }
124629
124921
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124630
124922
  });
124631
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
124632
- /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
124923
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
124633
124924
  return { emitSkipped: false, diagnostics: emitDiagnostics };
124634
124925
  }
124635
124926
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -124680,6 +124971,13 @@ var ts;
124680
124971
  !ts.isIncrementalCompilation(config.options);
124681
124972
  }
124682
124973
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124974
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
124975
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
124976
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
124977
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
124978
+ return result;
124979
+ }
124980
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124683
124981
  if (!state.projectPendingBuild.size)
124684
124982
  return undefined;
124685
124983
  if (isCircularBuildOrder(buildOrder))
@@ -124728,7 +125026,7 @@ var ts;
124728
125026
  }
124729
125027
  continue;
124730
125028
  }
124731
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125029
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
124732
125030
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124733
125031
  return {
124734
125032
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -124779,9 +125077,7 @@ var ts;
124779
125077
  }
124780
125078
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124781
125079
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124782
- if (!info)
124783
- return info;
124784
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
125080
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124785
125081
  }
124786
125082
  function listEmittedFile(_a, proj, file) {
124787
125083
  var write = _a.write;
@@ -124789,14 +125085,17 @@ var ts;
124789
125085
  write("TSFILE: " + file);
124790
125086
  }
124791
125087
  }
124792
- function getOldProgram(_a, proj, parsed) {
124793
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
124794
- if (options.force)
125088
+ function getOldProgram(state, proj, parsed) {
125089
+ if (state.options.force)
124795
125090
  return undefined;
124796
- var value = builderPrograms.get(proj);
125091
+ var value = state.builderPrograms.get(proj);
124797
125092
  if (value)
124798
125093
  return value;
124799
- return ts.readBuilderProgram(parsed.options, compilerHost);
125094
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
125095
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
125096
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
125097
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
125098
+ return program;
124800
125099
  }
124801
125100
  function afterProgramDone(state, program, config) {
124802
125101
  if (program) {
@@ -124813,7 +125112,7 @@ var ts;
124813
125112
  state.projectCompilerOptions = state.baseCompilerOptions;
124814
125113
  }
124815
125114
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
124816
- var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125115
+ var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
124817
125116
  reportAndStoreErrors(state, resolvedPath, diagnostics);
124818
125117
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
124819
125118
  if (canEmitBuildInfo)
@@ -124821,9 +125120,101 @@ var ts;
124821
125120
  afterProgramDone(state, program, config);
124822
125121
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
124823
125122
  }
125123
+ function isFileWatcherWithModifiedTime(value) {
125124
+ return !!value.watcher;
125125
+ }
125126
+ function getModifiedTime(state, fileName) {
125127
+ var path = toPath(state, fileName);
125128
+ var existing = state.filesWatched.get(path);
125129
+ if (state.watch && !!existing) {
125130
+ if (!isFileWatcherWithModifiedTime(existing))
125131
+ return existing;
125132
+ if (existing.modifiedTime)
125133
+ return existing.modifiedTime;
125134
+ }
125135
+ var result = ts.getModifiedTime(state.host, fileName);
125136
+ if (state.watch) {
125137
+ if (existing)
125138
+ existing.modifiedTime = result;
125139
+ else
125140
+ state.filesWatched.set(path, result);
125141
+ }
125142
+ return result;
125143
+ }
125144
+ function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125145
+ var path = toPath(state, file);
125146
+ var existing = state.filesWatched.get(path);
125147
+ if (existing && isFileWatcherWithModifiedTime(existing)) {
125148
+ existing.callbacks.push(callback);
125149
+ }
125150
+ else {
125151
+ var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125152
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125153
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125154
+ existing.modifiedTime = modifiedTime;
125155
+ existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125156
+ }, pollingInterval, options, watchType, project);
125157
+ state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125158
+ }
125159
+ return {
125160
+ close: function () {
125161
+ var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125162
+ ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125163
+ if (existing.callbacks.length === 1) {
125164
+ state.filesWatched.delete(path);
125165
+ ts.closeFileWatcherOf(existing);
125166
+ }
125167
+ else {
125168
+ ts.unorderedRemoveItem(existing.callbacks, callback);
125169
+ }
125170
+ }
125171
+ };
125172
+ }
125173
+ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125174
+ if (!state.watch)
125175
+ return undefined;
125176
+ var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125177
+ if (!result)
125178
+ state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125179
+ return result;
125180
+ }
125181
+ function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125182
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125183
+ var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125184
+ if (existing) {
125185
+ existing.buildInfo = buildInfo;
125186
+ existing.modifiedTime = getCurrentTime(state.host);
125187
+ }
125188
+ else {
125189
+ state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125190
+ }
125191
+ }
125192
+ function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125193
+ var path = toPath(state, buildInfoPath);
125194
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125195
+ return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125196
+ }
125197
+ function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125198
+ var path = toPath(state, buildInfoPath);
125199
+ var existing = state.buildInfoCache.get(resolvedConfigPath);
125200
+ if (existing !== undefined && existing.path === path) {
125201
+ return existing.buildInfo || undefined;
125202
+ }
125203
+ ts.solutionPerformance.mark("beforeGetBuildInfo");
125204
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125205
+ var value = state.readFileWithCache(buildInfoPath);
125206
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125207
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125208
+ var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125209
+ ts.Debug.assert(modifiedTime || !buildInfo);
125210
+ state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125211
+ ts.solutionPerformance.mark("afterGetBuildInfo");
125212
+ ts.solutionPerformance.measure("GetBuildInfo", "beforeGetBuildInfo", "afterGetBuildInfo");
125213
+ return buildInfo;
125214
+ }
124824
125215
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
124825
125216
  // Check tsconfig time
124826
- var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125217
+ var tsconfigTime = getModifiedTime(state, configFile);
124827
125218
  if (oldestOutputFileTime < tsconfigTime) {
124828
125219
  return {
124829
125220
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -124833,88 +125224,24 @@ var ts;
124833
125224
  }
124834
125225
  }
124835
125226
  function getUpToDateStatusWorker(state, project, resolvedPath) {
124836
- var force = !!state.options.force;
124837
- var newestInputFileName = undefined;
124838
- var newestInputFileTime = minimumDate;
124839
- var host = state.host;
124840
- // Get timestamps of input files
124841
- for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
124842
- var inputFile = _a[_i];
124843
- if (!host.fileExists(inputFile)) {
124844
- return {
124845
- type: ts.UpToDateStatusType.Unbuildable,
124846
- reason: inputFile + " does not exist"
124847
- };
124848
- }
124849
- if (!force) {
124850
- var inputTime = ts.getModifiedTime(host, inputFile);
124851
- if (inputTime > newestInputFileTime) {
124852
- newestInputFileName = inputFile;
124853
- newestInputFileTime = inputTime;
124854
- }
124855
- }
124856
- }
125227
+ var _a, _b, _c;
124857
125228
  // Container if no files are specified in the project
124858
125229
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
124859
125230
  return {
124860
125231
  type: ts.UpToDateStatusType.ContainerOnly
124861
125232
  };
124862
125233
  }
124863
- // Collect the expected outputs of this project
124864
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
124865
- // Now see if all outputs are newer than the newest input
124866
- var oldestOutputFileName = "(none)";
124867
- var oldestOutputFileTime = maximumDate;
124868
- var newestOutputFileName = "(none)";
124869
- var newestOutputFileTime = minimumDate;
124870
- var missingOutputFileName;
124871
- var newestDeclarationFileContentChangedTime = minimumDate;
124872
- var isOutOfDateWithInputs = false;
124873
- if (!force) {
124874
- for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
124875
- var output = outputs_1[_b];
124876
- // Output is missing; can stop checking
124877
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
124878
- if (!host.fileExists(output)) {
124879
- missingOutputFileName = output;
124880
- break;
124881
- }
124882
- var outputTime = ts.getModifiedTime(host, output);
124883
- if (outputTime < oldestOutputFileTime) {
124884
- oldestOutputFileTime = outputTime;
124885
- oldestOutputFileName = output;
124886
- }
124887
- // If an output is older than the newest input, we can stop checking
124888
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
124889
- if (outputTime < newestInputFileTime) {
124890
- isOutOfDateWithInputs = true;
124891
- break;
124892
- }
124893
- if (outputTime > newestOutputFileTime) {
124894
- newestOutputFileTime = outputTime;
124895
- newestOutputFileName = output;
124896
- }
124897
- // Keep track of when the most recent time a .d.ts file was changed.
124898
- // In addition to file timestamps, we also keep track of when a .d.ts file
124899
- // had its file touched but not had its contents changed - this allows us
124900
- // to skip a downstream typecheck
124901
- if (ts.isDeclarationFileName(output)) {
124902
- var outputModifiedTime = ts.getModifiedTime(host, output);
124903
- newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124904
- }
124905
- }
124906
- }
124907
- var pseudoUpToDate = false;
124908
- var usesPrepend = false;
124909
- var upstreamChangedProject;
125234
+ // Fast check to see if reference projects are buildable
125235
+ var referenceStatuses;
125236
+ var force = !!state.options.force;
124910
125237
  if (project.projectReferences) {
124911
125238
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
124912
- for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
124913
- var ref = _d[_c];
124914
- usesPrepend = usesPrepend || !!(ref.prepend);
125239
+ for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125240
+ var ref = _d[_i];
124915
125241
  var resolvedRef = ts.resolveProjectReferencePath(ref);
124916
125242
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
124917
- var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125243
+ var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125244
+ var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
124918
125245
  // Its a circular reference ignore the status of this project
124919
125246
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
124920
125247
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -124936,75 +125263,188 @@ var ts;
124936
125263
  upstreamProjectName: ref.path
124937
125264
  };
124938
125265
  }
124939
- // Check oldest output file name only if there is no missing output file name
124940
- // (a check we will have skipped if this is a forced build)
124941
- if (!force && !missingOutputFileName) {
124942
- // If the upstream project's newest file is older than our oldest output, we
124943
- // can't be out of date because of it
124944
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
124945
- continue;
124946
- }
124947
- // If the upstream project has only change .d.ts files, and we've built
124948
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
124949
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
124950
- pseudoUpToDate = true;
124951
- upstreamChangedProject = ref.path;
124952
- continue;
124953
- }
124954
- // We have an output older than an upstream output - we are out of date
124955
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125266
+ if (!force)
125267
+ (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125268
+ }
125269
+ }
125270
+ if (force)
125271
+ return { type: ts.UpToDateStatusType.ForceBuild };
125272
+ // Check buildinfo first
125273
+ var host = state.host;
125274
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125275
+ var oldestOutputFileName = "(none)";
125276
+ var oldestOutputFileTime = maximumDate;
125277
+ var buildInfoTime;
125278
+ var buildInfoProgram;
125279
+ var buildInfoVersionMap;
125280
+ var newestDeclarationFileContentChangedTime;
125281
+ if (buildInfoPath) {
125282
+ var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125283
+ buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125284
+ if (buildInfoTime === ts.missingFileModifiedTime) {
125285
+ if (!buildInfoCacheEntry_1) {
125286
+ state.buildInfoCache.set(resolvedPath, {
125287
+ path: toPath(state, buildInfoPath),
125288
+ buildInfo: false,
125289
+ modifiedTime: buildInfoTime
125290
+ });
125291
+ }
125292
+ return {
125293
+ type: ts.UpToDateStatusType.OutputMissing,
125294
+ missingOutputFileName: buildInfoPath
125295
+ };
125296
+ }
125297
+ var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125298
+ if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125299
+ return {
125300
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125301
+ version: buildInfo.version
125302
+ };
125303
+ }
125304
+ if (buildInfo.program) {
125305
+ if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125306
+ (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
124956
125307
  return {
124957
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
124958
- outOfDateOutputFileName: oldestOutputFileName,
124959
- newerProjectName: ref.path
125308
+ type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125309
+ buildInfoFile: buildInfoPath
124960
125310
  };
124961
125311
  }
125312
+ buildInfoProgram = buildInfo.program;
124962
125313
  }
125314
+ oldestOutputFileTime = buildInfoTime;
125315
+ oldestOutputFileName = buildInfoPath;
125316
+ newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
124963
125317
  }
124964
- if (missingOutputFileName !== undefined) {
124965
- return {
124966
- type: ts.UpToDateStatusType.OutputMissing,
124967
- missingOutputFileName: missingOutputFileName
124968
- };
125318
+ // Check input files
125319
+ var newestInputFileName = undefined;
125320
+ var newestInputFileTime = minimumDate;
125321
+ var pseudoInputUptodate = false;
125322
+ // Get timestamps of input files
125323
+ for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125324
+ var inputFile = _f[_e];
125325
+ var inputTime = getModifiedTime(state, inputFile);
125326
+ if (inputTime === ts.missingFileModifiedTime) {
125327
+ return {
125328
+ type: ts.UpToDateStatusType.Unbuildable,
125329
+ reason: inputFile + " does not exist"
125330
+ };
125331
+ }
125332
+ // If an buildInfo is older than the newest input, we can stop checking
125333
+ if (buildInfoTime && buildInfoTime < inputTime) {
125334
+ var version_3 = void 0;
125335
+ var currentVersion = void 0;
125336
+ if (buildInfoProgram) {
125337
+ // Read files and see if they are same, read is anyways cached
125338
+ if (!buildInfoVersionMap)
125339
+ buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125340
+ version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125341
+ var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125342
+ currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125343
+ if (version_3 && version_3 === currentVersion)
125344
+ pseudoInputUptodate = true;
125345
+ }
125346
+ if (!version_3 || version_3 !== currentVersion) {
125347
+ return {
125348
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125349
+ outOfDateOutputFileName: buildInfoPath,
125350
+ newerInputFileName: inputFile
125351
+ };
125352
+ }
125353
+ }
125354
+ if (inputTime > newestInputFileTime) {
125355
+ newestInputFileName = inputFile;
125356
+ newestInputFileTime = inputTime;
125357
+ }
124969
125358
  }
124970
- if (isOutOfDateWithInputs) {
124971
- return {
124972
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
124973
- outOfDateOutputFileName: oldestOutputFileName,
124974
- newerInputFileName: newestInputFileName
124975
- };
125359
+ // Now see if all outputs are newer than the newest input
125360
+ // Dont check output timestamps if we have buildinfo telling us output is uptodate
125361
+ if (!buildInfoPath) {
125362
+ // Collect the expected outputs of this project
125363
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125364
+ var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125365
+ for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125366
+ var output = outputs_1[_g];
125367
+ var path = toPath(state, output);
125368
+ // Output is missing; can stop checking
125369
+ var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125370
+ if (!outputTime) {
125371
+ outputTime = ts.getModifiedTime(state.host, output);
125372
+ outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125373
+ }
125374
+ if (outputTime === ts.missingFileModifiedTime) {
125375
+ return {
125376
+ type: ts.UpToDateStatusType.OutputMissing,
125377
+ missingOutputFileName: output
125378
+ };
125379
+ }
125380
+ if (outputTime < oldestOutputFileTime) {
125381
+ oldestOutputFileTime = outputTime;
125382
+ oldestOutputFileName = output;
125383
+ }
125384
+ // If an output is older than the newest input, we can stop checking
125385
+ if (outputTime < newestInputFileTime) {
125386
+ return {
125387
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125388
+ outOfDateOutputFileName: oldestOutputFileName,
125389
+ newerInputFileName: newestInputFileName
125390
+ };
125391
+ }
125392
+ }
124976
125393
  }
124977
- else {
124978
- // Check tsconfig time
124979
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
124980
- if (configStatus)
124981
- return configStatus;
124982
- // Check extended config time
124983
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
124984
- if (extendedConfigStatus)
124985
- return extendedConfigStatus;
124986
- // Check package file time
124987
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
124988
- var path = _a[0];
124989
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
124990
- });
124991
- if (dependentPackageFileStatus)
124992
- return dependentPackageFileStatus;
124993
- }
124994
- if (!force && !state.buildInfoChecked.has(resolvedPath)) {
124995
- state.buildInfoChecked.set(resolvedPath, true);
124996
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
124997
- if (buildInfoPath) {
124998
- var value = state.readFileWithCache(buildInfoPath);
124999
- var buildInfo = value && ts.getBuildInfo(value);
125000
- if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125394
+ var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125395
+ var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125396
+ seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125397
+ var pseudoUpToDate = false;
125398
+ var usesPrepend = false;
125399
+ var upstreamChangedProject;
125400
+ if (referenceStatuses) {
125401
+ for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125402
+ var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125403
+ usesPrepend = usesPrepend || !!(ref.prepend);
125404
+ // If the upstream project's newest file is older than our oldest output, we
125405
+ // can't be out of date because of it
125406
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125407
+ continue;
125408
+ }
125409
+ // Check if tsbuildinfo path is shared, then we need to rebuild
125410
+ if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125001
125411
  return {
125002
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125003
- version: buildInfo.version
125412
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125413
+ outOfDateOutputFileName: buildInfoPath,
125414
+ newerProjectName: ref.path
125004
125415
  };
125005
125416
  }
125417
+ // If the upstream project has only change .d.ts files, and we've built
125418
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125419
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125420
+ pseudoUpToDate = true;
125421
+ upstreamChangedProject = ref.path;
125422
+ continue;
125423
+ }
125424
+ // We have an output older than an upstream output - we are out of date
125425
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125426
+ return {
125427
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125428
+ outOfDateOutputFileName: oldestOutputFileName,
125429
+ newerProjectName: ref.path
125430
+ };
125006
125431
  }
125007
125432
  }
125433
+ // Check tsconfig time
125434
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125435
+ if (configStatus)
125436
+ return configStatus;
125437
+ // Check extended config time
125438
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125439
+ if (extendedConfigStatus)
125440
+ return extendedConfigStatus;
125441
+ // Check package file time
125442
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125443
+ var path = _a[0];
125444
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125445
+ });
125446
+ if (dependentPackageFileStatus)
125447
+ return dependentPackageFileStatus;
125008
125448
  if (usesPrepend && pseudoUpToDate) {
125009
125449
  return {
125010
125450
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125014,15 +125454,37 @@ var ts;
125014
125454
  }
125015
125455
  // Up to date
125016
125456
  return {
125017
- type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
125457
+ type: pseudoUpToDate ?
125458
+ ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
125459
+ pseudoInputUptodate ?
125460
+ ts.UpToDateStatusType.UpToDateWithInputFileText :
125461
+ ts.UpToDateStatusType.UpToDate,
125018
125462
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125019
125463
  newestInputFileTime: newestInputFileTime,
125020
- newestOutputFileTime: newestOutputFileTime,
125021
125464
  newestInputFileName: newestInputFileName,
125022
- newestOutputFileName: newestOutputFileName,
125023
125465
  oldestOutputFileName: oldestOutputFileName
125024
125466
  };
125025
125467
  }
125468
+ function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
125469
+ if (seenRefs.has(resolvedRefPath))
125470
+ return false;
125471
+ seenRefs.add(resolvedRefPath);
125472
+ var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
125473
+ if (refBuildInfo.path === buildInfoCacheEntry.path)
125474
+ return true;
125475
+ if (resolvedConfig.projectReferences) {
125476
+ // Check references
125477
+ for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
125478
+ var ref = _a[_i];
125479
+ var resolvedRef = ts.resolveProjectReferencePath(ref);
125480
+ var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
125481
+ var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
125482
+ if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
125483
+ return true;
125484
+ }
125485
+ }
125486
+ return false;
125487
+ }
125026
125488
  function getUpToDateStatus(state, project, resolvedPath) {
125027
125489
  if (project === undefined) {
125028
125490
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125031,43 +125493,76 @@ var ts;
125031
125493
  if (prior !== undefined) {
125032
125494
  return prior;
125033
125495
  }
125496
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125034
125497
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125498
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125499
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125035
125500
  state.projectStatus.set(resolvedPath, actual);
125036
125501
  return actual;
125037
125502
  }
125038
- function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125503
+ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125039
125504
  if (proj.options.noEmit)
125040
- return priorNewestUpdateTime;
125041
- var host = state.host;
125042
- var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125043
- if (!skipOutputs || outputs.length !== skipOutputs.size) {
125044
- var reportVerbose = !!state.options.verbose;
125045
- var now = host.now ? host.now() : new Date();
125046
- for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125047
- var file = outputs_2[_i];
125048
- if (skipOutputs && skipOutputs.has(toPath(state, file))) {
125049
- continue;
125050
- }
125051
- if (reportVerbose) {
125052
- reportVerbose = false;
125505
+ return;
125506
+ var now;
125507
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125508
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
125509
+ if (buildInfoPath) {
125510
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
125511
+ if (!!state.options.verbose)
125053
125512
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125513
+ state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
125514
+ getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
125515
+ }
125516
+ state.outputTimeStamps.delete(projectPath);
125517
+ }
125518
+ else {
125519
+ var host = state.host;
125520
+ var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125521
+ var outputTimeStampMap_1 = getOutputTimeStampMap(state, projectPath);
125522
+ var modifiedOutputs_1 = outputTimeStampMap_1 ? new ts.Set() : undefined;
125523
+ if (!skipOutputs || outputs.length !== skipOutputs.size) {
125524
+ var reportVerbose = !!state.options.verbose;
125525
+ for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125526
+ var file = outputs_2[_i];
125527
+ var path = toPath(state, file);
125528
+ if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125529
+ continue;
125530
+ if (reportVerbose) {
125531
+ reportVerbose = false;
125532
+ reportStatus(state, verboseMessage, proj.options.configFilePath);
125533
+ }
125534
+ host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
125535
+ if (outputTimeStampMap_1) {
125536
+ outputTimeStampMap_1.set(path, now);
125537
+ modifiedOutputs_1.add(path);
125538
+ }
125054
125539
  }
125055
- if (ts.isDeclarationFileName(file)) {
125056
- priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
125057
- }
125058
- host.setModifiedTime(file, now);
125059
125540
  }
125541
+ // Clear out timestamps not in output list any more
125542
+ outputTimeStampMap_1 === null || outputTimeStampMap_1 === void 0 ? void 0 : outputTimeStampMap_1.forEach(function (_value, key) {
125543
+ if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs_1.has(key))
125544
+ outputTimeStampMap_1.delete(key);
125545
+ });
125060
125546
  }
125061
- return priorNewestUpdateTime;
125547
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125548
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125549
+ }
125550
+ function getDtsChangeTime(state, options, resolvedConfigPath) {
125551
+ var _a;
125552
+ if (!options.composite)
125553
+ return undefined;
125554
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125555
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
125556
+ 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;
125062
125557
  }
125063
125558
  function updateOutputTimestamps(state, proj, resolvedPath) {
125064
125559
  if (state.options.dry) {
125065
125560
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125066
125561
  }
125067
- var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125562
+ updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125068
125563
  state.projectStatus.set(resolvedPath, {
125069
125564
  type: ts.UpToDateStatusType.UpToDate,
125070
- newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
125565
+ newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125071
125566
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125072
125567
  });
125073
125568
  }
@@ -125113,6 +125608,7 @@ var ts;
125113
125608
  break;
125114
125609
  }
125115
125610
  // falls through
125611
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125116
125612
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125117
125613
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125118
125614
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125136,6 +125632,13 @@ var ts;
125136
125632
  }
125137
125633
  }
125138
125634
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125635
+ ts.solutionPerformance.mark("beforeBuild");
125636
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125637
+ ts.solutionPerformance.mark("afterBuild");
125638
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125639
+ return result;
125640
+ }
125641
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125139
125642
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125140
125643
  if (!buildOrder)
125141
125644
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125147,7 +125650,10 @@ var ts;
125147
125650
  if (!invalidatedProject)
125148
125651
  break;
125149
125652
  reportQueue = false;
125653
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125150
125654
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125655
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125656
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125151
125657
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125152
125658
  successfulProjects++;
125153
125659
  }
@@ -125236,6 +125742,14 @@ var ts;
125236
125742
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125237
125743
  }
125238
125744
  function buildNextInvalidatedProject(state, changeDetected) {
125745
+ ts.solutionPerformance.mark("beforeBuild");
125746
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125747
+ ts.solutionPerformance.mark("afterBuild");
125748
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125749
+ if (buildOrder)
125750
+ reportErrorSummary(state, buildOrder);
125751
+ }
125752
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125239
125753
  state.timerToBuildInvalidatedProject = undefined;
125240
125754
  if (state.reportFileChangeDetected) {
125241
125755
  state.reportFileChangeDetected = false;
@@ -125246,7 +125760,10 @@ var ts;
125246
125760
  var buildOrder = getBuildOrder(state);
125247
125761
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125248
125762
  if (invalidatedProject) {
125763
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125249
125764
  invalidatedProject.done();
125765
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125766
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125250
125767
  projectsBuilt++;
125251
125768
  while (state.projectPendingBuild.size) {
125252
125769
  // If already scheduled, skip
@@ -125262,23 +125779,24 @@ var ts;
125262
125779
  return;
125263
125780
  }
125264
125781
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125782
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125265
125783
  project.done();
125784
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125785
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125266
125786
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125267
125787
  projectsBuilt++;
125268
125788
  }
125269
125789
  }
125270
125790
  disableCache(state);
125271
- reportErrorSummary(state, buildOrder);
125791
+ return buildOrder;
125272
125792
  }
125273
125793
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125274
125794
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125275
125795
  return;
125276
- state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125277
- invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125278
- }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
125796
+ 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));
125279
125797
  }
125280
125798
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125281
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
125799
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125282
125800
  var _a;
125283
125801
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125284
125802
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125310,7 +125828,7 @@ var ts;
125310
125828
  if (!state.watch)
125311
125829
  return;
125312
125830
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125313
- 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); },
125831
+ 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); },
125314
125832
  onDeleteValue: ts.closeFileWatcher,
125315
125833
  });
125316
125834
  }
@@ -125318,13 +125836,14 @@ var ts;
125318
125836
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125319
125837
  return;
125320
125838
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125321
- 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); },
125839
+ 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); },
125322
125840
  onDeleteValue: ts.closeFileWatcher,
125323
125841
  });
125324
125842
  }
125325
125843
  function startWatching(state, buildOrder) {
125326
125844
  if (!state.watchAllProjectsPending)
125327
125845
  return;
125846
+ ts.solutionPerformance.mark("beforeStartWatching");
125328
125847
  state.watchAllProjectsPending = false;
125329
125848
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125330
125849
  var resolved = _a[_i];
@@ -125342,6 +125861,8 @@ var ts;
125342
125861
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125343
125862
  }
125344
125863
  }
125864
+ ts.solutionPerformance.mark("afterStartWatching");
125865
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125345
125866
  }
125346
125867
  function stopWatching(state) {
125347
125868
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -125448,19 +125969,18 @@ var ts;
125448
125969
  }
125449
125970
  }
125450
125971
  function reportUpToDateStatus(state, configFileName, status) {
125451
- if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
125452
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125453
- }
125454
125972
  switch (status.type) {
125455
125973
  case ts.UpToDateStatusType.OutOfDateWithSelf:
125456
- 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));
125974
+ 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));
125457
125975
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
125458
- 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));
125976
+ 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));
125459
125977
  case ts.UpToDateStatusType.OutputMissing:
125460
125978
  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));
125979
+ case ts.UpToDateStatusType.OutOfDateBuildInfo:
125980
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_are_not_emitted, relName(state, configFileName), relName(state, status.buildInfoFile));
125461
125981
  case ts.UpToDateStatusType.UpToDate:
125462
125982
  if (status.newestInputFileTime !== undefined) {
125463
- 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 || ""));
125983
+ 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 || ""));
125464
125984
  }
125465
125985
  // Don't report anything for "up to date because it was already built" -- too verbose
125466
125986
  break;
@@ -125468,6 +125988,8 @@ var ts;
125468
125988
  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));
125469
125989
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125470
125990
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
125991
+ case ts.UpToDateStatusType.UpToDateWithInputFileText:
125992
+ return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_but_needs_update_to_timestamps_of_output_files_that_are_older_than_input_files, relName(state, configFileName));
125471
125993
  case ts.UpToDateStatusType.UpstreamOutOfDate:
125472
125994
  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));
125473
125995
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -125478,6 +126000,8 @@ var ts;
125478
126000
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
125479
126001
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
125480
126002
  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);
126003
+ case ts.UpToDateStatusType.ForceBuild:
126004
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125481
126005
  case ts.UpToDateStatusType.ContainerOnly:
125482
126006
  // Don't report status on "solution" projects
125483
126007
  // falls through