@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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220527";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220531";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5298,6 +5298,11 @@ var ts;
5298
5298
  // Flags that require TypeFlags.Union
5299
5299
  /* @internal */
5300
5300
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5301
+ /* @internal */
5302
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5303
+ /* @internal */
5304
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5305
+ /* @internal */
5301
5306
  // Flags that require TypeFlags.Intersection
5302
5307
  /* @internal */
5303
5308
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -6389,7 +6394,7 @@ var ts;
6389
6394
  };
6390
6395
  }
6391
6396
  function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6392
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) {
6397
+ var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
6393
6398
  // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
6394
6399
  if (!ts.isString(relativeFileName))
6395
6400
  return;
@@ -6399,7 +6404,7 @@ var ts;
6399
6404
  if (callbacks) {
6400
6405
  for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
6401
6406
  var fileCallback = callbacks_1[_i];
6402
- fileCallback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6407
+ fileCallback(fileName, FileWatcherEventKind.Changed);
6403
6408
  }
6404
6409
  }
6405
6410
  },
@@ -6453,7 +6458,7 @@ var ts;
6453
6458
  }
6454
6459
  else {
6455
6460
  cache.set(path, {
6456
- watcher: watchFile(fileName, function (fileName, eventKind, modifiedTime) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind, modifiedTime); }); }, pollingInterval, options),
6461
+ watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6457
6462
  refCount: 1
6458
6463
  });
6459
6464
  }
@@ -6481,7 +6486,7 @@ var ts;
6481
6486
  var newTime = modifiedTime.getTime();
6482
6487
  if (oldTime !== newTime) {
6483
6488
  watchedFile.mtime = modifiedTime;
6484
- watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime), modifiedTime);
6489
+ watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
6485
6490
  return true;
6486
6491
  }
6487
6492
  return false;
@@ -6732,18 +6737,17 @@ var ts;
6732
6737
  })(FileSystemEntryKind = ts.FileSystemEntryKind || (ts.FileSystemEntryKind = {}));
6733
6738
  /*@internal*/
6734
6739
  function createFileWatcherCallback(callback) {
6735
- return function (_fileName, eventKind, modifiedTime) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); };
6740
+ return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6736
6741
  }
6737
6742
  ts.createFileWatcherCallback = createFileWatcherCallback;
6738
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime) {
6739
- return function (eventName, _relativeFileName, modifiedTime) {
6743
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6744
+ return function (eventName) {
6740
6745
  if (eventName === "rename") {
6741
- modifiedTime || (modifiedTime = getModifiedTime(fileName) || ts.missingFileModifiedTime);
6742
- callback(fileName, modifiedTime !== ts.missingFileModifiedTime ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted, modifiedTime);
6746
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6743
6747
  }
6744
6748
  else {
6745
6749
  // Change
6746
- callback(fileName, FileWatcherEventKind.Changed, modifiedTime);
6750
+ callback(fileName, FileWatcherEventKind.Changed);
6747
6751
  }
6748
6752
  };
6749
6753
  }
@@ -6767,7 +6771,7 @@ var ts;
6767
6771
  }
6768
6772
  /*@internal*/
6769
6773
  function createSystemWatchFunctions(_a) {
6770
- 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;
6774
+ 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;
6771
6775
  var dynamicPollingWatchFile;
6772
6776
  var fixedChunkSizePollingWatchFile;
6773
6777
  var nonPollingWatchFile;
@@ -6789,7 +6793,7 @@ var ts;
6789
6793
  case ts.WatchFileKind.FixedChunkSizePolling:
6790
6794
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6791
6795
  case ts.WatchFileKind.UseFsEvents:
6792
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime),
6796
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6793
6797
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6794
6798
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6795
6799
  if (!nonPollingWatchFile) {
@@ -6971,6 +6975,7 @@ var ts;
6971
6975
  fsWatch: fsWatch,
6972
6976
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6973
6977
  getCurrentDirectory: getCurrentDirectory,
6978
+ fileExists: fileExists,
6974
6979
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6975
6980
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6976
6981
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
@@ -7230,7 +7235,7 @@ var ts;
7230
7235
  // File changed
7231
7236
  eventKind = FileWatcherEventKind.Changed;
7232
7237
  }
7233
- callback(fileName, eventKind, curr.mtime);
7238
+ callback(fileName, eventKind);
7234
7239
  }
7235
7240
  }
7236
7241
  function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
@@ -7256,10 +7261,10 @@ var ts;
7256
7261
  * Invoke the callback with rename and update the watcher if not closed
7257
7262
  * @param createWatcher
7258
7263
  */
7259
- function invokeCallbackAndUpdateWatcher(createWatcher, modifiedTime) {
7264
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
7260
7265
  sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7261
7266
  // Call the callback for current directory
7262
- callback("rename", "", modifiedTime);
7267
+ callback("rename", "");
7263
7268
  // If watcher is not closed, update it
7264
7269
  if (watcher) {
7265
7270
  watcher.close();
@@ -7305,14 +7310,13 @@ var ts;
7305
7310
  function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7306
7311
  // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7307
7312
  // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7308
- var modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime;
7309
7313
  return event === "rename" &&
7310
7314
  (!relativeName ||
7311
7315
  relativeName === lastDirectoryPart ||
7312
7316
  (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7313
- modifiedTime === ts.missingFileModifiedTime ?
7314
- invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry, modifiedTime) :
7315
- callback(event, relativeName, modifiedTime);
7317
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7318
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7319
+ callback(event, relativeName);
7316
7320
  }
7317
7321
  /**
7318
7322
  * Watch the file or directory using fs.watchFile since fs.watch threw exception
@@ -7326,15 +7330,12 @@ var ts;
7326
7330
  * and switch to existing file or directory when the missing filesystem entry is created
7327
7331
  */
7328
7332
  function watchMissingFileSystemEntry() {
7329
- return watchFile(fileOrDirectory, function (_fileName, eventKind, modifiedTime) {
7330
- if (eventKind === FileWatcherEventKind.Created) {
7331
- modifiedTime || (modifiedTime = getModifiedTime(fileOrDirectory) || ts.missingFileModifiedTime);
7332
- if (modifiedTime !== ts.missingFileModifiedTime) {
7333
- // Call the callback for current file or directory
7334
- // For now it could be callback for the inner directory creation,
7335
- // but just return current directory, better than current no-op
7336
- invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry, modifiedTime);
7337
- }
7333
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7334
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7335
+ // Call the callback for current file or directory
7336
+ // For now it could be callback for the inner directory creation,
7337
+ // but just return current directory, better than current no-op
7338
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7338
7339
  }
7339
7340
  }, fallbackPollingInterval, fallbackOptions);
7340
7341
  }
@@ -7484,19 +7485,12 @@ var ts;
7484
7485
  }
7485
7486
  function getModifiedTime(path) {
7486
7487
  var _a;
7487
- // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
7488
- // the CPU time performance.
7489
- var originalStackTraceLimit = Error.stackTraceLimit;
7490
- Error.stackTraceLimit = 0;
7491
7488
  try {
7492
7489
  return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7493
7490
  }
7494
7491
  catch (e) {
7495
7492
  return undefined;
7496
7493
  }
7497
- finally {
7498
- Error.stackTraceLimit = originalStackTraceLimit;
7499
- }
7500
7494
  }
7501
7495
  function setModifiedTime(path, time) {
7502
7496
  try {
@@ -8622,6 +8616,7 @@ var ts;
8622
8616
  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),
8623
8617
  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."),
8624
8618
  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."),
8619
+ 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."),
8625
8620
  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."),
8626
8621
  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."),
8627
8622
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -9517,8 +9512,8 @@ var ts;
9517
9512
  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"),
9518
9513
  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"),
9519
9514
  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."),
9520
- 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}'"),
9521
- 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}'"),
9515
+ 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}'"),
9516
+ 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}'"),
9522
9517
  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"),
9523
9518
  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"),
9524
9519
  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"),
@@ -9562,8 +9557,6 @@ var ts;
9562
9557
  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}'."),
9563
9558
  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}'."),
9564
9559
  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."),
9565
- 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"),
9566
- 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"),
9567
9560
  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}'"),
9568
9561
  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."),
9569
9562
  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."),
@@ -20393,10 +20386,6 @@ var ts;
20393
20386
  return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations);
20394
20387
  }
20395
20388
  ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
20396
- function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20397
- return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations);
20398
- }
20399
- ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath;
20400
20389
  function getCompilerOptionValue(options, option) {
20401
20390
  return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20402
20391
  }
@@ -39437,7 +39426,6 @@ var ts;
39437
39426
  type: "boolean",
39438
39427
  affectsSemanticDiagnostics: true,
39439
39428
  affectsEmit: true,
39440
- affectsMultiFileEmitBuildInfo: true,
39441
39429
  category: ts.Diagnostics.Watch_and_Build_Modes,
39442
39430
  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,
39443
39431
  defaultValueDescription: false,
@@ -39472,40 +39460,12 @@ var ts;
39472
39460
  affectsSourceFile: true,
39473
39461
  affectsModuleResolution: true,
39474
39462
  affectsEmit: true,
39475
- affectsMultiFileEmitBuildInfo: true,
39476
39463
  paramType: ts.Diagnostics.VERSION,
39477
39464
  showInSimplifiedHelpView: true,
39478
39465
  category: ts.Diagnostics.Language_and_Environment,
39479
39466
  description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
39480
39467
  defaultValueDescription: 0 /* ES3 */,
39481
39468
  };
39482
- /*@internal*/
39483
- ts.moduleOptionDeclaration = {
39484
- name: "module",
39485
- shortName: "m",
39486
- type: new ts.Map(ts.getEntries({
39487
- none: ts.ModuleKind.None,
39488
- commonjs: ts.ModuleKind.CommonJS,
39489
- amd: ts.ModuleKind.AMD,
39490
- system: ts.ModuleKind.System,
39491
- umd: ts.ModuleKind.UMD,
39492
- es6: ts.ModuleKind.ES2015,
39493
- es2015: ts.ModuleKind.ES2015,
39494
- es2020: ts.ModuleKind.ES2020,
39495
- es2022: ts.ModuleKind.ES2022,
39496
- esnext: ts.ModuleKind.ESNext,
39497
- node16: ts.ModuleKind.Node16,
39498
- nodenext: ts.ModuleKind.NodeNext,
39499
- })),
39500
- affectsModuleResolution: true,
39501
- affectsEmit: true,
39502
- affectsMultiFileEmitBuildInfo: true,
39503
- paramType: ts.Diagnostics.KIND,
39504
- showInSimplifiedHelpView: true,
39505
- category: ts.Diagnostics.Modules,
39506
- description: ts.Diagnostics.Specify_what_module_code_is_generated,
39507
- defaultValueDescription: undefined,
39508
- };
39509
39469
  var commandOptionsWithoutBuild = [
39510
39470
  // CommandLine only options
39511
39471
  {
@@ -39567,14 +39527,37 @@ var ts;
39567
39527
  category: ts.Diagnostics.Command_line_Options,
39568
39528
  affectsSemanticDiagnostics: true,
39569
39529
  affectsEmit: true,
39570
- affectsMultiFileEmitBuildInfo: true,
39571
39530
  isCommandLineOnly: true,
39572
39531
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
39573
39532
  defaultValueDescription: false,
39574
39533
  },
39575
39534
  // Basic
39576
39535
  ts.targetOptionDeclaration,
39577
- ts.moduleOptionDeclaration,
39536
+ {
39537
+ name: "module",
39538
+ shortName: "m",
39539
+ type: new ts.Map(ts.getEntries({
39540
+ none: ts.ModuleKind.None,
39541
+ commonjs: ts.ModuleKind.CommonJS,
39542
+ amd: ts.ModuleKind.AMD,
39543
+ system: ts.ModuleKind.System,
39544
+ umd: ts.ModuleKind.UMD,
39545
+ es6: ts.ModuleKind.ES2015,
39546
+ es2015: ts.ModuleKind.ES2015,
39547
+ es2020: ts.ModuleKind.ES2020,
39548
+ es2022: ts.ModuleKind.ES2022,
39549
+ esnext: ts.ModuleKind.ESNext,
39550
+ node16: ts.ModuleKind.Node16,
39551
+ nodenext: ts.ModuleKind.NodeNext,
39552
+ })),
39553
+ affectsModuleResolution: true,
39554
+ affectsEmit: true,
39555
+ paramType: ts.Diagnostics.KIND,
39556
+ showInSimplifiedHelpView: true,
39557
+ category: ts.Diagnostics.Modules,
39558
+ description: ts.Diagnostics.Specify_what_module_code_is_generated,
39559
+ defaultValueDescription: undefined,
39560
+ },
39578
39561
  {
39579
39562
  name: "lib",
39580
39563
  type: "list",
@@ -39611,7 +39594,6 @@ var ts;
39611
39594
  type: jsxOptionMap,
39612
39595
  affectsSourceFile: true,
39613
39596
  affectsEmit: true,
39614
- affectsMultiFileEmitBuildInfo: true,
39615
39597
  affectsModuleResolution: true,
39616
39598
  paramType: ts.Diagnostics.KIND,
39617
39599
  showInSimplifiedHelpView: true,
@@ -39624,7 +39606,6 @@ var ts;
39624
39606
  shortName: "d",
39625
39607
  type: "boolean",
39626
39608
  affectsEmit: true,
39627
- affectsMultiFileEmitBuildInfo: true,
39628
39609
  showInSimplifiedHelpView: true,
39629
39610
  category: ts.Diagnostics.Emit,
39630
39611
  transpileOptionValue: undefined,
@@ -39635,7 +39616,6 @@ var ts;
39635
39616
  name: "declarationMap",
39636
39617
  type: "boolean",
39637
39618
  affectsEmit: true,
39638
- affectsMultiFileEmitBuildInfo: true,
39639
39619
  showInSimplifiedHelpView: true,
39640
39620
  category: ts.Diagnostics.Emit,
39641
39621
  transpileOptionValue: undefined,
@@ -39646,7 +39626,6 @@ var ts;
39646
39626
  name: "emitDeclarationOnly",
39647
39627
  type: "boolean",
39648
39628
  affectsEmit: true,
39649
- affectsMultiFileEmitBuildInfo: true,
39650
39629
  showInSimplifiedHelpView: true,
39651
39630
  category: ts.Diagnostics.Emit,
39652
39631
  description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files,
@@ -39657,7 +39636,6 @@ var ts;
39657
39636
  name: "sourceMap",
39658
39637
  type: "boolean",
39659
39638
  affectsEmit: true,
39660
- affectsMultiFileEmitBuildInfo: true,
39661
39639
  showInSimplifiedHelpView: true,
39662
39640
  category: ts.Diagnostics.Emit,
39663
39641
  defaultValueDescription: false,
@@ -39667,9 +39645,6 @@ var ts;
39667
39645
  name: "outFile",
39668
39646
  type: "string",
39669
39647
  affectsEmit: true,
39670
- affectsMultiFileEmitBuildInfo: true,
39671
- affectsDeclarationPath: true,
39672
- affectsBundleEmitBuildInfo: true,
39673
39648
  isFilePath: true,
39674
39649
  paramType: ts.Diagnostics.FILE,
39675
39650
  showInSimplifiedHelpView: true,
@@ -39681,8 +39656,6 @@ var ts;
39681
39656
  name: "outDir",
39682
39657
  type: "string",
39683
39658
  affectsEmit: true,
39684
- affectsMultiFileEmitBuildInfo: true,
39685
- affectsDeclarationPath: true,
39686
39659
  isFilePath: true,
39687
39660
  paramType: ts.Diagnostics.DIRECTORY,
39688
39661
  showInSimplifiedHelpView: true,
@@ -39693,8 +39666,6 @@ var ts;
39693
39666
  name: "rootDir",
39694
39667
  type: "string",
39695
39668
  affectsEmit: true,
39696
- affectsMultiFileEmitBuildInfo: true,
39697
- affectsDeclarationPath: true,
39698
39669
  isFilePath: true,
39699
39670
  paramType: ts.Diagnostics.LOCATION,
39700
39671
  category: ts.Diagnostics.Modules,
@@ -39705,8 +39676,6 @@ var ts;
39705
39676
  name: "composite",
39706
39677
  type: "boolean",
39707
39678
  affectsEmit: true,
39708
- affectsMultiFileEmitBuildInfo: true,
39709
- affectsBundleEmitBuildInfo: true,
39710
39679
  isTSConfigOnly: true,
39711
39680
  category: ts.Diagnostics.Projects,
39712
39681
  transpileOptionValue: undefined,
@@ -39717,8 +39686,6 @@ var ts;
39717
39686
  name: "tsBuildInfoFile",
39718
39687
  type: "string",
39719
39688
  affectsEmit: true,
39720
- affectsMultiFileEmitBuildInfo: true,
39721
- affectsBundleEmitBuildInfo: true,
39722
39689
  isFilePath: true,
39723
39690
  paramType: ts.Diagnostics.FILE,
39724
39691
  category: ts.Diagnostics.Projects,
@@ -39730,7 +39697,6 @@ var ts;
39730
39697
  name: "removeComments",
39731
39698
  type: "boolean",
39732
39699
  affectsEmit: true,
39733
- affectsMultiFileEmitBuildInfo: true,
39734
39700
  showInSimplifiedHelpView: true,
39735
39701
  category: ts.Diagnostics.Emit,
39736
39702
  defaultValueDescription: false,
@@ -39749,7 +39715,6 @@ var ts;
39749
39715
  name: "importHelpers",
39750
39716
  type: "boolean",
39751
39717
  affectsEmit: true,
39752
- affectsMultiFileEmitBuildInfo: true,
39753
39718
  category: ts.Diagnostics.Emit,
39754
39719
  description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
39755
39720
  defaultValueDescription: false,
@@ -39763,7 +39728,6 @@ var ts;
39763
39728
  })),
