@typescript-deploys/pr-build 4.8.0-pr-48784-14 → 4.8.0-pr-49285-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220527";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220531";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5104,6 +5104,11 @@ var ts;
5104
5104
  // Flags that require TypeFlags.Union
5105
5105
  /* @internal */
5106
5106
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5107
+ /* @internal */
5108
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5109
+ /* @internal */
5110
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5111
+ /* @internal */
5107
5112
  // Flags that require TypeFlags.Intersection
5108
5113
  /* @internal */
5109
5114
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -6195,7 +6200,7 @@ var ts;
6195
6200
  };
6196
6201
  }
6197
6202
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6198
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6203
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6199
6204
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6200
6205
  if (!ts.isString(relativeFileName))
6201
6206
  return;
@@ -6205,7 +6210,7 @@ var ts;
6205
6210
  if (callbacks) {
6206
6211
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6207
6212
  var fileCallback = callbacks_1[_i];
6208
- fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6213
+ fileCallback(fileName, FileWatcherEventKind.Changed);
6209
6214
  }
6210
6215
  }
6211
6216
  },
@@ -6259,7 +6264,7 @@ var ts;
6259
6264
  }
6260
6265
  else {
6261
6266
  cache.set(path, {
6262
- watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6267
+ watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6263
6268
  refCount: 1
6264
6269
  });
6265
6270
  }
@@ -6287,7 +6292,7 @@ var ts;
6287
6292
  var newTime = modifiedTime.getTime();
6288
6293
  if (oldTime !== newTime) {
6289
6294
  watchedFile.mtime = modifiedTime;
6290
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6295
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6291
6296
  return true;
6292
6297
  }
6293
6298
  return false;
@@ -6538,18 +6543,17 @@ var ts;
6538
6543
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6539
6544
  /*@internal*/
6540
6545
  function createFileWatcherCallback(callback) {
6541
- return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6546
+ return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6542
6547
  }
6543
6548
  ts.createFileWatcherCallback = createFileWatcherCallback;
6544
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6545
- return function (eventName, _relativeFileName, modifiedTime) {
6549
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6550
+ return function (eventName) {
6546
6551
  if (eventName === "rename") {
6547
- modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6548
- callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6552
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6549
6553
  }
6550
6554
  else {
6551
6555
  // Change
6552
- callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6556
+ callback(fileName, FileWatcherEventKind.Changed);
6553
6557
  }
6554
6558
  };
6555
6559
  }
@@ -6573,7 +6577,7 @@ var ts;
6573
6577
  }
6574
6578
  /*@internal*/
6575
6579
  function createSystemWatchFunctions(_a) {
6576
- 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;
6580
+ 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;
6577
6581
  var dynamicPollingWatchFile;
6578
6582
  var fixedChunkSizePollingWatchFile;
6579
6583
  var nonPollingWatchFile;
@@ -6595,7 +6599,7 @@ var ts;
6595
6599
  case ts.WatchFileKind.FixedChunkSizePolling:
6596
6600
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6597
6601
  case ts.WatchFileKind.UseFsEvents:
6598
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6602
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6599
6603
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6600
6604
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6601
6605
  if (!nonPollingWatchFile) {
@@ -6777,6 +6781,7 @@ var ts;
6777
6781
  fsWatch: fsWatch,
6778
6782
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6779
6783
  getCurrentDirectory: getCurrentDirectory,
6784
+ fileExists: fileExists,
6780
6785
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6781
6786
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6782
6787
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
@@ -7036,7 +7041,7 @@ var ts;
7036
7041
  // File changed
7037
7042
  eventKind = FileWatcherEventKind.Changed;
7038
7043
  }
7039
- callback(fileName, eventKind, curr.mtime);
7044
+ callback(fileName, eventKind);
7040
7045
  }
7041
7046
  }
7042
7047
  function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
@@ -7062,10 +7067,10 @@ var ts;
7062
7067
  * Invoke the callback with rename and update the watcher if not closed
7063
7068
  * @param createWatcher
7064
7069
  */
7065
- function invokeCallbackAndUpdateWatcher(createWatcher, modifiedTime) {
7070
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
7066
7071
  sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7067
7072
  // Call the callback for current directory
7068
- callback("rename", "", modifiedTime);
7073
+ callback("rename", "");
7069
7074
  // If watcher is not closed, update it
7070
7075
  if (watcher) {
7071
7076
  watcher.close();
@@ -7111,14 +7116,13 @@ var ts;
7111
7116
  function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7112
7117
  // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7113
7118
  // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7114
- var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
7115
7119
  return event === "rename" &&
7116
7120
  (!relativeName ||
7117
7121
  relativeName === lastDirectoryPart ||
7118
7122
  (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7119
- modifiedTime === ts.missingFileModifiedTime ?
7120
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry, modifiedTime) :
7121
- callback(event, relativeName, modifiedTime);
7123
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7124
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7125
+ callback(event, relativeName);
7122
7126
  }
7123
7127
  /**
7124
7128
  * Watch the file or directory using fs.watchFile since fs.watch threw exception
@@ -7132,15 +7136,12 @@ var ts;
7132
7136
  * and switch to existing file or directory when the missing filesystem entry is created
7133
7137
  */
7134
7138
  function watchMissingFileSystemEntry() {
7135
- return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7136
- if (eventKind === FileWatcherEventKind.Created) {
7137
- modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7138
- if (modifiedTime !== ts.missingFileModifiedTime) {
7139
- // Call the callback for current file or directory
7140
- // For now it could be callback for the inner directory creation,
7141
- // but just return current directory, better than current no-op
7142
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry, modifiedTime);
7143
- }
7139
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7140
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7141
+ // Call the callback for current file or directory
7142
+ // For now it could be callback for the inner directory creation,
7143
+ // but just return current directory, better than current no-op
7144
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7144
7145
  }
7145
7146
  }, fallbackPollingInterval, fallbackOptions);
7146
7147
  }
@@ -7290,19 +7291,12 @@ var ts;
7290
7291
  }
7291
7292
  function getModifiedTime(path) {
7292
7293
  var _a;
7293
- // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7294
- // the CPU time performance.
7295
- var originalStackTraceLimit = Error.stackTraceLimit;
7296
- Error.stackTraceLimit = 0;
7297
7294
  try {
7298
7295
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7299
7296
  }
7300
7297
  catch (e) {
7301
7298
  return undefined;
7302
7299
  }
7303
- finally {
7304
- Error.stackTraceLimit = originalStackTraceLimit;
7305
- }
7306
7300
  }
7307
7301
  function setModifiedTime(path, time) {
7308
7302
  try {
@@ -8428,6 +8422,7 @@ var ts;
8428
8422
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8429
8423
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8430
8424
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8425
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8431
8426
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8432
8427
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8433
8428
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -9323,8 +9318,8 @@ var ts;
9323
9318
  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"),
9324
9319
  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"),
9325
9320
  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."),
9326
- 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}'"),
9327
- 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}'"),
9321
+ 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}'"),
9322
+ 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}'"),
9328
9323
  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"),
9329
9324
  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"),
9330
9325
  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"),
@@ -9368,8 +9363,6 @@ var ts;
9368
9363
  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}'."),
9369
9364
  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}'."),
9370
9365
  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."),
9371
- 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"),
9372
- 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"),
9373
9366
  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}'"),
9374
9367
  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."),
9375
9368
  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."),
@@ -20199,10 +20192,6 @@ var ts;
20199
20192
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20200
20193
  }
20201
20194
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20202
- function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20203
- return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20204
- }
20205
- ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20206
20195
  function getCompilerOptionValue(options, option) {
20207
20196
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20208
20197
  }
@@ -39243,7 +39232,6 @@ var ts;
39243
39232
  type: "boolean",
39244
39233
  affectsSemanticDiagnostics: true,
39245
39234
  affectsEmit: true,
39246
- affectsMultiFileEmitBuildInfo: true,
39247
39235
  category: ts.Diagnostics.Watch_and_Build_Modes,
39248
39236
  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,
39249
39237
  defaultValueDescription: false,
@@ -39278,40 +39266,12 @@ var ts;
39278
39266
  affectsSourceFile: true,
39279
39267
  affectsModuleResolution: true,
39280
39268
  affectsEmit: true,
39281
- affectsMultiFileEmitBuildInfo: true,
39282
39269
  paramType: ts.Diagnostics.VERSION,
39283
39270
  showInSimplifiedHelpView: true,
39284
39271
  category: ts.Diagnostics.Language_and_Environment,
39285
39272
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39286
39273
  defaultValueDescription: 0 /* ES3 */,
39287
39274
  };
39288
- /*@internal*/
39289
- ts.moduleOptionDeclaration = {
39290
- name: "module",
39291
- shortName: "m",
39292
- type: new ts.Map(ts.getEntries({
39293
- none: ts.ModuleKind.None,
39294
- commonjs: ts.ModuleKind.CommonJS,
39295
- amd: ts.ModuleKind.AMD,
39296
- system: ts.ModuleKind.System,
39297
- umd: ts.ModuleKind.UMD,
39298
- es6: ts.ModuleKind.ES2015,
39299
- es2015: ts.ModuleKind.ES2015,
39300
- es2020: ts.ModuleKind.ES2020,
39301
- es2022: ts.ModuleKind.ES2022,
39302
- esnext: ts.ModuleKind.ESNext,
39303
- node16: ts.ModuleKind.Node16,
39304
- nodenext: ts.ModuleKind.NodeNext,
39305
- })),
39306
- affectsModuleResolution: true,
39307
- affectsEmit: true,
39308
- affectsMultiFileEmitBuildInfo: true,
39309
- paramType: ts.Diagnostics.KIND,
39310
- showInSimplifiedHelpView: true,
39311
- category: ts.Diagnostics.Modules,
39312
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39313
- defaultValueDescription: undefined,
39314
- };
39315
39275
  var commandOptionsWithoutBuild = [
39316
39276
  // CommandLine only options
39317
39277
  {
@@ -39373,14 +39333,37 @@ var ts;
39373
39333
  category: ts.Diagnostics.Command_line_Options,
39374
39334
  affectsSemanticDiagnostics: true,
39375
39335
  affectsEmit: true,
39376
- affectsMultiFileEmitBuildInfo: true,
39377
39336
  isCommandLineOnly: true,
39378
39337
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39379
39338
  defaultValueDescription: false,
39380
39339
  },
39381
39340
  // Basic
39382
39341
  ts.targetOptionDeclaration,
39383
- ts.moduleOptionDeclaration,
39342
+ {
39343
+ name: "module",
39344
+ shortName: "m",
39345
+ type: new ts.Map(ts.getEntries({
39346
+ none: ts.ModuleKind.None,
39347
+ commonjs: ts.ModuleKind.CommonJS,
39348
+ amd: ts.ModuleKind.AMD,
39349
+ system: ts.ModuleKind.System,
39350
+ umd: ts.ModuleKind.UMD,
39351
+ es6: ts.ModuleKind.ES2015,
39352
+ es2015: ts.ModuleKind.ES2015,
39353
+ es2020: ts.ModuleKind.ES2020,
39354
+ es2022: ts.ModuleKind.ES2022,
39355
+ esnext: ts.ModuleKind.ESNext,
39356
+ node16: ts.ModuleKind.Node16,
39357
+ nodenext: ts.ModuleKind.NodeNext,
39358
+ })),
39359
+ affectsModuleResolution: true,
39360
+ affectsEmit: true,
39361
+ paramType: ts.Diagnostics.KIND,
39362
+ showInSimplifiedHelpView: true,
39363
+ category: ts.Diagnostics.Modules,
39364
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39365
+ defaultValueDescription: undefined,
39366
+ },
39384
39367
  {
39385
39368
  name: "lib",
39386
39369
  type: "list",
@@ -39417,7 +39400,6 @@ var ts;
39417
39400
  type: jsxOptionMap,
39418
39401
  affectsSourceFile: true,
39419
39402
  affectsEmit: true,
39420
- affectsMultiFileEmitBuildInfo: true,
39421
39403
  affectsModuleResolution: true,
39422
39404
  paramType: ts.Diagnostics.KIND,
39423
39405
  showInSimplifiedHelpView: true,
@@ -39430,7 +39412,6 @@ var ts;
39430
39412
  shortName: "d",
39431
39413
  type: "boolean",
39432
39414
  affectsEmit: true,
39433
- affectsMultiFileEmitBuildInfo: true,
39434
39415
  showInSimplifiedHelpView: true,
39435
39416
  category: ts.Diagnostics.Emit,
39436
39417
  transpileOptionValue: undefined,
@@ -39441,7 +39422,6 @@ var ts;
39441
39422
  name: "declarationMap",
39442
39423
  type: "boolean",
39443
39424
  affectsEmit: true,
39444
- affectsMultiFileEmitBuildInfo: true,
39445
39425
  showInSimplifiedHelpView: true,
39446
39426
  category: ts.Diagnostics.Emit,
39447
39427
  transpileOptionValue: undefined,
@@ -39452,7 +39432,6 @@ var ts;
39452
39432
  name: "emitDeclarationOnly",
39453
39433
  type: "boolean",
39454
39434
  affectsEmit: true,
39455
- affectsMultiFileEmitBuildInfo: true,
39456
39435
  showInSimplifiedHelpView: true,
39457
39436
  category: ts.Diagnostics.Emit,
39458
39437
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39463,7 +39442,6 @@ var ts;
39463
39442
  name: "sourceMap",
39464
39443
  type: "boolean",
39465
39444
  affectsEmit: true,
39466
- affectsMultiFileEmitBuildInfo: true,
39467
39445
  showInSimplifiedHelpView: true,
39468
39446
  category: ts.Diagnostics.Emit,
39469
39447
  defaultValueDescription: false,
@@ -39473,9 +39451,6 @@ var ts;
39473
39451
  name: "outFile",
39474
39452
  type: "string",
39475
39453
  affectsEmit: true,
39476
- affectsMultiFileEmitBuildInfo: true,
39477
- affectsDeclarationPath: true,
39478
- affectsBundleEmitBuildInfo: true,
39479
39454
  isFilePath: true,
39480
39455
  paramType: ts.Diagnostics.FILE,
39481
39456
  showInSimplifiedHelpView: true,
@@ -39487,8 +39462,6 @@ var ts;
39487
39462
  name: "outDir",
39488
39463
  type: "string",
39489
39464
  affectsEmit: true,
39490
- affectsMultiFileEmitBuildInfo: true,
39491
- affectsDeclarationPath: true,
39492
39465
  isFilePath: true,
39493
39466
  paramType: ts.Diagnostics.DIRECTORY,
39494
39467
  showInSimplifiedHelpView: true,
@@ -39499,8 +39472,6 @@ var ts;
39499
39472
  name: "rootDir",
39500
39473
  type: "string",
39501
39474
  affectsEmit: true,
39502
- affectsMultiFileEmitBuildInfo: true,
39503
- affectsDeclarationPath: true,
39504
39475
  isFilePath: true,
39505
39476
  paramType: ts.Diagnostics.LOCATION,
39506
39477
  category: ts.Diagnostics.Modules,
@@ -39511,8 +39482,6 @@ var ts;
39511
39482
  name: "composite",
39512
39483
  type: "boolean",
39513
39484
  affectsEmit: true,
39514
- affectsMultiFileEmitBuildInfo: true,
39515
- affectsBundleEmitBuildInfo: true,
39516
39485
  isTSConfigOnly: true,
39517
39486
  category: ts.Diagnostics.Projects,
39518
39487
  transpileOptionValue: undefined,
@@ -39523,8 +39492,6 @@ var ts;
39523
39492
  name: "tsBuildInfoFile",
39524
39493
  type: "string",
39525
39494
  affectsEmit: true,
39526
- affectsMultiFileEmitBuildInfo: true,
39527
- affectsBundleEmitBuildInfo: true,
39528
39495
  isFilePath: true,
39529
39496
  paramType: ts.Diagnostics.FILE,
39530
39497
  category: ts.Diagnostics.Projects,
@@ -39536,7 +39503,6 @@ var ts;
39536
39503
  name: "removeComments",
39537
39504
  type: "boolean",
39538
39505
  affectsEmit: true,
39539
- affectsMultiFileEmitBuildInfo: true,
39540
39506
  showInSimplifiedHelpView: true,
39541
39507
  category: ts.Diagnostics.Emit,
39542
39508
  defaultValueDescription: false,
@@ -39555,7 +39521,6 @@ var ts;
39555
39521
  name: "importHelpers",
39556
39522
  type: "boolean",
39557
39523
  affectsEmit: true,
39558
- affectsMultiFileEmitBuildInfo: true,
39559
39524
  category: ts.Diagnostics.Emit,
39560
39525
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39561
39526
  defaultValueDescription: false,
@@ -39569,7 +39534,6 @@ var ts;
39569
39534
  })),