39764
39729
  affectsEmit: true,
39765
39730
  affectsSemanticDiagnostics: true,
39766
- affectsMultiFileEmitBuildInfo: true,
39767
39731
  category: ts.Diagnostics.Emit,
39768
39732
  description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
39769
39733
  defaultValueDescription: 0 /* Remove */,
@@ -39772,7 +39736,6 @@ var ts;
39772
39736
  name: "downlevelIteration",
39773
39737
  type: "boolean",
39774
39738
  affectsEmit: true,
39775
- affectsMultiFileEmitBuildInfo: true,
39776
39739
  category: ts.Diagnostics.Emit,
39777
39740
  description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration,
39778
39741
  defaultValueDescription: false,
@@ -39791,9 +39754,6 @@ var ts;
39791
39754
  type: "boolean",
39792
39755
  // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here
39793
39756
  // The value of each strictFlag depends on own strictFlag value or this and never accessed directly.
39794
- // But we need to store `strict` in builf info, even though it won't be examined directly, so that the
39795
- // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly
39796
- affectsMultiFileEmitBuildInfo: true,
39797
39757
  showInSimplifiedHelpView: true,
39798
39758
  category: ts.Diagnostics.Type_Checking,
39799
39759
  description: ts.Diagnostics.Enable_all_strict_type_checking_options,
@@ -39803,7 +39763,6 @@ var ts;
39803
39763
  name: "noImplicitAny",
39804
39764
  type: "boolean",
39805
39765
  affectsSemanticDiagnostics: true,
39806
- affectsMultiFileEmitBuildInfo: true,
39807
39766
  strictFlag: true,
39808
39767
  category: ts.Diagnostics.Type_Checking,
39809
39768
  description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
@@ -39813,7 +39772,6 @@ var ts;
39813
39772
  name: "strictNullChecks",
39814
39773
  type: "boolean",
39815
39774
  affectsSemanticDiagnostics: true,
39816
- affectsMultiFileEmitBuildInfo: true,
39817
39775
  strictFlag: true,
39818
39776
  category: ts.Diagnostics.Type_Checking,
39819
39777
  description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined,
@@ -39822,8 +39780,6 @@ var ts;
39822
39780
  {
39823
39781
  name: "strictFunctionTypes",
39824
39782
  type: "boolean",
39825
- affectsSemanticDiagnostics: true,
39826
- affectsMultiFileEmitBuildInfo: true,
39827
39783
  strictFlag: true,
39828
39784
  category: ts.Diagnostics.Type_Checking,
39829
39785
  description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
@@ -39832,8 +39788,6 @@ var ts;
39832
39788
  {
39833
39789
  name: "strictBindCallApply",
39834
39790
  type: "boolean",
39835
- affectsSemanticDiagnostics: true,
39836
- affectsMultiFileEmitBuildInfo: true,
39837
39791
  strictFlag: true,
39838
39792
  category: ts.Diagnostics.Type_Checking,
39839
39793
  description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
@@ -39843,7 +39797,6 @@ var ts;
39843
39797
  name: "strictPropertyInitialization",
39844
39798
  type: "boolean",
39845
39799
  affectsSemanticDiagnostics: true,
39846
- affectsMultiFileEmitBuildInfo: true,
39847
39800
  strictFlag: true,
39848
39801
  category: ts.Diagnostics.Type_Checking,
39849
39802
  description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
@@ -39853,7 +39806,6 @@ var ts;
39853
39806
  name: "noImplicitThis",
39854
39807
  type: "boolean",
39855
39808
  affectsSemanticDiagnostics: true,
39856
- affectsMultiFileEmitBuildInfo: true,
39857
39809
  strictFlag: true,
39858
39810
  category: ts.Diagnostics.Type_Checking,
39859
39811
  description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
@@ -39863,7 +39815,6 @@ var ts;
39863
39815
  name: "useUnknownInCatchVariables",
39864
39816
  type: "boolean",
39865
39817
  affectsSemanticDiagnostics: true,
39866
- affectsMultiFileEmitBuildInfo: true,
39867
39818
  strictFlag: true,
39868
39819
  category: ts.Diagnostics.Type_Checking,
39869
39820
  description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
@@ -39873,8 +39824,6 @@ var ts;
39873
39824
  name: "alwaysStrict",
39874
39825
  type: "boolean",
39875
39826
  affectsSourceFile: true,
39876
- affectsEmit: true,
39877
- affectsMultiFileEmitBuildInfo: true,
39878
39827
  strictFlag: true,
39879
39828
  category: ts.Diagnostics.Type_Checking,
39880
39829
  description: ts.Diagnostics.Ensure_use_strict_is_always_emitted,
@@ -39885,7 +39834,6 @@ var ts;
39885
39834
  name: "noUnusedLocals",
39886
39835
  type: "boolean",
39887
39836
  affectsSemanticDiagnostics: true,
39888
- affectsMultiFileEmitBuildInfo: true,
39889
39837
  category: ts.Diagnostics.Type_Checking,
39890
39838
  description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
39891
39839
  defaultValueDescription: false,
@@ -39894,7 +39842,6 @@ var ts;
39894
39842
  name: "noUnusedParameters",
39895
39843
  type: "boolean",
39896
39844
  affectsSemanticDiagnostics: true,
39897
- affectsMultiFileEmitBuildInfo: true,
39898
39845
  category: ts.Diagnostics.Type_Checking,
39899
39846
  description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
39900
39847
  defaultValueDescription: false,
@@ -39903,7 +39850,6 @@ var ts;
39903
39850
  name: "exactOptionalPropertyTypes",
39904
39851
  type: "boolean",
39905
39852
  affectsSemanticDiagnostics: true,
39906
- affectsMultiFileEmitBuildInfo: true,
39907
39853
  category: ts.Diagnostics.Type_Checking,
39908
39854
  description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
39909
39855
  defaultValueDescription: false,
@@ -39912,7 +39858,6 @@ var ts;
39912
39858
  name: "noImplicitReturns",
39913
39859
  type: "boolean",
39914
39860
  affectsSemanticDiagnostics: true,
39915
- affectsMultiFileEmitBuildInfo: true,
39916
39861
  category: ts.Diagnostics.Type_Checking,
39917
39862
  description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function,
39918
39863
  defaultValueDescription: false,
@@ -39922,7 +39867,6 @@ var ts;
39922
39867
  type: "boolean",
39923
39868
  affectsBindDiagnostics: true,
39924
39869
  affectsSemanticDiagnostics: true,
39925
- affectsMultiFileEmitBuildInfo: true,
39926
39870
  category: ts.Diagnostics.Type_Checking,
39927
39871
  description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
39928
39872
  defaultValueDescription: false,
@@ -39931,7 +39875,6 @@ var ts;
39931
39875
  name: "noUncheckedIndexedAccess",
39932
39876
  type: "boolean",
39933
39877
  affectsSemanticDiagnostics: true,
39934
- affectsMultiFileEmitBuildInfo: true,
39935
39878
  category: ts.Diagnostics.Type_Checking,
39936
39879
  description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
39937
39880
  defaultValueDescription: false,
@@ -39940,7 +39883,6 @@ var ts;
39940
39883
  name: "noImplicitOverride",
39941
39884
  type: "boolean",
39942
39885
  affectsSemanticDiagnostics: true,
39943
- affectsMultiFileEmitBuildInfo: true,
39944
39886
  category: ts.Diagnostics.Type_Checking,
39945
39887
  description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
39946
39888
  defaultValueDescription: false,
@@ -39948,8 +39890,6 @@ var ts;
39948
39890
  {
39949
39891
  name: "noPropertyAccessFromIndexSignature",
39950
39892
  type: "boolean",
39951
- affectsSemanticDiagnostics: true,
39952
- affectsMultiFileEmitBuildInfo: true,
39953
39893
  showInSimplifiedHelpView: false,
39954
39894
  category: ts.Diagnostics.Type_Checking,
39955
39895
  description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type,
@@ -40035,7 +39975,6 @@ var ts;
40035
39975
  name: "allowSyntheticDefaultImports",
40036
39976
  type: "boolean",
40037
39977
  affectsSemanticDiagnostics: true,
40038
- affectsMultiFileEmitBuildInfo: true,
40039
39978
  category: ts.Diagnostics.Interop_Constraints,
40040
39979
  description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export,
40041
39980
  defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop
@@ -40045,7 +39984,6 @@ var ts;
40045
39984
  type: "boolean",
40046
39985
  affectsSemanticDiagnostics: true,
40047
39986
  affectsEmit: true,
40048
- affectsMultiFileEmitBuildInfo: true,
40049
39987
  showInSimplifiedHelpView: true,
40050
39988
  category: ts.Diagnostics.Interop_Constraints,
40051
39989
  description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility,
@@ -40062,7 +40000,6 @@ var ts;
40062
40000
  name: "allowUmdGlobalAccess",
40063
40001
  type: "boolean",
40064
40002
  affectsSemanticDiagnostics: true,
40065
- affectsMultiFileEmitBuildInfo: true,
40066
40003
  category: ts.Diagnostics.Modules,
40067
40004
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
40068
40005
  defaultValueDescription: false,
@@ -40084,7 +40021,6 @@ var ts;
40084
40021
  name: "sourceRoot",
40085
40022
  type: "string",
40086
40023
  affectsEmit: true,
40087
- affectsMultiFileEmitBuildInfo: true,
40088
40024
  paramType: ts.Diagnostics.LOCATION,
40089
40025
  category: ts.Diagnostics.Emit,
40090
40026
  description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code,
@@ -40093,7 +40029,6 @@ var ts;
40093
40029
  name: "mapRoot",
40094
40030
  type: "string",
40095
40031
  affectsEmit: true,
40096
- affectsMultiFileEmitBuildInfo: true,
40097
40032
  paramType: ts.Diagnostics.LOCATION,
40098
40033
  category: ts.Diagnostics.Emit,
40099
40034
  description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
@@ -40102,7 +40037,6 @@ var ts;
40102
40037
  name: "inlineSourceMap",
40103
40038
  type: "boolean",
40104
40039
  affectsEmit: true,
40105
- affectsMultiFileEmitBuildInfo: true,
40106
40040
  category: ts.Diagnostics.Emit,
40107
40041
  description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
40108
40042
  defaultValueDescription: false,
@@ -40111,7 +40045,6 @@ var ts;
40111
40045
  name: "inlineSources",
40112
40046
  type: "boolean",
40113
40047
  affectsEmit: true,
40114
- affectsMultiFileEmitBuildInfo: true,
40115
40048
  category: ts.Diagnostics.Emit,
40116
40049
  description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript,
40117
40050
  defaultValueDescription: false,
@@ -40121,7 +40054,6 @@ var ts;
40121
40054
  name: "experimentalDecorators",
40122
40055
  type: "boolean",
40123
40056
  affectsSemanticDiagnostics: true,
40124
- affectsMultiFileEmitBuildInfo: true,
40125
40057
  category: ts.Diagnostics.Language_and_Environment,
40126
40058
  description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
40127
40059
  defaultValueDescription: false,
@@ -40131,7 +40063,6 @@ var ts;
40131
40063
  type: "boolean",
40132
40064
  affectsSemanticDiagnostics: true,
40133
40065
  affectsEmit: true,
40134
- affectsMultiFileEmitBuildInfo: true,
40135
40066
  category: ts.Diagnostics.Language_and_Environment,
40136
40067
  description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
40137
40068
  defaultValueDescription: false,
@@ -40156,7 +40087,6 @@ var ts;
40156
40087
  type: "string",
40157
40088
  affectsSemanticDiagnostics: true,
40158
40089
  affectsEmit: true,
40159
- affectsMultiFileEmitBuildInfo: true,
40160
40090
  affectsModuleResolution: true,
40161
40091
  category: ts.Diagnostics.Language_and_Environment,
40162
40092
  description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
@@ -40174,9 +40104,6 @@ var ts;
40174
40104
  name: "out",
40175
40105
  type: "string",
40176
40106
  affectsEmit: true,
40177
- affectsMultiFileEmitBuildInfo: true,
40178
- affectsDeclarationPath: true,
40179
- affectsBundleEmitBuildInfo: true,
40180
40107
  isFilePath: false,
40181
40108
  // for correct behaviour, please use outFile
40182
40109
  category: ts.Diagnostics.Backwards_Compatibility,
@@ -40188,7 +40115,6 @@ var ts;
40188
40115
  name: "reactNamespace",
40189
40116
  type: "string",
40190
40117
  affectsEmit: true,
40191
- affectsMultiFileEmitBuildInfo: true,
40192
40118
  category: ts.Diagnostics.Language_and_Environment,
40193
40119
  description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit,
40194
40120
  defaultValueDescription: "`React`",
@@ -40196,8 +40122,6 @@ var ts;
40196
40122
  {
40197
40123
  name: "skipDefaultLibCheck",
40198
40124
  type: "boolean",
40199
- // We need to store these to determine whether `lib` files need to be rechecked
40200
- affectsMultiFileEmitBuildInfo: true,
40201
40125
  category: ts.Diagnostics.Completeness,
40202
40126
  description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript,
40203
40127
  defaultValueDescription: false,
@@ -40213,7 +40137,6 @@ var ts;
40213
40137
  name: "emitBOM",
40214
40138
  type: "boolean",
40215
40139
  affectsEmit: true,
40216
- affectsMultiFileEmitBuildInfo: true,
40217
40140
  category: ts.Diagnostics.Emit,
40218
40141
  description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files,
40219
40142
  defaultValueDescription: false,
@@ -40225,7 +40148,6 @@ var ts;
40225
40148
  lf: 1 /* LineFeed */
40226
40149
  })),
40227
40150
  affectsEmit: true,
40228
- affectsMultiFileEmitBuildInfo: true,
40229
40151
  paramType: ts.Diagnostics.NEWLINE,
40230
40152
  category: ts.Diagnostics.Emit,
40231
40153
  description: ts.Diagnostics.Set_the_newline_character_for_emitting_files,
@@ -40235,7 +40157,6 @@ var ts;
40235
40157
  name: "noErrorTruncation",
40236
40158
  type: "boolean",
40237
40159
  affectsSemanticDiagnostics: true,
40238
- affectsMultiFileEmitBuildInfo: true,
40239
40160
  category: ts.Diagnostics.Output_Formatting,
40240
40161
  description: ts.Diagnostics.Disable_truncating_types_in_error_messages,
40241
40162
  defaultValueDescription: false,
@@ -40266,7 +40187,6 @@ var ts;
40266
40187
  name: "stripInternal",
40267
40188
  type: "boolean",
40268
40189
  affectsEmit: true,
40269
- affectsMultiFileEmitBuildInfo: true,
40270
40190
  category: ts.Diagnostics.Emit,
40271
40191
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
40272
40192
  defaultValueDescription: false,
@@ -40307,7 +40227,6 @@ var ts;
40307
40227
  name: "noImplicitUseStrict",
40308
40228
  type: "boolean",
40309
40229
  affectsSemanticDiagnostics: true,
40310
- affectsMultiFileEmitBuildInfo: true,
40311
40230
  category: ts.Diagnostics.Backwards_Compatibility,
40312
40231
  description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files,
40313
40232
  defaultValueDescription: false,
@@ -40316,7 +40235,6 @@ var ts;
40316
40235
  name: "noEmitHelpers",
40317
40236
  type: "boolean",
40318
40237
  affectsEmit: true,
40319
- affectsMultiFileEmitBuildInfo: true,
40320
40238
  category: ts.Diagnostics.Emit,
40321
40239
  description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output,
40322
40240
  defaultValueDescription: false,
@@ -40325,7 +40243,6 @@ var ts;
40325
40243
  name: "noEmitOnError",
40326
40244
  type: "boolean",
40327
40245
  affectsEmit: true,
40328
- affectsMultiFileEmitBuildInfo: true,
40329
40246
  category: ts.Diagnostics.Emit,
40330
40247
  transpileOptionValue: undefined,
40331
40248
  description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported,
@@ -40335,7 +40252,6 @@ var ts;
40335
40252
  name: "preserveConstEnums",
40336
40253
  type: "boolean",
40337
40254
  affectsEmit: true,
40338
- affectsMultiFileEmitBuildInfo: true,
40339
40255
  category: ts.Diagnostics.Emit,
40340
40256
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
40341
40257
  defaultValueDescription: false,
@@ -40344,8 +40260,6 @@ var ts;
40344
40260
  name: "declarationDir",
40345
40261
  type: "string",
40346
40262
  affectsEmit: true,
40347
- affectsMultiFileEmitBuildInfo: true,
40348
- affectsDeclarationPath: true,
40349
40263
  isFilePath: true,
40350
40264
  paramType: ts.Diagnostics.DIRECTORY,
40351
40265
  category: ts.Diagnostics.Emit,
@@ -40355,8 +40269,6 @@ var ts;
40355
40269
  {
40356
40270
  name: "skipLibCheck",
40357
40271
  type: "boolean",
40358
- // We need to store these to determine whether `lib` files need to be rechecked
40359
- affectsMultiFileEmitBuildInfo: true,
40360
40272
  category: ts.Diagnostics.Completeness,
40361
40273
  description: ts.Diagnostics.Skip_type_checking_all_d_ts_files,
40362
40274
  defaultValueDescription: false,
@@ -40366,7 +40278,6 @@ var ts;
40366
40278
  type: "boolean",
40367
40279
  affectsBindDiagnostics: true,
40368
40280
  affectsSemanticDiagnostics: true,
40369
- affectsMultiFileEmitBuildInfo: true,
40370
40281
  category: ts.Diagnostics.Type_Checking,
40371
40282
  description: ts.Diagnostics.Disable_error_reporting_for_unused_labels,
40372
40283
  defaultValueDescription: undefined,
@@ -40376,7 +40287,6 @@ var ts;
40376
40287
  type: "boolean",
40377
40288
  affectsBindDiagnostics: true,
40378
40289
  affectsSemanticDiagnostics: true,
40379
- affectsMultiFileEmitBuildInfo: true,
40380
40290
  category: ts.Diagnostics.Type_Checking,
40381
40291
  description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code,
40382
40292
  defaultValueDescription: undefined,
@@ -40385,7 +40295,6 @@ var ts;
40385
40295
  name: "suppressExcessPropertyErrors",
40386
40296
  type: "boolean",
40387
40297
  affectsSemanticDiagnostics: true,
40388
- affectsMultiFileEmitBuildInfo: true,
40389
40298
  category: ts.Diagnostics.Backwards_Compatibility,
40390
40299
  description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals,
40391
40300
  defaultValueDescription: false,
@@ -40394,7 +40303,6 @@ var ts;
40394
40303
  name: "suppressImplicitAnyIndexErrors",
40395
40304
  type: "boolean",
40396
40305
  affectsSemanticDiagnostics: true,
40397
- affectsMultiFileEmitBuildInfo: true,
40398
40306
  category: ts.Diagnostics.Backwards_Compatibility,
40399
40307
  description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures,
40400
40308
  defaultValueDescription: false,
@@ -40419,7 +40327,6 @@ var ts;
40419
40327
  name: "noStrictGenericChecks",
40420
40328
  type: "boolean",
40421
40329
  affectsSemanticDiagnostics: true,
40422
- affectsMultiFileEmitBuildInfo: true,
40423
40330
  category: ts.Diagnostics.Backwards_Compatibility,
40424
40331
  description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
40425
40332
  defaultValueDescription: false,
@@ -40429,7 +40336,6 @@ var ts;
40429
40336
  type: "boolean",
40430
40337
  affectsSemanticDiagnostics: true,
40431
40338
  affectsEmit: true,
40432
- affectsMultiFileEmitBuildInfo: true,
40433
40339
  category: ts.Diagnostics.Language_and_Environment,
40434
40340
  description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
40435
40341
  defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext
@@ -40438,7 +40344,6 @@ var ts;
40438
40344
  name: "preserveValueImports",
40439
40345
  type: "boolean",
40440
40346
  affectsEmit: true,
40441
- affectsMultiFileEmitBuildInfo: true,
40442
40347
  category: ts.Diagnostics.Emit,
40443
40348
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
40444
40349
  defaultValueDescription: false,
@@ -40482,8 +40387,6 @@ var ts;
40482
40387
  /* @internal */
40483
40388
  ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
40484
40389
  /* @internal */
40485
- ts.affectsDeclarationPathOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsDeclarationPath; });
40486
- /* @internal */
40487
40390
  ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
40488
40391
  /* @internal */
40489
40392
  ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
@@ -41339,7 +41242,6 @@ var ts;
41339
41242
  return optionDefinition.type;
41340
41243
  }
41341
41244
  }
41342
- /* @internal */
41343
41245
  function getNameOfCompilerOptionValue(value, customTypeMap) {
41344
41246
  // There is a typeMap associated with this command-line option so use it to map value back to its name
41345
41247
  return ts.forEachEntry(customTypeMap, function (mapValue, key) {
@@ -41348,7 +41250,6 @@ var ts;
41348
41250
  }
41349
41251
  });
41350
41252
  }
41351
- ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
41352
41253
  function serializeCompilerOptions(options, pathOptions) {
41353
41254
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
41354
41255
  }
@@ -48849,6 +48750,7 @@ var ts;
48849
48750
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48850
48751
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48851
48752
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48753
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48852
48754
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48853
48755
  emptyGenericType.instantiations = new ts.Map();
48854
48756
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -59019,7 +58921,7 @@ var ts;
59019
58921
  }
59020
58922
  }
59021
58923
  }
59022
- else if (t.flags & 469892092 /* DisjointDomains */) {
58924
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
59023
58925
  hasDisjointDomainType = true;
59024
58926
  }
59025
58927
  }
@@ -59031,7 +58933,7 @@ var ts;
59031
58933
  // intersection operation to reduce the union constraints.
59032
58934
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
59033
58935
  var t = types_6[_a];
59034
- if (t.flags & 469892092 /* DisjointDomains */) {
58936
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
59035
58937
  constraints = ts.append(constraints, t);
59036
58938
  }
59037
58939
  }
@@ -61580,7 +61482,7 @@ var ts;
61580
61482
  }
61581
61483
  return includes;
61582
61484
  }
61583
- function removeRedundantPrimitiveTypes(types, includes) {
61485
+ function removeRedundantSupertypes(types, includes) {
61584
61486
  var i = types.length;
61585
61487
  while (i > 0) {
61586
61488
  i--;
@@ -61588,7 +61490,9 @@ var ts;
61588
61490
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61589
61491
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61590
61492
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61591
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61493
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61494
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61495
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61592
61496
  if (remove) {
61593
61497
  ts.orderedRemoveItemAt(types, i);
61594
61498
  }
@@ -61710,7 +61614,7 @@ var ts;
61710
61614
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61711
61615
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61712
61616
  // for intersections of types with signatures can be deterministic.
61713
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61617
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61714
61618
  var typeMembershipMap = new ts.Map();
61715
61619
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61716
61620
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61747,11 +61651,11 @@ var ts;
61747
61651
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61748
61652
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61749
61653
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61750
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61751
- removeRedundantPrimitiveTypes(typeSet, includes);
61752
- }
61753
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61754
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61654
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61655
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61656
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61657
+ if (!noSupertypeReduction)
61658
+ removeRedundantSupertypes(typeSet, includes);
61755
61659
  }
61756
61660
  if (includes & 262144 /* IncludesMissingType */) {
61757
61661
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61790,8 +61694,9 @@ var ts;
61790
61694
  }
61791
61695
  var constituents = getCrossProductIntersections(typeSet);
61792
61696
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61793
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61794
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61697
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61698
+ // the denormalized origin has fewer constituents than the union itself.
61699
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61795
61700
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61796
61701
  }
61797
61702
  }
@@ -61834,11 +61739,21 @@ var ts;
61834
61739
  }
61835
61740
  return intersections;
61836
61741
  }
61742
+ function getConstituentCount(type) {
61743
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61744
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61745
+ getConstituentCountOfTypes(type.types);
61746
+ }
61747
+ function getConstituentCountOfTypes(types) {
61748
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61749
+ }
61837
61750
  function getTypeFromIntersectionTypeNode(node) {
61838
61751
  var links = getNodeLinks(node);
61839
61752
  if (!links.resolvedType) {
61840
61753
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61841
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61754
+ var types = ts.map(node.types, getTypeFromTypeNode);
61755
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61756
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61842
61757
  }
61843
61758
  return links.resolvedType;
61844
61759
  }
@@ -64624,6 +64539,17 @@ var ts;
64624
64539
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64625
64540
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64626
64541
  }
64542
+ function isUnknownLikeUnionType(type) {
64543
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64544
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64545
+ var types = type.types;
64546
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64547
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64548
+ }
64549
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64550
+ }
64551
+ return false;
64552
+ }
64627
64553
  function isStringIndexSignatureOnlyType(type) {
64628
64554
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64629
64555
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64703,7 +64629,7 @@ var ts;
64703
64629
  return true;
64704
64630
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64705
64631
  return true;
64706
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64632
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64707
64633
  return true;
64708
64634
  if (relation === assignableRelation || relation === comparableRelation) {
64709
64635
  if (s & 1 /* Any */)
@@ -64713,6 +64639,9 @@ var ts;
64713
64639
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64714
64640
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64715
64641
  return true;
64642
+ // Anything is assignable to a union containing undefined, null, and {}
64643
+ if (isUnknownLikeUnionType(target))
64644
+ return true;
64716
64645
  }
64717
64646
  return false;
64718
64647
  }
@@ -64755,16 +64684,27 @@ var ts;
64755
64684
  function getNormalizedType(type, writing) {
64756
64685
  while (true) {
64757
64686
  var t = isFreshLiteralType(type) ? type.regularType :
64758
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64759
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64687
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64688
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64760
64689
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64761
64690
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64762
64691
  type;
64763
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64764
64692
  if (t === type)
64765
- break;
64693
+ return t;
64766
64694
  type = t;
64767
64695
  }
64696
+ }
64697
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64698
+ var reduced = getReducedType(type);
64699
+ if (reduced !== type) {
64700
+ return reduced;
64701
+ }
64702
+ if (type.flags & 2097152 /* Intersection */) {
64703
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64704
+ if (normalizedTypes !== type.types) {
64705
+ return getIntersectionType(normalizedTypes);
64706
+ }
64707
+ }
64768
64708
  return type;
64769
64709
  }
64770
64710
  /**
@@ -65211,6 +65151,7 @@ var ts;
65211
65151
  return 0 /* False */;
65212
65152
  }
65213
65153
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
65154
+ var _a, _b;
65214
65155
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
65215
65156
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
65216
65157
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -65251,6 +65192,9 @@ var ts;
65251
65192
  return;
65252
65193
  }
65253
65194
  reportRelationError(headMessage, source, target);
65195
+ 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 */))) {
65196
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65197
+ }
65254
65198
  }
65255
65199
  function traceUnionsOrIntersectionsTooLarge(source, target) {
65256
65200
  if (!ts.tracing) {
@@ -66037,13 +65981,6 @@ var ts;
66037
65981
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66038
65982
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
66039
65983
  var constraint = getConstraintOfType(source) || unknownType;
66040
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
66041
- // A type variable with no constraint is not related to the non-primitive object type.
66042
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
66043
- resetErrorInfo(saveErrorInfo);
66044
- return result;
66045
- }
66046
- }
66047
65984
  // 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
66048
65985
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66049
65986
  resetErrorInfo(saveErrorInfo);
@@ -67517,9 +67454,11 @@ var ts;
67517
67454
  return getSupertypeOrUnion(types);
67518
67455
  }
67519
67456
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67520
- return primaryTypes.length ?
67521
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67522
- getUnionType(types, 2 /* Subtype */);
67457
+ if (primaryTypes.length) {
67458
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67459
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67460
+ }
67461
+ return getUnionType(types, 2 /* Subtype */);
67523
67462
  }
67524
67463
  // Return the leftmost type for which no type to the right is a subtype.
67525
67464
  function getCommonSubtype(types) {
@@ -67718,12 +67657,13 @@ var ts;
67718
67657
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67719
67658
  // no flags for all other types (including non-falsy literal types).
67720
67659
  function getFalsyFlags(type) {
67721
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67722
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67723
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67724
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67725
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67726
- type.flags & 117724 /* PossiblyFalsy */;
67660
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67661
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67662
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67663
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67664
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67665
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67666
+ t.flags & 117724 /* PossiblyFalsy */;
67727
67667
  }
67728
67668
  function removeDefinitelyFalsyTypes(type) {
67729
67669
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67763,20 +67703,22 @@ var ts;
67763
67703
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67764
67704
  }
67765
67705
  function getGlobalNonNullableTypeInstantiation(type) {
67766
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67767
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67768
- // that isn't eliminated by a NonNullable<T> instantiation.
67769
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67770
67706
  if (!deferredGlobalNonNullableTypeAlias) {
67771
67707
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67772
67708
  }
67773
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67774
67709
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67775
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67776
- reducedType;
67710
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67711
+ getIntersectionType([type, emptyObjectType]);
67777
67712
  }
67778
67713
  function getNonNullableType(type) {
67779
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67714
+ if (strictNullChecks) {
67715
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67716
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67717
+ // that isn't eliminated by a NonNullable<T> instantiation.
67718
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67719
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67720
+ }
67721
+ return type;
67780
67722
  }
67781
67723
  function addOptionalTypeMarker(type) {
67782
67724
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -69884,6 +69826,24 @@ var ts;
69884
69826
  function getTypeWithFacts(type, include) {
69885
69827
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69886
69828
  }
69829
+ function getIntersectionWithFacts(type, facts) {
69830
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69831
+ if (strictNullChecks) {
69832
+ switch (facts) {
69833
+ case 524288 /* NEUndefined */:
69834
+ 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; });
69835
+ case 1048576 /* NENull */:
69836
+ 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; });
69837
+ case 2097152 /* NEUndefinedOrNull */:
69838
+ case 4194304 /* Truthy */:
69839
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69840
+ }
69841
+ }
69842
+ return reduced;
69843
+ }
69844
+ function recombineUnknownType(type) {
69845
+ return type === unknownUnionType ? unknownType : type;
69846
+ }
69887
69847
  function getTypeWithDefault(type, defaultExpression) {
69888
69848
  return defaultExpression ?
69889
69849
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70941,7 +70901,7 @@ var ts;
70941
70901
  if (isEvolvingArrayTypeList(types)) {
70942
70902
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70943
70903
  }
70944
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70904
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70945
70905
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70946
70906
  return declaredType;
70947
70907
  }
@@ -71043,8 +71003,7 @@ var ts;
71043
71003
  }
71044
71004
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
71045
71005
  if (isMatchingReference(reference, expr)) {
71046
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
71047
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
71006
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
71048
71007
  }
71049
71008
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
71050
71009
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -71197,9 +71156,6 @@ var ts;
71197
71156
  assumeTrue = !assumeTrue;
71198
71157
  }
71199
71158
  var valueType = getTypeOfExpression(value);
71200
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
71201
- return getUnionType([nullType, undefinedType]);
71202
- }
71203
71159
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
71204
71160
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
71205
71161
  return valueType;
@@ -71219,7 +71175,7 @@ var ts;
71219
71175
  valueType.flags & 65536 /* Null */ ?
71220
71176
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
71221
71177
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
71222
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
71178
+ return getIntersectionWithFacts(type, facts);
71223
71179
  }
71224
71180
  if (assumeTrue) {
71225
71181
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -71247,17 +71203,11 @@ var ts;
71247
71203
  if (type.flags & 1 /* Any */ && literal.text === "function") {
71248
71204
  return type;
71249
71205
  }
71250
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
71251
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
71252
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
71253
- // unknown type, and then narrows that to the non-primitive type.
71254
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
71255
- }
71256
71206
  var facts = assumeTrue ?
71257
71207
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71258
71208
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71259
71209
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71260
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71210
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71261
71211
  }
71262
71212
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71263
71213
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71306,10 +71256,10 @@ var ts;
71306
71256
  }
71307
71257
  function getImpliedTypeFromTypeofGuard(type, text) {
71308
71258
  switch (text) {
71259
+ case "object":
71260
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71309
71261
  case "function":
71310
71262
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
71311
- case "object":
71312
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71313
71263
  default:
71314
71264
  return typeofTypesByName.get(text);
71315
71265
  }
@@ -71320,22 +71270,27 @@ var ts;
71320
71270
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71321
71271
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71322
71272
  // filtering by type-facts.
71323
- function narrowUnionMemberByTypeof(candidate) {
71324
- return function (type) {
71325
- if (isTypeSubtypeOf(type, candidate)) {
71326
- return type;
71327
- }
71328
- if (isTypeSubtypeOf(candidate, type)) {
71329
- return candidate;
71273
+ function narrowTypeByImpliedType(type, candidate) {
71274
+ if (type.flags & 3 /* AnyOrUnknown */) {
71275
+ return candidate;
71276
+ }
71277
+ return mapType(type, function (t) {
71278
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71279
+ return t;
71330
71280
  }
71331
- if (type.flags & 465829888 /* Instantiable */) {
71332
- var constraint = getBaseConstraintOfType(type) || anyType;
71333
- if (isTypeSubtypeOf(candidate, constraint)) {
71334
- return getIntersectionType([type, candidate]);
71281
+ return mapType(candidate, function (c) {
71282
+ if (!areTypesComparable(t, c)) {
71283
+ return neverType;
71335
71284
  }
71336
- }
71337
- return type;
71338
- };
71285
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71286
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71287
+ }
71288
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71289
+ return c;
71290
+ }
71291
+ return getIntersectionType([t, c]);
71292
+ });
71293
+ });
71339
71294
  }
71340
71295
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71341
71296
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71394,7 +71349,7 @@ var ts;
71394
71349
  because it is caught in the first clause.
71395
71350
  */
71396
71351
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71397
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71352
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71398
71353
  }