39570
39535
  affectsEmit: true,
39571
39536
  affectsSemanticDiagnostics: true,
39572
- affectsMultiFileEmitBuildInfo: true,
39573
39537
  category: ts.Diagnostics.Emit,
39574
39538
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39575
39539
  defaultValueDescription: 0 /* Remove */,
@@ -39578,7 +39542,6 @@ var ts;
39578
39542
  name: "downlevelIteration",
39579
39543
  type: "boolean",
39580
39544
  affectsEmit: true,
39581
- affectsMultiFileEmitBuildInfo: true,
39582
39545
  category: ts.Diagnostics.Emit,
39583
39546
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39584
39547
  defaultValueDescription: false,
@@ -39597,9 +39560,6 @@ var ts;
39597
39560
  type: "boolean",
39598
39561
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39599
39562
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39600
- // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39601
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39602
- affectsMultiFileEmitBuildInfo: true,
39603
39563
  showInSimplifiedHelpView: true,
39604
39564
  category: ts.Diagnostics.Type_Checking,
39605
39565
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39609,7 +39569,6 @@ var ts;
39609
39569
  name: "noImplicitAny",
39610
39570
  type: "boolean",
39611
39571
  affectsSemanticDiagnostics: true,
39612
- affectsMultiFileEmitBuildInfo: true,
39613
39572
  strictFlag: true,
39614
39573
  category: ts.Diagnostics.Type_Checking,
39615
39574
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39619,7 +39578,6 @@ var ts;
39619
39578
  name: "strictNullChecks",
39620
39579
  type: "boolean",
39621
39580
  affectsSemanticDiagnostics: true,
39622
- affectsMultiFileEmitBuildInfo: true,
39623
39581
  strictFlag: true,
39624
39582
  category: ts.Diagnostics.Type_Checking,
39625
39583
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39628,8 +39586,6 @@ var ts;
39628
39586
  {
39629
39587
  name: "strictFunctionTypes",
39630
39588
  type: "boolean",
39631
- affectsSemanticDiagnostics: true,
39632
- affectsMultiFileEmitBuildInfo: true,
39633
39589
  strictFlag: true,
39634
39590
  category: ts.Diagnostics.Type_Checking,
39635
39591
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39638,8 +39594,6 @@ var ts;
39638
39594
  {
39639
39595
  name: "strictBindCallApply",
39640
39596
  type: "boolean",
39641
- affectsSemanticDiagnostics: true,
39642
- affectsMultiFileEmitBuildInfo: true,
39643
39597
  strictFlag: true,
39644
39598
  category: ts.Diagnostics.Type_Checking,
39645
39599
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39649,7 +39603,6 @@ var ts;
39649
39603
  name: "strictPropertyInitialization",
39650
39604
  type: "boolean",
39651
39605
  affectsSemanticDiagnostics: true,
39652
- affectsMultiFileEmitBuildInfo: true,
39653
39606
  strictFlag: true,
39654
39607
  category: ts.Diagnostics.Type_Checking,
39655
39608
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39659,7 +39612,6 @@ var ts;
39659
39612
  name: "noImplicitThis",
39660
39613
  type: "boolean",
39661
39614
  affectsSemanticDiagnostics: true,
39662
- affectsMultiFileEmitBuildInfo: true,
39663
39615
  strictFlag: true,
39664
39616
  category: ts.Diagnostics.Type_Checking,
39665
39617
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39669,7 +39621,6 @@ var ts;
39669
39621
  name: "useUnknownInCatchVariables",
39670
39622
  type: "boolean",
39671
39623
  affectsSemanticDiagnostics: true,
39672
- affectsMultiFileEmitBuildInfo: true,
39673
39624
  strictFlag: true,
39674
39625
  category: ts.Diagnostics.Type_Checking,
39675
39626
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39679,8 +39630,6 @@ var ts;
39679
39630
  name: "alwaysStrict",
39680
39631
  type: "boolean",
39681
39632
  affectsSourceFile: true,
39682
- affectsEmit: true,
39683
- affectsMultiFileEmitBuildInfo: true,
39684
39633
  strictFlag: true,
39685
39634
  category: ts.Diagnostics.Type_Checking,
39686
39635
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39691,7 +39640,6 @@ var ts;
39691
39640
  name: "noUnusedLocals",
39692
39641
  type: "boolean",
39693
39642
  affectsSemanticDiagnostics: true,
39694
- affectsMultiFileEmitBuildInfo: true,
39695
39643
  category: ts.Diagnostics.Type_Checking,
39696
39644
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39697
39645
  defaultValueDescription: false,
@@ -39700,7 +39648,6 @@ var ts;
39700
39648
  name: "noUnusedParameters",
39701
39649
  type: "boolean",
39702
39650
  affectsSemanticDiagnostics: true,
39703
- affectsMultiFileEmitBuildInfo: true,
39704
39651
  category: ts.Diagnostics.Type_Checking,
39705
39652
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39706
39653
  defaultValueDescription: false,
@@ -39709,7 +39656,6 @@ var ts;
39709
39656
  name: "exactOptionalPropertyTypes",
39710
39657
  type: "boolean",
39711
39658
  affectsSemanticDiagnostics: true,
39712
- affectsMultiFileEmitBuildInfo: true,
39713
39659
  category: ts.Diagnostics.Type_Checking,
39714
39660
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39715
39661
  defaultValueDescription: false,
@@ -39718,7 +39664,6 @@ var ts;
39718
39664
  name: "noImplicitReturns",
39719
39665
  type: "boolean",
39720
39666
  affectsSemanticDiagnostics: true,
39721
- affectsMultiFileEmitBuildInfo: true,
39722
39667
  category: ts.Diagnostics.Type_Checking,
39723
39668
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39724
39669
  defaultValueDescription: false,
@@ -39728,7 +39673,6 @@ var ts;
39728
39673
  type: "boolean",
39729
39674
  affectsBindDiagnostics: true,
39730
39675
  affectsSemanticDiagnostics: true,
39731
- affectsMultiFileEmitBuildInfo: true,
39732
39676
  category: ts.Diagnostics.Type_Checking,
39733
39677
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39734
39678
  defaultValueDescription: false,
@@ -39737,7 +39681,6 @@ var ts;
39737
39681
  name: "noUncheckedIndexedAccess",
39738
39682
  type: "boolean",
39739
39683
  affectsSemanticDiagnostics: true,
39740
- affectsMultiFileEmitBuildInfo: true,
39741
39684
  category: ts.Diagnostics.Type_Checking,
39742
39685
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39743
39686
  defaultValueDescription: false,
@@ -39746,7 +39689,6 @@ var ts;
39746
39689
  name: "noImplicitOverride",
39747
39690
  type: "boolean",
39748
39691
  affectsSemanticDiagnostics: true,
39749
- affectsMultiFileEmitBuildInfo: true,
39750
39692
  category: ts.Diagnostics.Type_Checking,
39751
39693
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39752
39694
  defaultValueDescription: false,
@@ -39754,8 +39696,6 @@ var ts;
39754
39696
  {
39755
39697
  name: "noPropertyAccessFromIndexSignature",
39756
39698
  type: "boolean",
39757
- affectsSemanticDiagnostics: true,
39758
- affectsMultiFileEmitBuildInfo: true,
39759
39699
  showInSimplifiedHelpView: false,
39760
39700
  category: ts.Diagnostics.Type_Checking,
39761
39701
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -39841,7 +39781,6 @@ var ts;
39841
39781
  name: "allowSyntheticDefaultImports",
39842
39782
  type: "boolean",
39843
39783
  affectsSemanticDiagnostics: true,
39844
- affectsMultiFileEmitBuildInfo: true,
39845
39784
  category: ts.Diagnostics.Interop_Constraints,
39846
39785
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
39847
39786
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -39851,7 +39790,6 @@ var ts;
39851
39790
  type: "boolean",
39852
39791
  affectsSemanticDiagnostics: true,
39853
39792
  affectsEmit: true,
39854
- affectsMultiFileEmitBuildInfo: true,
39855
39793
  showInSimplifiedHelpView: true,
39856
39794
  category: ts.Diagnostics.Interop_Constraints,
39857
39795
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -39868,7 +39806,6 @@ var ts;
39868
39806
  name: "allowUmdGlobalAccess",
39869
39807
  type: "boolean",
39870
39808
  affectsSemanticDiagnostics: true,
39871
- affectsMultiFileEmitBuildInfo: true,
39872
39809
  category: ts.Diagnostics.Modules,
39873
39810
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39874
39811
  defaultValueDescription: false,
@@ -39890,7 +39827,6 @@ var ts;
39890
39827
  name: "sourceRoot",
39891
39828
  type: "string",
39892
39829
  affectsEmit: true,
39893
- affectsMultiFileEmitBuildInfo: true,
39894
39830
  paramType: ts.Diagnostics.LOCATION,
39895
39831
  category: ts.Diagnostics.Emit,
39896
39832
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -39899,7 +39835,6 @@ var ts;
39899
39835
  name: "mapRoot",
39900
39836
  type: "string",
39901
39837
  affectsEmit: true,
39902
- affectsMultiFileEmitBuildInfo: true,
39903
39838
  paramType: ts.Diagnostics.LOCATION,
39904
39839
  category: ts.Diagnostics.Emit,
39905
39840
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -39908,7 +39843,6 @@ var ts;
39908
39843
  name: "inlineSourceMap",
39909
39844
  type: "boolean",
39910
39845
  affectsEmit: true,
39911
- affectsMultiFileEmitBuildInfo: true,
39912
39846
  category: ts.Diagnostics.Emit,
39913
39847
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
39914
39848
  defaultValueDescription: false,
@@ -39917,7 +39851,6 @@ var ts;
39917
39851
  name: "inlineSources",
39918
39852
  type: "boolean",
39919
39853
  affectsEmit: true,
39920
- affectsMultiFileEmitBuildInfo: true,
39921
39854
  category: ts.Diagnostics.Emit,
39922
39855
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
39923
39856
  defaultValueDescription: false,
@@ -39927,7 +39860,6 @@ var ts;
39927
39860
  name: "experimentalDecorators",
39928
39861
  type: "boolean",
39929
39862
  affectsSemanticDiagnostics: true,
39930
- affectsMultiFileEmitBuildInfo: true,
39931
39863
  category: ts.Diagnostics.Language_and_Environment,
39932
39864
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39933
39865
  defaultValueDescription: false,
@@ -39937,7 +39869,6 @@ var ts;
39937
39869
  type: "boolean",
39938
39870
  affectsSemanticDiagnostics: true,
39939
39871
  affectsEmit: true,
39940
- affectsMultiFileEmitBuildInfo: true,
39941
39872
  category: ts.Diagnostics.Language_and_Environment,
39942
39873
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39943
39874
  defaultValueDescription: false,
@@ -39962,7 +39893,6 @@ var ts;
39962
39893
  type: "string",
39963
39894
  affectsSemanticDiagnostics: true,
39964
39895
  affectsEmit: true,
39965
- affectsMultiFileEmitBuildInfo: true,
39966
39896
  affectsModuleResolution: true,
39967
39897
  category: ts.Diagnostics.Language_and_Environment,
39968
39898
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -39980,9 +39910,6 @@ var ts;
39980
39910
  name: "out",
39981
39911
  type: "string",
39982
39912
  affectsEmit: true,
39983
- affectsMultiFileEmitBuildInfo: true,
39984
- affectsDeclarationPath: true,
39985
- affectsBundleEmitBuildInfo: true,
39986
39913
  isFilePath: false,
39987
39914
  // for correct behaviour, please use outFile
39988
39915
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -39994,7 +39921,6 @@ var ts;
39994
39921
  name: "reactNamespace",
39995
39922
  type: "string",
39996
39923
  affectsEmit: true,
39997
- affectsMultiFileEmitBuildInfo: true,
39998
39924
  category: ts.Diagnostics.Language_and_Environment,
39999
39925
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
40000
39926
  defaultValueDescription: "`React`",
@@ -40002,8 +39928,6 @@ var ts;
40002
39928
  {
40003
39929
  name: "skipDefaultLibCheck",
40004
39930
  type: "boolean",
40005
- // We need to store these to determine whether `lib` files need to be rechecked
40006
- affectsMultiFileEmitBuildInfo: true,
40007
39931
  category: ts.Diagnostics.Completeness,
40008
39932
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
40009
39933
  defaultValueDescription: false,
@@ -40019,7 +39943,6 @@ var ts;
40019
39943
  name: "emitBOM",
40020
39944
  type: "boolean",
40021
39945
  affectsEmit: true,
40022
- affectsMultiFileEmitBuildInfo: true,
40023
39946
  category: ts.Diagnostics.Emit,
40024
39947
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
40025
39948
  defaultValueDescription: false,
@@ -40031,7 +39954,6 @@ var ts;
40031
39954
  lf: 1 /* LineFeed */
40032
39955
  })),
40033
39956
  affectsEmit: true,
40034
- affectsMultiFileEmitBuildInfo: true,
40035
39957
  paramType: ts.Diagnostics.NEWLINE,
40036
39958
  category: ts.Diagnostics.Emit,
40037
39959
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -40041,7 +39963,6 @@ var ts;
40041
39963
  name: "noErrorTruncation",
40042
39964
  type: "boolean",
40043
39965
  affectsSemanticDiagnostics: true,
40044
- affectsMultiFileEmitBuildInfo: true,
40045
39966
  category: ts.Diagnostics.Output_Formatting,
40046
39967
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
40047
39968
  defaultValueDescription: false,
@@ -40072,7 +39993,6 @@ var ts;
40072
39993
  name: "stripInternal",
40073
39994
  type: "boolean",
40074
39995
  affectsEmit: true,
40075
- affectsMultiFileEmitBuildInfo: true,
40076
39996
  category: ts.Diagnostics.Emit,
40077
39997
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40078
39998
  defaultValueDescription: false,
@@ -40113,7 +40033,6 @@ var ts;
40113
40033
  name: "noImplicitUseStrict",
40114
40034
  type: "boolean",
40115
40035
  affectsSemanticDiagnostics: true,
40116
- affectsMultiFileEmitBuildInfo: true,
40117
40036
  category: ts.Diagnostics.Backwards_Compatibility,
40118
40037
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40119
40038
  defaultValueDescription: false,
@@ -40122,7 +40041,6 @@ var ts;
40122
40041
  name: "noEmitHelpers",
40123
40042
  type: "boolean",
40124
40043
  affectsEmit: true,
40125
- affectsMultiFileEmitBuildInfo: true,
40126
40044
  category: ts.Diagnostics.Emit,
40127
40045
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40128
40046
  defaultValueDescription: false,
@@ -40131,7 +40049,6 @@ var ts;
40131
40049
  name: "noEmitOnError",
40132
40050
  type: "boolean",
40133
40051
  affectsEmit: true,
40134
- affectsMultiFileEmitBuildInfo: true,
40135
40052
  category: ts.Diagnostics.Emit,
40136
40053
  transpileOptionValue: undefined,
40137
40054
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40141,7 +40058,6 @@ var ts;
40141
40058
  name: "preserveConstEnums",
40142
40059
  type: "boolean",
40143
40060
  affectsEmit: true,
40144
- affectsMultiFileEmitBuildInfo: true,
40145
40061
  category: ts.Diagnostics.Emit,
40146
40062
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40147
40063
  defaultValueDescription: false,
@@ -40150,8 +40066,6 @@ var ts;
40150
40066
  name: "declarationDir",
40151
40067
  type: "string",
40152
40068
  affectsEmit: true,
40153
- affectsMultiFileEmitBuildInfo: true,
40154
- affectsDeclarationPath: true,
40155
40069
  isFilePath: true,
40156
40070
  paramType: ts.Diagnostics.DIRECTORY,
40157
40071
  category: ts.Diagnostics.Emit,
@@ -40161,8 +40075,6 @@ var ts;
40161
40075
  {
40162
40076
  name: "skipLibCheck",
40163
40077
  type: "boolean",
40164
- // We need to store these to determine whether `lib` files need to be rechecked
40165
- affectsMultiFileEmitBuildInfo: true,
40166
40078
  category: ts.Diagnostics.Completeness,
40167
40079
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40168
40080
  defaultValueDescription: false,
@@ -40172,7 +40084,6 @@ var ts;
40172
40084
  type: "boolean",
40173
40085
  affectsBindDiagnostics: true,
40174
40086
  affectsSemanticDiagnostics: true,
40175
- affectsMultiFileEmitBuildInfo: true,
40176
40087
  category: ts.Diagnostics.Type_Checking,
40177
40088
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40178
40089
  defaultValueDescription: undefined,
@@ -40182,7 +40093,6 @@ var ts;
40182
40093
  type: "boolean",
40183
40094
  affectsBindDiagnostics: true,
40184
40095
  affectsSemanticDiagnostics: true,
40185
- affectsMultiFileEmitBuildInfo: true,
40186
40096
  category: ts.Diagnostics.Type_Checking,
40187
40097
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40188
40098
  defaultValueDescription: undefined,
@@ -40191,7 +40101,6 @@ var ts;
40191
40101
  name: "suppressExcessPropertyErrors",
40192
40102
  type: "boolean",
40193
40103
  affectsSemanticDiagnostics: true,
40194
- affectsMultiFileEmitBuildInfo: true,
40195
40104
  category: ts.Diagnostics.Backwards_Compatibility,
40196
40105
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40197
40106
  defaultValueDescription: false,
@@ -40200,7 +40109,6 @@ var ts;
40200
40109
  name: "suppressImplicitAnyIndexErrors",
40201
40110
  type: "boolean",
40202
40111
  affectsSemanticDiagnostics: true,
40203
- affectsMultiFileEmitBuildInfo: true,
40204
40112
  category: ts.Diagnostics.Backwards_Compatibility,
40205
40113
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40206
40114
  defaultValueDescription: false,
@@ -40225,7 +40133,6 @@ var ts;
40225
40133
  name: "noStrictGenericChecks",
40226
40134
  type: "boolean",
40227
40135
  affectsSemanticDiagnostics: true,
40228
- affectsMultiFileEmitBuildInfo: true,
40229
40136
  category: ts.Diagnostics.Backwards_Compatibility,
40230
40137
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40231
40138
  defaultValueDescription: false,
@@ -40235,7 +40142,6 @@ var ts;
40235
40142
  type: "boolean",
40236
40143
  affectsSemanticDiagnostics: true,
40237
40144
  affectsEmit: true,
40238
- affectsMultiFileEmitBuildInfo: true,
40239
40145
  category: ts.Diagnostics.Language_and_Environment,
40240
40146
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40241
40147
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40244,7 +40150,6 @@ var ts;
40244
40150
  name: "preserveValueImports",
40245
40151
  type: "boolean",
40246
40152
  affectsEmit: true,
40247
- affectsMultiFileEmitBuildInfo: true,
40248
40153
  category: ts.Diagnostics.Emit,
40249
40154
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40250
40155
  defaultValueDescription: false,
@@ -40288,8 +40193,6 @@ var ts;
40288
40193
  /* @internal */
40289
40194
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40290
40195
  /* @internal */
40291
- ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40292
- /* @internal */
40293
40196
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40294
40197
  /* @internal */
40295
40198
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41145,7 +41048,6 @@ var ts;
41145
41048
  return optionDefinition.type;
41146
41049
  }
41147
41050
  }