71399
71354
  function isMatchingConstructorReference(expr) {
71400
71355
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71698,7 +71653,9 @@ var ts;
71698
71653
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71699
71654
  }
71700
71655
  function isGenericTypeWithUnionConstraint(type) {
71701
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71656
+ return type.flags & 2097152 /* Intersection */ ?
71657
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71658
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71702
71659
  }
71703
71660
  function isGenericTypeWithoutNullableConstraint(type) {
71704
71661
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71726,7 +71683,7 @@ var ts;
71726
71683
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71727
71684
  someType(type, isGenericTypeWithUnionConstraint) &&
71728
71685
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71729
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71686
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71730
71687
  }
71731
71688
  function isExportOrExportExpression(location) {
71732
71689
  return !!ts.findAncestor(location, function (n) {
@@ -82826,7 +82783,7 @@ var ts;
82826
82783
  // For a binding pattern, validate the initializer and exit
82827
82784
  if (ts.isBindingPattern(node.name)) {
82828
82785
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82829
- var needCheckWidenedType = node.name.elements.length === 0;
82786
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82830
82787
  if (needCheckInitializer || needCheckWidenedType) {
82831
82788
  // Don't validate for-in initializer as it is already an error
82832
82789
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -110574,8 +110531,7 @@ var ts;
110574
110531
  return;
110575
110532
  }
110576
110533
  var version = ts.version; // Extracted into a const so the form is stable between namespace and module
110577
- var buildInfo = { bundle: bundle, program: program, version: version };
110578
- ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), /*writeByteOrderMark*/ false, /*sourceFiles*/ undefined, { buildInfo: buildInfo });
110534
+ ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), /*writeByteOrderMark*/ false);
110579
110535
  }
110580
110536
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
110581
110537
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
@@ -110729,18 +110685,13 @@ var ts;
110729
110685
  if (sourceMapFilePath) {
110730
110686
  var sourceMap = sourceMapGenerator.toString();
110731
110687
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
110732
- if (printer.bundleFileInfo)
110733
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
110734
110688
  }
110735
110689
  }
110736
110690
  else {
110737
110691
  writer.writeLine();
110738
110692
  }
110739
110693
  // Write the output file
110740
- var text = writer.getText();
110741
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110742
- if (printer.bundleFileInfo)
110743
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
110694
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110744
110695
  // Reset state
110745
110696
  writer.clear();
110746
110697
  }
@@ -110883,54 +110834,34 @@ var ts;
110883
110834
  }
110884
110835
  /*@internal*/
110885
110836
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
110886
- var createHash = ts.maybeBind(host, host.createHash);
110887
110837
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
110888
- var buildInfo;
110889
- if (host.getBuildInfo) {
110890
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
110891
- if (!hostBuildInfo)
110892
- return buildInfoPath;
110893
- buildInfo = hostBuildInfo;
110894
- }
110895
- else {
110896
- var buildInfoText = host.readFile(buildInfoPath);
110897
- if (!buildInfoText)
110898
- return buildInfoPath;
110899
- buildInfo = getBuildInfo(buildInfoText);
110900
- }
110901
- if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
110838
+ var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
110839
+ if (!buildInfoText)
110902
110840
  return buildInfoPath;
110903
110841
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
110904
110842
  if (!jsFileText)
110905
110843
  return jsFilePath;
110906
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
110907
- return jsFilePath;
110908
110844
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
110909
110845
  // error if no source map or for now if inline sourcemap
110910
110846
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
110911
110847
  return sourceMapFilePath || "inline sourcemap decoding";
110912
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
110913
- return sourceMapFilePath;
110914
110848
  // read declaration text
110915
110849
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
110916
110850
  if (declarationFilePath && !declarationText)
110917
110851
  return declarationFilePath;
110918
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
110919
- return declarationFilePath;
110920
110852
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
110921
110853
  // error if no source map or for now if inline sourcemap
110922
110854
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
110923
110855
  return declarationMapPath || "inline sourcemap decoding";
110924
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
110925
- return declarationMapPath;
110856
+ var buildInfo = getBuildInfo(buildInfoText);
110857
+ if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
110858
+ return buildInfoPath;
110926
110859
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110927
110860
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
110928
110861
  /*onlyOwnText*/ true);
110929
110862
  var outputFiles = [];
110930
110863
  var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
110931
110864
  var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
110932
- var changedDtsText;
110933
- var changedDtsData;
110934
110865
  var emitHost = {
110935
110866
  getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }),
110936
110867
  getCanonicalFileName: host.getCanonicalFileName,
@@ -110946,7 +110877,7 @@ var ts;
110946
110877
  getResolvedProjectReferenceToRedirect: ts.returnUndefined,
110947
110878
  getProjectReferenceRedirect: ts.returnUndefined,
110948
110879
  isSourceOfProjectReferenceRedirect: ts.returnFalse,
110949
- writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) {
110880
+ writeFile: function (name, text, writeByteOrderMark) {
110950
110881
  switch (name) {
110951
110882
  case jsFilePath:
110952
110883
  if (jsFileText === text)
@@ -110957,13 +110888,8 @@ var ts;
110957
110888
  return;
110958
110889
  break;
110959
110890
  case buildInfoPath:
110960
- var newBuildInfo = data.buildInfo;
110891
+ var newBuildInfo = getBuildInfo(text);
110961
110892
  newBuildInfo.program = buildInfo.program;
110962
- if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
110963
- // Update the output signature
110964
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
110965
- newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
110966
- }
110967
110893
  // Update sourceFileInfo
110968
110894
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
110969
110895
  newBuildInfo.bundle.js.sources = js.sources;
@@ -110971,13 +110897,11 @@ var ts;
110971
110897
  newBuildInfo.bundle.dts.sources = dts.sources;
110972
110898
  }
110973
110899
  newBuildInfo.bundle.sourceFiles = sourceFiles;
110974
- outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo });
110900
+ outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
110975
110901
  return;
110976
110902
  case declarationFilePath:
110977
110903
  if (declarationText === text)
110978
110904
  return;
110979
- changedDtsText = text;
110980
- changedDtsData = data;
110981
110905
  break;
110982
110906
  case declarationMapPath:
110983
110907
  if (declarationMapText === text)
@@ -110996,7 +110920,6 @@ var ts;
110996
110920
  getSourceFileFromReference: ts.returnUndefined,
110997
110921
  redirectTargetsMap: ts.createMultiMap(),
110998
110922
  getFileIncludeReasons: ts.notImplemented,
110999
- createHash: createHash,
111000
110923
  };
111001
110924
  emitFiles(ts.notImplementedResolver, emitHost,
111002
110925
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -116081,10 +116004,12 @@ var ts;
116081
116004
  }
116082
116005
  ts.createCompilerHost = createCompilerHost;
116083
116006
  /*@internal*/
116007
+ // TODO(shkamat): update this after reworking ts build API
116084
116008
  function createCompilerHostWorker(options, setParentNodes, system) {
116085
116009
  if (system === void 0) { system = ts.sys; }
116086
116010
  var existingDirectories = new ts.Map();
116087
116011
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
116012
+ var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
116088
116013
  function getSourceFile(fileName, languageVersionOrOptions, onError) {
116089
116014
  var text;
116090
116015
  try {
@@ -116117,7 +116042,7 @@ var ts;
116117
116042
  // NOTE: If patchWriteFileEnsuringDirectory has been called,
116118
116043
  // the system.writeFile will do its own directory creation and
116119
116044
  // the ensureDirectoriesExist call will always be redundant.
116120
- 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); });
116045
+ 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); });
116121
116046
  ts.performance.mark("afterIOWrite");
116122
116047
  ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
116123
116048
  }
@@ -116127,6 +116052,35 @@ var ts;
116127
116052
  }
116128
116053
  }
116129
116054
  }
116055
+ var outputFingerprints;
116056
+ function writeFileWorker(fileName, data, writeByteOrderMark) {
116057
+ if (!ts.isWatchSet(options) || !system.getModifiedTime) {
116058
+ system.writeFile(fileName, data, writeByteOrderMark);
116059
+ return;
116060
+ }
116061
+ if (!outputFingerprints) {
116062
+ outputFingerprints = new ts.Map();
116063
+ }
116064
+ var hash = computeHash(data);
116065
+ var mtimeBefore = system.getModifiedTime(fileName);
116066
+ if (mtimeBefore) {
116067
+ var fingerprint = outputFingerprints.get(fileName);
116068
+ // If output has not been changed, and the file has no external modification
116069
+ if (fingerprint &&
116070
+ fingerprint.byteOrderMark === writeByteOrderMark &&
116071
+ fingerprint.hash === hash &&
116072
+ fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
116073
+ return;
116074
+ }
116075
+ }
116076
+ system.writeFile(fileName, data, writeByteOrderMark);
116077
+ var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
116078
+ outputFingerprints.set(fileName, {
116079
+ hash: hash,
116080
+ byteOrderMark: writeByteOrderMark,
116081
+ mtime: mtimeAfter
116082
+ });
116083
+ }
116130
116084
  function getDefaultLibLocation() {
116131
116085
  return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
116132
116086
  }
@@ -117716,7 +117670,6 @@ var ts;
117716
117670
  getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
117717
117671
  redirectTargetsMap: redirectTargetsMap,
117718
117672
  getFileIncludeReasons: program.getFileIncludeReasons,
117719
- createHash: ts.maybeBind(host, host.createHash),
117720
117673
  };
117721
117674
  }
117722
117675
  function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -119830,9 +119783,13 @@ var ts;
119830
119783
  function createManyToManyPathMap() {
119831
119784
  function create(forward, reverse, deleted) {
119832
119785
  var map = {
119786
+ clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
119787
+ forEach: function (fn) { return forward.forEach(fn); },
119833
119788
  getKeys: function (v) { return reverse.get(v); },
119834
119789
  getValues: function (k) { return forward.get(k); },
119790
+ hasKey: function (k) { return forward.has(k); },
119835
119791
  keys: function () { return forward.keys(); },
119792
+ deletedKeys: function () { return deleted; },
119836
119793
  deleteKey: function (k) {
119837
119794
  (deleted || (deleted = new ts.Set())).add(k);
119838
119795
  var set = forward.get(k);
@@ -119859,6 +119816,11 @@ var ts;
119859
119816
  });
119860
119817
  return map;
119861
119818
  },
119819
+ clear: function () {
119820
+ forward.clear();
119821
+ reverse.clear();
119822
+ deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119823
+ }
119862
119824
  };
119863
119825
  return map;
119864
119826
  }
@@ -119986,21 +119948,18 @@ var ts;
119986
119948
  * Creates the state of file references and signature for the new program from oldState if it is safe
119987
119949
  */
119988
119950
  function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
119989
- var _a, _b, _c;
119990
119951
  var fileInfos = new ts.Map();
119991
119952
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
119992
119953
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
119954
+ var hasCalledUpdateShapeSignature = new ts.Set();
119993
119955
  var useOldState = canReuseOldState(referencedMap, oldState);
119994
119956
  // Ensure source files have parent pointers set
119995
119957
  newProgram.getTypeChecker();
119996
119958
  // Create the reference map, and set the file infos
119997
- for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
119998
- var sourceFile = _d[_i];
119959
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
119960
+ var sourceFile = _a[_i];
119999
119961
  var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
120000
- var oldUncommitedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined;
120001
- var signature = oldUncommitedSignature === undefined ?
120002
- useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined :
120003
- oldUncommitedSignature || undefined;
119962
+ var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
120004
119963
  if (referencedMap) {
120005
119964
  var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
120006
119965
  if (newReferences) {
@@ -120008,26 +119967,19 @@ var ts;
120008
119967
  }
120009
119968
  // Copy old visible to outside files map
120010
119969
  if (useOldState) {
120011
- var oldUncommitedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath);
120012
- var exportedModules = oldUncommitedExportedModules === undefined ?
120013
- oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) :
120014
- oldUncommitedExportedModules || undefined;
119970
+ var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath);
120015
119971
  if (exportedModules) {
120016
119972
  exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120017
119973
  }
120018
119974
  }
120019
119975
  }
120020
- fileInfos.set(sourceFile.resolvedPath, {
120021
- version: version_2,
120022
- signature: signature,
120023
- affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined,
120024
- impliedFormat: sourceFile.impliedNodeFormat
120025
- });
119976
+ fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
120026
119977
  }
120027
119978
  return {
120028
119979
  fileInfos: fileInfos,
120029
119980
  referencedMap: referencedMap,
120030
119981
  exportedModulesMap: exportedModulesMap,
119982
+ hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature,
120031
119983
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
120032
119984
  };
120033
119985
  }
@@ -120041,42 +119993,71 @@ var ts;
120041
119993
  }
120042
119994
  BuilderState.releaseCache = releaseCache;
120043
119995
  /**
120044
- * Gets the files affected by the path from the program
119996
+ * Creates a clone of the state
120045
119997
  */
120046
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
119998
+ function clone(state) {
120047
119999
  var _a, _b;
120048
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120049
- (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120050
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120051
- return result;
120000
+ // Dont need to backup allFiles info since its cache anyway
120001
+ return {
120002
+ fileInfos: new ts.Map(state.fileInfos),
120003
+ referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(),
120004
+ exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(),
120005
+ hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
120006
+ useFileVersionAsSignature: state.useFileVersionAsSignature,
120007
+ };
120052
120008
  }
120053
- BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120054
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120009
+ BuilderState.clone = clone;
120010
+ /**
120011
+ * Gets the files affected by the path from the program
120012
+ */
120013
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
120014
+ // Since the operation could be cancelled, the signatures are always stored in the cache
120015
+ // They will be committed once it is safe to use them
120016
+ // eg when calling this api from tsserver, if there is no cancellation of the operation
120017
+ // In the other cases the affected files signatures are committed only after the iteration through the result is complete
120018
+ var signatureCache = cacheToUpdateSignature || new ts.Map();
120055
120019
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120056
120020
  if (!sourceFile) {
120057
120021
  return ts.emptyArray;
120058
120022
  }
120059
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120023
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
120060
120024
  return [sourceFile];
120061
120025
  }
120062
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120026
+ var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
120027
+ if (!cacheToUpdateSignature) {
120028
+ // Commit all the signatures in the signature cache
120029
+ updateSignaturesFromCache(state, signatureCache);
120030
+ }
120031
+ return result;
120063
120032
  }
120064
- BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120033
+ BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120034
+ /**
120035
+ * Updates the signatures from the cache into state's fileinfo signatures
120036
+ * This should be called whenever it is safe to commit the state of the builder
120037
+ */
120038
+ function updateSignaturesFromCache(state, signatureCache) {
120039
+ signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
120040
+ }
120041
+ BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
120065
120042
  function updateSignatureOfFile(state, signature, path) {
120066
120043
  state.fileInfos.get(path).signature = signature;
120067
- (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
120044
+ state.hasCalledUpdateShapeSignature.add(path);
120068
120045
  }
120069
120046
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
120070
120047
  /**
120071
120048
  * Returns if the shape of the signature has changed since last emit
120072
120049
  */
120073
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120074
- var _a;
120050
+ function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) {
120075
120051
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120052
+ ts.Debug.assert(!!sourceFile);
120053
+ ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
120076
120054
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
120077
- if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
120055
+ if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
120078
120056
  return false;
120057
+ }
120079
120058
  var info = state.fileInfos.get(sourceFile.resolvedPath);
120059
+ if (!info)
120060
+ return ts.Debug.fail();
120080
120061
  var prevSignature = info.signature;
120081
120062
  var latestSignature;
120082
120063
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
@@ -120087,55 +120068,45 @@ var ts;
120087
120068
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120088
120069
  if (firstDts_1) {
120089
120070
  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; })); });
120090
- latestSignature = computeSignature(firstDts_1.text, computeHash);
120091
- if (latestSignature !== prevSignature) {
120092
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120071
+ latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
120072
+ if (exportedModulesMapCache && latestSignature !== prevSignature) {
120073
+ updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
120093
120074
  }
120094
120075
  }
120095
120076
  }
120096
120077
  // Default is to use file version as signature
120097
120078
  if (latestSignature === undefined) {
120098
120079
  latestSignature = sourceFile.version;
120099
- if (state.exportedModulesMap && latestSignature !== prevSignature) {
120100
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120080
+ if (exportedModulesMapCache && latestSignature !== prevSignature) {
120101
120081
  // All the references in this file are exported
120102
120082
  var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined;
120103
120083
  if (references) {
120104
- state.exportedModulesMap.set(sourceFile.resolvedPath, references);
120084
+ exportedModulesMapCache.set(sourceFile.resolvedPath, references);
120105
120085
  }
120106
120086
  else {
120107
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120087
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120108
120088
  }
120109
120089
  }
120110
120090
  }
120111
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false);
120112
- (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath);
120113
- info.signature = latestSignature;
120091
+ cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
120114
120092
  return latestSignature !== prevSignature;
120115
120093
  }
120116
120094
  BuilderState.updateShapeSignature = updateShapeSignature;
120117
- function computeSignature(text, computeHash) {
120118
- return (computeHash || ts.generateDjb2Hash)(text);
120119
- }
120120
- BuilderState.computeSignature = computeSignature;
120121
120095
  /**
120122
120096
  * Coverts the declaration emit result into exported modules map
120123
120097
  */
120124
- function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
120125
- if (!state.exportedModulesMap)
120126
- return;
120127
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
120098
+ function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
120128
120099
  if (!exportedModulesFromDeclarationEmit) {
120129
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120100
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120130
120101
  return;
120131
120102
  }
120132
120103
  var exportedModules;
120133
120104
  exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); });
120134
120105
  if (exportedModules) {
120135
- state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
120106
+ exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
120136
120107
  }
120137
120108
  else {
120138
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
120109
+ exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
120139
120110
  }
120140
120111
  function addExportedModule(exportedModulePaths) {
120141
120112
  if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) {
@@ -120147,6 +120118,19 @@ var ts;
120147
120118
  }
120148
120119
  }
120149
120120
  BuilderState.updateExportedModules = updateExportedModules;
120121
+ /**
120122
+ * Updates the exported modules from cache into state's exported modules map
120123
+ * This should be called whenever it is safe to commit the state of the builder
120124
+ */
120125
+ function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
120126
+ var _a;
120127
+ if (exportedModulesMapCache) {
120128
+ ts.Debug.assert(!!state.exportedModulesMap);
120129
+ (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
120130
+ exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
120131
+ }
120132
+ }
120133
+ BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
120150
120134
  /**
120151
120135
  * Get all the dependencies of the sourceFile
120152
120136
  */
@@ -120267,7 +120251,7 @@ var ts;
120267
120251
  /**
120268
120252
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120269
120253
  */
120270
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120254
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
120271
120255
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120272
120256
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120273
120257
  }
@@ -120287,7 +120271,7 @@ var ts;
120287
120271
  if (!seenFileNamesMap.has(currentPath)) {
120288
120272
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120289
120273
  seenFileNamesMap.set(currentPath, currentSourceFile);
120290
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120274
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
120291
120275
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120292
120276
  }
120293
120277
  }
@@ -120313,33 +120297,32 @@ var ts;
120313
120297
  * Create the state so that we can iterate on changedFiles/affected files
120314
120298
  */
120315
120299
  function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
120316
- var _a, _b;
120317
120300
  var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
120318
120301
  state.program = newProgram;
120319
120302
  var compilerOptions = newProgram.getCompilerOptions();
120320
120303
  state.compilerOptions = compilerOptions;
120321
- var outFilePath = ts.outFile(compilerOptions);
120322
120304
  // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
120323
- if (!outFilePath) {
120305
+ if (!ts.outFile(compilerOptions)) {
120324
120306
  state.semanticDiagnosticsPerFile = new ts.Map();
120325
120307
  }
120326
- 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)) {
120327
- state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature;
120328
- }
120329
120308
  state.changedFilesSet = new ts.Set();
120330
- state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined;
120331
120309
  var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
120332
120310
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
120333
120311
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
120334
120312
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
120335
- var canCopyEmitSignatures = compilerOptions.composite &&
120336
- (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
120337
- !outFilePath &&
120338
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
120339
120313
  if (useOldState) {
120314
+ // Verify the sanity of old state
120315
+ if (!oldState.currentChangedFilePath) {
120316
+ var affectedSignatures = oldState.currentAffectedFilesSignatures;
120317
+ ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
120318
+ }
120319
+ var changedFilesSet = oldState.changedFilesSet;
120320
+ if (canCopySemanticDiagnostics) {
120321
+ ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
120322
+ }
120340
120323
  // Copy old state's changed files set
120341
- (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
120342
- if (!outFilePath && oldState.affectedFilesPendingEmit) {
120324
+ changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
120325
+ if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
120343
120326
  state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
120344
120327
  state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
120345
120328
  state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
@@ -120360,8 +120343,6 @@ var ts;
120360
120343
  !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
120361
120344
  // versions dont match
120362
120345
  oldInfo.version !== info.version ||
120363
- // Implied formats dont match
120364
- oldInfo.impliedFormat !== info.impliedFormat ||
120365
120346
  // Referenced files changed
120366
120347
  !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) ||
120367
120348
  // Referenced file was deleted in the new program
@@ -120385,25 +120366,27 @@ var ts;
120385
120366
  state.semanticDiagnosticsFromOldState.add(sourceFilePath);
120386
120367
  }
120387
120368
  }
120388
- if (canCopyEmitSignatures) {
120389
- var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath);
120390
- if (oldEmitSignature)
120391
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature);
120392
- }
120393
120369
  });
120394
120370
  // If the global file is removed, add all files as changed
120395
120371
  if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
120396
120372
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
120397
120373
  .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
120398
120374
  }
120399
- else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120375
+ else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
120400
120376
  // Add all files to affectedFilesPendingEmit since emit changed
120401
120377
  newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
120402
120378
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
120403
120379
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
120404
120380
  }
120405
- // Since old states change files set is copied, any additional change means we would need to emit build info
120406
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
120381
+ if (useOldState) {
120382
+ // Any time the interpretation of a source file changes, mark it as changed
120383
+ ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
120384
+ if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
120385
+ state.changedFilesSet.add(sourceFilePath);
120386
+ }
120387
+ });
120388
+ }
120389
+ state.buildInfoEmitPending = !!state.changedFilesSet.size;
120407
120390
  return state;
120408
120391
  }
120409
120392
  function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
@@ -120439,35 +120422,30 @@ var ts;
120439
120422
  ts.BuilderState.releaseCache(state);
120440
120423
  state.program = undefined;
120441
120424
  }
120442
- function backupEmitBuilderProgramState(state) {
120443
- var outFilePath = ts.outFile(state.compilerOptions);
120444
- // Only in --out changeFileSet is kept around till emit
120445
- ts.Debug.assert(!state.changedFilesSet.size || outFilePath);
120446
- return {
120447
- affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(),
120448
- affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind),
120449
- affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex,
120450
- seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles),
120451
- programEmitComplete: state.programEmitComplete,
120452
- emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures),
120453
- outSignature: state.outSignature,
120454
- dtsChangeTime: state.dtsChangeTime,
120455
- hasChangedEmitSignature: state.hasChangedEmitSignature,
120456
- changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined,
120457
- };
120458
- }
120459
- function restoreEmitBuilderProgramState(state, backupEmitState) {
120460
- state.affectedFilesPendingEmit = backupEmitState.affectedFilesPendingEmit;
120461
- state.affectedFilesPendingEmitKind = backupEmitState.affectedFilesPendingEmitKind;
120462
- state.affectedFilesPendingEmitIndex = backupEmitState.affectedFilesPendingEmitIndex;
120463
- state.seenEmittedFiles = backupEmitState.seenEmittedFiles;
120464
- state.programEmitComplete = backupEmitState.programEmitComplete;
120465
- state.emitSignatures = backupEmitState.emitSignatures;
120466
- state.outSignature = backupEmitState.outSignature;
120467
- state.dtsChangeTime = backupEmitState.dtsChangeTime;
120468
- state.hasChangedEmitSignature = backupEmitState.hasChangedEmitSignature;
120469
- if (backupEmitState.changedFilesSet)
120470
- state.changedFilesSet = backupEmitState.changedFilesSet;
120425
+ /**
120426
+ * Creates a clone of the state
120427
+ */
120428
+ function cloneBuilderProgramState(state) {
120429
+ var _a;
120430
+ var newState = ts.BuilderState.clone(state);
120431
+ newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
120432
+ newState.changedFilesSet = new ts.Set(state.changedFilesSet);
120433
+ newState.affectedFiles = state.affectedFiles;
120434
+ newState.affectedFilesIndex = state.affectedFilesIndex;
120435
+ newState.currentChangedFilePath = state.currentChangedFilePath;
120436
+ newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
120437
+ newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone();
120438
+ newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
120439
+ newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
120440
+ newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
120441
+ newState.program = state.program;
120442
+ newState.compilerOptions = state.compilerOptions;
120443
+ newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120444
+ newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120445
+ newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120446
+ newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
120447
+ newState.programEmitComplete = state.programEmitComplete;
120448
+ return newState;
120471
120449
  }
120472
120450
  /**
120473
120451
  * Verifies that source file is ok to be used in calls that arent handled by next
@@ -120482,7 +120460,7 @@ var ts;
120482
120460
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120483
120461
  */
120484
120462
  function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120485
- var _a, _b;
120463
+ var _a;
120486
120464
  while (true) {
120487
120465
  var affectedFiles = state.affectedFiles;
120488
120466
  if (affectedFiles) {
@@ -120502,8 +120480,10 @@ var ts;
120502
120480
  state.changedFilesSet.delete(state.currentChangedFilePath);
120503
120481
  state.currentChangedFilePath = undefined;
120504
120482
  // Commit the changes in file signature
120505
- (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120506
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120483
+ ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120484
+ state.currentAffectedFilesSignatures.clear();
120485
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120486
+ (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120507
120487
  state.affectedFiles = undefined;
120508
120488
  }
120509
120489
  // Get next changed file
@@ -120521,7 +120501,12 @@ var ts;
120521
120501
  return program;
120522
120502
  }
120523
120503
  // Get next batch of affected files
120524
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
120504
+ if (!state.currentAffectedFilesSignatures)
120505
+ state.currentAffectedFilesSignatures = new ts.Map();
120506
+ if (state.exportedModulesMap) {
120507
+ state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120508
+ }
120509
+ state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120525
120510
  state.currentChangedFilePath = nextKey.value;
120526
120511
  state.affectedFilesIndex = 0;
120527
120512
  if (!state.seenAffectedFiles)
@@ -120573,6 +120558,7 @@ var ts;
120573
120558
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
120574
120559
  */
120575
120560
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120561
+ var _a;
120576
120562
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
120577
120563
  // If affected files is everything except default library, then nothing more to do
120578
120564
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -120580,9 +120566,10 @@ var ts;
120580
120566
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120581
120567
  // That means when affected file is handled, its signature can be out of date
120582
120568
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120583
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
120569
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120584
120570
  return;
120585
120571
  }
120572
+ 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);
120586
120573
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120587
120574
  return;
120588
120575
  handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
@@ -120602,7 +120589,7 @@ var ts;
120602
120589
  // This ensures that we dont later during incremental builds considering wrong signature.
120603
120590
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
120604
120591
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
120605
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
120592
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
120606
120593
  // If not dts emit, nothing more to do
120607
120594
  if (ts.getEmitDeclarations(state.compilerOptions)) {
120608
120595
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120623,10 +120610,27 @@ var ts;
120623
120610
  return !state.semanticDiagnosticsFromOldState.size;
120624
120611
  }
120625
120612
  function isChangedSignature(state, path) {
120626
- var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined;
120627
- var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120613
+ var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
120614
+ var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120628
120615
  return newSignature !== oldSignature;
120629
120616
  }
120617
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120618
+ // Go through exported modules from cache first
120619
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120620
+ var result = keys && ts.forEachKey(keys, fn);
120621
+ if (result)
120622
+ return result;
120623
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120624
+ keys = state.exportedModulesMap.getKeys(filePath);
120625
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
120626
+ var _a;
120627
+ // If the cache had an updated value, skip
120628
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120629
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120630
+ fn(exportedFromPath) :
120631
+ undefined;
120632
+ });
120633
+ }
120630
120634
  function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120631
120635
  var _a;
120632
120636
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
@@ -120641,7 +120645,6 @@ var ts;
120641
120645
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120642
120646
  */
120643
120647
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120644
- var _a;
120645
120648
  // If there was change in signature (dts output) for the changed file,
120646
120649
  // then only we need to handle pending file emit
120647
120650
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
@@ -120668,10 +120671,11 @@ var ts;
120668
120671
  }
120669
120672
  }
120670
120673
  }
120674
+ ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120671
120675
  var seenFileAndExportsOfFile = new ts.Set();
120672
120676
  // Go through exported modules from cache first
120673
120677
  // If exported modules has path, all files referencing file exported from are affected
120674
- (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120678
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120675
120679
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120676
120680
  return true;
120677
120681
  var references = state.referencedMap.getKeys(exportedFromPath);
@@ -120685,18 +120689,19 @@ var ts;
120685
120689
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120686
120690
  */
120687
120691
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120688
- var _a, _b;
120692
+ var _a;
120689
120693
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120690
120694
  return undefined;
120691
120695
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120692
120696
  return true;
120693
120697
  handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120698
+ ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120694
120699
  // If exported modules has path, all files referencing file exported from are affected
120695
- (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120700
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120696
120701
  return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120697
120702
  });
120698
120703
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120699
- (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
120704
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120700
120705
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120701
120706
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120702
120707
  state, referencingFilePath, cancellationToken, computeHash, host);
@@ -120717,13 +120722,12 @@ var ts;
120717
120722
  }
120718
120723
  else {
120719
120724
  state.seenAffectedFiles.add(affected.resolvedPath);
120720
- // Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
120721
- state.buildInfoEmitPending = true;
120722
120725
  if (emitKind !== undefined) {
120723
120726
  (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
120724
120727
  }
120725
120728
  if (isPendingEmit) {
120726
120729
  state.affectedFilesPendingEmitIndex++;
120730
+ state.buildInfoEmitPending = true;
120727
120731
  }
120728
120732
  else {
120729
120733
  state.affectedFilesIndex++;
@@ -120771,61 +120775,25 @@ var ts;
120771
120775
  }
120772
120776
  return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions);
120773
120777
  }
120774
- function isProgramBundleEmitBuildInfo(info) {
120775
- return !!ts.outFile(info.options || {});
120776
- }
120777
- ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
120778
120778
  /**
120779
120779
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
120780
120780
  */
120781
- function getProgramBuildInfo(state, getCanonicalFileName, host) {
120782
- var outFilePath = ts.outFile(state.compilerOptions);
120783
- if (outFilePath && !state.compilerOptions.composite)
120784
- return;
120781
+ function getProgramBuildInfo(state, getCanonicalFileName) {
120782
+ if (ts.outFile(state.compilerOptions))
120783
+ return undefined;
120785
120784
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
120786
120785
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
120787
- state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime;
120788
- if (outFilePath) {
120789
- var fileNames_1 = [];
120790
- var fileInfos_1 = [];
120791
- state.program.getRootFileNames().forEach(function (f) {
120792
- var sourceFile = state.program.getSourceFile(f);
120793
- if (!sourceFile)
120794
- return;
120795
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
120796
- fileInfos_1.push(sourceFile.version);
120797
- });
120798
- var result_15 = {
120799
- fileNames: fileNames_1,
120800
- fileInfos: fileInfos_1,
120801
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
120802
- outSignature: state.outSignature,
120803
- dtsChangeTime: state.dtsChangeTime,
120804
- };
120805
- return result_15;
120806
- }
120807
120786
  var fileNames = [];
120808
120787
  var fileNameToFileId = new ts.Map();
120809
120788
  var fileIdsList;
120810
120789
  var fileNamesToFileIdListId;
120811
- var emitSignatures;
120812
120790
  var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) {
120813
- var _b, _c;
120814
120791
  var key = _a[0], value = _a[1];
120815
120792
  // Ensure fileId
120816
120793
  var fileId = toFileId(key);
120817
120794
  ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
120818
- var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key);
120819
- var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature;
120820
- if (state.compilerOptions.composite) {
120821
- var file = state.program.getSourceFileByPath(key);
120822
- if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) {
120823
- var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key);
120824
- if (emitSignature !== actualSignature) {
120825
- (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]);
120826
- }
120827
- }
120828
- }
120795
+ var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120796
+ var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120829
120797
  return value.version === actualSignature ?
120830
120798
  value.affectsGlobalScope || value.impliedFormat ?
120831
120799
  // If file version is same as signature, dont serialize signature
@@ -120833,11 +120801,11 @@ var ts;
120833
120801
  // If file info only contains version and signature and both are same we can just write string
120834
120802
  value.version :
120835
120803
  actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120836
- oldSignature === undefined ?
120804
+ signature === undefined ?
120837
120805
  // If we havent computed signature, use fileInfo as is
120838
120806
  value :
120839
120807
  // Serialize fileInfo with new updated signature
120840
- { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120808
+ { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120841
120809
  // Signature of the FileInfo is undefined, serialize it as false
120842
120810
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120843
120811
  });
@@ -120852,13 +120820,17 @@ var ts;
120852
120820
  if (state.exportedModulesMap) {
120853
120821
  exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) {
120854
120822
  var _a;
120855
- var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key);
120823
+ if (state.currentAffectedFilesExportedModulesMap) {
120824
+ if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) {
120825
+ return undefined;
120826
+ }
120827
+ var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key);
120828
+ if (newValue) {
120829
+ return [toFileId(key), toFileIdListId(newValue)];
120830
+ }
120831
+ }
120856
120832
  // Not in temporary cache, use existing value