41148
- /* @internal */
41149
41051
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41150
41052
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41151
41053
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41154,7 +41056,6 @@ var ts;
41154
41056
  }
41155
41057
  });
41156
41058
  }
41157
- ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41158
41059
  function serializeCompilerOptions(options, pathOptions) {
41159
41060
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41160
41061
  }
@@ -48655,6 +48556,7 @@ var ts;
48655
48556
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48656
48557
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48657
48558
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48559
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48658
48560
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48659
48561
  emptyGenericType.instantiations = new ts.Map();
48660
48562
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -58825,7 +58727,7 @@ var ts;
58825
58727
  }
58826
58728
  }
58827
58729
  }
58828
- else if (t.flags & 469892092 /* DisjointDomains */) {
58730
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58829
58731
  hasDisjointDomainType = true;
58830
58732
  }
58831
58733
  }
@@ -58837,7 +58739,7 @@ var ts;
58837
58739
  // intersection operation to reduce the union constraints.
58838
58740
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58839
58741
  var t = types_6[_a];
58840
- if (t.flags & 469892092 /* DisjointDomains */) {
58742
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58841
58743
  constraints = ts.append(constraints, t);
58842
58744
  }
58843
58745
  }
@@ -61386,7 +61288,7 @@ var ts;
61386
61288
  }
61387
61289
  return includes;
61388
61290
  }
61389
- function removeRedundantPrimitiveTypes(types, includes) {
61291
+ function removeRedundantSupertypes(types, includes) {
61390
61292
  var i = types.length;
61391
61293
  while (i > 0) {
61392
61294
  i--;
@@ -61394,7 +61296,9 @@ var ts;
61394
61296
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61395
61297
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61396
61298
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61397
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61299
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61300
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61301
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61398
61302
  if (remove) {
61399
61303
  ts.orderedRemoveItemAt(types, i);
61400
61304
  }
@@ -61516,7 +61420,7 @@ var ts;
61516
61420
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61517
61421
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61518
61422
  // for intersections of types with signatures can be deterministic.
61519
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61423
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61520
61424
  var typeMembershipMap = new ts.Map();
61521
61425
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61522
61426
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61553,11 +61457,11 @@ var ts;
61553
61457
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61554
61458
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61555
61459
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61556
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61557
- removeRedundantPrimitiveTypes(typeSet, includes);
61558
- }
61559
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61560
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61460
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61461
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61462
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61463
+ if (!noSupertypeReduction)
61464
+ removeRedundantSupertypes(typeSet, includes);
61561
61465
  }
61562
61466
  if (includes & 262144 /* IncludesMissingType */) {
61563
61467
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61596,8 +61500,9 @@ var ts;
61596
61500
  }
61597
61501
  var constituents = getCrossProductIntersections(typeSet);
61598
61502
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61599
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61600
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61503
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61504
+ // the denormalized origin has fewer constituents than the union itself.
61505
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61601
61506
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61602
61507
  }
61603
61508
  }
@@ -61640,11 +61545,21 @@ var ts;
61640
61545
  }
61641
61546
  return intersections;
61642
61547
  }
61548
+ function getConstituentCount(type) {
61549
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61550
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61551
+ getConstituentCountOfTypes(type.types);
61552
+ }
61553
+ function getConstituentCountOfTypes(types) {
61554
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61555
+ }
61643
61556
  function getTypeFromIntersectionTypeNode(node) {
61644
61557
  var links = getNodeLinks(node);
61645
61558
  if (!links.resolvedType) {
61646
61559
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61647
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61560
+ var types = ts.map(node.types, getTypeFromTypeNode);
61561
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61562
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61648
61563
  }
61649
61564
  return links.resolvedType;
61650
61565
  }
@@ -64430,6 +64345,17 @@ var ts;
64430
64345
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64431
64346
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64432
64347
  }
64348
+ function isUnknownLikeUnionType(type) {
64349
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64350
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64351
+ var types = type.types;
64352
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64353
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64354
+ }
64355
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64356
+ }
64357
+ return false;
64358
+ }
64433
64359
  function isStringIndexSignatureOnlyType(type) {
64434
64360
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64435
64361
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64509,7 +64435,7 @@ var ts;
64509
64435
  return true;
64510
64436
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64511
64437
  return true;
64512
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64438
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64513
64439
  return true;
64514
64440
  if (relation === assignableRelation || relation === comparableRelation) {
64515
64441
  if (s & 1 /* Any */)
@@ -64519,6 +64445,9 @@ var ts;
64519
64445
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64520
64446
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64521
64447
  return true;
64448
+ // Anything is assignable to a union containing undefined, null, and {}
64449
+ if (isUnknownLikeUnionType(target))
64450
+ return true;
64522
64451
  }
64523
64452
  return false;
64524
64453
  }
@@ -64561,16 +64490,27 @@ var ts;
64561
64490
  function getNormalizedType(type, writing) {
64562
64491
  while (true) {
64563
64492
  var t = isFreshLiteralType(type) ? type.regularType :
64564
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64565
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64493
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64494
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64566
64495
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64567
64496
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64568
64497
  type;
64569
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64570
64498
  if (t === type)
64571
- break;
64499
+ return t;
64572
64500
  type = t;
64573
64501
  }
64502
+ }
64503
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64504
+ var reduced = getReducedType(type);
64505
+ if (reduced !== type) {
64506
+ return reduced;
64507
+ }
64508
+ if (type.flags & 2097152 /* Intersection */) {
64509
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64510
+ if (normalizedTypes !== type.types) {
64511
+ return getIntersectionType(normalizedTypes);
64512
+ }
64513
+ }
64574
64514
  return type;
64575
64515
  }
64576
64516
  /**
@@ -65017,6 +64957,7 @@ var ts;
65017
64957
  return 0 /* False */;
65018
64958
  }
65019
64959
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64960
+ var _a, _b;
65020
64961
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
65021
64962
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
65022
64963
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -65057,6 +64998,9 @@ var ts;
65057
64998
  return;
65058
64999
  }
65059
65000
  reportRelationError(headMessage, source, target);
65001
+ if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65002
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65003
+ }
65060
65004
  }
65061
65005
  function traceUnionsOrIntersectionsTooLarge(source, target) {
65062
65006
  if (!ts.tracing) {
@@ -65843,13 +65787,6 @@ var ts;
65843
65787
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65844
65788
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65845
65789
  var constraint = getConstraintOfType(source) || unknownType;
65846
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65847
- // A type variable with no constraint is not related to the non-primitive object type.
65848
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65849
- resetErrorInfo(saveErrorInfo);
65850
- return result;
65851
- }
65852
- }
65853
65790
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
65854
65791
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65855
65792
  resetErrorInfo(saveErrorInfo);
@@ -67323,9 +67260,11 @@ var ts;
67323
67260
  return getSupertypeOrUnion(types);
67324
67261
  }
67325
67262
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67326
- return primaryTypes.length ?
67327
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67328
- getUnionType(types, 2 /* Subtype */);
67263
+ if (primaryTypes.length) {
67264
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67265
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67266
+ }
67267
+ return getUnionType(types, 2 /* Subtype */);
67329
67268
  }
67330
67269
  // Return the leftmost type for which no type to the right is a subtype.
67331
67270
  function getCommonSubtype(types) {
@@ -67524,12 +67463,13 @@ var ts;
67524
67463
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67525
67464
  // no flags for all other types (including non-falsy literal types).
67526
67465
  function getFalsyFlags(type) {
67527
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67528
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67529
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67530
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67531
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67532
- type.flags & 117724 /* PossiblyFalsy */;
67466
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67467
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67468
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67469
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67470
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67471
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67472
+ t.flags & 117724 /* PossiblyFalsy */;
67533
67473
  }
67534
67474
  function removeDefinitelyFalsyTypes(type) {
67535
67475
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67569,20 +67509,22 @@ var ts;
67569
67509
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67570
67510
  }
67571
67511
  function getGlobalNonNullableTypeInstantiation(type) {
67572
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67573
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67574
- // that isn't eliminated by a NonNullable<T> instantiation.
67575
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67576
67512
  if (!deferredGlobalNonNullableTypeAlias) {
67577
67513
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67578
67514
  }
67579
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67580
67515
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67581
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67582
- reducedType;
67516
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67517
+ getIntersectionType([type, emptyObjectType]);
67583
67518
  }
67584
67519
  function getNonNullableType(type) {
67585
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67520
+ if (strictNullChecks) {
67521
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67522
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67523
+ // that isn't eliminated by a NonNullable<T> instantiation.
67524
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67525
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67526
+ }
67527
+ return type;
67586
67528
  }
67587
67529
  function addOptionalTypeMarker(type) {
67588
67530
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -69690,6 +69632,24 @@ var ts;
69690
69632
  function getTypeWithFacts(type, include) {
69691
69633
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69692
69634
  }
69635
+ function getIntersectionWithFacts(type, facts) {
69636
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69637
+ if (strictNullChecks) {
69638
+ switch (facts) {
69639
+ case 524288 /* NEUndefined */:
69640
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
69641
+ case 1048576 /* NENull */:
69642
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
69643
+ case 2097152 /* NEUndefinedOrNull */:
69644
+ case 4194304 /* Truthy */:
69645
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69646
+ }
69647
+ }
69648
+ return reduced;
69649
+ }
69650
+ function recombineUnknownType(type) {
69651
+ return type === unknownUnionType ? unknownType : type;
69652
+ }
69693
69653
  function getTypeWithDefault(type, defaultExpression) {
69694
69654
  return defaultExpression ?
69695
69655
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70747,7 +70707,7 @@ var ts;
70747
70707
  if (isEvolvingArrayTypeList(types)) {
70748
70708
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70749
70709
  }
70750
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70710
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70751
70711
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70752
70712
  return declaredType;
70753
70713
  }
@@ -70849,8 +70809,7 @@ var ts;
70849
70809
  }
70850
70810
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70851
70811
  if (isMatchingReference(reference, expr)) {
70852
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70853
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70812
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70854
70813
  }
70855
70814
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70856
70815
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -71003,9 +70962,6 @@ var ts;
71003
70962
  assumeTrue = !assumeTrue;
71004
70963
  }
71005
70964
  var valueType = getTypeOfExpression(value);
71006
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
71007
- return getUnionType([nullType, undefinedType]);
71008
- }
71009
70965
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
71010
70966
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
71011
70967
  return valueType;
@@ -71025,7 +70981,7 @@ var ts;
71025
70981
  valueType.flags & 65536 /* Null */ ?
71026
70982
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
71027
70983
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
71028
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
70984
+ return getIntersectionWithFacts(type, facts);
71029
70985
  }
71030
70986
  if (assumeTrue) {
71031
70987
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -71053,17 +71009,11 @@ var ts;
71053
71009
  if (type.flags & 1 /* Any */ && literal.text === "function") {
71054
71010
  return type;
71055
71011
  }
71056
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
71057
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
71058
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
71059
- // unknown type, and then narrows that to the non-primitive type.
71060
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
71061
- }
71062
71012
  var facts = assumeTrue ?
71063
71013
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71064
71014
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71065
71015
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71066
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71016
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71067
71017
  }
71068
71018
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71069
71019
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71112,10 +71062,10 @@ var ts;
71112
71062
  }
71113
71063
  function getImpliedTypeFromTypeofGuard(type, text) {
71114
71064
  switch (text) {
71065
+ case "object":
71066
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71115
71067
  case "function":
71116
71068
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
71117
- case "object":
71118
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71119
71069
  default:
71120
71070
  return typeofTypesByName.get(text);
71121
71071
  }
@@ -71126,22 +71076,27 @@ var ts;
71126
71076
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71127
71077
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71128
71078
  // filtering by type-facts.
71129
- function narrowUnionMemberByTypeof(candidate) {
71130
- return function (type) {
71131
- if (isTypeSubtypeOf(type, candidate)) {
71132
- return type;
71133
- }
71134
- if (isTypeSubtypeOf(candidate, type)) {
71135
- return candidate;
71079
+ function narrowTypeByImpliedType(type, candidate) {
71080
+ if (type.flags & 3 /* AnyOrUnknown */) {
71081
+ return candidate;
71082
+ }
71083
+ return mapType(type, function (t) {
71084
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71085
+ return t;
71136
71086
  }
71137
- if (type.flags & 465829888 /* Instantiable */) {
71138
- var constraint = getBaseConstraintOfType(type) || anyType;
71139
- if (isTypeSubtypeOf(candidate, constraint)) {
71140
- return getIntersectionType([type, candidate]);
71087
+ return mapType(candidate, function (c) {
71088
+ if (!areTypesComparable(t, c)) {
71089
+ return neverType;
71141
71090
  }
71142
- }
71143
- return type;
71144
- };
71091
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71092
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71093
+ }
71094
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71095
+ return c;
71096
+ }
71097
+ return getIntersectionType([t, c]);
71098
+ });
71099
+ });
71145
71100
  }
71146
71101
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71147
71102
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71200,7 +71155,7 @@ var ts;
71200
71155
  because it is caught in the first clause.
71201
71156
  */
71202
71157
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71203
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71158
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71204
71159
  }
71205
71160
  function isMatchingConstructorReference(expr) {
71206
71161
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71504,7 +71459,9 @@ var ts;
71504
71459
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71505
71460
  }
71506
71461
  function isGenericTypeWithUnionConstraint(type) {
71507
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71462
+ return type.flags & 2097152 /* Intersection */ ?
71463
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71464
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71508
71465
  }
71509
71466
  function isGenericTypeWithoutNullableConstraint(type) {
71510
71467
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71532,7 +71489,7 @@ var ts;
71532
71489
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71533
71490
  someType(type, isGenericTypeWithUnionConstraint) &&
71534
71491
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71535
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71492
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71536
71493
  }
71537
71494
  function isExportOrExportExpression(location) {
71538
71495
  return !!ts.findAncestor(location, function (n) {
@@ -82632,7 +82589,7 @@ var ts;
82632
82589
  // For a binding pattern, validate the initializer and exit
82633
82590
  if (ts.isBindingPattern(node.name)) {
82634
82591
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82635
- var needCheckWidenedType = node.name.elements.length === 0;
82592
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82636
82593
  if (needCheckInitializer || needCheckWidenedType) {
82637
82594
  // Don't validate for-in initializer as it is already an error
82638
82595
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -110380,8 +110337,7 @@ var ts;
110380
110337
  return;
110381
110338
  }
110382
110339
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110383
- var buildInfo = { bundle: bundle, program: program, version: version };
110384
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110340
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110385
110341
  }
110386
110342
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110387
110343
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110535,18 +110491,13 @@ var ts;
110535
110491
  if (sourceMapFilePath) {
110536
110492
  var sourceMap = sourceMapGenerator.toString();
110537
110493
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
110538
- if (printer.bundleFileInfo)
110539
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110540
110494
  }
110541
110495
  }
110542
110496
  else {
110543
110497
  writer.writeLine();
110544
110498
  }
110545
110499
  // Write the output file
110546
- var text = writer.getText();
110547
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110548
- if (printer.bundleFileInfo)
110549
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110500
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110550
110501
  // Reset state
110551
110502
  writer.clear();
110552
110503
  }
@@ -110689,54 +110640,34 @@ var ts;
110689
110640
  }
110690
110641
  /*@internal*/
110691
110642
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
110692
- var createHash = ts.maybeBind(host, host.createHash);
110693
110643
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
110694
- var buildInfo;
110695
- if (host.getBuildInfo) {
110696
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
110697
- if (!hostBuildInfo)
110698
- return buildInfoPath;
110699
- buildInfo = hostBuildInfo;
110700
- }
110701
- else {
110702
- var buildInfoText = host.readFile(buildInfoPath);
110703
- if (!buildInfoText)
110704
- return buildInfoPath;
110705
- buildInfo = getBuildInfo(buildInfoText);
110706
- }
110707
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
110644
+ var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
110645
+ if (!buildInfoText)
110708
110646
  return buildInfoPath;
110709
110647
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
110710
110648
  if (!jsFileText)
110711
110649
  return jsFilePath;
110712
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
110713
- return jsFilePath;
110714
110650
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
110715
110651
  // error if no source map or for now if inline sourcemap
110716
110652
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
110717
110653
  return sourceMapFilePath || "inline sourcemap decoding";
110718
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
110719
- return sourceMapFilePath;
110720
110654
  // read declaration text
110721
110655
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
110722
110656
  if (declarationFilePath && !declarationText)
110723
110657
  return declarationFilePath;
110724
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
110725
- return declarationFilePath;
110726
110658
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
110727
110659
  // error if no source map or for now if inline sourcemap
110728
110660
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
110729
110661
  return declarationMapPath || "inline sourcemap decoding";
110730
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
110731
- return declarationMapPath;
110662
+ var buildInfo = getBuildInfo(buildInfoText);
110663
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
110664
+ return buildInfoPath;
110732
110665
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110733
110666
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
110734
110667
  /*onlyOwnText*/ true);
110735
110668
  var outputFiles = [];
110736
110669
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
110737
110670
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
110738
- var changedDtsText;
110739
- var changedDtsData;
110740
110671
  var emitHost = {
110741
110672
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
110742
110673
  getCanonicalFileName: host.getCanonicalFileName,
@@ -110752,7 +110683,7 @@ var ts;
110752
110683
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
110753
110684
  getProjectReferenceRedirect: ts.returnUndefined,
110754
110685
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
110755
- writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
110686
+ writeFile: function (name, text, writeByteOrderMark) {
110756
110687
  switch (name) {
110757
110688
  case jsFilePath:
110758
110689
  if (jsFileText === text)
@@ -110763,13 +110694,8 @@ var ts;
110763
110694
  return;
110764
110695
  break;
110765
110696
  case buildInfoPath:
110766
- var newBuildInfo = data.buildInfo;
110697
+ var newBuildInfo = getBuildInfo(text);
110767
110698
  newBuildInfo.program = buildInfo.program;
110768
- if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
110769
- // Update the output signature
110770
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
110771
- newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
110772
- }
110773
110699
  // Update sourceFileInfo
110774
110700
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
110775
110701
  newBuildInfo.bundle.js.sources = js.sources;
@@ -110777,13 +110703,11 @@ var ts;
110777
110703
  newBuildInfo.bundle.dts.sources = dts.sources;
110778
110704
  }
110779
110705
  newBuildInfo.bundle.sourceFiles = sourceFiles;
110780
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
110706
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
110781
110707
  return;
110782
110708
  case declarationFilePath:
110783
110709
  if (declarationText === text)
110784
110710
  return;
110785
- changedDtsText = text;
110786
- changedDtsData = data;
110787
110711
  break;
110788
110712
  case declarationMapPath:
110789
110713
  if (declarationMapText === text)
@@ -110802,7 +110726,6 @@ var ts;
110802
110726
  getSourceFileFromReference: ts.returnUndefined,
110803
110727
  redirectTargetsMap: ts.createMultiMap(),
110804
110728
  getFileIncludeReasons: ts.notImplemented,
110805
- createHash: createHash,
110806
110729
  };
110807
110730
  emitFiles(ts.notImplementedResolver, emitHost,
110808
110731
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -115887,10 +115810,12 @@ var ts;
115887
115810
  }
115888
115811
  ts.createCompilerHost = createCompilerHost;
115889
115812
  /*@internal*/
115813
+ // TODO(shkamat): update this after reworking ts build API
115890
115814
  function createCompilerHostWorker(options, setParentNodes, system) {
115891
115815
  if (system === void 0) { system = ts.sys; }
115892
115816
  var existingDirectories = new ts.Map();
115893
115817
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
115818
+ var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
115894
115819
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
115895
115820
  var text;
115896
115821
  try {
@@ -115923,7 +115848,7 @@ var ts;
115923
115848
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
115924
115849
  // the system.writeFile will do its own directory creation and
115925
115850
  // the ensureDirectoriesExist call will always be redundant.
115926
- 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); });
115851
+ 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); });
115927
115852
  ts.performance.mark("afterIOWrite");
115928
115853
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
115929
115854
  }
@@ -115933,6 +115858,35 @@ var ts;
115933
115858
  }
115934
115859
  }
115935
115860
  }
115861
+ var outputFingerprints;
115862
+ function writeFileWorker(fileName, data, writeByteOrderMark) {
115863
+ if (!ts.isWatchSet(options) || !system.getModifiedTime) {
115864
+ system.writeFile(fileName, data, writeByteOrderMark);
115865
+ return;
115866
+ }
115867
+ if (!outputFingerprints) {
115868
+ outputFingerprints = new ts.Map();
115869
+ }
115870
+ var hash = computeHash(data);
115871
+ var mtimeBefore = system.getModifiedTime(fileName);
115872
+ if (mtimeBefore) {
115873
+ var fingerprint = outputFingerprints.get(fileName);
115874
+ // If output has not been changed, and the file has no external modification
115875
+ if (fingerprint &&
115876
+ fingerprint.byteOrderMark === writeByteOrderMark &&
115877
+ fingerprint.hash === hash &&
115878
+ fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
115879
+ return;
115880
+ }
115881
+ }
115882
+ system.writeFile(fileName, data, writeByteOrderMark);
115883
+ var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
115884
+ outputFingerprints.set(fileName, {
115885
+ hash: hash,
115886
+ byteOrderMark: writeByteOrderMark,
115887
+ mtime: mtimeAfter
115888
+ });
115889
+ }
115936
115890
  function getDefaultLibLocation() {
115937
115891
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
115938
115892
  }
@@ -117522,7 +117476,6 @@ var ts;
117522
117476
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117523
117477
  redirectTargetsMap: redirectTargetsMap,
117524
117478
  getFileIncludeReasons: program.getFileIncludeReasons,
117525
- createHash: ts.maybeBind(host, host.createHash),
117526
117479
  };
117527
117480
  }
117528
117481
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -119636,9 +119589,13 @@ var ts;
119636
119589
  function createManyToManyPathMap() {
119637
119590
  function create(forward, reverse, deleted) {
119638
119591
  var map = {
119592
+ clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
119593
+ forEach: function (fn) { return forward.forEach(fn); },
119639
119594
  getKeys: function (v) { return reverse.get(v); },
119640
119595
  getValues: function (k) { return forward.get(k); },
119596
+ hasKey: function (k) { return forward.has(k); },
119641
119597
  keys: function () { return forward.keys(); },
119598
+ deletedKeys: function () { return deleted; },
119642
119599
  deleteKey: function (k) {
119643
119600
  (deleted || (deleted = new ts.Set())).add(k);
119644
119601
  var set = forward.get(k);
@@ -119665,6 +119622,11 @@ var ts;
119665
119622
  });
119666
119623
  return map;
119667
119624
  },
119625
+ clear: function () {
119626
+ forward.clear();
119627
+ reverse.clear();
119628
+ deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119629
+ }
119668
119630
  };
119669
119631
  return map;
119670
119632
  }
@@ -119792,21 +119754,18 @@ var ts;
119792
119754
  * Creates the state of file references and signature for the new program from oldState if it is safe
119793
119755
  */
119794
119756
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
119795
- var _a, _b, _c;
119796
119757
  var fileInfos = new ts.Map();
119797
119758
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
119798
119759
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
119760
+ var hasCalledUpdateShapeSignature = new ts.Set();
119799
119761
  var useOldState = canReuseOldState(referencedMap, oldState);
119800
119762
  // Ensure source files have parent pointers set
119801
119763
  newProgram.getTypeChecker();
119802
119764
  // Create the reference map, and set the file infos
119803
- for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
119804
- var sourceFile = _d[_i];
119765
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
119766
+ var sourceFile = _a[_i];
119805
119767
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
119806
- var oldUncommitedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
119807
- var signature = oldUncommitedSignature === undefined ?
119808
- useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
119809
- oldUncommitedSignature || undefined;
119768
+ var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
119810
119769
  if (referencedMap) {
119811
119770
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
119812
119771
  if (newReferences) {
@@ -119814,26 +119773,19 @@ var ts;
119814
119773
  }
119815
119774
  // Copy old visible to outside files map
119816
119775
  if (useOldState) {
119817
- var oldUncommitedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
119818
- var exportedModules = oldUncommitedExportedModules === undefined ?
119819
- oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
119820
- oldUncommitedExportedModules || undefined;
119776
+ var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
119821
119777
  if (exportedModules) {
119822
119778
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119823
119779
  }
119824
119780
  }
119825
119781
  }
119826
- fileInfos.set(sourceFile.resolvedPath, {
119827
- version: version_2,
119828
- signature: signature,
119829
- affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
119830
- impliedFormat: sourceFile.impliedNodeFormat
119831
- });
119782
+ fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
119832
119783
  }
119833
119784
  return {
119834
119785
  fileInfos: fileInfos,
119835
119786
  referencedMap: referencedMap,
119836
119787
  exportedModulesMap: exportedModulesMap,
119788
+ hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
119837
119789
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
119838
119790
  };
119839
119791
  }
@@ -119847,42 +119799,71 @@ var ts;
119847
119799
  }
119848
119800
  BuilderState.releaseCache = releaseCache;
119849
119801
  /**
119850
- * Gets the files affected by the path from the program
119802
+ * Creates a clone of the state
119851
119803
  */
119852
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
119804
+ function clone(state) {
119853
119805
  var _a, _b;
119854
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
119855
- (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
119856
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
119857
- return result;
119806
+ // Dont need to backup allFiles info since its cache anyway
119807
+ return {
119808
+ fileInfos: new ts.Map(state.fileInfos),
119809
+ referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
119810
+ exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
119811
+ hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
119812
+ useFileVersionAsSignature: state.useFileVersionAsSignature,
119813
+ };
119858
119814
  }
119859
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119860
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
119815
+ BuilderState.clone = clone;
119816
+ /**
119817
+ * Gets the files affected by the path from the program
119818
+ */
119819
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
119820
+ // Since the operation could be cancelled, the signatures are always stored in the cache
119821
+ // They will be committed once it is safe to use them
119822
+ // eg when calling this api from tsserver, if there is no cancellation of the operation
119823
+ // In the other cases the affected files signatures are committed only after the iteration through the result is complete
119824
+ var signatureCache = cacheToUpdateSignature || new ts.Map();
119861
119825
  var sourceFile = programOfThisState.getSourceFileByPath(path);
119862
119826
  if (!sourceFile) {
119863
119827
  return ts.emptyArray;
119864
119828
  }
119865
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
119829
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
119866
119830
  return [sourceFile];
119867
119831
  }
119868
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
119832
+ var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
119833
+ if (!cacheToUpdateSignature) {
119834
+ // Commit all the signatures in the signature cache
119835
+ updateSignaturesFromCache(state, signatureCache);
119836
+ }
119837
+ return result;
119869
119838
  }
119870
- BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
119839
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
119840
+ /**
119841
+ * Updates the signatures from the cache into state's fileinfo signatures
119842
+ * This should be called whenever it is safe to commit the state of the builder
119843
+ */
119844
+ function updateSignaturesFromCache(state, signatureCache) {
119845
+ signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
119846
+ }
119847
+ BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
119871
119848
  function updateSignatureOfFile(state, signature, path) {
119872
119849
  state.fileInfos.get(path).signature = signature;
119873
- (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
119850
+ state.hasCalledUpdateShapeSignature.add(path);
119874
119851
  }
119875
119852
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
119876
119853
  /**
119877
119854
  * Returns if the shape of the signature has changed since last emit
119878
119855
  */
119879
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
119880
- var _a;
119856
+ function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
119881
119857
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
119858
+ ts.Debug.assert(!!sourceFile);
119859
+ ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
119882
119860
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
119883
- if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
119861
+ if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
119884
119862
  return false;
119863
+ }
119885
119864
  var info = state.fileInfos.get(sourceFile.resolvedPath);