120857
- if (oldValue === undefined)
120858
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120859
- if (oldValue)
120860
- return [toFileId(key), toFileIdListId(oldValue)];
120861
- return undefined;
120833
+ return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
120862
120834
  });
120863
120835
  }
120864
120836
  var semanticDiagnosticsPerFile;
@@ -120869,7 +120841,9 @@ var ts;
120869
120841
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
120870
120842
  [
120871
120843
  toFileId(key),
120872
- convertToReusableDiagnostics(value, relativeToBuildInfo)
120844
+ state.hasReusableDiagnostic ?
120845
+ value :
120846
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
120873
120847
  ] :
120874
120848
  toFileId(key));
120875
120849
  }
@@ -120884,27 +120858,16 @@ var ts;
120884
120858
  }
120885
120859
  }
120886
120860
  }
120887
- var changeFileSet;
120888
- if (state.changedFilesSet.size) {
120889
- for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
120890
- var path = _e[_d];
120891
- (changeFileSet || (changeFileSet = [])).push(toFileId(path));
120892
- }
120893
- }
120894
- var result = {
120861
+ return {
120895
120862
  fileNames: fileNames,
120896
120863
  fileInfos: fileInfos,
120897
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
120864
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
120898
120865
  fileIdsList: fileIdsList,
120899
120866
  referencedMap: referencedMap,
120900
120867
  exportedModulesMap: exportedModulesMap,
120901
120868
  semanticDiagnosticsPerFile: semanticDiagnosticsPerFile,
120902
120869
  affectedFilesPendingEmit: affectedFilesPendingEmit,
120903
- changeFileSet: changeFileSet,
120904
- emitSignatures: emitSignatures,
120905
- dtsChangeTime: state.dtsChangeTime,
120906
120870
  };
120907
- return result;
120908
120871
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
120909
120872
  return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
120910
120873
  }
@@ -120929,18 +120892,24 @@ var ts;
120929
120892
  }
120930
120893
  return fileIdListId;
120931
120894
  }
120932
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
120933
- var result;
120934
- var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120935
- for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120936
- var name = _a[_i];
120937
- var optionInfo = optionsNameMap.get(name.toLowerCase());
120938
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
120939
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
120940
- }
120895
+ }
120896
+ function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) {
120897
+ var result;
120898
+ var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
120899
+ for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
120900
+ var name = _a[_i];
120901
+ var optionKey = name.toLowerCase();
120902
+ var optionInfo = optionsNameMap.get(optionKey);
120903
+ if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) ||
120904
+ // We need to store `strict`, even though it won't be examined directly, so that the
120905
+ // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo
120906
+ optionKey === "strict" ||
120907
+ // We need to store these to determine whether `lib` files need to be rechecked.
120908
+ optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") {
120909
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo);
120941
120910
  }
120942
- return result;
120943
120911
  }
120912
+ return result;
120944
120913
  }
120945
120914
  function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
120946
120915
  if (option) {
@@ -121014,10 +120983,6 @@ var ts;
121014
120983
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121015
120984
  }
121016
120985
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121017
- function computeSignature(text, data, computeHash) {
121018
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121019
- }
121020
- ts.computeSignature = computeSignature;
121021
120986
  function createBuilderProgram(kind, _a) {
121022
120987
  var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
121023
120988
  // Return same program if underlying program doesnt change
@@ -121036,8 +121001,8 @@ var ts;
121036
121001
  */
121037
121002
  var computeHash = ts.maybeBind(host, host.createHash);
121038
121003
  var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
121039
- var backupEmitState;
121040
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); };
121004
+ var backupState;
121005
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
121041
121006
  // To ensure that we arent storing any references to old program or new program without state
121042
121007
  newProgram = undefined; // TODO: GH#18217
121043
121008
  oldProgram = undefined;
@@ -121045,20 +121010,20 @@ var ts;
121045
121010
  var getState = function () { return state; };
121046
121011
  var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics);
121047
121012
  builderProgram.getState = getState;