119865
+ if (!info)
119866
+ return ts.Debug.fail();
119886
119867
  var prevSignature = info.signature;
119887
119868
  var latestSignature;
119888
119869
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -119893,55 +119874,45 @@ var ts;
119893
119874
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119894
119875
  if (firstDts_1) {
119895
119876
  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; })); });
119896
- latestSignature = computeSignature(firstDts_1.text, computeHash);
119897
- if (latestSignature !== prevSignature) {
119898
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
119877
+ latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119878
+ if (exportedModulesMapCache && latestSignature !== prevSignature) {
119879
+ updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
119899
119880
  }
119900
119881
  }
119901
119882
  }
119902
119883
  // Default is to use file version as signature
119903
119884
  if (latestSignature === undefined) {
119904
119885
  latestSignature = sourceFile.version;
119905
- if (state.exportedModulesMap && latestSignature !== prevSignature) {
119906
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119886
+ if (exportedModulesMapCache && latestSignature !== prevSignature) {
119907
119887
  // All the references in this file are exported
119908
119888
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
119909
119889
  if (references) {
119910
- state.exportedModulesMap.set(sourceFile.resolvedPath, references);
119890
+ exportedModulesMapCache.set(sourceFile.resolvedPath, references);
119911
119891
  }
119912
119892
  else {
119913
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119893
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119914
119894
  }
119915
119895
  }
119916
119896
  }
119917
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
119918
- (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
119919
- info.signature = latestSignature;
119897
+ cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
119920
119898
  return latestSignature !== prevSignature;
119921
119899
  }
119922
119900
  BuilderState.updateShapeSignature = updateShapeSignature;
119923
- function computeSignature(text, computeHash) {
119924
- return (computeHash || ts.generateDjb2Hash)(text);
119925
- }
119926
- BuilderState.computeSignature = computeSignature;
119927
119901
  /**
119928
119902
  * Coverts the declaration emit result into exported modules map
119929
119903
  */
119930
- function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
119931
- if (!state.exportedModulesMap)
119932
- return;
119933
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
119904
+ function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
119934
119905
  if (!exportedModulesFromDeclarationEmit) {
119935
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119906
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119936
119907
  return;
119937
119908
  }
119938
119909
  var exportedModules;
119939
119910
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
119940
119911
  if (exportedModules) {
119941
- state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
119912
+ exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
119942
119913
  }
119943
119914
  else {
119944
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
119915
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
119945
119916
  }
119946
119917
  function addExportedModule(exportedModulePaths) {
119947
119918
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -119953,6 +119924,19 @@ var ts;
119953
119924
  }
119954
119925
  }
119955
119926
  BuilderState.updateExportedModules = updateExportedModules;
119927
+ /**
119928
+ * Updates the exported modules from cache into state's exported modules map
119929
+ * This should be called whenever it is safe to commit the state of the builder
119930
+ */
119931
+ function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
119932
+ var _a;
119933
+ if (exportedModulesMapCache) {
119934
+ ts.Debug.assert(!!state.exportedModulesMap);
119935
+ (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119936
+ exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119937
+ }
119938
+ }
119939
+ BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
119956
119940
  /**
119957
119941
  * Get all the dependencies of the sourceFile
119958
119942
  */
@@ -120073,7 +120057,7 @@ var ts;
120073
120057
  /**
120074
120058
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120075
120059
  */
120076
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120060
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120077
120061
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120078
120062
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120079
120063
  }
@@ -120093,7 +120077,7 @@ var ts;
120093
120077
  if (!seenFileNamesMap.has(currentPath)) {
120094
120078
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120095
120079
  seenFileNamesMap.set(currentPath, currentSourceFile);
120096
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120080
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120097
120081
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120098
120082
  }
120099
120083
  }
@@ -120119,33 +120103,32 @@ var ts;
120119
120103
  * Create the state so that we can iterate on changedFiles/affected files
120120
120104
  */
120121
120105
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120122
- var _a, _b;
120123
120106
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120124
120107
  state.program = newProgram;
120125
120108
  var compilerOptions = newProgram.getCompilerOptions();
120126
120109
  state.compilerOptions = compilerOptions;
120127
- var outFilePath = ts.outFile(compilerOptions);
120128
120110
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120129
- if (!outFilePath) {
120111
+ if (!ts.outFile(compilerOptions)) {
120130
120112
  state.semanticDiagnosticsPerFile = new ts.Map();
120131
120113
  }
120132
- 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)) {
120133
- state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120134
- }
120135
120114
  state.changedFilesSet = new ts.Set();
120136
- state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120137
120115
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120138
120116
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120139
120117
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120140
120118
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120141
- var canCopyEmitSignatures = compilerOptions.composite &&
120142
- (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120143
- !outFilePath &&
120144
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120145
120119
  if (useOldState) {
120120
+ // Verify the sanity of old state
120121
+ if (!oldState.currentChangedFilePath) {
120122
+ var affectedSignatures = oldState.currentAffectedFilesSignatures;
120123
+ ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120124
+ }
120125
+ var changedFilesSet = oldState.changedFilesSet;
120126
+ if (canCopySemanticDiagnostics) {
120127
+ ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120128
+ }
120146
120129
  // Copy old state's changed files set
120147
- (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120148
- if (!outFilePath && oldState.affectedFilesPendingEmit) {
120130
+ changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120131
+ if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120149
120132
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120150
120133
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120151
120134
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120166,8 +120149,6 @@ var ts;
120166
120149
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120167
120150
  // versions dont match
120168
120151
  oldInfo.version !== info.version ||
120169
- // Implied formats dont match
120170
- oldInfo.impliedFormat !== info.impliedFormat ||
120171
120152
  // Referenced files changed
120172
120153
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120173
120154
  // Referenced file was deleted in the new program
@@ -120191,25 +120172,27 @@ var ts;
120191
120172
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120192
120173
  }
120193
120174
  }
120194
- if (canCopyEmitSignatures) {
120195
- var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120196
- if (oldEmitSignature)
120197
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120198
- }
120199
120175
  });
120200
120176
  // If the global file is removed, add all files as changed
120201
120177
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120202
120178
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120203
120179
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120204
120180
  }
120205
- else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120181
+ else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120206
120182
  // Add all files to affectedFilesPendingEmit since emit changed
120207
120183
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120208
120184
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120209
120185
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120210
120186
  }
120211
- // Since old states change files set is copied, any additional change means we would need to emit build info
120212
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120187
+ if (useOldState) {
120188
+ // Any time the interpretation of a source file changes, mark it as changed
120189
+ ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120190
+ if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120191
+ state.changedFilesSet.add(sourceFilePath);
120192
+ }
120193
+ });
120194
+ }
120195
+ state.buildInfoEmitPending = !!state.changedFilesSet.size;
120213
120196
  return state;
120214
120197
  }
120215
120198
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120245,35 +120228,30 @@ var ts;
120245
120228
  ts.BuilderState.releaseCache(state);
120246
120229
  state.program = undefined;
120247
120230
  }
120248
- function backupEmitBuilderProgramState(state) {
120249
- var outFilePath = ts.outFile(state.compilerOptions);
120250
- // Only in --out changeFileSet is kept around till emit
120251
- ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120252
- return {
120253
- affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120254
- affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120255
- affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120256
- seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120257
- programEmitComplete: state.programEmitComplete,
120258
- emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120259
- outSignature: state.outSignature,
120260
- dtsChangeTime: state.dtsChangeTime,
120261
- hasChangedEmitSignature: state.hasChangedEmitSignature,
120262
- changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120263
- };
120264
- }
120265
- function restoreEmitBuilderProgramState(state, backupEmitState) {
120266
- state.affectedFilesPendingEmit = backupEmitState.affectedFilesPendingEmit;
120267
- state.affectedFilesPendingEmitKind = backupEmitState.affectedFilesPendingEmitKind;
120268
- state.affectedFilesPendingEmitIndex = backupEmitState.affectedFilesPendingEmitIndex;
120269
- state.seenEmittedFiles = backupEmitState.seenEmittedFiles;
120270
- state.programEmitComplete = backupEmitState.programEmitComplete;
120271
- state.emitSignatures = backupEmitState.emitSignatures;
120272
- state.outSignature = backupEmitState.outSignature;
120273
- state.dtsChangeTime = backupEmitState.dtsChangeTime;
120274
- state.hasChangedEmitSignature = backupEmitState.hasChangedEmitSignature;
120275
- if (backupEmitState.changedFilesSet)
120276
- state.changedFilesSet = backupEmitState.changedFilesSet;
120231
+ /**
120232
+ * Creates a clone of the state
120233
+ */
120234
+ function cloneBuilderProgramState(state) {
120235
+ var _a;
120236
+ var newState = ts.BuilderState.clone(state);
120237
+ newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120238
+ newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120239
+ newState.affectedFiles = state.affectedFiles;
120240
+ newState.affectedFilesIndex = state.affectedFilesIndex;
120241
+ newState.currentChangedFilePath = state.currentChangedFilePath;
120242
+ newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120243
+ newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120244
+ newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120245
+ newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120246
+ newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120247
+ newState.program = state.program;
120248
+ newState.compilerOptions = state.compilerOptions;
120249
+ newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120250
+ newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120251
+ newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120252
+ newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120253
+ newState.programEmitComplete = state.programEmitComplete;
120254
+ return newState;
120277
120255
  }
120278
120256
  /**
120279
120257
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120288,7 +120266,7 @@ var ts;
120288
120266
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120289
120267
  */
120290
120268
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120291
- var _a, _b;
120269
+ var _a;
120292
120270
  while (true) {
120293
120271
  var affectedFiles = state.affectedFiles;
120294
120272
  if (affectedFiles) {
@@ -120308,8 +120286,10 @@ var ts;
120308
120286
  state.changedFilesSet.delete(state.currentChangedFilePath);
120309
120287
  state.currentChangedFilePath = undefined;
120310
120288
  // Commit the changes in file signature
120311
- (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120312
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120289
+ ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120290
+ state.currentAffectedFilesSignatures.clear();
120291
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120292
+ (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120313
120293
  state.affectedFiles = undefined;
120314
120294
  }
120315
120295
  // Get next changed file
@@ -120327,7 +120307,12 @@ var ts;
120327
120307
  return program;
120328
120308
  }
120329
120309
  // Get next batch of affected files
120330
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120310
+ if (!state.currentAffectedFilesSignatures)
120311
+ state.currentAffectedFilesSignatures = new ts.Map();
120312
+ if (state.exportedModulesMap) {
120313
+ state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120314
+ }
120315
+ state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120331
120316
  state.currentChangedFilePath = nextKey.value;
120332
120317
  state.affectedFilesIndex = 0;
120333
120318
  if (!state.seenAffectedFiles)
@@ -120379,6 +120364,7 @@ var ts;
120379
120364
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120380
120365
  */
120381
120366
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120367
+ var _a;
120382
120368
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120383
120369
  // If affected files is everything except default library, then nothing more to do
120384
120370
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120386,9 +120372,10 @@ var ts;
120386
120372
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120387
120373
  // That means when affected file is handled, its signature can be out of date
120388
120374
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120389
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120375
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120390
120376
  return;
120391
120377
  }
120378
+ 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);
120392
120379
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120393
120380
  return;
120394
120381
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120408,7 +120395,7 @@ var ts;
120408
120395
  // This ensures that we dont later during incremental builds considering wrong signature.
120409
120396
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120410
120397
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120411
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120398
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120412
120399
  // If not dts emit, nothing more to do
120413
120400
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120414
120401
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120429,10 +120416,27 @@ var ts;
120429
120416
  return !state.semanticDiagnosticsFromOldState.size;
120430
120417
  }
120431
120418
  function isChangedSignature(state, path) {
120432
- var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120433
- var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120419
+ var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120420
+ var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120434
120421
  return newSignature !== oldSignature;
120435
120422
  }
120423
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120424
+ // Go through exported modules from cache first
120425
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120426
+ var result = keys && ts.forEachKey(keys, fn);
120427
+ if (result)
120428
+ return result;
120429
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120430
+ keys = state.exportedModulesMap.getKeys(filePath);
120431
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
120432
+ var _a;
120433
+ // If the cache had an updated value, skip
120434
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120435
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120436
+ fn(exportedFromPath) :
120437
+ undefined;
120438
+ });
120439
+ }
120436
120440
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120437
120441
  var _a;
120438
120442
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120447,7 +120451,6 @@ var ts;
120447
120451
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120448
120452
  */
120449
120453
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120450
- var _a;
120451
120454
  // If there was change in signature (dts output) for the changed file,
120452
120455
  // then only we need to handle pending file emit
120453
120456
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120474,10 +120477,11 @@ var ts;
120474
120477
  }
120475
120478
  }
120476
120479
  }
120480
+ ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120477
120481
  var seenFileAndExportsOfFile = new ts.Set();
120478
120482
  // Go through exported modules from cache first
120479
120483
  // If exported modules has path, all files referencing file exported from are affected
120480
- (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120484
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120481
120485
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120482
120486
  return true;
120483
120487
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120491,18 +120495,19 @@ var ts;
120491
120495
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120492
120496
  */
120493
120497
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120494
- var _a, _b;
120498
+ var _a;
120495
120499
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120496
120500
  return undefined;
120497
120501
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120498
120502
  return true;
120499
120503
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120504
+ ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120500
120505
  // If exported modules has path, all files referencing file exported from are affected
120501
- (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120506
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120502
120507
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120503
120508
  });
120504
120509
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120505
- (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120510
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120506
120511
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120507
120512
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120508
120513
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120523,13 +120528,12 @@ var ts;
120523
120528
  }
120524
120529
  else {
120525
120530
  state.seenAffectedFiles.add(affected.resolvedPath);
120526
- // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
120527
- state.buildInfoEmitPending = true;
120528
120531
  if (emitKind !== undefined) {
120529
120532
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120530
120533
  }
120531
120534
  if (isPendingEmit) {
120532
120535
  state.affectedFilesPendingEmitIndex++;
120536
+ state.buildInfoEmitPending = true;
120533
120537
  }
120534
120538
  else {
120535
120539
  state.affectedFilesIndex++;
@@ -120577,61 +120581,25 @@ var ts;
120577
120581
  }
120578
120582
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
120579
120583
  }
120580
- function isProgramBundleEmitBuildInfo(info) {
120581
- return !!ts.outFile(info.options || {});
120582
- }
120583
- ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
120584
120584
  /**
120585
120585
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
120586
120586
  */
120587
- function getProgramBuildInfo(state, getCanonicalFileName, host) {
120588
- var outFilePath = ts.outFile(state.compilerOptions);
120589
- if (outFilePath && !state.compilerOptions.composite)
120590
- return;
120587
+ function getProgramBuildInfo(state, getCanonicalFileName) {
120588
+ if (ts.outFile(state.compilerOptions))
120589
+ return undefined;
120591
120590
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
120592
120591
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
120593
- state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
120594
- if (outFilePath) {
120595
- var fileNames_1 = [];
120596
- var fileInfos_1 = [];
120597
- state.program.getRootFileNames().forEach(function (f) {
120598
- var sourceFile = state.program.getSourceFile(f);
120599
- if (!sourceFile)
120600
- return;
120601
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
120602
- fileInfos_1.push(sourceFile.version);
120603
- });
120604
- var result_15 = {
120605
- fileNames: fileNames_1,
120606
- fileInfos: fileInfos_1,
120607
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
120608
- outSignature: state.outSignature,
120609
- dtsChangeTime: state.dtsChangeTime,
120610
- };
120611
- return result_15;
120612
- }
120613
120592
  var fileNames = [];
120614
120593
  var fileNameToFileId = new ts.Map();
120615
120594
  var fileIdsList;
120616
120595
  var fileNamesToFileIdListId;
120617
- var emitSignatures;
120618
120596
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
120619
- var _b, _c;
120620
120597
  var key = _a[0], value = _a[1];
120621
120598
  // Ensure fileId
120622
120599
  var fileId = toFileId(key);
120623
120600
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
120624
- var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
120625
- var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
120626
- if (state.compilerOptions.composite) {
120627
- var file = state.program.getSourceFileByPath(key);
120628
- if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
120629
- var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
120630
- if (emitSignature !== actualSignature) {
120631
- (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
120632
- }
120633
- }
120634
- }
120601
+ var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120602
+ var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120635
120603
  return value.version === actualSignature ?
120636
120604
  value.affectsGlobalScope || value.impliedFormat ?
120637
120605
  // If file version is same as signature, dont serialize signature
@@ -120639,11 +120607,11 @@ var ts;
120639
120607
  // If file info only contains version and signature and both are same we can just write string
120640
120608
  value.version :
120641
120609
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120642
- oldSignature === undefined ?
120610
+ signature === undefined ?
120643
120611
  // If we havent computed signature, use fileInfo as is
120644
120612
  value :
120645
120613
  // Serialize fileInfo with new updated signature
120646
- { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120614
+ { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120647
120615
  // Signature of the FileInfo is undefined, serialize it as false
120648
120616
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120649
120617
  });
@@ -120658,13 +120626,17 @@ var ts;
120658
120626
  if (state.exportedModulesMap) {
120659
120627
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
120660
120628
  var _a;
120661
- var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
120629
+ if (state.currentAffectedFilesExportedModulesMap) {
120630
+ if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
120631
+ return undefined;
120632
+ }
120633
+ var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
120634
+ if (newValue) {
120635
+ return [toFileId(key), toFileIdListId(newValue)];
120636
+ }
120637
+ }
120662
120638
  // Not in temporary cache, use existing value
120663
- if (oldValue === undefined)
120664
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120665
- if (oldValue)
120666
- return [toFileId(key), toFileIdListId(oldValue)];
120667
- return undefined;
120639
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120668
120640
  });
120669
120641
  }
120670
120642
  var semanticDiagnosticsPerFile;
@@ -120675,7 +120647,9 @@ var ts;
120675
120647
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
120676
120648
  [
120677
120649
  toFileId(key),
120678
- convertToReusableDiagnostics(value, relativeToBuildInfo)
120650
+ state.hasReusableDiagnostic ?
120651
+ value :
120652
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
120679
120653
  ] :
120680
120654
  toFileId(key));
120681
120655
  }
@@ -120690,27 +120664,16 @@ var ts;
120690
120664
  }
120691
120665
  }
120692
120666
  }
120693
- var changeFileSet;
120694
- if (state.changedFilesSet.size) {
120695
- for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
120696
- var path = _e[_d];
120697
- (changeFileSet || (changeFileSet = [])).push(toFileId(path));
120698
- }
120699
- }
120700
- var result = {
120667
+ return {
120701
120668
  fileNames: fileNames,
120702
120669
  fileInfos: fileInfos,
120703
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
120670
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
120704
120671
  fileIdsList: fileIdsList,
120705
120672
  referencedMap: referencedMap,
120706
120673
  exportedModulesMap: exportedModulesMap,
120707
120674
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
120708
120675
  affectedFilesPendingEmit: affectedFilesPendingEmit,
120709
- changeFileSet: changeFileSet,
120710
- emitSignatures: emitSignatures,
120711
- dtsChangeTime: state.dtsChangeTime,
120712
120676
  };
120713
- return result;
120714
120677
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
120715
120678
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
120716
120679
  }
@@ -120735,18 +120698,24 @@ var ts;
120735
120698
  }
120736
120699
  return fileIdListId;
120737
120700
  }
120738
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
120739
- var result;
120740
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120741
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120742
- var name = _a[_i];
120743
- var optionInfo = optionsNameMap.get(name.toLowerCase());
120744
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
120745
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
120746
- }
120701
+ }
120702
+ function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
120703
+ var result;
120704
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120705
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120706
+ var name = _a[_i];
120707
+ var optionKey = name.toLowerCase();
120708
+ var optionInfo = optionsNameMap.get(optionKey);
120709
+ if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
120710
+ // We need to store `strict`, even though it won't be examined directly, so that the
120711
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
120712
+ optionKey === "strict" ||
120713
+ // We need to store these to determine whether `lib` files need to be rechecked.
120714
+ optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
120715
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
120747
120716
  }
120748
- return result;
120749
120717
  }
120718
+ return result;
120750
120719
  }
120751
120720
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
120752
120721
  if (option) {
@@ -120820,10 +120789,6 @@ var ts;
120820
120789
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
120821
120790
  }