121048
- builderProgram.backupEmitState = function () {
121049
- ts.Debug.assert(backupEmitState === undefined);
121050
- backupEmitState = backupEmitBuilderProgramState(state);
121013
+ builderProgram.backupState = function () {
121014
+ ts.Debug.assert(backupState === undefined);
121015
+ backupState = cloneBuilderProgramState(state);
121051
121016
  };
121052
- builderProgram.restoreEmitState = function () {
121053
- restoreEmitBuilderProgramState(state, ts.Debug.checkDefined(backupEmitState));
121054
- backupEmitState = undefined;
121017
+ builderProgram.restoreState = function () {
121018
+ state = ts.Debug.checkDefined(backupState);
121019
+ backupState = undefined;
121055
121020
  };
121056
121021
  builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
121057
121022
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
121058
121023
  builderProgram.emit = emit;
121059
121024
  builderProgram.releaseProgram = function () {
121060
121025
  releaseCache(state);
121061
- backupEmitState = undefined;
121026
+ backupState = undefined;
121062
121027
  };
121063
121028
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
121064
121029
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
@@ -121117,59 +121082,35 @@ var ts;
121117
121082
  return toAffectedFileEmitResult(state,
121118
121083
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
121119
121084
  // Otherwise just affected file
121120
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ?
121121
- getWriteFileCallback(writeFile, customTransformers) :
121085
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121086
+ getWriteFileUpdatingSignatureCallback(writeFile) :
121122
121087
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
121123
121088
  }
121124
- function getWriteFileCallback(writeFile, customTransformers) {
121089
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
121125
121090
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121126
- var _a, _b, _c;
121091
+ var _a;
121127
121092
  if (ts.isDeclarationFileName(fileName)) {
121128
- if (!ts.outFile(state.compilerOptions)) {
121129
- ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121130
- var newSignature = void 0;
121131
- if (!customTransformers) {
121132
- var file = sourceFiles[0];
121133
- var info = state.fileInfos.get(file.resolvedPath);
121134
- if (info.signature === file.version) {
121135
- newSignature = computeSignature(text, data, computeHash);
121136
- if (newSignature !== file.version) { // Update it
121137
- if (host.storeFilesChangingSignatureDuringEmit)
121138
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121139
- if (state.exportedModulesMap)
121140
- ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121141
- if (state.affectedFiles) {
121142
- // Keep old signature so we know what to undo if cancellation happens
121143
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121144
- if (existing === undefined)
121145
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121146
- info.signature = newSignature;
121147
- }
121148
- else {
121149
- // These are directly commited
121150
- info.signature = newSignature;
121151
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121152
- }
121153
- }
121093
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121094
+ var file = sourceFiles[0];
121095
+ var info = state.fileInfos.get(file.resolvedPath);
121096
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
121097
+ if (signature === file.version) {
121098
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
121099
+ if (newSignature !== file.version) { // Update it
121100
+ if (host.storeFilesChangingSignatureDuringEmit)
121101
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121102
+ if (state.exportedModulesMap)
121103
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
121104
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
121105
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
121154
121106
  }
121155
- }
121156
- if (state.compilerOptions.composite) {
121157
- var filePath = sourceFiles[0].resolvedPath;
121158
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121159
- newSignature || (newSignature = computeSignature(text, data, computeHash));
121160
- if (newSignature !== oldSignature) {
121161
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121162
- state.hasChangedEmitSignature = true;
121107
+ else {
121108
+ info.signature = newSignature;
121109
+ if (state.exportedModulesMap)
121110
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
121163
121111
  }
121164
121112
  }
121165
121113
  }
121166
- else if (state.compilerOptions.composite) {
121167
- var newSignature = computeSignature(text, data, computeHash);
121168
- if (newSignature !== state.outSignature) {
121169
- state.outSignature = newSignature;
121170
- state.hasChangedEmitSignature = true;
121171
- }
121172
- }
121173
121114
  }
121174
121115
  if (writeFile)
121175
121116
  writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
@@ -121234,8 +121175,8 @@ var ts;
121234
121175
  }
121235
121176
  }
121236
121177
  }
121237
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ?
121238
- getWriteFileCallback(writeFile, customTransformers) :
121178
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
121179
+ getWriteFileUpdatingSignatureCallback(writeFile) :
121239
121180
  writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
121240
121181
  }
121241
121182
  /**
@@ -121324,58 +121265,29 @@ var ts;
121324
121265
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
121325
121266
  }
121326
121267
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
121327
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121328
- var _a, _b, _c, _d;
121268
+ function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
121269
+ var _a;
121329
121270
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121330
121271
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121331
- var state;
121332
- var filePaths;
121333
- var filePathsSetList;
121334
- if (isProgramBundleEmitBuildInfo(program)) {
121335
- state = {
121336
- fileInfos: new ts.Map(),
121337
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121338
- dtsChangeTime: program.dtsChangeTime,
121339
- outSignature: program.outSignature,
121340
- };
121341
- }
121342
- else {
121343
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
121344
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121345
- var fileInfos_2 = new ts.Map();
121346
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
121347
- program.fileInfos.forEach(function (fileInfo, index) {
121348
- var path = toFilePath(index + 1);
121349
- var stateFileInfo = toBuilderStateFileInfo(fileInfo);
121350
- fileInfos_2.set(path, stateFileInfo);
121351
- if (emitSignatures_1 && stateFileInfo.signature)
121352
- emitSignatures_1.set(path, stateFileInfo.signature);
121353
- });
121354
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
121355
- if (ts.isNumber(value))
121356
- emitSignatures_1.delete(toFilePath(value));
121357
- else
121358
- emitSignatures_1.set(toFilePath(value[0]), value[1]);
121359
- });
121360
- state = {
121361
- fileInfos: fileInfos_2,
121362
- compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121363
- referencedMap: toManyToManyPathMap(program.referencedMap),
121364
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121365
- 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]; }),
121366
- hasReusableDiagnostic: true,
121367
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121368
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121369
- affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121370
- changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
121371
- dtsChangeTime: program.dtsChangeTime,
121372
- emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
121373
- };
121374
- }
121272
+ var filePaths = program.fileNames.map(toPath);
121273
+ var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
121274
+ var fileInfos = new ts.Map();
121275
+ program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); });
121276
+ var state = {
121277
+ fileInfos: fileInfos,
121278
+ compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
121279
+ referencedMap: toManyToManyPathMap(program.referencedMap),
121280
+ exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
121281
+ 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]; }),
121282
+ hasReusableDiagnostic: true,
121283
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
121284
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
121285
+ affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
121286
+ };
121375
121287
  return {
121376
121288
  getState: function () { return state; },
121377
- backupEmitState: ts.noop,
121378
- restoreEmitState: ts.noop,
121289
+ backupState: ts.noop,
121290
+ restoreState: ts.noop,
121379
121291
  getProgram: ts.notImplemented,
121380
121292
  getProgramOrUndefined: ts.returnUndefined,
121381
121293
  releaseProgram: ts.noop,
@@ -121420,24 +121332,12 @@ var ts;
121420
121332
  return map;
121421
121333
  }
121422
121334
  }
121423
- ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
121424
- function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
121425
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
121426
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
121427
- var fileInfos = new ts.Map();
121428
- program.fileInfos.forEach(function (fileInfo, index) {
121429
- var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
121430
- var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
121431
- fileInfos.set(path, version);
121432
- });
121433
- return fileInfos;
121434
- }
121435
- ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap;
121335
+ ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
121436
121336
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
121437
121337
  return {
121438
121338
  getState: ts.notImplemented,
121439
- backupEmitState: ts.noop,
121440
- restoreEmitState: ts.noop,
121339
+ backupState: ts.noop,
121340
+ restoreState: ts.noop,
121441
121341
  getProgram: getProgram,
121442
121342
  getProgramOrUndefined: function () { return getState().program; },
121443
121343
  releaseProgram: function () { return getState().program = undefined; },
@@ -122553,9 +122453,9 @@ var ts;
122553
122453
  if (!preferSymlinks) {
122554
122454
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
122555
122455
  // so we only need to remove them from the realpath filenames.
122556
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122557
- if (result_16)
122558
- return result_16;
122456
+ var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122457
+ if (result_15)
122458
+ return result_15;
122559
122459
  }
122560
122460
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122561
122461
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -122575,10 +122475,10 @@ var ts;
122575
122475
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122576
122476
  var symlinkDirectory = symlinkDirectories_1[_i];
122577
122477
  var option = ts.resolvePath(symlinkDirectory, relative);
122578
- var result_17 = cb(option, target === referenceRedirect);
122478
+ var result_16 = cb(option, target === referenceRedirect);
122579
122479
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122580
- if (result_17)
122581
- return result_17;
122480
+ if (result_16)
122481
+ return result_16;
122582
122482
  }
122583
122483
  });
122584
122484
  });
@@ -123488,7 +123388,6 @@ var ts;
123488
123388
  readDirectory: ts.maybeBind(host, host.readDirectory),
123489
123389
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
123490
123390
  storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
123491
- now: ts.maybeBind(host, host.now),
123492
123391
  };
123493
123392
  function writeFile(fileName, text, writeByteOrderMark, onError) {
123494
123393
  try {
@@ -123549,7 +123448,6 @@ var ts;
123549
123448
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
123550
123449
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
123551
123450
  storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
123552
- now: ts.maybeBind(system, system.now),
123553
123451
  };
123554
123452
  }
123555
123453
  ts.createProgramHost = createProgramHost;
@@ -123617,26 +123515,20 @@ var ts;
123617
123515
  var ts;
123618
123516
  (function (ts) {
123619
123517
  function readBuilderProgram(compilerOptions, host) {
123518
+ if (ts.outFile(compilerOptions))
123519
+ return undefined;
123620
123520
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
123621
123521
  if (!buildInfoPath)
123622
123522
  return undefined;
123623
- var buildInfo;
123624
- if (host.getBuildInfo) {
123625
- buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
123626
- if (!buildInfo)
123627
- return undefined;
123628
- }
123629
- else {
123630
- var content = host.readFile(buildInfoPath);
123631
- if (!content)
123632
- return undefined;
123633
- buildInfo = ts.getBuildInfo(content);
123634
- }
123523
+ var content = host.readFile(buildInfoPath);
123524
+ if (!content)
123525
+ return undefined;
123526
+ var buildInfo = ts.getBuildInfo(content);
123635
123527
  if (buildInfo.version !== ts.version)
123636
123528
  return undefined;
123637
123529
  if (!buildInfo.program)
123638
123530
  return undefined;
123639
- return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123531
+ return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
123640
123532
  }
123641
123533
  ts.readBuilderProgram = readBuilderProgram;
123642
123534
  function createIncrementalCompilerHost(options, system) {
@@ -123645,7 +123537,6 @@ var ts;
123645
123537
  host.createHash = ts.maybeBind(system, system.createHash);
123646
123538
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
123647
123539
  host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
123648
- host.now = ts.maybeBind(system, system.now);
123649
123540
  ts.setGetSourceFileAsHashVersioned(host, system);
123650
123541
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
123651
123542
  return host;
@@ -124381,17 +124272,14 @@ var ts;
124381
124272
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
124382
124273
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
124383
124274
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
124384
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
124385
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
124386
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
124387
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
124388
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
124389
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
124275
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
124276
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
124277
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
124278
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
124390
124279
  /**
124391
124280
  * Projects with no outputs (i.e. "solution" files)
124392
124281
  */
124393
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
124394
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
124282
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
124395
124283
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
124396
124284
  function resolveConfigFileProjectName(project) {
124397
124285
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -124436,11 +124324,9 @@ var ts;
124436
124324
  function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
124437
124325
  return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
124438
124326
  }
124439
- /*@internal*/
124440
- function getCurrentTime(host) {
124441
- return host.now ? host.now() : new Date();
124327
+ function newer(date1, date2) {
124328
+ return date2 > date1 ? date2 : date1;
124442
124329
  }
124443
- ts.getCurrentTime = getCurrentTime;
124444
124330
  /*@internal*/
124445
124331
  function isCircularBuildOrder(buildOrder) {
124446
124332
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124530,7 +124416,6 @@ var ts;
124530
124416
  return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
124531
124417
  };
124532
124418
  }
124533
- compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
124534
124419
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
124535
124420
  var state = {
124536
124421
  host: host,
@@ -124547,9 +124432,8 @@ var ts;
124547
124432
  resolvedConfigFilePaths: new ts.Map(),
124548
124433
  configFileCache: new ts.Map(),
124549
124434
  projectStatus: new ts.Map(),
124435
+ buildInfoChecked: new ts.Map(),
124550
124436
  extendedConfigCache: new ts.Map(),
124551
- buildInfoCache: new ts.Map(),
124552
- outputTimeStamps: new ts.Map(),
124553
124437
  builderPrograms: new ts.Map(),
124554
124438
  diagnostics: new ts.Map(),
124555
124439
  projectPendingBuild: new ts.Map(),
@@ -124572,7 +124456,6 @@ var ts;
124572
124456
  allWatchedConfigFiles: new ts.Map(),
124573
124457
  allWatchedExtendedConfigFiles: new ts.Map(),
124574
124458
  allWatchedPackageJsonFiles: new ts.Map(),
124575
- filesWatched: new ts.Map(),
124576
124459
  lastCachedPackageJsonLookups: new ts.Map(),
124577
124460
  timerToBuildInvalidatedProject: undefined,
124578
124461
  reportFileChangeDetected: false,
@@ -124683,12 +124566,11 @@ var ts;
124683
124566
  // Config file cache
124684
124567
  ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
124685
124568
  ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
124569
+ ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
124686
124570
  ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
124687
124571
  ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
124688
124572
  ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
124689
124573
  ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124690
- ts.mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124691
- ts.mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124692
124574
  // Remove watches for the program no longer in the solution
124693
124575
  if (state.watch) {
124694
124576
  ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
@@ -124985,21 +124867,21 @@ var ts;
124985
124867
  }
124986
124868
  function emit(writeFileCallback, cancellationToken, customTransformers) {
124987
124869
  var _a;
124988
- var _b, _c, _d;
124870
+ var _b, _c;
124989
124871
  ts.Debug.assertIsDefined(program);
124990
124872
  ts.Debug.assert(step === BuildStep.Emit);
124991
124873
  // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
124992
- program.backupEmitState();
124874
+ program.backupState();
124993
124875
  var declDiagnostics;
124994
124876
  var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
124995
124877
  var outputFiles = [];
124996
124878
  var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics,
124997
124879
  /*write*/ undefined,
124998
- /*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,
124880
+ /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken,
124999
124881
  /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult;
125000
124882
  // Don't emit .d.ts if there are decl file errors
125001
124883
  if (declDiagnostics) {
125002
- program.restoreEmitState();
124884
+ program.restoreState();
125003
124885
  (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
125004
124886
  return {
125005
124887
  emitSkipped: true,
@@ -125009,46 +124891,40 @@ var ts;
125009
124891
  // Actual Emit
125010
124892
  var host = state.host, compilerHost = state.compilerHost;
125011
124893
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125012
- var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined;
124894
+ var newestDeclarationFileContentChangedTime = minimumDate;
124895
+ var anyDtsChanged = false;
125013
124896
  var emitterDiagnostics = ts.createDiagnosticCollection();
125014
124897
  var emittedOutputs = new ts.Map();
125015
- var options = program.getCompilerOptions();
125016
- var isIncremental = ts.isIncrementalCompilation(options);
125017
- var outputTimeStampMap;
125018
- var now;
125019
124898
  ts.solutionPerformance.mark("beforeOutputFilesWrite");
125020
124899
  outputFiles.forEach(function (_a) {
125021
- var _b, _c;
125022
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
125023
- var path = toPath(state, name);
125024
- emittedOutputs.set(toPath(state, name), name);
125025
- if (buildInfo) {
125026
- setBuildInfo(state, buildInfo, projectPath, options);
125027
- 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)) {
124900
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124901
+ var priorChangeTime;
124902
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124903
+ // Check for unchanged .d.ts files
124904
+ if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124905
+ priorChangeTime = host.getModifiedTime(name);
124906
+ }
124907
+ else {
125028
124908
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
124909
+ anyDtsChanged = true;
125029
124910
  }
125030
124911
  }
124912
+ emittedOutputs.set(toPath(state, name), name);
125031
124913
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125032
- if (!isIncremental && state.watch) {
125033
- (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
124914
+ if (priorChangeTime !== undefined) {
124915
+ newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
125034
124916
  }
125035
124917
  });
125036
124918
  ts.solutionPerformance.mark("afterOutputFilesWrite");
125037
124919
  ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
125038
- finishEmit(emitterDiagnostics, emittedOutputs, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124920
+ finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124921
+ /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
125039
124922
  return emitResult;
125040
124923
  }
125041
124924
  function emitBuildInfo(writeFileCallback, cancellationToken) {
125042
124925
  ts.Debug.assertIsDefined(program);
125043
124926
  ts.Debug.assert(step === BuildStep.EmitBuildInfo);
125044
- var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) {
125045
- if (data === null || data === void 0 ? void 0 : data.buildInfo)
125046
- setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions());
125047
- if (writeFileCallback)
125048
- writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
125049
- else
125050
- state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
125051
- }, cancellationToken);
124927
+ var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
125052
124928
  if (emitResult.diagnostics.length) {
125053
124929
  reportErrors(state, emitResult.diagnostics);
125054
124930
  state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true));
@@ -125061,7 +124937,7 @@ var ts;
125061
124937
  step = BuildStep.QueueReferencingProjects;
125062
124938
  return emitResult;
125063
124939
  }
125064
- function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
124940
+ function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
125065
124941
  var _a;
125066
124942
  var emitDiagnostics = emitterDiagnostics.getDiagnostics();
125067
124943
  if (emitDiagnostics.length) {
@@ -125072,11 +124948,13 @@ var ts;
125072
124948
  emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
125073
124949
  }
125074
124950
  // Update time stamps for rest of the outputs
125075
- updateOutputTimestampsWorker(state, config, projectPath, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
124951
+ var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
125076
124952
  state.diagnostics.delete(projectPath);
125077
124953
  state.projectStatus.set(projectPath, {
125078
124954
  type: ts.UpToDateStatusType.UpToDate,
125079
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath),
124955
+ newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
124956
+ maximumDate :
124957
+ newestDeclarationFileContentChangedTime,
125080
124958
  oldestOutputFileName: oldestOutputFileName
125081
124959
  });
125082
124960
  afterProgramDone(state, program, config);
@@ -125111,21 +124989,13 @@ var ts;
125111
124989
  ts.Debug.assert(!!outputFiles.length);
125112
124990
  var emitterDiagnostics = ts.createDiagnosticCollection();
125113
124991
  var emittedOutputs = new ts.Map();
125114
- var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
125115
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
125116
124992
  outputFiles.forEach(function (_a) {
125117
- var _b, _c;
125118
- var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
124993
+ var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
125119
124994
  emittedOutputs.set(toPath(state, name), name);
125120
- if (buildInfo) {
125121
- setBuildInfo(state, buildInfo, projectPath, config.options);
125122
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) {
125123
- resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
125124
- }
125125
- }
125126
124995
  ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
125127
124996
  });
125128
- var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, outputFiles[0].name, resultFlags);
124997
+ var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate,
124998
+ /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
125129
124999
  return { emitSkipped: false, diagnostics: emitDiagnostics };
125130
125000
  }
125131
125001
  function executeSteps(till, cancellationToken, writeFile, customTransformers) {
@@ -125231,7 +125101,7 @@ var ts;
125231
125101
  }
125232
125102
  continue;
125233
125103
  }
125234
- if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes || status.type === ts.UpToDateStatusType.UpToDateWithInputFileText) {
125104
+ if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
125235
125105
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
125236
125106
  return {
125237
125107
  kind: InvalidatedProjectKind.UpdateOutputFileStamps,
@@ -125317,7 +125187,7 @@ var ts;
125317
125187
  state.projectCompilerOptions = state.baseCompilerOptions;
125318
125188
  }
125319
125189
  function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
125320
- var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions());
125190
+ var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
125321
125191
  reportAndStoreErrors(state, resolvedPath, diagnostics);
125322
125192
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
125323
125193
  if (canEmitBuildInfo)
@@ -125325,101 +125195,9 @@ var ts;
125325
125195
  afterProgramDone(state, program, config);
125326
125196
  return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
125327
125197
  }
125328
- function isFileWatcherWithModifiedTime(value) {
125329
- return !!value.watcher;
125330
- }
125331
- function getModifiedTime(state, fileName) {
125332
- var path = toPath(state, fileName);
125333
- var existing = state.filesWatched.get(path);
125334
- if (state.watch && !!existing) {
125335
- if (!isFileWatcherWithModifiedTime(existing))
125336
- return existing;
125337
- if (existing.modifiedTime)
125338
- return existing.modifiedTime;
125339
- }
125340
- var result = ts.getModifiedTime(state.host, fileName);
125341
- if (state.watch) {
125342
- if (existing)
125343
- existing.modifiedTime = result;
125344
- else
125345
- state.filesWatched.set(path, result);
125346
- }
125347
- return result;
125348
- }
125349
- function watchFile(state, file, callback, pollingInterval, options, watchType, project) {
125350
- var path = toPath(state, file);
125351
- var existing = state.filesWatched.get(path);
125352
- if (existing && isFileWatcherWithModifiedTime(existing)) {
125353
- existing.callbacks.push(callback);
125354
- }
125355
- else {
125356
- var watcher = state.watchFile(file, function (fileName, eventKind, modifiedTime) {
125357
- var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125358
- ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125359
- existing.modifiedTime = modifiedTime;
125360
- existing.callbacks.forEach(function (cb) { return cb(fileName, eventKind, modifiedTime); });
125361
- }, pollingInterval, options, watchType, project);
125362
- state.filesWatched.set(path, { callbacks: [callback], watcher: watcher, modifiedTime: existing });
125363
- }
125364
- return {
125365
- close: function () {
125366
- var existing = ts.Debug.checkDefined(state.filesWatched.get(path));
125367
- ts.Debug.assert(isFileWatcherWithModifiedTime(existing));
125368
- if (existing.callbacks.length === 1) {
125369
- state.filesWatched.delete(path);
125370
- ts.closeFileWatcherOf(existing);
125371
- }
125372
- else {
125373
- ts.unorderedRemoveItem(existing.callbacks, callback);
125374
- }
125375
- }
125376
- };
125377
- }
125378
- function getOutputTimeStampMap(state, resolvedConfigFilePath) {
125379
- if (!state.watch)
125380
- return undefined;
125381
- var result = state.outputTimeStamps.get(resolvedConfigFilePath);
125382
- if (!result)
125383
- state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map());
125384
- return result;
125385
- }
125386
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options) {
125387
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125388
- var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
125389
- if (existing) {
125390
- existing.buildInfo = buildInfo;
125391
- existing.modifiedTime = getCurrentTime(state.host);
125392
- }
125393
- else {
125394
- state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) });
125395
- }
125396
- }
125397
- function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
125398
- var path = toPath(state, buildInfoPath);
125399
- var existing = state.buildInfoCache.get(resolvedConfigPath);
125400
- return (existing === null || existing === void 0 ? void 0 : existing.path) === path ? existing : undefined;
125401
- }
125402
- function getBuildInfo(state, buildInfoPath, resolvedConfigPath, modifiedTime) {
125403
- var path = toPath(state, buildInfoPath);
125404
- var existing = state.buildInfoCache.get(resolvedConfigPath);
125405
- if (existing !== undefined && existing.path === path) {
125406
- return existing.buildInfo || undefined;
125407
- }
125408
- ts.solutionPerformance.mark("beforeGetBuildInfo");
125409
- ts.solutionPerformance.mark("beforeBuildInfoRead");
125410
- var value = state.readFileWithCache(buildInfoPath);
125411
- ts.solutionPerformance.mark("afterBuildInfoRead");
125412
- ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125413
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
125414
- ts.Debug.assert(modifiedTime || !buildInfo);
125415
- state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
125416
- ts.solutionPerformance.mark("afterGetBuildInfo");
125417
- ts.solutionPerformance.measure("GetBuildInfo", "beforeGetBuildInfo", "afterGetBuildInfo");
125418
- return buildInfo;
125419
- }
125420
125198
  function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
125421
125199
  // Check tsconfig time
125422
- var tsconfigTime = getModifiedTime(state, configFile);
125200
+ var tsconfigTime = ts.getModifiedTime(state.host, configFile);
125423
125201
  if (oldestOutputFileTime < tsconfigTime) {
125424
125202
  return {
125425
125203
  type: ts.UpToDateStatusType.OutOfDateWithSelf,
@@ -125429,24 +125207,88 @@ var ts;
125429
125207
  }
125430
125208
  }
125431
125209
  function getUpToDateStatusWorker(state, project, resolvedPath) {
125432
- var _a, _b, _c;
125210
+ var force = !!state.options.force;
125211
+ var newestInputFileName = undefined;
125212
+ var newestInputFileTime = minimumDate;
125213
+ var host = state.host;
125214
+ // Get timestamps of input files
125215
+ for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
125216
+ var inputFile = _a[_i];
125217
+ if (!host.fileExists(inputFile)) {
125218
+ return {
125219
+ type: ts.UpToDateStatusType.Unbuildable,
125220
+ reason: inputFile + " does not exist"
125221
+ };
125222
+ }
125223
+ if (!force) {
125224
+ var inputTime = ts.getModifiedTime(host, inputFile);
125225
+ if (inputTime > newestInputFileTime) {
125226
+ newestInputFileName = inputFile;
125227
+ newestInputFileTime = inputTime;
125228
+ }
125229
+ }
125230
+ }
125433
125231
  // Container if no files are specified in the project
125434
125232
  if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
125435
125233
  return {
125436
125234
  type: ts.UpToDateStatusType.ContainerOnly
125437
125235
  };
125438
125236
  }
125439
- // Fast check to see if reference projects are buildable
125440
- var referenceStatuses;
125441
- var force = !!state.options.force;
125237
+ // Collect the expected outputs of this project
125238
+ var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125239
+ // Now see if all outputs are newer than the newest input
125240
+ var oldestOutputFileName = "(none)";
125241
+ var oldestOutputFileTime = maximumDate;
125242
+ var newestOutputFileName = "(none)";
125243
+ var newestOutputFileTime = minimumDate;
125244
+ var missingOutputFileName;
125245
+ var newestDeclarationFileContentChangedTime = minimumDate;
125246
+ var isOutOfDateWithInputs = false;
125247
+ if (!force) {
125248
+ for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
125249
+ var output = outputs_1[_b];
125250
+ // Output is missing; can stop checking
125251
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125252
+ if (!host.fileExists(output)) {
125253
+ missingOutputFileName = output;
125254
+ break;
125255
+ }
125256
+ var outputTime = ts.getModifiedTime(host, output);
125257
+ if (outputTime < oldestOutputFileTime) {
125258
+ oldestOutputFileTime = outputTime;
125259
+ oldestOutputFileName = output;
125260
+ }
125261
+ // If an output is older than the newest input, we can stop checking
125262
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
125263
+ if (outputTime < newestInputFileTime) {
125264
+ isOutOfDateWithInputs = true;
125265
+ break;
125266
+ }
125267
+ if (outputTime > newestOutputFileTime) {
125268
+ newestOutputFileTime = outputTime;
125269
+ newestOutputFileName = output;
125270
+ }
125271
+ // Keep track of when the most recent time a .d.ts file was changed.
125272
+ // In addition to file timestamps, we also keep track of when a .d.ts file
125273
+ // had its file touched but not had its contents changed - this allows us
125274
+ // to skip a downstream typecheck
125275
+ if (ts.isDeclarationFileName(output)) {
125276
+ var outputModifiedTime = ts.getModifiedTime(host, output);
125277
+ newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
125278
+ }
125279
+ }
125280
+ }
125281
+ var pseudoUpToDate = false;
125282
+ var usesPrepend = false;
125283
+ var upstreamChangedProject;
125442
125284
  if (project.projectReferences) {
125443
125285
  state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
125444
- for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) {
125445
- var ref = _d[_i];
125286
+ for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
125287
+ var ref = _d[_c];
125288
+ usesPrepend = usesPrepend || !!(ref.prepend);
125446
125289
  var resolvedRef = ts.resolveProjectReferencePath(ref);
125447
125290
  var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
125448
- var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
125449
- var refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
125291
+ var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
125450
125292
  // Its a circular reference ignore the status of this project
125451
125293
  if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
125452
125294
  refStatus.type === ts.UpToDateStatusType.ContainerOnly) { // Container only ignore this project
@@ -125468,188 +125310,78 @@ var ts;
125468
125310
  upstreamProjectName: ref.path
125469
125311
  };
125470
125312
  }
125471
- if (!force)
125472
- (referenceStatuses || (referenceStatuses = [])).push({ ref: ref, refStatus: refStatus, resolvedRefPath: resolvedRefPath, resolvedConfig: resolvedConfig });
125473
- }
125474
- }
125475
- if (force)
125476
- return { type: ts.UpToDateStatusType.ForceBuild };
125477
- // Check buildinfo first
125478
- var host = state.host;
125479
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125480
- var oldestOutputFileName = "(none)";
125481
- var oldestOutputFileTime = maximumDate;
125482
- var buildInfoTime;
125483
- var buildInfoProgram;
125484
- var buildInfoVersionMap;
125485
- var newestDeclarationFileContentChangedTime;
125486
- if (buildInfoPath) {
125487
- var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
125488
- buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath);
125489
- if (buildInfoTime === ts.missingFileModifiedTime) {
125490
- if (!buildInfoCacheEntry_1) {
125491
- state.buildInfoCache.set(resolvedPath, {
125492
- path: toPath(state, buildInfoPath),
125493
- buildInfo: false,
125494
- modifiedTime: buildInfoTime
125495
- });
125496
- }
125497
- return {
125498
- type: ts.UpToDateStatusType.OutputMissing,
125499
- missingOutputFileName: buildInfoPath
125500
- };
125501
- }
125502
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
125503
- if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125504
- return {
125505
- type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125506
- version: buildInfo.version
125507
- };
125508
- }
125509
- if (buildInfo.program) {
125510
- if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
125511
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
125313
+ // Check oldest output file name only if there is no missing output file name
125314
+ // (a check we will have skipped if this is a forced build)
125315
+ if (!force && !missingOutputFileName) {
125316
+ // If the upstream project's newest file is older than our oldest output, we
125317
+ // can't be out of date because of it
125318
+ if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125319
+ continue;
125320
+ }
125321
+ // If the upstream project has only change .d.ts files, and we've built
125322
+ // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125323
+ if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125324
+ pseudoUpToDate = true;
125325
+ upstreamChangedProject = ref.path;
125326
+ continue;
125327
+ }
125328
+ // We have an output older than an upstream output - we are out of date
125329
+ ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125512
125330
  return {
125513
- type: ts.UpToDateStatusType.OutOfDateBuildInfo,
125514
- buildInfoFile: buildInfoPath
125331
+ type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125332
+ outOfDateOutputFileName: oldestOutputFileName,
125333
+ newerProjectName: ref.path
125515
125334
  };
125516
125335
  }
125517
- buildInfoProgram = buildInfo.program;
125518
125336
  }
125519
- oldestOutputFileTime = buildInfoTime;
125520
- oldestOutputFileName = buildInfoPath;
125521
- newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined;
125522
125337
  }
125523
- // Check input files
125524
- var newestInputFileName = undefined;
125525
- var newestInputFileTime = minimumDate;
125526
- var pseudoInputUptodate = false;
125527
- // Get timestamps of input files
125528
- for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) {
125529
- var inputFile = _f[_e];
125530
- var inputTime = getModifiedTime(state, inputFile);
125531
- if (inputTime === ts.missingFileModifiedTime) {
125532
- return {
125533
- type: ts.UpToDateStatusType.Unbuildable,
125534
- reason: inputFile + " does not exist"
125535
- };
125536
- }
125537
- // If an buildInfo is older than the newest input, we can stop checking
125538
- if (buildInfoTime && buildInfoTime < inputTime) {
125539
- var version_3 = void 0;
125540
- var currentVersion = void 0;
125541
- if (buildInfoProgram) {
125542
- // Read files and see if they are same, read is anyways cached
125543
- if (!buildInfoVersionMap)
125544
- buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
125545
- version_3 = buildInfoVersionMap.get(toPath(state, inputFile));
125546
- var text = version_3 ? state.readFileWithCache(inputFile) : undefined;
125547
- currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text);
125548
- if (version_3 && version_3 === currentVersion)
125549
- pseudoInputUptodate = true;
125550
- }
125551
- if (!version_3 || version_3 !== currentVersion) {
125552
- return {
125553
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125554
- outOfDateOutputFileName: buildInfoPath,
125555
- newerInputFileName: inputFile
125556
- };
125557
- }
125558
- }
125559
- if (inputTime > newestInputFileTime) {
125560
- newestInputFileName = inputFile;
125561
- newestInputFileTime = inputTime;
125562
- }
125338
+ if (missingOutputFileName !== undefined) {
125339
+ return {
125340
+ type: ts.UpToDateStatusType.OutputMissing,
125341
+ missingOutputFileName: missingOutputFileName
125342
+ };
125563
125343
  }
125564
- // Now see if all outputs are newer than the newest input
125565
- // Dont check output timestamps if we have buildinfo telling us output is uptodate
125566
- if (!buildInfoPath) {
125567
- // Collect the expected outputs of this project
125568
- var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
125569
- var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
125570
- for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) {
125571
- var output = outputs_1[_g];
125572
- var path = toPath(state, output);
125573
- // Output is missing; can stop checking
125574
- var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path);
125575
- if (!outputTime) {
125576
- outputTime = ts.getModifiedTime(state.host, output);
125577
- outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.set(path, outputTime);
125578
- }
125579
- if (outputTime === ts.missingFileModifiedTime) {
125580
- return {
125581
- type: ts.UpToDateStatusType.OutputMissing,
125582
- missingOutputFileName: output
125583
- };
125584
- }
125585
- if (outputTime < oldestOutputFileTime) {
125586
- oldestOutputFileTime = outputTime;
125587
- oldestOutputFileName = output;
125588
- }
125589
- // If an output is older than the newest input, we can stop checking
125590
- if (outputTime < newestInputFileTime) {
125591
- return {
125592
- type: ts.UpToDateStatusType.OutOfDateWithSelf,
125593
- outOfDateOutputFileName: oldestOutputFileName,
125594
- newerInputFileName: newestInputFileName
125595
- };
125596
- }
125597
- }
125344
+ if (isOutOfDateWithInputs) {
125345
+ return {
125346
+ type: ts.UpToDateStatusType.OutOfDateWithSelf,
125347
+ outOfDateOutputFileName: oldestOutputFileName,
125348
+ newerInputFileName: newestInputFileName
125349
+ };
125598
125350
  }
125599
- var seenRefs = buildInfoPath ? new ts.Set() : undefined;
125600
- var buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
125601
- seenRefs === null || seenRefs === void 0 ? void 0 : seenRefs.add(resolvedPath);
125602
- var pseudoUpToDate = false;
125603
- var usesPrepend = false;
125604
- var upstreamChangedProject;
125605
- if (referenceStatuses) {
125606
- for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) {
125607
- var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath;
125608
- usesPrepend = usesPrepend || !!(ref.prepend);
125609
- // If the upstream project's newest file is older than our oldest output, we
125610
- // can't be out of date because of it
125611
- if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
125612
- continue;
125613
- }
125614
- // Check if tsbuildinfo path is shared, then we need to rebuild
125615
- if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath)) {
125351
+ else {
125352
+ // Check tsconfig time
125353
+ var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125354
+ if (configStatus)
125355
+ return configStatus;
125356
+ // Check extended config time
125357
+ var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125358
+ if (extendedConfigStatus)
125359
+ return extendedConfigStatus;
125360
+ // Check package file time
125361
+ var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125362
+ var path = _a[0];
125363
+ return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125364
+ });
125365
+ if (dependentPackageFileStatus)
125366
+ return dependentPackageFileStatus;
125367
+ }
125368
+ if (!force && !state.buildInfoChecked.has(resolvedPath)) {
125369
+ state.buildInfoChecked.set(resolvedPath, true);
125370
+ var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125371
+ if (buildInfoPath) {
125372
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125373
+ var value = state.readFileWithCache(buildInfoPath);
125374
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125375
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125376
+ var buildInfo = value && ts.getBuildInfo(value);
125377
+ if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125616
125378
  return {
125617
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125618
- outOfDateOutputFileName: buildInfoPath,
125619
- newerProjectName: ref.path
125379
+ type: ts.UpToDateStatusType.TsVersionOutputOfDate,
125380
+ version: buildInfo.version
125620
125381
  };
125621
125382
  }
125622
- // If the upstream project has only change .d.ts files, and we've built
125623
- // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
125624
- if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
125625
- pseudoUpToDate = true;
125626
- upstreamChangedProject = ref.path;
125627
- continue;
125628
- }
125629
- // We have an output older than an upstream output - we are out of date
125630
- ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
125631
- return {
125632
- type: ts.UpToDateStatusType.OutOfDateWithUpstream,
125633
- outOfDateOutputFileName: oldestOutputFileName,
125634
- newerProjectName: ref.path
125635
- };
125636
125383
  }
125637
125384
  }
125638
- // Check tsconfig time
125639
- var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
125640
- if (configStatus)
125641
- return configStatus;
125642
- // Check extended config time
125643
- var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
125644
- if (extendedConfigStatus)
125645
- return extendedConfigStatus;
125646
- // Check package file time
125647
- var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) {
125648
- var path = _a[0];
125649
- return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName);
125650
- });
125651
- if (dependentPackageFileStatus)
125652
- return dependentPackageFileStatus;
125653
125385
  if (usesPrepend && pseudoUpToDate) {
125654
125386
  return {
125655
125387
  type: ts.UpToDateStatusType.OutOfDateWithPrepend,
@@ -125659,37 +125391,15 @@ var ts;
125659
125391
  }
125660
125392
  // Up to date
125661
125393
  return {
125662
- type: pseudoUpToDate ?
125663
- ts.UpToDateStatusType.UpToDateWithUpstreamTypes :
125664
- pseudoInputUptodate ?
125665
- ts.UpToDateStatusType.UpToDateWithInputFileText :
125666
- ts.UpToDateStatusType.UpToDate,
125394
+ type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
125667
125395
  newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
125668
125396
  newestInputFileTime: newestInputFileTime,
125397
+ newestOutputFileTime: newestOutputFileTime,
125669
125398
  newestInputFileName: newestInputFileName,
125399
+ newestOutputFileName: newestOutputFileName,
125670
125400
  oldestOutputFileName: oldestOutputFileName
125671
125401
  };
125672
125402
  }
125673
- function hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig, resolvedRefPath) {
125674
- if (seenRefs.has(resolvedRefPath))
125675
- return false;
125676
- seenRefs.add(resolvedRefPath);
125677
- var refBuildInfo = state.buildInfoCache.get(resolvedRefPath);
125678
- if (refBuildInfo.path === buildInfoCacheEntry.path)
125679
- return true;
125680
- if (resolvedConfig.projectReferences) {
125681
- // Check references
125682
- for (var _i = 0, _a = resolvedConfig.projectReferences; _i < _a.length; _i++) {
125683
- var ref = _a[_i];
125684
- var resolvedRef = ts.resolveProjectReferencePath(ref);
125685
- var resolvedRefPath_1 = toResolvedConfigFilePath(state, resolvedRef);
125686
- var resolvedConfig_1 = parseConfigFile(state, resolvedRef, resolvedRefPath_1);
125687
- if (hasSameBuildInfo(state, buildInfoCacheEntry, seenRefs, resolvedConfig_1, resolvedRefPath_1))
125688
- return true;
125689
- }
125690
- }
125691
- return false;
125692
- }
125693
125403
  function getUpToDateStatus(state, project, resolvedPath) {
125694
125404
  if (project === undefined) {
125695
125405
  return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
@@ -125705,69 +125415,42 @@ var ts;
125705
125415
  state.projectStatus.set(resolvedPath, actual);
125706
125416
  return actual;
125707
125417
  }
125708
- function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage, skipOutputs) {
125418
+ function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125709
125419
  if (proj.options.noEmit)
125710
- return;
125711
- var now;
125420
+ return priorNewestUpdateTime;
125712
125421
  ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125713
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(proj.options);
125714
- if (buildInfoPath) {
125715
- if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(toPath(state, buildInfoPath)))) {
125716
- if (!!state.options.verbose)
125422
+ var host = state.host;
125423
+ var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125424
+ if (!skipOutputs || outputs.length !== skipOutputs.size) {
125425
+ var reportVerbose = !!state.options.verbose;
125426
+ var now = host.now ? host.now() : new Date();
125427
+ for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125428
+ var file = outputs_2[_i];
125429
+ if (skipOutputs && skipOutputs.has(toPath(state, file))) {
125430
+ continue;
125431
+ }
125432
+ if (reportVerbose) {
125433
+ reportVerbose = false;
125717
125434
  reportStatus(state, verboseMessage, proj.options.configFilePath);
125718
- state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
125719
- getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
125720
- }
125721
- state.outputTimeStamps.delete(projectPath);
125722
- }
125723
- else {
125724
- var host = state.host;
125725
- var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125726
- var outputTimeStampMap_1 = getOutputTimeStampMap(state, projectPath);
125727
- var modifiedOutputs_1 = outputTimeStampMap_1 ? new ts.Set() : undefined;
125728
- if (!skipOutputs || outputs.length !== skipOutputs.size) {
125729
- var reportVerbose = !!state.options.verbose;
125730
- for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
125731
- var file = outputs_2[_i];
125732
- var path = toPath(state, file);
125733
- if (skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(path))
125734
- continue;
125735
- if (reportVerbose) {
125736
- reportVerbose = false;
125737
- reportStatus(state, verboseMessage, proj.options.configFilePath);
125738
- }
125739
- host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
125740
- if (outputTimeStampMap_1) {
125741
- outputTimeStampMap_1.set(path, now);
125742
- modifiedOutputs_1.add(path);
125743
- }
125744
125435
  }
125436
+ if (ts.isDeclarationFileName(file)) {
125437
+ priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
125438
+ }
125439
+ host.setModifiedTime(file, now);
125745
125440
  }
125746
- // Clear out timestamps not in output list any more
125747
- outputTimeStampMap_1 === null || outputTimeStampMap_1 === void 0 ? void 0 : outputTimeStampMap_1.forEach(function (_value, key) {
125748
- if (!(skipOutputs === null || skipOutputs === void 0 ? void 0 : skipOutputs.has(key)) && !modifiedOutputs_1.has(key))
125749
- outputTimeStampMap_1.delete(key);
125750
- });
125751
125441
  }
125752
125442
  ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125753
125443
  ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125754
- }
125755
- function getDtsChangeTime(state, options, resolvedConfigPath) {
125756
- var _a;
125757
- if (!options.composite)
125758
- return undefined;
125759
- var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options);
125760
- var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
125761
- 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;
125444
+ return priorNewestUpdateTime;
125762
125445
  }
125763
125446
  function updateOutputTimestamps(state, proj, resolvedPath) {
125764
125447
  if (state.options.dry) {
125765
125448
  return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
125766
125449
  }
125767
- updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125450
+ var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
125768
125451
  state.projectStatus.set(resolvedPath, {
125769
125452
  type: ts.UpToDateStatusType.UpToDate,
125770
- newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
125453
+ newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
125771
125454
  oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
125772
125455
  });
125773
125456
  }
@@ -125813,7 +125496,6 @@ var ts;
125813
125496
  break;
125814
125497
  }
125815
125498
  // falls through
125816
- case ts.UpToDateStatusType.UpToDateWithInputFileText:
125817
125499
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
125818
125500
  case ts.UpToDateStatusType.OutOfDateWithPrepend:
125819
125501
  if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
@@ -125998,10 +125680,12 @@ var ts;
125998
125680
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125999
125681
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
126000
125682
  return;
126001
- 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));
125683
+ state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
125684
+ invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
125685
+ }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
126002
125686
  }
126003
125687
  function watchExtendedConfigFiles(state, resolvedPath, parsed) {
126004
- ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(state, extendedConfigFileName, function () {
125688
+ ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
126005
125689
  var _a;
126006
125690
  return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
126007
125691
  return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
@@ -126033,7 +125717,7 @@ var ts;
126033
125717
  if (!state.watch)
126034
125718
  return;
126035
125719
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
126036
- 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); },
125720
+ 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); },
126037
125721
  onDeleteValue: ts.closeFileWatcher,
126038
125722
  });
126039
125723
  }
@@ -126041,7 +125725,7 @@ var ts;
126041
125725
  if (!state.watch || !state.lastCachedPackageJsonLookups)
126042
125726
  return;
126043
125727
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
126044
- 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); },
125728
+ 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); },
126045
125729
  onDeleteValue: ts.closeFileWatcher,
126046
125730
  });
126047
125731
  }
@@ -126174,18 +125858,19 @@ var ts;
126174
125858
  }
126175
125859
  }
126176
125860
  function reportUpToDateStatus(state, configFileName, status) {
125861
+ if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) {
125862
+ return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
125863
+ }
126177
125864
  switch (status.type) {
126178
125865
  case ts.UpToDateStatusType.OutOfDateWithSelf:
126179
- 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));
125866
+ 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));
126180
125867
  case ts.UpToDateStatusType.OutOfDateWithUpstream:
126181
- 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));
125868
+ 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));
126182
125869
  case ts.UpToDateStatusType.OutputMissing:
126183
125870
  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));
126184
- case ts.UpToDateStatusType.OutOfDateBuildInfo:
126185
- 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));
126186
125871
  case ts.UpToDateStatusType.UpToDate:
126187
125872
  if (status.newestInputFileTime !== undefined) {
126188
- 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 || ""));
125873
+ 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 || ""));
126189
125874
  }
126190
125875
  // Don't report anything for "up to date because it was already built" -- too verbose
126191
125876
  break;
@@ -126193,8 +125878,6 @@ var ts;
126193
125878
  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));
126194
125879
  case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
126195
125880
  return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
126196
- case ts.UpToDateStatusType.UpToDateWithInputFileText:
126197
- 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));
126198
125881
  case ts.UpToDateStatusType.UpstreamOutOfDate:
126199
125882
  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));
126200
125883
  case ts.UpToDateStatusType.UpstreamBlocked:
@@ -126205,8 +125888,6 @@ var ts;
126205
125888
  return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
126206
125889
  case ts.UpToDateStatusType.TsVersionOutputOfDate:
126207
125890
  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);
126208
- case ts.UpToDateStatusType.ForceBuild:
126209
- return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName));
126210
125891
  case ts.UpToDateStatusType.ContainerOnly:
126211
125892
  // Don't report status on "solution" projects
126212
125893
  // falls through