120822
120791
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
120823
- function computeSignature(text, data, computeHash) {
120824
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
120825
- }
120826
- ts.computeSignature = computeSignature;
120827
120792
  function createBuilderProgram(kind, _a) {
120828
120793
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
120829
120794
  // Return same program if underlying program doesnt change
@@ -120842,8 +120807,8 @@ var ts;
120842
120807
  */
120843
120808
  var computeHash = ts.maybeBind(host, host.createHash);
120844
120809
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
120845
- var backupEmitState;
120846
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
120810
+ var backupState;
120811
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
120847
120812
  // To ensure that we arent storing any references to old program or new program without state
120848
120813
  newProgram = undefined; // TODO: GH#18217
120849
120814
  oldProgram = undefined;
@@ -120851,20 +120816,20 @@ var ts;
120851
120816
  var getState = function () { return state; };
120852
120817
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
120853
120818
  builderProgram.getState = getState;
120854
- builderProgram.backupEmitState = function () {
120855
- ts.Debug.assert(backupEmitState === undefined);
120856
- backupEmitState = backupEmitBuilderProgramState(state);
120819
+ builderProgram.backupState = function () {
120820
+ ts.Debug.assert(backupState === undefined);
120821
+ backupState = cloneBuilderProgramState(state);
120857
120822
  };
120858
- builderProgram.restoreEmitState = function () {
120859
- restoreEmitBuilderProgramState(state, ts.Debug.checkDefined(backupEmitState));
120860
- backupEmitState = undefined;
120823
+ builderProgram.restoreState = function () {
120824
+ state = ts.Debug.checkDefined(backupState);
120825
+ backupState = undefined;
120861
120826
  };
120862
120827
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
120863
120828
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
120864
120829
  builderProgram.emit = emit;
120865
120830
  builderProgram.releaseProgram = function () {
120866
120831
  releaseCache(state);
120867
- backupEmitState = undefined;
120832
+ backupState = undefined;
120868
120833
  };
120869
120834
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
120870
120835
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
@@ -120923,59 +120888,35 @@ var ts;
120923
120888
  return toAffectedFileEmitResult(state,
120924
120889
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120925
120890
  // Otherwise just affected file
120926
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
120927
- getWriteFileCallback(writeFile, customTransformers) :
120891
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120892
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120928
120893
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120929
120894
  }
120930
- function getWriteFileCallback(writeFile, customTransformers) {
120895
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
120931
120896
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120932
- var _a, _b, _c;
120897
+ var _a;
120933
120898
  if (ts.isDeclarationFileName(fileName)) {
120934
- if (!ts.outFile(state.compilerOptions)) {
120935
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120936
- var newSignature = void 0;
120937
- if (!customTransformers) {
120938
- var file = sourceFiles[0];
120939
- var info = state.fileInfos.get(file.resolvedPath);
120940
- if (info.signature === file.version) {
120941
- newSignature = computeSignature(text, data, computeHash);
120942
- if (newSignature !== file.version) { // Update it
120943
- if (host.storeFilesChangingSignatureDuringEmit)
120944
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120945
- if (state.exportedModulesMap)
120946
- ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
120947
- if (state.affectedFiles) {
120948
- // Keep old signature so we know what to undo if cancellation happens
120949
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
120950
- if (existing === undefined)
120951
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
120952
- info.signature = newSignature;
120953
- }
120954
- else {
120955
- // These are directly commited
120956
- info.signature = newSignature;
120957
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120958
- }
120959
- }
120899
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120900
+ var file = sourceFiles[0];
120901
+ var info = state.fileInfos.get(file.resolvedPath);
120902
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120903
+ if (signature === file.version) {
120904
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120905
+ if (newSignature !== file.version) { // Update it
120906
+ if (host.storeFilesChangingSignatureDuringEmit)
120907
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120908
+ if (state.exportedModulesMap)
120909
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120910
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120911
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120960
120912
  }
120961
- }
120962
- if (state.compilerOptions.composite) {
120963
- var filePath = sourceFiles[0].resolvedPath;
120964
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
120965
- newSignature || (newSignature = computeSignature(text, data, computeHash));
120966
- if (newSignature !== oldSignature) {
120967
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
120968
- state.hasChangedEmitSignature = true;
120913
+ else {
120914
+ info.signature = newSignature;
120915
+ if (state.exportedModulesMap)
120916
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120969
120917
  }
120970
120918
  }
120971
120919
  }
120972
- else if (state.compilerOptions.composite) {
120973
- var newSignature = computeSignature(text, data, computeHash);
120974
- if (newSignature !== state.outSignature) {
120975
- state.outSignature = newSignature;
120976
- state.hasChangedEmitSignature = true;
120977
- }
120978
- }
120979
120920
  }
120980
120921
  if (writeFile)
120981
120922
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121040,8 +120981,8 @@ var ts;
121040
120981
  }
121041
120982
  }
121042
120983
  }
121043
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121044
- getWriteFileCallback(writeFile, customTransformers) :
120984
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120985
+ getWriteFileUpdatingSignatureCallback(writeFile) :
121045
120986
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121046
120987
  }
121047
120988
  /**
@@ -121130,58 +121071,29 @@ var ts;
121130
121071
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121131
121072
  }
121132
121073
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121133
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121134
- var _a, _b, _c, _d;
121074
+ function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121075
+ var _a;
121135
121076
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121136
121077
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121137
- var state;
121138
- var filePaths;
121139
- var filePathsSetList;
121140
- if (isProgramBundleEmitBuildInfo(program)) {
121141
- state = {
121142
- fileInfos: new ts.Map(),
121143
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121144
- dtsChangeTime: program.dtsChangeTime,
121145
- outSignature: program.outSignature,
121146
- };
121147
- }
121148
- else {
121149
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121150
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121151
- var fileInfos_2 = new ts.Map();
121152
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121153
- program.fileInfos.forEach(function (fileInfo, index) {
121154
- var path = toFilePath(index + 1);
121155
- var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121156
- fileInfos_2.set(path, stateFileInfo);
121157
- if (emitSignatures_1 && stateFileInfo.signature)
121158
- emitSignatures_1.set(path, stateFileInfo.signature);
121159
- });
121160
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121161
- if (ts.isNumber(value))
121162
- emitSignatures_1.delete(toFilePath(value));
121163
- else
121164
- emitSignatures_1.set(toFilePath(value[0]), value[1]);
121165
- });
121166
- state = {
121167
- fileInfos: fileInfos_2,
121168
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121169
- referencedMap: toManyToManyPathMap(program.referencedMap),
121170
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121171
- 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]; }),
121172
- hasReusableDiagnostic: true,
121173
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121174
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121175
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121176
- changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121177
- dtsChangeTime: program.dtsChangeTime,
121178
- emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121179
- };
121180
- }
121078
+ var filePaths = program.fileNames.map(toPath);
121079
+ var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121080
+ var fileInfos = new ts.Map();
121081
+ program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121082
+ var state = {
121083
+ fileInfos: fileInfos,
121084
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121085
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121086
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121087
+ 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]; }),
121088
+ hasReusableDiagnostic: true,
121089
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121090
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121091
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121092
+ };
121181
121093
  return {
121182
121094
  getState: function () { return state; },
121183
- backupEmitState: ts.noop,
121184
- restoreEmitState: ts.noop,
121095
+ backupState: ts.noop,
121096
+ restoreState: ts.noop,
121185
121097
  getProgram: ts.notImplemented,
121186
121098
  getProgramOrUndefined: ts.returnUndefined,
121187
121099
  releaseProgram: ts.noop,
@@ -121226,24 +121138,12 @@ var ts;
121226
121138
  return map;
121227
121139
  }
121228
121140
  }
121229
- ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121230
- function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121231
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121232
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121233
- var fileInfos = new ts.Map();
121234
- program.fileInfos.forEach(function (fileInfo, index) {
121235
- var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121236
- var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121237
- fileInfos.set(path, version);
121238
- });
121239
- return fileInfos;
121240
- }
121241
- ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121141
+ ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121242
121142
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121243
121143
  return {
121244
121144
  getState: ts.notImplemented,
121245
- backupEmitState: ts.noop,
121246
- restoreEmitState: ts.noop,
121145
+ backupState: ts.noop,
121146
+ restoreState: ts.noop,
121247
121147
  getProgram: getProgram,
121248
121148
  getProgramOrUndefined: function () { return getState().program; },
121249
121149
  releaseProgram: function () { return getState().program = undefined; },
@@ -122359,9 +122259,9 @@ var ts;
122359
122259
  if (!preferSymlinks) {
122360
122260
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122361
122261
  // so we only need to remove them from the realpath filenames.
122362
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122363
- if (result_16)
122364
- return result_16;
122262
+ var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122263
+ if (result_15)
122264
+ return result_15;
122365
122265
  }
122366
122266
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122367
122267
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122381,10 +122281,10 @@ var ts;
122381
122281
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122382
122282
  var symlinkDirectory = symlinkDirectories_1[_i];
122383
122283
  var option = ts.resolvePath(symlinkDirectory, relative);
122384
- var result_17 = cb(option, target === referenceRedirect);
122284
+ var result_16 = cb(option, target === referenceRedirect);
122385
122285
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122386
- if (result_17)
122387
- return result_17;
122286
+ if (result_16)
122287
+ return result_16;
122388
122288
  }
122389
122289
  });
122390
122290
  });
@@ -123294,7 +123194,6 @@ var ts;
123294
123194
  readDirectory: ts.maybeBind(host, host.readDirectory),
123295
123195
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123296
123196
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123297
- now: ts.maybeBind(host, host.now),
123298
123197
  };
123299
123198
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123300
123199
  try {
@@ -123355,7 +123254,6 @@ var ts;
123355
123254
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123356
123255
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123357
123256
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123358
- now: ts.maybeBind(system, system.now),
123359
123257
  };
123360
123258
  }
123361
123259
  ts.createProgramHost = createProgramHost;
@@ -123423,26 +123321,20 @@ var ts;
123423
123321
  var ts;
123424
123322
  (function (ts) {
123425
123323
  function readBuilderProgram(compilerOptions, host) {
123324
+ if (ts.outFile(compilerOptions))
123325
+ return undefined;
123426
123326
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123427
123327
  if (!buildInfoPath)
123428
123328
  return undefined;
123429
- var buildInfo;
123430
- if (host.getBuildInfo) {
123431
- buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
123432
- if (!buildInfo)
123433
- return undefined;
123434
- }
123435
- else {
123436
- var content = host.readFile(buildInfoPath);
123437
- if (!content)
123438
- return undefined;
123439
- buildInfo = ts.getBuildInfo(content);
123440
- }
123329
+ var content = host.readFile(buildInfoPath);
123330
+ if (!content)
123331
+ return undefined;
123332
+ var buildInfo = ts.getBuildInfo(content);
123441
123333
  if (buildInfo.version !== ts.version)
123442
123334
  return undefined;
123443
123335
  if (!buildInfo.program)
123444
123336
  return undefined;
123445
- return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123337
+ return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123446
123338
  }
123447
123339
  ts.readBuilderProgram = readBuilderProgram;
123448
123340
  function createIncrementalCompilerHost(options, system) {
@@ -123451,7 +123343,6 @@ var ts;
123451
123343
  host.createHash = ts.maybeBind(system, system.createHash);
123452
123344
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123453
123345
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
123454
- host.now = ts.maybeBind(system, system.now);
123455
123346
  ts.setGetSourceFileAsHashVersioned(host, system);
123456
123347
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123457
123348
  return host;
@@ -124187,17 +124078,14 @@ var ts;
124187
124078
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124188
124079
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124189
124080
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124190
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124191
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124192
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124193
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124194
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124195
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124081
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124082
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124083
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124084
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124196
124085
  /**
124197
124086
  * Projects with no outputs (i.e. "solution" files)
124198
124087
  */
124199
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124200
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124088
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124201
124089
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124202
124090
  function resolveConfigFileProjectName(project) {
124203
124091
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124242,11 +124130,9 @@ var ts;
124242
124130
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124243
124131
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124244
124132
  }
124245
- /*@internal*/
124246
- function getCurrentTime(host) {
124247
- return host.now ? host.now() : new Date();
124133
+ function newer(date1, date2) {
124134
+ return date2 > date1 ? date2 : date1;
124248
124135
  }
124249
- ts.getCurrentTime = getCurrentTime;
124250
124136
  /*@internal*/
124251
124137
  function isCircularBuildOrder(buildOrder) {
124252
124138
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124336,7 +124222,6 @@ var ts;
124336
124222
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124337
124223
  };
124338
124224
  }
124339
- compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124340
124225
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124341
124226
  var state = {
124342
124227
  host: host,
@@ -124353,9 +124238,8 @@ var ts;
124353
124238
  resolvedConfigFilePaths: new ts.Map(),
124354
124239
  configFileCache: new ts.Map(),
124355
124240
  projectStatus: new ts.Map(),
124241
+ buildInfoChecked: new ts.Map(),
124356
124242
  extendedConfigCache: new ts.Map(),
124357
- buildInfoCache: new ts.Map(),
124358
- outputTimeStamps: new ts.Map(),
124359
124243
  builderPrograms: new ts.Map(),
124360
124244
  diagnostics: new ts.Map(),
124361
124245
  projectPendingBuild: new ts.Map(),
@@ -124378,7 +124262,6 @@ var ts;
124378
124262
  allWatchedConfigFiles: new ts.Map(),
124379
124263
  allWatchedExtendedConfigFiles: new ts.Map(),
124380
124264
  allWatchedPackageJsonFiles: new ts.Map(),
124381
- filesWatched: new ts.Map(),
124382
124265
  lastCachedPackageJsonLookups: new ts.Map(),
124383
124266
  timerToBuildInvalidatedProject: undefined,
124384
124267
  reportFileChangeDetected: false,
@@ -124489,12 +124372,11 @@ var ts;
124489
124372
  // Config file cache
124490
124373
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124491
124374
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124375
+ ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124492
124376
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124493
124377
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124494
124378
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124495
124379
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124496
- ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124497
- ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124498
124380
  // Remove watches for the program no longer in the solution
124499
124381
  if (state.watch) {
124500
124382
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -124791,21 +124673,21 @@ var ts;
124791
124673
  }
124792
124674
  function emit(writeFileCallback, cancellationToken, customTransformers) {
124793
124675
  var _a;
124794
- var _b, _c, _d;
124676
+ var _b, _c;
124795
124677
  ts.Debug.assertIsDefined(program);
124796
124678
  ts.Debug.assert(step === BuildStep.Emit);
124797
124679
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
124798
- program.backupEmitState();
124680
+ program.backupState();
124799
124681
  var declDiagnostics;
124800
124682
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
124801
124683
  var outputFiles = [];
124802
124684
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
124803
124685
  /*write*/ undefined,
124804
- /*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,
124686
+ /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
124805
124687
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
124806
124688
  // Don't emit .d.ts if there are decl file errors
124807
124689
  if (declDiagnostics) {
124808
- program.restoreEmitState();
124690
+ program.restoreState();
124809
124691
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
124810
124692
  return {
124811
124693
  emitSkipped: true,
@@ -124815,46 +124697,40 @@ var ts;
124815
124697
  // Actual Emit
124816
124698
  var host = state.host, compilerHost = state.compilerHost;
124817
124699
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124818
- var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
124700
+ var newestDeclarationFileContentChangedTime = minimumDate;
124701
+ var anyDtsChanged = false;
124819
124702
  var emitterDiagnostics = ts.createDiagnosticCollection();
124820
124703
  var emittedOutputs = new ts.Map();
124821
- var options = program.getCompilerOptions();
124822
- var isIncremental = ts.isIncrementalCompilation(options);
124823
- var outputTimeStampMap;
124824
- var now;
124825
124704
  ts.solutionPerformance.mark("beforeOutputFilesWrite");
124826
124705
  outputFiles.forEach(function (_a) {
124827
- var _b, _c;
124828
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124829
- var path = toPath(state, name);
124830
- emittedOutputs.set(toPath(state, name), name);
124831
- if (buildInfo) {
124832
- setBuildInfo(state, buildInfo, projectPath, options);
124833
- 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)) {
124706
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124707
+ var priorChangeTime;
124708
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124709
+ // Check for unchanged .d.ts files
124710
+ if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124711
+ priorChangeTime = host.getModifiedTime(name);
124712
+ }
124713
+ else {
124834
124714
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124715
+ anyDtsChanged = true;
124835
124716
  }
124836
124717
  }
124718
+ emittedOutputs.set(toPath(state, name), name);
124837
124719
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124838
- if (!isIncremental && state.watch) {
124839
- (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
124720
+ if (priorChangeTime !== undefined) {
124721
+ newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124840
124722
  }
124841
124723
  });
124842
124724
  ts.solutionPerformance.mark("afterOutputFilesWrite");
124843
124725
  ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124844
- finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124726
+ finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124727
+ /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124845
124728
  return emitResult;
124846
124729
  }
124847
124730
  function emitBuildInfo(writeFileCallback, cancellationToken) {
124848
124731
  ts.Debug.assertIsDefined(program);
124849
124732
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
124850
- var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
124851
- if (data === null || data === void 0 ? void 0 : data.buildInfo)
124852
- setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
124853
- if (writeFileCallback)
124854
- writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
124855
- else
124856
- state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
124857
- }, cancellationToken);
124733
+ var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
124858
124734
  if (emitResult.diagnostics.length) {
124859
124735
  reportErrors(state, emitResult.diagnostics);
124860
124736
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -124867,7 +124743,7 @@ var ts;
124867
124743
  step = BuildStep.QueueReferencingProjects;
124868
124744
  return emitResult;
124869
124745
  }
124870
- function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
124746
+ function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
124871
124747
  var _a;
124872
124748
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
124873
124749
  if (emitDiagnostics.length) {
@@ -124878,11 +124754,13 @@ var ts;
124878
124754
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
124879
124755
  }
124880
124756
  // Update time stamps for rest of the outputs
124881
- updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124757
+ var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124882
124758
  state.diagnostics.delete(projectPath);
124883
124759
  state.projectStatus.set(projectPath, {
124884
124760
  type: ts.UpToDateStatusType.UpToDate,
124885
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
124761
+ newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
124762
+ maximumDate :
124763
+ newestDeclarationFileContentChangedTime,
124886
124764
  oldestOutputFileName: oldestOutputFileName
124887
124765
  });
124888
124766
  afterProgramDone(state, program, config);
@@ -124917,21 +124795,13 @@ var ts;
124917
124795
  ts.Debug.assert(!!outputFiles.length);
124918
124796
  var emitterDiagnostics = ts.createDiagnosticCollection();
124919
124797
  var emittedOutputs = new ts.Map();
124920
- var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
124921
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
124922
124798
  outputFiles.forEach(function (_a) {
124923
- var _b, _c;
124924
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124799
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124925
124800
  emittedOutputs.set(toPath(state, name), name);
124926
- if (buildInfo) {
124927
- setBuildInfo(state, buildInfo, projectPath, config.options);
124928
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
124929
- resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124930
- }
124931
- }
124932
124801
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
124933
124802
  });
124934
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
124803
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
124804
+ /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
124935
124805
  return { emitSkipped: false, diagnostics: emitDiagnostics };
124936
124806
  }
124937
124807
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125037,7 +124907,7 @@ var ts;
125037
124907
  }
125038
124908
  continue;
125039
124909
  }
125040
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
124910
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125041
124911
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125042
124912
  return {
125043
124913
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125123,7 +124993,7 @@ var ts;
125123
124993
  state.projectCompilerOptions = state.baseCompilerOptions;
125124
124994
  }
125125
124995
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125126
- var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
124996
+ var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125127
124997
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125128
124998
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125129
124999
  if (canEmitBuildInfo)
@@ -125131,101 +125001,9 @@ var ts;
125131
125001
  afterProgramDone(state, program, config);
125132
125002
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125133
125003
  }
125134
- function isFileWatcherWithModifiedTime(value) {
125135
- return !!value.watcher;
125136
- }
125137
- function getModifiedTime(state, fileName) {
125138
- var path = toPath(state, fileName);
125139
- var existing = state.filesWatched.get(path);
125140
- if (state.watch && !!existing) {
125141
- if (!isFileWatcherWithModifiedTime(existing))
125142
- return existing;
125143
- if (existing.modifiedTime)
125144
- return existing.modifiedTime;
125145
- }
125146
- var result = ts.getModifiedTime(state.host, fileName);
125147
- if (state.watch) {
125148
- if (existing)
125149
- existing.modifiedTime = result;
125150
- else
125151
- state.filesWatched.set(path, result);
125152
- }
125153
- return result;
125154
- }
125155
- function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125156
- var path = toPath(state, file);
125157
- var existing = state.filesWatched.get(path);
125158
- if (existing && isFileWatcherWithModifiedTime(existing)) {
125159
- existing.callbacks.push(callback);
125160
- }
125161
- else {
125162
- var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125163
- var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125164
- ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125165
- existing.modifiedTime = modifiedTime;
125166
- existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125167
- }, pollingInterval, options, watchType, project);
125168
- state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125169
- }
125170
- return {
125171
- close: function () {
125172
- var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125173
- ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125174
- if (existing.callbacks.length === 1) {
125175
- state.filesWatched.delete(path);
125176
- ts.closeFileWatcherOf(existing);
125177
- }
125178
- else {
125179
- ts.unorderedRemoveItem(existing.callbacks, callback);
125180
- }
125181
- }
125182
- };
125183
- }
125184
- function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125185
- if (!state.watch)
125186
- return undefined;
125187
- var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125188
- if (!result)
125189
- state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125190
- return result;
125191
- }
125192
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125193
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125194
- var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125195
- if (existing) {
125196
- existing.buildInfo = buildInfo;
125197
- existing.modifiedTime = getCurrentTime(state.host);
125198
- }
125199
- else {
125200
- state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125201
- }
125202
- }
125203
- function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125204
- var path = toPath(state, buildInfoPath);
125205
- var existing = state.buildInfoCache.get(resolvedConfigPath);
125206
- return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125207
- }
125208
- function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125209
- var path = toPath(state, buildInfoPath);
125210
- var existing = state.buildInfoCache.get(resolvedConfigPath);
125211
- if (existing !== undefined && existing.path === path) {
125212
- return existing.buildInfo || undefined;
125213
- }
125214
- ts.solutionPerformance.mark("beforeGetBuildInfo");
125215
- ts.solutionPerformance.mark("beforeBuildInfoRead");
125216
- var value = state.readFileWithCache(buildInfoPath);
125217
- ts.solutionPerformance.mark("afterBuildInfoRead");
125218
- ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125219
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125220
- ts.Debug.assert(modifiedTime || !buildInfo);
125221
- state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125222
- ts.solutionPerformance.mark("afterGetBuildInfo");
125223
- ts.solutionPerformance.measure("GetBuildInfo", "beforeGetBuildInfo", "afterGetBuildInfo");
125224
- return buildInfo;
125225
- }
125226
125004
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125227
125005
  // Check tsconfig time
125228
- var tsconfigTime = getModifiedTime(state, configFile);
125006
+ var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125229
125007
  if (oldestOutputFileTime < tsconfigTime) {
125230
125008
  return {
125231
125009
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125235,24 +125013,88 @@ var ts;
125235
125013
  }
125236
125014
  }
125237
125015
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125238
- var _a, _b, _c;
125016
+ var force = !!state.options.force;
125017
+ var newestInputFileName = undefined;
125018
+ var newestInputFileTime = minimumDate;
125019
+ var host = state.host;
125020
+ // Get timestamps of input files
125021
+ for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125022
+ var inputFile = _a[_i];
125023
+ if (!host.fileExists(inputFile)) {
125024
+ return {
125025
+ type: ts.UpToDateStatusType.Unbuildable,
125026
+ reason: inputFile + " does not exist"
125027
+ };
125028
+ }
125029
+ if (!force) {
125030
+ var inputTime = ts.getModifiedTime(host, inputFile);
125031
+ if (inputTime > newestInputFileTime) {
125032
+ newestInputFileName = inputFile;
125033
+ newestInputFileTime = inputTime;
125034
+ }
125035
+ }
125036
+ }
125239
125037
  // Container if no files are specified in the project
125240
125038
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125241
125039
  return {
125242
125040
  type: ts.UpToDateStatusType.ContainerOnly
125243
125041
  };
125244
125042
  }
125245
- // Fast check to see if reference projects are buildable
125246
- var referenceStatuses;
125247
- var force = !!state.options.force;
125043
+ // Collect the expected outputs of this project
125044
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125045
+ // Now see if all outputs are newer than the newest input
125046
+ var oldestOutputFileName = "(none)";
125047
+ var oldestOutputFileTime = maximumDate;
125048
+ var newestOutputFileName = "(none)";
125049
+ var newestOutputFileTime = minimumDate;
125050
+ var missingOutputFileName;
125051
+ var newestDeclarationFileContentChangedTime = minimumDate;
125052
+ var isOutOfDateWithInputs = false;
125053
+ if (!force) {
125054
+ for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125055
+ var output = outputs_1[_b];
125056
+ // Output is missing; can stop checking
125057
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125058
+ if (!host.fileExists(output)) {
125059
+ missingOutputFileName = output;
125060
+ break;
125061
+ }
125062
+ var outputTime = ts.getModifiedTime(host, output);
125063
+ if (outputTime < oldestOutputFileTime) {
125064
+ oldestOutputFileTime = outputTime;
125065
+ oldestOutputFileName = output;
125066
+ }
125067
+ // If an output is older than the newest input, we can stop checking
125068
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125069
+ if (outputTime < newestInputFileTime) {
125070
+ isOutOfDateWithInputs = true;
125071
+ break;
125072
+ }
125073
+ if (outputTime > newestOutputFileTime) {
125074
+ newestOutputFileTime = outputTime;
125075
+ newestOutputFileName = output;
125076
+ }
125077
+ // Keep track of when the most recent time a .d.ts file was changed.
125078
+ // In addition to file timestamps, we also keep track of when a .d.ts file
125079
+ // had its file touched but not had its contents changed - this allows us
125080
+ // to skip a downstream typecheck
125081
+ if (ts.isDeclarationFileName(output)) {
125082
+ var outputModifiedTime = ts.getModifiedTime(host, output);
125083
+ newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125084
+ }
125085
+ }
125086
+ }
125087
+ var pseudoUpToDate = false;
125088
+ var usesPrepend = false;
125089
+ var upstreamChangedProject;
125248
125090
  if (project.projectReferences) {
125249
125091
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125250
- for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125251
- var ref = _d[_i];
125092
+ for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125093
+ var ref = _d[_c];
125094
+ usesPrepend = usesPrepend || !!(ref.prepend);
125252
125095
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125253
125096
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125254
- var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125255
- var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125097
+ var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125256
125098
  // Its a circular reference ignore the status of this project
125257
125099
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125258
125100
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125274,188 +125116,78 @@ var ts;
125274
125116
  upstreamProjectName: ref.path
125275
125117
  };
125276
125118
  }
125277
- if (!force)
125278
- (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125279
- }
125280
- }
125281
- if (force)
125282
- return { type: ts.UpToDateStatusType.ForceBuild };
125283
- // Check buildinfo first
125284
- var host = state.host;
125285
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125286
- var oldestOutputFileName = "(none)";
125287
- var oldestOutputFileTime = maximumDate;
125288
- var buildInfoTime;
125289
- var buildInfoProgram;
125290
- var buildInfoVersionMap;
125291
- var newestDeclarationFileContentChangedTime;
125292
- if (buildInfoPath) {
125293
- var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125294
- buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125295
- if (buildInfoTime === ts.missingFileModifiedTime) {
125296
- if (!buildInfoCacheEntry_1) {
125297
- state.buildInfoCache.set(resolvedPath, {
125298
- path: toPath(state, buildInfoPath),
125299
- buildInfo: false,
125300
- modifiedTime: buildInfoTime
125301
- });
125302
- }
125303
- return {
125304
- type: ts.UpToDateStatusType.OutputMissing,
125305
- missingOutputFileName: buildInfoPath
125306
- };
125307
- }
125308
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125309
- if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125310
- return {
125311
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125312
- version: buildInfo.version
125313
- };
125314
- }
125315
- if (buildInfo.program) {
125316
- if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125317
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125119
+ // Check oldest output file name only if there is no missing output file name
125120
+ // (a check we will have skipped if this is a forced build)
125121
+ if (!force && !missingOutputFileName) {
125122
+ // If the upstream project's newest file is older than our oldest output, we
125123
+ // can't be out of date because of it
125124
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125125
+ continue;
125126
+ }
125127
+ // If the upstream project has only change .d.ts files, and we've built
125128
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125129
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125130
+ pseudoUpToDate = true;
125131
+ upstreamChangedProject = ref.path;
125132
+ continue;
125133
+ }
125134
+ // We have an output older than an upstream output - we are out of date
125135
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125318
125136
  return {
125319
- type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125320
- buildInfoFile: buildInfoPath
125137
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125138
+ outOfDateOutputFileName: oldestOutputFileName,
125139
+ newerProjectName: ref.path
125321
125140
  };
125322
125141
  }
125323
- buildInfoProgram = buildInfo.program;
125324
125142
  }
125325
- oldestOutputFileTime = buildInfoTime;
125326
- oldestOutputFileName = buildInfoPath;
125327
- newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125328
125143
  }
125329
- // Check input files
125330
- var newestInputFileName = undefined;
125331
- var newestInputFileTime = minimumDate;
125332
- var pseudoInputUptodate = false;
125333
- // Get timestamps of input files
125334
- for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125335
- var inputFile = _f[_e];
125336
- var inputTime = getModifiedTime(state, inputFile);
125337
- if (inputTime === ts.missingFileModifiedTime) {
125338
- return {
125339
- type: ts.UpToDateStatusType.Unbuildable,
125340
- reason: inputFile + " does not exist"
125341
- };
125342
- }
125343
- // If an buildInfo is older than the newest input, we can stop checking
125344
- if (buildInfoTime && buildInfoTime < inputTime) {
125345
- var version_3 = void 0;
125346
- var currentVersion = void 0;
125347
- if (buildInfoProgram) {
125348
- // Read files and see if they are same, read is anyways cached
125349
- if (!buildInfoVersionMap)
125350
- buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125351
- version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125352
- var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125353
- currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125354
- if (version_3 && version_3 === currentVersion)
125355
- pseudoInputUptodate = true;
125356
- }
125357
- if (!version_3 || version_3 !== currentVersion) {
125358
- return {
125359
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125360
- outOfDateOutputFileName: buildInfoPath,
125361
- newerInputFileName: inputFile
125362
- };
125363
- }
125364
- }
125365
- if (inputTime > newestInputFileTime) {
125366
- newestInputFileName = inputFile;
125367
- newestInputFileTime = inputTime;
125368
- }
125144
+ if (missingOutputFileName !== undefined) {
125145
+ return {
125146
+ type: ts.UpToDateStatusType.OutputMissing,
125147
+ missingOutputFileName: missingOutputFileName
125148
+ };
125369
125149
  }
125370
- // Now see if all outputs are newer than the newest input
125371
- // Dont check output timestamps if we have buildinfo telling us output is uptodate
125372
- if (!buildInfoPath) {
125373
- // Collect the expected outputs of this project
125374
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125375
- var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125376
- for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125377
- var output = outputs_1[_g];
125378
- var path = toPath(state, output);
125379
- // Output is missing; can stop checking
125380
- var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125381
- if (!outputTime) {
125382
- outputTime = ts.getModifiedTime(state.host, output);
125383
- outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125384
- }
125385
- if (outputTime === ts.missingFileModifiedTime) {
125386
- return {
125387
- type: ts.UpToDateStatusType.OutputMissing,
125388
- missingOutputFileName: output
125389
- };
125390
- }
125391
- if (outputTime < oldestOutputFileTime) {
125392
- oldestOutputFileTime = outputTime;
125393
- oldestOutputFileName = output;
125394
- }
125395
- // If an output is older than the newest input, we can stop checking
125396
- if (outputTime < newestInputFileTime) {
125397
- return {
125398
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125399
- outOfDateOutputFileName: oldestOutputFileName,
125400
- newerInputFileName: newestInputFileName
125401
- };
125402
- }
125403
- }
125150
+ if (isOutOfDateWithInputs) {
125151
+ return {
125152
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125153
+ outOfDateOutputFileName: oldestOutputFileName,
125154
+ newerInputFileName: newestInputFileName
125155
+ };
125404
125156
  }
125405
- var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125406
- var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125407
- seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125408
- var pseudoUpToDate = false;
125409
- var usesPrepend = false;
125410
- var upstreamChangedProject;
125411
- if (referenceStatuses) {
125412
- for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125413
- var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125414
- usesPrepend = usesPrepend || !!(ref.prepend);
125415
- // If the upstream project's newest file is older than our oldest output, we
125416
- // can't be out of date because of it
125417
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125418
- continue;
125419
- }
125420
- // Check if tsbuildinfo path is shared, then we need to rebuild
125421
- if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125157
+ else {
125158
+ // Check tsconfig time
125159
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125160
+ if (configStatus)
125161
+ return configStatus;
125162
+ // Check extended config time
125163
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125164
+ if (extendedConfigStatus)
125165
+ return extendedConfigStatus;
125166
+ // Check package file time
125167
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125168
+ var path = _a[0];
125169
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125170
+ });
125171
+ if (dependentPackageFileStatus)
125172
+ return dependentPackageFileStatus;
125173
+ }
125174
+ if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125175
+ state.buildInfoChecked.set(resolvedPath, true);
125176
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125177
+ if (buildInfoPath) {
125178
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125179
+ var value = state.readFileWithCache(buildInfoPath);
125180
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125181
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125182
+ var buildInfo = value && ts.getBuildInfo(value);
125183
+ if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125422
125184
  return {
125423
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125424
- outOfDateOutputFileName: buildInfoPath,
125425
- newerProjectName: ref.path
125185
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125186
+ version: buildInfo.version
125426
125187
  };
125427
125188
  }
125428
- // If the upstream project has only change .d.ts files, and we've built
125429
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125430
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125431
- pseudoUpToDate = true;
125432
- upstreamChangedProject = ref.path;
125433
- continue;
125434
- }
125435
- // We have an output older than an upstream output - we are out of date
125436
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125437
- return {
125438
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125439
- outOfDateOutputFileName: oldestOutputFileName,
125440
- newerProjectName: ref.path
125441
- };
125442
125189
  }
125443
125190
  }
125444
- // Check tsconfig time
125445
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125446
- if (configStatus)
125447
- return configStatus;
125448
- // Check extended config time
125449
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125450
- if (extendedConfigStatus)
125451
- return extendedConfigStatus;
125452
- // Check package file time
125453
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125454
- var path = _a[0];
125455
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125456
- });
125457
- if (dependentPackageFileStatus)
125458
- return dependentPackageFileStatus;
125459
125191
  if (usesPrepend && pseudoUpToDate) {
125460
125192
  return {
125461
125193
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125465,37 +125197,15 @@ var ts;
125465
125197
  }
125466
125198
  // Up to date
125467
125199
  return {
125468
- type: pseudoUpToDate ?
125469
- ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
125470
- pseudoInputUptodate ?
125471
- ts.UpToDateStatusType.UpToDateWithInputFileText :
125472
- ts.UpToDateStatusType.UpToDate,
125200
+ type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
125473
125201
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125474
125202
  newestInputFileTime: newestInputFileTime,
125203
+ newestOutputFileTime: newestOutputFileTime,
125475
125204
  newestInputFileName: newestInputFileName,
125205
+ newestOutputFileName: newestOutputFileName,
125476
125206
  oldestOutputFileName: oldestOutputFileName
125477
125207
  };
125478
125208
  }
125479
- function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
125480
- if (seenRefs.has(resolvedRefPath))
125481
- return false;
125482
- seenRefs.add(resolvedRefPath);
125483
- var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
125484
- if (refBuildInfo.path === buildInfoCacheEntry.path)
125485
- return true;
125486
- if (resolvedConfig.projectReferences) {
125487
- // Check references
125488
- for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
125489
- var ref = _a[_i];
125490
- var resolvedRef = ts.resolveProjectReferencePath(ref);
125491
- var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
125492
- var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
125493
- if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
125494
- return true;
125495
- }
125496
- }
125497
- return false;
125498
- }
125499
125209
  function getUpToDateStatus(state, project, resolvedPath) {
125500
125210
  if (project === undefined) {
125501
125211
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125511,69 +125221,42 @@ var ts;
125511
125221
  state.projectStatus.set(resolvedPath, actual);
125512
125222
  return actual;
125513
125223
  }
125514
- function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125224
+ function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125515
125225
  if (proj.options.noEmit)
125516
- return;
125517
- var now;
125226
+ return priorNewestUpdateTime;
125518
125227
  ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125519
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
125520
- if (buildInfoPath) {
125521
- if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
125522
- if (!!state.options.verbose)
125228
+ var host = state.host;
125229
+ var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125230
+ if (!skipOutputs || outputs.length !== skipOutputs.size) {
125231
+ var reportVerbose = !!state.options.verbose;
125232
+ var now = host.now ? host.now() : new Date();
125233
+ for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125234
+ var file = outputs_2[_i];
125235
+ if (skipOutputs && skipOutputs.has(toPath(state, file))) {
125236
+ continue;
125237
+ }
125238
+ if (reportVerbose) {
125239
+ reportVerbose = false;
125523
125240
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125524
- state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
125525
- getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
125526
- }
125527
- state.outputTimeStamps.delete(projectPath);
125528
- }
125529
- else {
125530
- var host = state.host;
125531
- var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125532
- var outputTimeStampMap_1 = getOutputTimeStampMap(state, projectPath);
125533
- var modifiedOutputs_1 = outputTimeStampMap_1 ? new ts.Set() : undefined;
125534
- if (!skipOutputs || outputs.length !== skipOutputs.size) {
125535
- var reportVerbose = !!state.options.verbose;
125536
- for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125537
- var file = outputs_2[_i];
125538
- var path = toPath(state, file);
125539
- if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125540
- continue;
125541
- if (reportVerbose) {
125542
- reportVerbose = false;
125543
- reportStatus(state, verboseMessage, proj.options.configFilePath);
125544
- }
125545
- host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
125546
- if (outputTimeStampMap_1) {
125547
- outputTimeStampMap_1.set(path, now);
125548
- modifiedOutputs_1.add(path);
125549
- }
125550
125241
  }
125242
+ if (ts.isDeclarationFileName(file)) {
125243
+ priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
125244
+ }
125245
+ host.setModifiedTime(file, now);
125551
125246
  }
125552
- // Clear out timestamps not in output list any more
125553
- outputTimeStampMap_1 === null || outputTimeStampMap_1 === void 0 ? void 0 : outputTimeStampMap_1.forEach(function (_value, key) {
125554
- if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs_1.has(key))
125555
- outputTimeStampMap_1.delete(key);
125556
- });
125557
125247
  }
125558
125248
  ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125559
125249
  ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125560
- }
125561
- function getDtsChangeTime(state, options, resolvedConfigPath) {
125562
- var _a;
125563
- if (!options.composite)
125564
- return undefined;
125565
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125566
- var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
125567
- 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;
125250
+ return priorNewestUpdateTime;
125568
125251
  }
125569
125252
  function updateOutputTimestamps(state, proj, resolvedPath) {
125570
125253
  if (state.options.dry) {
125571
125254
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125572
125255
  }
125573
- updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125256
+ var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125574
125257
  state.projectStatus.set(resolvedPath, {
125575
125258
  type: ts.UpToDateStatusType.UpToDate,
125576
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125259
+ newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
125577
125260
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125578
125261
  });
125579
125262
  }
@@ -125619,7 +125302,6 @@ var ts;
125619
125302
  break;
125620
125303
  }
125621
125304
  // falls through
125622
- case ts.UpToDateStatusType.UpToDateWithInputFileText:
125623
125305
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125624
125306
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125625
125307
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125804,10 +125486,12 @@ var ts;
125804
125486
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125805
125487
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
125806
125488
  return;
125807
- 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));
125489
+ state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125490
+ invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125491
+ }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
125808
125492
  }
125809
125493
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
125810
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125494
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
125811
125495
  var _a;
125812
125496
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
125813
125497
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -125839,7 +125523,7 @@ var ts;
125839
125523
  if (!state.watch)
125840
125524
  return;
125841
125525
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
125842
- 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); },
125526
+ 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); },
125843
125527
  onDeleteValue: ts.closeFileWatcher,
125844
125528
  });
125845
125529
  }
@@ -125847,7 +125531,7 @@ var ts;
125847
125531
  if (!state.watch || !state.lastCachedPackageJsonLookups)
125848
125532
  return;
125849
125533
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
125850
- 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); },
125534
+ 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); },
125851
125535
  onDeleteValue: ts.closeFileWatcher,
125852
125536
  });
125853
125537
  }
@@ -125980,18 +125664,19 @@ var ts;
125980
125664
  }
125981
125665
  }
125982
125666
  function reportUpToDateStatus(state, configFileName, status) {
125667
+ if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
125668
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125669
+ }
125983
125670
  switch (status.type) {
125984
125671
  case ts.UpToDateStatusType.OutOfDateWithSelf:
125985
- 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));
125672
+ 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));
125986
125673
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
125987
- 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));
125674
+ 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));
125988
125675
  case ts.UpToDateStatusType.OutputMissing:
125989
125676
  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));
125990
- case ts.UpToDateStatusType.OutOfDateBuildInfo:
125991
- 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));
125992
125677
  case ts.UpToDateStatusType.UpToDate:
125993
125678
  if (status.newestInputFileTime !== undefined) {
125994
- 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 || ""));
125679
+ 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 || ""));
125995
125680
  }
125996
125681
  // Don't report anything for "up to date because it was already built" -- too verbose
125997
125682
  break;
@@ -125999,8 +125684,6 @@ var ts;
125999
125684
  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));
126000
125685
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126001
125686
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126002
- case ts.UpToDateStatusType.UpToDateWithInputFileText:
126003
- 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));
126004
125687
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126005
125688
  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));
126006
125689
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126011,8 +125694,6 @@ var ts;
126011
125694
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126012
125695
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126013
125696
  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);
126014
- case ts.UpToDateStatusType.ForceBuild:
126015
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126016
125697
  case ts.UpToDateStatusType.ContainerOnly:
126017
125698
  // Don't report status on "solution" projects
126018
125699
  // falls through