@typescript-deploys/pr-build 4.8.0-pr-48997-21 → 4.8.0-pr-49285-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
92
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220601";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -3499,16 +3499,34 @@ var ts;
3499
3499
  /** Performance measurements for the compiler. */
3500
3500
  var ts;
3501
3501
  (function (ts) {
3502
- var performance;
3503
- (function (performance) {
3502
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3503
+ ts.performance = createPerformanceTracker();
3504
+ ts.solutionPerformance = createPerformanceTracker();
3505
+ function createPerformanceTracker() {
3504
3506
  var perfHooks;
3505
3507
  // when set, indicates the implementation of `Performance` to use for user timing.
3506
3508
  // when unset, indicates user timing is unavailable or disabled.
3507
3509
  var performanceImpl;
3510
+ var enabled = false;
3511
+ var timeorigin = ts.timestamp();
3512
+ var marks = new ts.Map();
3513
+ var counts = new ts.Map();
3514
+ var durations = new ts.Map();
3515
+ return {
3516
+ createTimerIf: createTimerIf,
3517
+ createTimer: createTimer,
3518
+ mark: mark,
3519
+ measure: measure,
3520
+ getCount: getCount,
3521
+ getDuration: getDuration,
3522
+ forEachMeasure: forEachMeasure,
3523
+ isEnabled: isEnabled,
3524
+ enable: enable,
3525
+ disable: disable,
3526
+ };
3508
3527
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3509
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3528
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3510
3529
  }
3511
- performance.createTimerIf = createTimerIf;
3512
3530
  function createTimer(measureName, startMarkName, endMarkName) {
3513
3531
  var enterCount = 0;
3514
3532
  return {
@@ -3530,13 +3548,6 @@ var ts;
3530
3548
  }
3531
3549
  }
3532
3550
  }
3533
- performance.createTimer = createTimer;
3534
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3535
- var enabled = false;
3536
- var timeorigin = ts.timestamp();
3537
- var marks = new ts.Map();
3538
- var counts = new ts.Map();
3539
- var durations = new ts.Map();
3540
3551
  /**
3541
3552
  * Marks a performance event.
3542
3553
  *
@@ -3551,7 +3562,6 @@ var ts;
3551
3562
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3552
3563
  }
3553
3564
  }
3554
- performance.mark = mark;
3555
3565
  /**
3556
3566
  * Adds a performance measurement with the specified name.
3557
3567
  *
@@ -3564,14 +3574,13 @@ var ts;
3564
3574
  function measure(measureName, startMarkName, endMarkName) {
3565
3575
  var _a, _b;
3566
3576
  if (enabled) {
3567
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3568
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3577
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3578
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3569
3579
  var previousDuration = durations.get(measureName) || 0;
3570
3580
  durations.set(measureName, previousDuration + (end - start));
3571
3581
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3572
3582
  }
3573
3583
  }
3574
- performance.measure = measure;
3575
3584
  /**
3576
3585
  * Gets the number of times a marker was encountered.
3577
3586
  *
@@ -3580,7 +3589,6 @@ var ts;
3580
3589
  function getCount(markName) {
3581
3590
  return counts.get(markName) || 0;
3582
3591
  }
3583
- performance.getCount = getCount;
3584
3592
  /**
3585
3593
  * Gets the total duration of all measurements with the supplied name.
3586
3594
  *
@@ -3589,7 +3597,6 @@ var ts;
3589
3597
  function getDuration(measureName) {
3590
3598
  return durations.get(measureName) || 0;
3591
3599
  }
3592
- performance.getDuration = getDuration;
3593
3600
  /**
3594
3601
  * Iterate over each measure, performing some action
3595
3602
  *
@@ -3598,14 +3605,12 @@ var ts;
3598
3605
  function forEachMeasure(cb) {
3599
3606
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3600
3607
  }
3601
- performance.forEachMeasure = forEachMeasure;
3602
3608
  /**
3603
3609
  * Indicates whether the performance API is enabled.
3604
3610
  */
3605
3611
  function isEnabled() {
3606
3612
  return enabled;
3607
3613
  }
3608
- performance.isEnabled = isEnabled;
3609
3614
  /** Enables (and resets) performance measurements for the compiler. */
3610
3615
  function enable(system) {
3611
3616
  var _a;
@@ -3626,7 +3631,6 @@ var ts;
3626
3631
  }
3627
3632
  return true;
3628
3633
  }
3629
- performance.enable = enable;
3630
3634
  /** Disables performance measurements for the compiler. */
3631
3635
  function disable() {
3632
3636
  if (enabled) {
@@ -3637,8 +3641,7 @@ var ts;
3637
3641
  enabled = false;
3638
3642
  }
3639
3643
  }
3640
- performance.disable = disable;
3641
- })(performance = ts.performance || (ts.performance = {}));
3644
+ }
3642
3645
  })(ts || (ts = {}));
3643
3646
  /* @internal */
3644
3647
  var ts;
@@ -5090,6 +5093,11 @@ var ts;
5090
5093
  // Flags that require TypeFlags.Union
5091
5094
  /* @internal */
5092
5095
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5096
+ /* @internal */
5097
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5098
+ /* @internal */
5099
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5100
+ /* @internal */
5093
5101
  // Flags that require TypeFlags.Intersection
5094
5102
  /* @internal */
5095
5103
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -6308,7 +6316,7 @@ var ts;
6308
6316
  */
6309
6317
  /*@internal*/
6310
6318
  function createDirectoryWatcherSupportingRecursive(_a) {
6311
- var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, fileSystemEntryExists = _a.fileSystemEntryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6319
+ var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, directoryExists = _a.directoryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
6312
6320
  var cache = new ts.Map();
6313
6321
  var callbackCache = ts.createMultiMap();
6314
6322
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6408,7 +6416,7 @@ var ts;
6408
6416
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6409
6417
  // Iterate through existing children and update the watches if needed
6410
6418
  var parentWatcher = cache.get(dirPath);
6411
- if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6419
+ if (parentWatcher && directoryExists(dirName)) {
6412
6420
  // Schedule the update and postpone invoke for callbacks
6413
6421
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6414
6422
  return;
@@ -6481,7 +6489,7 @@ var ts;
6481
6489
  if (!parentWatcher)
6482
6490
  return false;
6483
6491
  var newChildWatches;
6484
- var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6492
+ var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6485
6493
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6486
6494
  // Filter our the symbolic link directories since those arent included in recursive watch
6487
6495
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6527,10 +6535,10 @@ var ts;
6527
6535
  return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6528
6536
  }
6529
6537
  ts.createFileWatcherCallback = createFileWatcherCallback;
6530
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists) {
6538
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6531
6539
  return function (eventName) {
6532
6540
  if (eventName === "rename") {
6533
- callback(fileName, fileSystemEntryExists(fileName, 0 /* File */) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6541
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6534
6542
  }
6535
6543
  else {
6536
6544
  // Change
@@ -6558,12 +6566,11 @@ var ts;
6558
6566
  }
6559
6567
  /*@internal*/
6560
6568
  function createSystemWatchFunctions(_a) {
6561
- var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6569
+ 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;
6562
6570
  var dynamicPollingWatchFile;
6563
6571
  var fixedChunkSizePollingWatchFile;
6564
6572
  var nonPollingWatchFile;
6565
6573
  var hostRecursiveDirectoryWatcher;
6566
- var hitSystemWatcherLimit = false;
6567
6574
  return {
6568
6575
  watchFile: watchFile,
6569
6576
  watchDirectory: watchDirectory
@@ -6581,7 +6588,7 @@ var ts;
6581
6588
  case ts.WatchFileKind.FixedChunkSizePolling:
6582
6589
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6583
6590
  case ts.WatchFileKind.UseFsEvents:
6584
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists),
6591
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6585
6592
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6586
6593
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6587
6594
  if (!nonPollingWatchFile) {
@@ -6642,7 +6649,7 @@ var ts;
6642
6649
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6643
6650
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6644
6651
  getCurrentDirectory: getCurrentDirectory,
6645
- fileSystemEntryExists: fileSystemEntryExists,
6652
+ directoryExists: directoryExists,
6646
6653
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6647
6654
  watchDirectory: nonRecursiveWatchDirectory,
6648
6655
  realpath: realpath,
@@ -6693,114 +6700,6 @@ var ts;
6693
6700
  };
6694
6701
  }
6695
6702
  }
6696
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6697
- var lastDirectoryPartWithDirectorySeparator;
6698
- var lastDirectoryPart;
6699
- if (inodeWatching) {
6700
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6701
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6702
- }
6703
- /** Watcher for the file system entry depending on whether it is missing or present */
6704
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6705
- watchMissingFileSystemEntry() :
6706
- watchPresentFileSystemEntry();
6707
- return {
6708
- close: function () {
6709
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6710
- watcher.close();
6711
- watcher = undefined;
6712
- }
6713
- };
6714
- function updateWatcher(createWatcher) {
6715
- // If watcher is not closed, update it
6716
- if (watcher) {
6717
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6718
- watcher.close();
6719
- watcher = createWatcher();
6720
- }
6721
- }
6722
- /**
6723
- * Watch the file or directory that is currently present
6724
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
6725
- */
6726
- function watchPresentFileSystemEntry() {
6727
- if (hitSystemWatcherLimit) {
6728
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6729
- return watchPresentFileSystemEntryWithFsWatchFile();
6730
- }
6731
- try {
6732
- var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6733
- callbackChangingToMissingFileSystemEntry :
6734
- function (eventName, relativeFileName) {
6735
- sysLog("sysLog:: watchPresentFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6736
- callback(eventName, relativeFileName);
6737
- });
6738
- // Watch the missing file or directory or error
6739
- presentWatcher.on("error", function () {
6740
- sysLog("sysLog:: watchPresentFileSystemEntry:: on Error " + fileOrDirectory + " " + entryKind + " rename, \"\"");
6741
- callback("rename", "");
6742
- updateWatcher(watchMissingFileSystemEntry);
6743
- });
6744
- return presentWatcher;
6745
- }
6746
- catch (e) {
6747
- // Catch the exception and use polling instead
6748
- // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6749
- // so instead of throwing error, use fs.watchFile
6750
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6751
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6752
- return watchPresentFileSystemEntryWithFsWatchFile();
6753
- }
6754
- }
6755
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6756
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + event + ":: " + relativeName + " " + inodeWatching + " " + lastDirectoryPart + " " + lastDirectoryPartWithDirectorySeparator);
6757
- if (relativeName && ts.endsWith(relativeName, "~")) {
6758
- relativeName = relativeName.slice(0, relativeName.length - 1);
6759
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: changed the relative name to " + relativeName);
6760
- }
6761
- callback(event, relativeName);
6762
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6763
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6764
- if (event === "rename" &&
6765
- (!relativeName ||
6766
- relativeName === lastDirectoryPart ||
6767
- ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6768
- if (inodeWatching) {
6769
- updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6770
- }
6771
- else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
6772
- updateWatcher(watchMissingFileSystemEntry);
6773
- }
6774
- }
6775
- }
6776
- /**
6777
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
6778
- * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
6779
- */
6780
- function watchPresentFileSystemEntryWithFsWatchFile() {
6781
- return watchFile(fileOrDirectory, createFileWatcherCallback(function (eventName, relativeFileName) {
6782
- sysLog("sysLog:: watchPresentFileSystemEntryWithFsWatchFile:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6783
- callback(eventName, relativeFileName);
6784
- }), fallbackPollingInterval, fallbackOptions);
6785
- }
6786
- /**
6787
- * Watch the file or directory that is missing
6788
- * and switch to existing file or directory when the missing filesystem entry is created
6789
- */
6790
- function watchMissingFileSystemEntry() {
6791
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
6792
- sysLog("sysLog:: watchMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + _fileName + ":: " + eventKind);
6793
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
6794
- sysLog("sysLog:: watchMissingFileSystemEntry:: Callback :: rename, \"\" and will update the watcher");
6795
- callback("rename", "");
6796
- // Call the callback for current file or directory
6797
- // For now it could be callback for the inner directory creation,
6798
- // but just return current directory, better than current no-op
6799
- updateWatcher(watchPresentFileSystemEntry);
6800
- }
6801
- }, fallbackPollingInterval, fallbackOptions);
6802
- }
6803
- }
6804
6703
  }
6805
6704
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6806
6705
  /**
@@ -6853,6 +6752,7 @@ var ts;
6853
6752
  }
6854
6753
  var activeSession;
6855
6754
  var profilePath = "./profile.cpuprofile";
6755
+ var hitSystemWatcherLimit = false;
6856
6756
  var Buffer = require("buffer").Buffer;
6857
6757
  var nodeVersion = getNodeMajorVersion();
6858
6758
  var isNode4OrLater = nodeVersion >= 4;
@@ -6867,21 +6767,20 @@ var ts;
6867
6767
  getModifiedTime: getModifiedTime,
6868
6768
  setTimeout: setTimeout,
6869
6769
  clearTimeout: clearTimeout,
6870
- fsWatchWorker: fsWatchWorker,
6770
+ fsWatch: fsWatch,
6871
6771
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6872
6772
  getCurrentDirectory: getCurrentDirectory,
6873
- fileSystemEntryExists: fileSystemEntryExists,
6773
+ fileExists: fileExists,
6874
6774
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6875
6775
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6876
6776
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6777
+ directoryExists: directoryExists,
6877
6778
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6878
6779
  realpath: realpath,
6879
6780
  tscWatchFile: process.env.TSC_WATCHFILE,
6880
6781
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6881
6782
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6882
6783
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
6883
- inodeWatching: isLinuxOrMacOs,
6884
- sysLog: sysLog,
6885
6784
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6886
6785
  var nodeSystem = {
6887
6786
  args: process.argv.slice(2),
@@ -7134,11 +7033,107 @@ var ts;
7134
7033
  callback(fileName, eventKind);
7135
7034
  }
7136
7035
  }
7137
- function fsWatchWorker(fileOrDirectory, recursive, callback) {
7138
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7139
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7140
- return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7141
- { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7036
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7037
+ var options;
7038
+ var lastDirectoryPartWithDirectorySeparator;
7039
+ var lastDirectoryPart;
7040
+ if (isLinuxOrMacOs) {
7041
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7042
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7043
+ }
7044
+ /** Watcher for the file system entry depending on whether it is missing or present */
7045
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7046
+ watchMissingFileSystemEntry() :
7047
+ watchPresentFileSystemEntry();
7048
+ return {
7049
+ close: function () {
7050
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7051
+ watcher.close();
7052
+ watcher = undefined;
7053
+ }
7054
+ };
7055
+ /**
7056
+ * Invoke the callback with rename and update the watcher if not closed
7057
+ * @param createWatcher
7058
+ */
7059
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
7060
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7061
+ // Call the callback for current directory
7062
+ callback("rename", "");
7063
+ // If watcher is not closed, update it
7064
+ if (watcher) {
7065
+ watcher.close();
7066
+ watcher = createWatcher();
7067
+ }
7068
+ }
7069
+ /**
7070
+ * Watch the file or directory that is currently present
7071
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
7072
+ */
7073
+ function watchPresentFileSystemEntry() {
7074
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7075
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7076
+ if (options === undefined) {
7077
+ if (fsSupportsRecursiveFsWatch) {
7078
+ options = { persistent: true, recursive: !!recursive };
7079
+ }
7080
+ else {
7081
+ options = { persistent: true };
7082
+ }
7083
+ }
7084
+ if (hitSystemWatcherLimit) {
7085
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7086
+ return watchPresentFileSystemEntryWithFsWatchFile();
7087
+ }
7088
+ try {
7089
+ var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7090
+ callbackChangingToMissingFileSystemEntry :
7091
+ callback);
7092
+ // Watch the missing file or directory or error
7093
+ presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7094
+ return presentWatcher;
7095
+ }
7096
+ catch (e) {
7097
+ // Catch the exception and use polling instead
7098
+ // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7099
+ // so instead of throwing error, use fs.watchFile
7100
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7101
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7102
+ return watchPresentFileSystemEntryWithFsWatchFile();
7103
+ }
7104
+ }
7105
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7106
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7107
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7108
+ return event === "rename" &&
7109
+ (!relativeName ||
7110
+ relativeName === lastDirectoryPart ||
7111
+ (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7112
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7113
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7114
+ callback(event, relativeName);
7115
+ }
7116
+ /**
7117
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
7118
+ * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7119
+ */
7120
+ function watchPresentFileSystemEntryWithFsWatchFile() {
7121
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7122
+ }
7123
+ /**
7124
+ * Watch the file or directory that is missing
7125
+ * and switch to existing file or directory when the missing filesystem entry is created
7126
+ */
7127
+ function watchMissingFileSystemEntry() {
7128
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7129
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7130
+ // Call the callback for current file or directory
7131
+ // For now it could be callback for the inner directory creation,
7132
+ // but just return current directory, better than current no-op
7133
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7134
+ }
7135
+ }, fallbackPollingInterval, fallbackOptions);
7136
+ }
7142
7137
  }
7143
7138
  function readFileWorker(fileName, _encoding) {
7144
7139
  var buffer;
@@ -8416,6 +8411,7 @@ var ts;
8416
8411
  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),
8417
8412
  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."),
8418
8413
  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."),
8414
+ 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."),
8419
8415
  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."),
8420
8416
  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."),
8421
8417
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -8901,6 +8897,7 @@ var ts;
8901
8897
  Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8902
8898
  All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
8903
8899
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
8900
+ An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
8904
8901
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8905
8902
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8906
8903
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -16220,9 +16217,6 @@ var ts;
16220
16217
  }
16221
16218
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16222
16219
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16223
- if (node.kind === 203 /* BindingElement */) {
16224
- node = node.parent.parent;
16225
- }
16226
16220
  return ts.isVariableDeclaration(node) &&
16227
16221
  !!node.initializer &&
16228
16222
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20034,8 +20028,9 @@ var ts;
20034
20028
  */
20035
20029
  function isFileForcedToBeModuleByFormat(file) {
20036
20030
  // Excludes declaration files - they still require an explicit `export {}` or the like
20037
- // for back compat purposes.
20038
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20031
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20032
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20033
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20039
20034
  }
20040
20035
  function getSetExternalModuleIndicator(options) {
20041
20036
  // TODO: Should this callback be cached?
@@ -20043,7 +20038,7 @@ var ts;
20043
20038
  case ts.ModuleDetectionKind.Force:
20044
20039
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20045
20040
  return function (file) {
20046
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20041
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20047
20042
  };
20048
20043
  case ts.ModuleDetectionKind.Legacy:
20049
20044
  // Files are modules if they have imports, exports, or import.meta
@@ -20103,7 +20098,8 @@ var ts;
20103
20098
  }
20104
20099
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20105
20100
  function getEmitModuleDetectionKind(options) {
20106
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20101
+ return options.moduleDetection ||
20102
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20107
20103
  }
20108
20104
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20109
20105
  function hasJsonModuleEmitEnabled(options) {
@@ -43150,16 +43146,20 @@ var ts;
43150
43146
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43151
43147
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43152
43148
  }
43149
+ var jsOnlyExtensions = [Extensions.JavaScript];
43150
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43151
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43152
+ var tsconfigExtensions = [Extensions.TSConfig];
43153
43153
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43154
43154
  var containingDirectory = ts.getDirectoryPath(containingFile);
43155
43155
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43156
43156
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43157
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43157
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43158
+ if (compilerOptions.resolveJsonModule) {
43159
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43160
+ }
43161
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43158
43162
  }
43159
- var jsOnlyExtensions = [Extensions.JavaScript];
43160
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43161
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43162
- var tsconfigExtensions = [Extensions.TSConfig];
43163
43163
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43164
43164
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43165
43165
  }
@@ -44167,8 +44167,8 @@ var ts;
44167
44167
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
44168
44168
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
44169
44169
  if (!pathAndExtension && packageInfo
44170
- && packageInfo.packageJsonContent.exports === undefined
44171
- && packageInfo.packageJsonContent.main === undefined
44170
+ // eslint-disable-next-line no-null/no-null
44171
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
44172
44172
  && state.features & NodeResolutionFeatures.EsmMode) {
44173
44173
  // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
44174
44174
  // a default `index.js` entrypoint if no `main` or `exports` are present
@@ -46944,12 +46944,14 @@ var ts;
46944
46944
  }
46945
46945
  }
46946
46946
  function setCommonJsModuleIndicator(node) {
46947
- if (file.externalModuleIndicator) {
46947
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46948
46948
  return false;
46949
46949
  }
46950
46950
  if (!file.commonJsModuleIndicator) {
46951
46951
  file.commonJsModuleIndicator = node;
46952
- bindSourceFileAsExternalModule();
46952
+ if (!file.externalModuleIndicator) {
46953
+ bindSourceFileAsExternalModule();
46954
+ }
46953
46955
  }
46954
46956
  return true;
46955
46957
  }
@@ -47363,7 +47365,11 @@ var ts;
47363
47365
  checkStrictModeEvalOrArguments(node, node.name);
47364
47366
  }
47365
47367
  if (!ts.isBindingPattern(node.name)) {
47366
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47368
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47369
+ if (ts.isInJSFile(node) &&
47370
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47371
+ !ts.getJSDocTypeTag(node) &&
47372
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47367
47373
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47368
47374
  }
47369
47375
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -47827,7 +47833,10 @@ var ts;
47827
47833
  TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull";
47828
47834
  TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy";
47829
47835
  TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy";
47830
- TypeFacts[TypeFacts["All"] = 16777215] = "All";
47836
+ TypeFacts[TypeFacts["IsUndefined"] = 16777216] = "IsUndefined";
47837
+ TypeFacts[TypeFacts["IsNull"] = 33554432] = "IsNull";
47838
+ TypeFacts[TypeFacts["IsUndefinedOrNull"] = 50331648] = "IsUndefinedOrNull";
47839
+ TypeFacts[TypeFacts["All"] = 134217727] = "All";
47831
47840
  // The following members encode facts about particular kinds of types for use in the getTypeFacts function.
47832
47841
  // The presence of a particular fact means that the given test is true for some (and possibly all) values
47833
47842
  // of that kind of type.
@@ -47869,14 +47878,16 @@ var ts;
47869
47878
  TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts";
47870
47879
  TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts";
47871
47880
  TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts";
47872
- TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts";
47873
- TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts";
47874
- TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
47881
+ TypeFacts[TypeFacts["VoidFacts"] = 9830144] = "VoidFacts";
47882
+ TypeFacts[TypeFacts["UndefinedFacts"] = 26607360] = "UndefinedFacts";
47883
+ TypeFacts[TypeFacts["NullFacts"] = 42917664] = "NullFacts";
47884
+ TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 83427327] = "EmptyObjectStrictFacts";
47885
+ TypeFacts[TypeFacts["EmptyObjectFacts"] = 83886079] = "EmptyObjectFacts";
47886
+ TypeFacts[TypeFacts["UnknownFacts"] = 83886079] = "UnknownFacts";
47875
47887
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
47876
- TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
47877
47888
  // Masks
47878
47889
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47879
- TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
47890
+ TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47880
47891
  })(TypeFacts || (TypeFacts = {}));
47881
47892
  var typeofEQFacts = new ts.Map(ts.getEntries({
47882
47893
  string: 1 /* TypeofEQString */,
@@ -48540,6 +48551,7 @@ var ts;
48540
48551
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48541
48552
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48542
48553
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48554
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48543
48555
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48544
48556
  emptyGenericType.instantiations = new ts.Map();
48545
48557
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50039,7 +50051,12 @@ var ts;
50039
50051
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
50040
50052
  if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) {
50041
50053
  if (isPrimitiveTypeName(name)) {
50042
- error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50054
+ if (isExtendedByInterface(errorLocation)) {
50055
+ error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name));
50056
+ }
50057
+ else {
50058
+ error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50059
+ }
50043
50060
  return true;
50044
50061
  }
50045
50062
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
@@ -50059,6 +50076,16 @@ var ts;
50059
50076
  }
50060
50077
  return false;
50061
50078
  }
50079
+ function isExtendedByInterface(node) {
50080
+ var grandparent = node.parent.parent;
50081
+ var parentOfGrandparent = grandparent.parent;
50082
+ if (grandparent && parentOfGrandparent) {
50083
+ var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */;
50084
+ var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent);
50085
+ return isExtending && isInterface;
50086
+ }
50087
+ return false;
50088
+ }
50062
50089
  function maybeMappedType(node, symbol) {
50063
50090
  var container = ts.findAncestor(node.parent, function (n) {
50064
50091
  return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
@@ -50190,7 +50217,8 @@ var ts;
50190
50217
  && isAliasableOrJsExpression(node.parent.right)
50191
50218
  || node.kind === 297 /* ShorthandPropertyAssignment */
50192
50219
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50193
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50220
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50221
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50194
50222
  }
50195
50223
  function isAliasableOrJsExpression(e) {
50196
50224
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50283,7 +50311,7 @@ var ts;
50283
50311
  return hasExportAssignmentSymbol(moduleSymbol);
50284
50312
  }
50285
50313
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50286
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50314
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50287
50315
  }
50288
50316
  function getTargetOfImportClause(node, dontResolveAlias) {
50289
50317
  var _a;
@@ -52898,7 +52926,7 @@ var ts;
52898
52926
  anyType : getNonMissingTypeOfSymbol(propertySymbol);
52899
52927
  var saveEnclosingDeclaration = context.enclosingDeclaration;
52900
52928
  context.enclosingDeclaration = undefined;
52901
- if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) {
52929
+ if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) {
52902
52930
  if (propertySymbol.declarations) {
52903
52931
  var decl = ts.first(propertySymbol.declarations);
52904
52932
  if (hasLateBindableName(decl)) {
@@ -54582,7 +54610,7 @@ var ts;
54582
54610
  ? getBaseConstructorTypeOfClass(staticType)
54583
54611
  : anyType;
54584
54612
  var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true);
54585
- var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
54613
+ var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
54586
54614
  var publicSymbolProps = ts.filter(symbolProps, function (s) {
54587
54615
  // `valueDeclaration` could be undefined if inherited from
54588
54616
  // a union/intersection base type, but inherited properties
@@ -55720,7 +55748,7 @@ var ts;
55720
55748
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
55721
55749
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
55722
55750
  // undefined from the final type.
55723
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
55751
+ return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
55724
55752
  }
55725
55753
  return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
55726
55754
  }
@@ -58709,7 +58737,7 @@ var ts;
58709
58737
  }
58710
58738
  }
58711
58739
  }
58712
- else if (t.flags & 469892092 /* DisjointDomains */) {
58740
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58713
58741
  hasDisjointDomainType = true;
58714
58742
  }
58715
58743
  }
@@ -58721,7 +58749,7 @@ var ts;
58721
58749
  // intersection operation to reduce the union constraints.
58722
58750
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58723
58751
  var t = types_6[_a];
58724
- if (t.flags & 469892092 /* DisjointDomains */) {
58752
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58725
58753
  constraints = ts.append(constraints, t);
58726
58754
  }
58727
58755
  }
@@ -58923,7 +58951,7 @@ var ts;
58923
58951
  var objectType;
58924
58952
  return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58925
58953
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58926
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
58954
+ !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
58927
58955
  }
58928
58956
  /**
58929
58957
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -61270,7 +61298,7 @@ var ts;
61270
61298
  }
61271
61299
  return includes;
61272
61300
  }
61273
- function removeRedundantPrimitiveTypes(types, includes) {
61301
+ function removeRedundantSupertypes(types, includes) {
61274
61302
  var i = types.length;
61275
61303
  while (i > 0) {
61276
61304
  i--;
@@ -61278,7 +61306,9 @@ var ts;
61278
61306
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61279
61307
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61280
61308
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61281
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61309
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61310
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61311
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61282
61312
  if (remove) {
61283
61313
  ts.orderedRemoveItemAt(types, i);
61284
61314
  }
@@ -61400,7 +61430,7 @@ var ts;
61400
61430
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61401
61431
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61402
61432
  // for intersections of types with signatures can be deterministic.
61403
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61433
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61404
61434
  var typeMembershipMap = new ts.Map();
61405
61435
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61406
61436
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61437,11 +61467,11 @@ var ts;
61437
61467
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61438
61468
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61439
61469
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61440
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61441
- removeRedundantPrimitiveTypes(typeSet, includes);
61442
- }
61443
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61444
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61470
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61471
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61472
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61473
+ if (!noSupertypeReduction)
61474
+ removeRedundantSupertypes(typeSet, includes);
61445
61475
  }
61446
61476
  if (includes & 262144 /* IncludesMissingType */) {
61447
61477
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61480,8 +61510,9 @@ var ts;
61480
61510
  }
61481
61511
  var constituents = getCrossProductIntersections(typeSet);
61482
61512
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61483
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61484
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61513
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61514
+ // the denormalized origin has fewer constituents than the union itself.
61515
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61485
61516
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61486
61517
  }
61487
61518
  }
@@ -61524,11 +61555,21 @@ var ts;
61524
61555
  }
61525
61556
  return intersections;
61526
61557
  }
61558
+ function getConstituentCount(type) {
61559
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61560
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61561
+ getConstituentCountOfTypes(type.types);
61562
+ }
61563
+ function getConstituentCountOfTypes(types) {
61564
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61565
+ }
61527
61566
  function getTypeFromIntersectionTypeNode(node) {
61528
61567
  var links = getNodeLinks(node);
61529
61568
  if (!links.resolvedType) {
61530
61569
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61531
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61570
+ var types = ts.map(node.types, getTypeFromTypeNode);
61571
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61572
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61532
61573
  }
61533
61574
  return links.resolvedType;
61534
61575
  }
@@ -64202,7 +64243,7 @@ var ts;
64202
64243
  var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
64203
64244
  var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType));
64204
64245
  var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
64205
- (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */);
64246
+ (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
64206
64247
  var related = callbacks ?
64207
64248
  compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
64208
64249
  !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
@@ -64314,6 +64355,17 @@ var ts;
64314
64355
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64315
64356
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64316
64357
  }
64358
+ function isUnknownLikeUnionType(type) {
64359
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64360
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64361
+ var types = type.types;
64362
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64363
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64364
+ }
64365
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64366
+ }
64367
+ return false;
64368
+ }
64317
64369
  function isStringIndexSignatureOnlyType(type) {
64318
64370
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64319
64371
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64393,7 +64445,7 @@ var ts;
64393
64445
  return true;
64394
64446
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64395
64447
  return true;
64396
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64448
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64397
64449
  return true;
64398
64450
  if (relation === assignableRelation || relation === comparableRelation) {
64399
64451
  if (s & 1 /* Any */)
@@ -64403,6 +64455,9 @@ var ts;
64403
64455
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64404
64456
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64405
64457
  return true;
64458
+ // Anything is assignable to a union containing undefined, null, and {}
64459
+ if (isUnknownLikeUnionType(target))
64460
+ return true;
64406
64461
  }
64407
64462
  return false;
64408
64463
  }
@@ -64445,16 +64500,27 @@ var ts;
64445
64500
  function getNormalizedType(type, writing) {
64446
64501
  while (true) {
64447
64502
  var t = isFreshLiteralType(type) ? type.regularType :
64448
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64449
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64503
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64504
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64450
64505
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64451
64506
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64452
64507
  type;
64453
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64454
64508
  if (t === type)
64455
- break;
64509
+ return t;
64456
64510
  type = t;
64457
64511
  }
64512
+ }
64513
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64514
+ var reduced = getReducedType(type);
64515
+ if (reduced !== type) {
64516
+ return reduced;
64517
+ }
64518
+ if (type.flags & 2097152 /* Intersection */) {
64519
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64520
+ if (normalizedTypes !== type.types) {
64521
+ return getIntersectionType(normalizedTypes);
64522
+ }
64523
+ }
64458
64524
  return type;
64459
64525
  }
64460
64526
  /**
@@ -64901,6 +64967,7 @@ var ts;
64901
64967
  return 0 /* False */;
64902
64968
  }
64903
64969
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64970
+ var _a, _b;
64904
64971
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
64905
64972
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
64906
64973
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -64941,6 +65008,9 @@ var ts;
64941
65008
  return;
64942
65009
  }
64943
65010
  reportRelationError(headMessage, source, target);
65011
+ 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 */))) {
65012
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65013
+ }
64944
65014
  }
64945
65015
  function traceUnionsOrIntersectionsTooLarge(source, target) {
64946
65016
  if (!ts.tracing) {
@@ -65727,13 +65797,6 @@ var ts;
65727
65797
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65728
65798
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65729
65799
  var constraint = getConstraintOfType(source) || unknownType;
65730
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65731
- // A type variable with no constraint is not related to the non-primitive object type.
65732
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65733
- resetErrorInfo(saveErrorInfo);
65734
- return result;
65735
- }
65736
- }
65737
65800
  // 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
65738
65801
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65739
65802
  resetErrorInfo(saveErrorInfo);
@@ -67207,9 +67270,11 @@ var ts;
67207
67270
  return getSupertypeOrUnion(types);
67208
67271
  }
67209
67272
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67210
- return primaryTypes.length ?
67211
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67212
- getUnionType(types, 2 /* Subtype */);
67273
+ if (primaryTypes.length) {
67274
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67275
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67276
+ }
67277
+ return getUnionType(types, 2 /* Subtype */);
67213
67278
  }
67214
67279
  // Return the leftmost type for which no type to the right is a subtype.
67215
67280
  function getCommonSubtype(types) {
@@ -67396,29 +67461,8 @@ var ts;
67396
67461
  var value = _a.value;
67397
67462
  return value.base10Value === "0";
67398
67463
  }
67399
- function getFalsyFlagsOfTypes(types) {
67400
- var result = 0;
67401
- for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
67402
- var t = types_14[_i];
67403
- result |= getFalsyFlags(t);
67404
- }
67405
- return result;
67406
- }
67407
- // Returns the String, Number, Boolean, StringLiteral, NumberLiteral, BooleanLiteral, Void, Undefined, or Null
67408
- // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67409
- // no flags for all other types (including non-falsy literal types).
67410
- function getFalsyFlags(type) {
67411
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67412
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67413
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67414
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67415
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67416
- type.flags & 117724 /* PossiblyFalsy */;
67417
- }
67418
67464
  function removeDefinitelyFalsyTypes(type) {
67419
- return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
67420
- filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) :
67421
- type;
67465
+ return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); });
67422
67466
  }
67423
67467
  function extractDefinitelyFalsyTypes(type) {
67424
67468
  return mapType(type, getDefinitelyFalsyPartOfType);
@@ -67453,20 +67497,15 @@ var ts;
67453
67497
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67454
67498
  }
67455
67499
  function getGlobalNonNullableTypeInstantiation(type) {
67456
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67457
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67458
- // that isn't eliminated by a NonNullable<T> instantiation.
67459
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67460
67500
  if (!deferredGlobalNonNullableTypeAlias) {
67461
67501
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67462
67502
  }
67463
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67464
67503
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67465
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67466
- reducedType;
67504
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67505
+ getIntersectionType([type, emptyObjectType]);
67467
67506
  }
67468
67507
  function getNonNullableType(type) {
67469
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67508
+ return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
67470
67509
  }
67471
67510
  function addOptionalTypeMarker(type) {
67472
67511
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68147,13 +68186,40 @@ var ts;
68147
68186
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68148
68187
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68149
68188
  }
68150
- function isValidBigIntString(s) {
68189
+ /**
68190
+ * Tests whether the provided string can be parsed as a number.
68191
+ * @param s The string to test.
68192
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68193
+ */
68194
+ function isValidNumberString(s, roundTripOnly) {
68195
+ if (s === "")
68196
+ return false;
68197
+ var n = +s;
68198
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68199
+ }
68200
+ /**
68201
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68202
+ */
68203
+ function parseBigIntLiteralType(text) {
68204
+ var negative = text.startsWith("-");
68205
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68206
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68207
+ }
68208
+ /**
68209
+ * Tests whether the provided string can be parsed as a bigint.
68210
+ * @param s The string to test.
68211
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68212
+ */
68213
+ function isValidBigIntString(s, roundTripOnly) {
68214
+ if (s === "")
68215
+ return false;
68151
68216
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68152
68217
  var success = true;
68153
68218
  scanner.setOnError(function () { return success = false; });
68154
68219
  scanner.setText(s + "n");
68155
68220
  var result = scanner.scan();
68156
- if (result === 40 /* MinusToken */) {
68221
+ var negative = result === 40 /* MinusToken */;
68222
+ if (negative) {
68157
68223
  result = scanner.scan();
68158
68224
  }
68159
68225
  var flags = scanner.getTokenFlags();
@@ -68162,7 +68228,8 @@ var ts;
68162
68228
  // * a bigint can be scanned, and that when it is scanned, it is
68163
68229
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68164
68230
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68165
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68231
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68232
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68166
68233
  }
68167
68234
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68168
68235
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68170,8 +68237,8 @@ var ts;
68170
68237
  }
68171
68238
  if (source.flags & 128 /* StringLiteral */) {
68172
68239
  var value = source.value;
68173
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68174
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68240
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68241
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68175
68242
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68176
68243
  }
68177
68244
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68582,8 +68649,8 @@ var ts;
68582
68649
  }
68583
68650
  function getSingleTypeVariableFromIntersectionTypes(types) {
68584
68651
  var typeVariable;
68585
- for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
68586
- var type = types_15[_i];
68652
+ for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
68653
+ var type = types_14[_i];
68587
68654
  var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
68588
68655
  if (!t || typeVariable && t !== typeVariable) {
68589
68656
  return undefined;
@@ -68744,8 +68811,57 @@ var ts;
68744
68811
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68745
68812
  // succeed. That would be a pointless and confusing outcome.
68746
68813
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68814
+ var _loop_23 = function (i) {
68815
+ var source_1 = matches ? matches[i] : neverType;
68816
+ var target_3 = types[i];
68817
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68818
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68819
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68820
+ var inferenceContext = getInferenceInfoForType(target_3);
68821
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68822
+ if (constraint && !isTypeAny(constraint)) {
68823
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68824
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68825
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68826
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68827
+ var str_1 = source_1.value;
68828
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68829
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68830
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68831
+ }
68832
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68833
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68834
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68835
+ }
68836
+ // for each type in the constraint, find the highest priority matching type
68837
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68838
+ return !(right.flags & allTypeFlags_1) ? left :
68839
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68840
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68841
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68842
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68843
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68844
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68845
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68846
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68847
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68848
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68849
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68850
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68851
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68852
+ left;
68853
+ }, neverType);
68854
+ if (!(matchingType.flags & 131072 /* Never */)) {
68855
+ inferFromTypes(matchingType, target_3);
68856
+ return "continue";
68857
+ }
68858
+ }
68859
+ }
68860
+ }
68861
+ inferFromTypes(source_1, target_3);
68862
+ };
68747
68863
  for (var i = 0; i < types.length; i++) {
68748
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68864
+ _loop_23(i);
68749
68865
  }
68750
68866
  }
68751
68867
  }
@@ -69263,7 +69379,7 @@ var ts;
69263
69379
  function mapTypesByKeyProperty(types, name) {
69264
69380
  var map = new ts.Map();
69265
69381
  var count = 0;
69266
- var _loop_23 = function (type) {
69382
+ var _loop_24 = function (type) {
69267
69383
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69268
69384
  var discriminant = getTypeOfPropertyOfType(type, name);
69269
69385
  if (discriminant) {
@@ -69287,9 +69403,9 @@ var ts;
69287
69403
  }
69288
69404
  }
69289
69405
  };
69290
- for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69291
- var type = types_16[_i];
69292
- var state_9 = _loop_23(type);
69406
+ for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
69407
+ var type = types_15[_i];
69408
+ var state_9 = _loop_24(type);
69293
69409
  if (typeof state_9 === "object")
69294
69410
  return state_9.value;
69295
69411
  }
@@ -69403,14 +69519,16 @@ var ts;
69403
69519
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
69404
69520
  resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
69405
69521
  }
69406
- function getTypeFacts(type, ignoreObjects) {
69407
- if (ignoreObjects === void 0) { ignoreObjects = false; }
69522
+ function getTypeFacts(type) {
69523
+ if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
69524
+ type = getBaseConstraintOfType(type) || unknownType;
69525
+ }
69408
69526
  var flags = type.flags;
69409
- if (flags & 4 /* String */) {
69527
+ if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
69410
69528
  return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
69411
69529
  }
69412
- if (flags & 128 /* StringLiteral */) {
69413
- var isEmpty = type.value === "";
69530
+ if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
69531
+ var isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
69414
69532
  return strictNullChecks ?
69415
69533
  isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ :
69416
69534
  isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
@@ -69442,20 +69560,20 @@ var ts;
69442
69560
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
69443
69561
  }
69444
69562
  if (flags & 524288 /* Object */) {
69445
- if (ignoreObjects) {
69446
- return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
69447
- }
69448
69563
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
69449
- strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
69564
+ strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ :
69450
69565
  isFunctionObjectType(type) ?
69451
69566
  strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ :
69452
69567
  strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
69453
69568
  }
69454
- if (flags & (16384 /* Void */ | 32768 /* Undefined */)) {
69455
- return 9830144 /* UndefinedFacts */;
69569
+ if (flags & 16384 /* Void */) {
69570
+ return 9830144 /* VoidFacts */;
69571
+ }
69572
+ if (flags & 32768 /* Undefined */) {
69573
+ return 26607360 /* UndefinedFacts */;
69456
69574
  }
69457
69575
  if (flags & 65536 /* Null */) {
69458
- return 9363232 /* NullFacts */;
69576
+ return 42917664 /* NullFacts */;
69459
69577
  }
69460
69578
  if (flags & 12288 /* ESSymbolLike */) {
69461
69579
  return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
@@ -69466,37 +69584,56 @@ var ts;
69466
69584
  if (flags & 131072 /* Never */) {
69467
69585
  return 0 /* None */;
69468
69586
  }
69469
- if (flags & 465829888 /* Instantiable */) {
69470
- return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
69471
- strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */;
69472
- }
69473
69587
  if (flags & 1048576 /* Union */) {
69474
- return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */);
69588
+ return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */);
69475
69589
  }
69476
69590
  if (flags & 2097152 /* Intersection */) {
69477
- // When an intersection contains a primitive type we ignore object type constituents as they are
69478
- // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69479
- ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
69480
- return getIntersectionTypeFacts(type, ignoreObjects);
69591
+ return getIntersectionTypeFacts(type);
69481
69592
  }
69482
- return 16777215 /* All */;
69593
+ return 83886079 /* UnknownFacts */;
69483
69594
  }
69484
- function getIntersectionTypeFacts(type, ignoreObjects) {
69595
+ function getIntersectionTypeFacts(type) {
69596
+ // When an intersection contains a primitive type we ignore object type constituents as they are
69597
+ // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69598
+ var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */);
69485
69599
  // When computing the type facts of an intersection type, certain type facts are computed as `and`
69486
69600
  // and others are computed as `or`.
69487
69601
  var oredFacts = 0 /* None */;
69488
- var andedFacts = 16777215 /* All */;
69602
+ var andedFacts = 134217727 /* All */;
69489
69603
  for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
69490
69604
  var t = _a[_i];
69491
- var f = getTypeFacts(t, ignoreObjects);
69492
- oredFacts |= f;
69493
- andedFacts &= f;
69605
+ if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
69606
+ var f = getTypeFacts(t);
69607
+ oredFacts |= f;
69608
+ andedFacts &= f;
69609
+ }
69494
69610
  }
69495
- return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
69611
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
69496
69612
  }
69497
69613
  function getTypeWithFacts(type, include) {
69498
69614
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69499
69615
  }
69616
+ // This function is similar to getTypeWithFacts, except that in strictNullChecks mode it replaces type
69617
+ // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining
69618
+ // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined.
69619
+ function getAdjustedTypeWithFacts(type, facts) {
69620
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69621
+ if (strictNullChecks) {
69622
+ switch (facts) {
69623
+ case 524288 /* NEUndefined */:
69624
+ 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; });
69625
+ case 1048576 /* NENull */:
69626
+ 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; });
69627
+ case 2097152 /* NEUndefinedOrNull */:
69628
+ case 4194304 /* Truthy */:
69629
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69630
+ }
69631
+ }
69632
+ return reduced;
69633
+ }
69634
+ function recombineUnknownType(type) {
69635
+ return type === unknownUnionType ? unknownType : type;
69636
+ }
69500
69637
  function getTypeWithDefault(type, defaultExpression) {
69501
69638
  return defaultExpression ?
69502
69639
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -69745,8 +69882,8 @@ var ts;
69745
69882
  var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
69746
69883
  var mappedTypes;
69747
69884
  var changed = false;
69748
- for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69749
- var t = types_17[_i];
69885
+ for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69886
+ var t = types_16[_i];
69750
69887
  var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t);
69751
69888
  changed || (changed = t !== mapped);
69752
69889
  if (mapped) {
@@ -69832,8 +69969,8 @@ var ts;
69832
69969
  }
69833
69970
  function isEvolvingArrayTypeList(types) {
69834
69971
  var hasEvolvingArrayType = false;
69835
- for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
69836
- var t = types_18[_i];
69972
+ for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69973
+ var t = types_17[_i];
69837
69974
  if (!(t.flags & 131072 /* Never */)) {
69838
69975
  if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) {
69839
69976
  return false;
@@ -70554,7 +70691,7 @@ var ts;
70554
70691
  if (isEvolvingArrayTypeList(types)) {
70555
70692
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70556
70693
  }
70557
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70694
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70558
70695
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70559
70696
  return declaredType;
70560
70697
  }
@@ -70656,11 +70793,10 @@ var ts;
70656
70793
  }
70657
70794
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70658
70795
  if (isMatchingReference(reference, expr)) {
70659
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70660
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70796
+ return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70661
70797
  }
70662
70798
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70663
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70799
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70664
70800
  }
70665
70801
  var access = getDiscriminantPropertyAccess(expr, type);
70666
70802
  if (access) {
@@ -70800,7 +70936,7 @@ var ts;
70800
70936
  // Note that we include any and unknown in the exclusion test because their domain includes null and undefined.
70801
70937
  var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
70802
70938
  equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); });
70803
- return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
70939
+ return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
70804
70940
  }
70805
70941
  function narrowTypeByEquality(type, operator, value, assumeTrue) {
70806
70942
  if (type.flags & 1 /* Any */) {
@@ -70810,9 +70946,6 @@ var ts;
70810
70946
  assumeTrue = !assumeTrue;
70811
70947
  }
70812
70948
  var valueType = getTypeOfExpression(value);
70813
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
70814
- return getUnionType([nullType, undefinedType]);
70815
- }
70816
70949
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
70817
70950
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
70818
70951
  return valueType;
@@ -70832,7 +70965,7 @@ var ts;
70832
70965
  valueType.flags & 65536 /* Null */ ?
70833
70966
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
70834
70967
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
70835
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
70968
+ return getAdjustedTypeWithFacts(type, facts);
70836
70969
  }
70837
70970
  if (assumeTrue) {
70838
70971
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -70853,24 +70986,18 @@ var ts;
70853
70986
  var target = getReferenceCandidate(typeOfExpr.expression);
70854
70987
  if (!isMatchingReference(reference, target)) {
70855
70988
  if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
70856
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70989
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70857
70990
  }
70858
70991
  return type;
70859
70992
  }
70860
70993
  if (type.flags & 1 /* Any */ && literal.text === "function") {
70861
70994
  return type;
70862
70995
  }
70863
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
70864
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
70865
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
70866
- // unknown type, and then narrows that to the non-primitive type.
70867
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
70868
- }
70869
70996
  var facts = assumeTrue ?
70870
70997
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
70871
70998
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
70872
70999
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
70873
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71000
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
70874
71001
  }
70875
71002
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
70876
71003
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -70919,10 +71046,10 @@ var ts;
70919
71046
  }
70920
71047
  function getImpliedTypeFromTypeofGuard(type, text) {
70921
71048
  switch (text) {
71049
+ case "object":
71050
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
70922
71051
  case "function":
70923
71052
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
70924
- case "object":
70925
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
70926
71053
  default:
70927
71054
  return typeofTypesByName.get(text);
70928
71055
  }
@@ -70933,22 +71060,27 @@ var ts;
70933
71060
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
70934
71061
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
70935
71062
  // filtering by type-facts.
70936
- function narrowUnionMemberByTypeof(candidate) {
70937
- return function (type) {
70938
- if (isTypeSubtypeOf(type, candidate)) {
70939
- return type;
70940
- }
70941
- if (isTypeSubtypeOf(candidate, type)) {
70942
- return candidate;
71063
+ function narrowTypeByImpliedType(type, candidate) {
71064
+ if (type.flags & 3 /* AnyOrUnknown */) {
71065
+ return candidate;
71066
+ }
71067
+ return mapType(type, function (t) {
71068
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71069
+ return t;
70943
71070
  }
70944
- if (type.flags & 465829888 /* Instantiable */) {
70945
- var constraint = getBaseConstraintOfType(type) || anyType;
70946
- if (isTypeSubtypeOf(candidate, constraint)) {
70947
- return getIntersectionType([type, candidate]);
71071
+ return mapType(candidate, function (c) {
71072
+ if (!areTypesComparable(t, c)) {
71073
+ return neverType;
70948
71074
  }
70949
- }
70950
- return type;
70951
- };
71075
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71076
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71077
+ }
71078
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71079
+ return c;
71080
+ }
71081
+ return getIntersectionType([t, c]);
71082
+ });
71083
+ });
70952
71084
  }
70953
71085
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
70954
71086
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71007,7 +71139,7 @@ var ts;
71007
71139
  because it is caught in the first clause.
71008
71140
  */
71009
71141
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71010
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71142
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71011
71143
  }
71012
71144
  function isMatchingConstructorReference(expr) {
71013
71145
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71058,7 +71190,7 @@ var ts;
71058
71190
  var left = getReferenceCandidate(expr.left);
71059
71191
  if (!isMatchingReference(reference, left)) {
71060
71192
  if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
71061
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71193
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71062
71194
  }
71063
71195
  return type;
71064
71196
  }
@@ -71146,7 +71278,7 @@ var ts;
71146
71278
  }
71147
71279
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
71148
71280
  !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
71149
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71281
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71150
71282
  }
71151
71283
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
71152
71284
  if (access) {
@@ -71203,7 +71335,7 @@ var ts;
71203
71335
  }
71204
71336
  function narrowTypeByOptionality(type, expr, assumePresent) {
71205
71337
  if (isMatchingReference(reference, expr)) {
71206
- return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71338
+ return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71207
71339
  }
71208
71340
  var access = getDiscriminantPropertyAccess(expr, type);
71209
71341
  if (access) {
@@ -71289,8 +71421,8 @@ var ts;
71289
71421
  var annotationIncludesUndefined = strictNullChecks &&
71290
71422
  declaration.kind === 164 /* Parameter */ &&
71291
71423
  declaration.initializer &&
71292
- getFalsyFlags(declaredType) & 32768 /* Undefined */ &&
71293
- !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */);
71424
+ getTypeFacts(declaredType) & 16777216 /* IsUndefined */ &&
71425
+ !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */);
71294
71426
  popTypeResolution();
71295
71427
  return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
71296
71428
  }
@@ -71311,7 +71443,9 @@ var ts;
71311
71443
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71312
71444
  }
71313
71445
  function isGenericTypeWithUnionConstraint(type) {
71314
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71446
+ return type.flags & 2097152 /* Intersection */ ?
71447
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71448
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71315
71449
  }
71316
71450
  function isGenericTypeWithoutNullableConstraint(type) {
71317
71451
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71339,7 +71473,7 @@ var ts;
71339
71473
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71340
71474
  someType(type, isGenericTypeWithUnionConstraint) &&
71341
71475
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71342
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71476
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71343
71477
  }
71344
71478
  function isExportOrExportExpression(location) {
71345
71479
  return !!ts.findAncestor(location, function (n) {
@@ -71616,7 +71750,7 @@ var ts;
71616
71750
  return convertAutoToAny(flowType);
71617
71751
  }
71618
71752
  }
71619
- else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
71753
+ else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
71620
71754
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
71621
71755
  // Return the declared type to reduce follow-on errors
71622
71756
  return type;
@@ -73145,8 +73279,8 @@ var ts;
73145
73279
  }
73146
73280
  var signatureList;
73147
73281
  var types = type.types;
73148
- for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
73149
- var current = types_19[_i];
73282
+ for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
73283
+ var current = types_18[_i];
73150
73284
  var signature = getContextualCallSignature(current, node);
73151
73285
  if (signature) {
73152
73286
  if (!signatureList) {
@@ -74308,19 +74442,19 @@ var ts;
74308
74442
  return checkNonNullType(checkExpression(node), node);
74309
74443
  }
74310
74444
  function isNullableType(type) {
74311
- return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */);
74445
+ return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
74312
74446
  }
74313
74447
  function getNonNullableTypeIfNeeded(type) {
74314
74448
  return isNullableType(type) ? getNonNullableType(type) : type;
74315
74449
  }
74316
- function reportObjectPossiblyNullOrUndefinedError(node, flags) {
74317
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74450
+ function reportObjectPossiblyNullOrUndefinedError(node, facts) {
74451
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74318
74452
  ts.Diagnostics.Object_is_possibly_null_or_undefined :
74319
74453
  ts.Diagnostics.Object_is_possibly_undefined :
74320
74454
  ts.Diagnostics.Object_is_possibly_null);
74321
74455
  }
74322
- function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
74323
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74456
+ function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) {
74457
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74324
74458
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
74325
74459
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
74326
74460
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
@@ -74330,9 +74464,9 @@ var ts;
74330
74464
  error(node, ts.Diagnostics.Object_is_of_type_unknown);
74331
74465
  return errorType;
74332
74466
  }
74333
- var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */;
74334
- if (kind) {
74335
- reportError(node, kind);
74467
+ var facts = getTypeFacts(type);
74468
+ if (facts & 50331648 /* IsUndefinedOrNull */) {
74469
+ reportError(node, facts);
74336
74470
  var t = getNonNullableType(type);
74337
74471
  return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
74338
74472
  }
@@ -74627,7 +74761,7 @@ var ts;
74627
74761
  assumeUninitialized = true;
74628
74762
  }
74629
74763
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
74630
- if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
74764
+ if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
74631
74765
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
74632
74766
  // Return the declared type to reduce follow-on errors
74633
74767
  return propType;
@@ -75677,7 +75811,7 @@ var ts;
75677
75811
  if (spreadIndex >= 0) {
75678
75812
  // Create synthetic arguments from spreads of tuple types.
75679
75813
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75680
- var _loop_24 = function (i) {
75814
+ var _loop_25 = function (i) {
75681
75815
  var arg = args[i];
75682
75816
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75683
75817
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75694,7 +75828,7 @@ var ts;
75694
75828
  }
75695
75829
  };
75696
75830
  for (var i = spreadIndex; i < args.length; i++) {
75697
- _loop_24(i);
75831
+ _loop_25(i);
75698
75832
  }
75699
75833
  return effectiveArgs_1;
75700
75834
  }
@@ -76014,7 +76148,7 @@ var ts;
76014
76148
  var min_3 = Number.MAX_VALUE;
76015
76149
  var minIndex = 0;
76016
76150
  var i_1 = 0;
76017
- var _loop_25 = function (c) {
76151
+ var _loop_26 = function (c) {
76018
76152
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76019
76153
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76020
76154
  if (diags_2) {
@@ -76032,7 +76166,7 @@ var ts;
76032
76166
  };
76033
76167
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76034
76168
  var c = candidatesForArgumentError_1[_a];
76035
- _loop_25(c);
76169
+ _loop_26(c);
76036
76170
  }
76037
76171
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76038
76172
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76190,7 +76324,7 @@ var ts;
76190
76324
  }
76191
76325
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76192
76326
  var parameters = [];
76193
- var _loop_26 = function (i) {
76327
+ var _loop_27 = function (i) {
76194
76328
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76195
76329
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76196
76330
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76198,7 +76332,7 @@ var ts;
76198
76332
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76199
76333
  };
76200
76334
  for (var i = 0; i < maxNonRestParam; i++) {
76201
- _loop_26(i);
76335
+ _loop_27(i);
76202
76336
  }
76203
76337
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76204
76338
  var flags = 0 /* None */;
@@ -76543,8 +76677,8 @@ var ts;
76543
76677
  if (apparentType.flags & 1048576 /* Union */) {
76544
76678
  var types = apparentType.types;
76545
76679
  var hasSignatures = false;
76546
- for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
76547
- var constituent = types_20[_i];
76680
+ for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
76681
+ var constituent = types_19[_i];
76548
76682
  var signatures = getSignaturesOfType(constituent, kind);
76549
76683
  if (signatures.length !== 0) {
76550
76684
  hasSignatures = true;
@@ -78235,7 +78369,7 @@ var ts;
78235
78369
  var type = getTypeOfSymbol(symbol);
78236
78370
  if (strictNullChecks &&
78237
78371
  !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) &&
78238
- !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) {
78372
+ !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
78239
78373
  error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
78240
78374
  }
78241
78375
  }
@@ -78403,8 +78537,8 @@ var ts;
78403
78537
  }
78404
78538
  if (type.flags & 3145728 /* UnionOrIntersection */) {
78405
78539
  var types = type.types;
78406
- for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
78407
- var t = types_21[_i];
78540
+ for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
78541
+ var t = types_20[_i];
78408
78542
  if (maybeTypeOfKind(t, kind)) {
78409
78543
  return true;
78410
78544
  }
@@ -78631,7 +78765,7 @@ var ts;
78631
78765
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
78632
78766
  // undefined from the final type.
78633
78767
  if (strictNullChecks &&
78634
- !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) {
78768
+ !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
78635
78769
  sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
78636
78770
  }
78637
78771
  checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
@@ -79031,7 +79165,7 @@ var ts;
79031
79165
  case 56 /* BarBarToken */:
79032
79166
  case 75 /* BarBarEqualsToken */: {
79033
79167
  var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ?
79034
- getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) :
79168
+ getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) :
79035
79169
  leftType;
79036
79170
  if (operator === 75 /* BarBarEqualsToken */) {
79037
79171
  checkAssignmentOperator(rightType);
@@ -80255,7 +80389,7 @@ var ts;
80255
80389
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80256
80390
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80257
80391
  var indexSignatureMap_1 = new ts.Map();
80258
- var _loop_27 = function (declaration) {
80392
+ var _loop_28 = function (declaration) {
80259
80393
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80260
80394
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80261
80395
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80270,7 +80404,7 @@ var ts;
80270
80404
  };
80271
80405
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80272
80406
  var declaration = _a[_i];
80273
- _loop_27(declaration);
80407
+ _loop_28(declaration);
80274
80408
  }
80275
80409
  indexSignatureMap_1.forEach(function (entry) {
80276
80410
  if (entry.declarations.length > 1) {
@@ -81572,8 +81706,8 @@ var ts;
81572
81706
  }
81573
81707
  function getEntityNameForDecoratorMetadataFromTypeList(types) {
81574
81708
  var commonEntityName;
81575
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
81576
- var typeNode = types_22[_i];
81709
+ for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
81710
+ var typeNode = types_21[_i];
81577
81711
  while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) {
81578
81712
  typeNode = typeNode.type; // Skip parens if need be
81579
81713
  }
@@ -82439,7 +82573,7 @@ var ts;
82439
82573
  // For a binding pattern, validate the initializer and exit
82440
82574
  if (ts.isBindingPattern(node.name)) {
82441
82575
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82442
- var needCheckWidenedType = node.name.elements.length === 0;
82576
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82443
82577
  if (needCheckInitializer || needCheckWidenedType) {
82444
82578
  // Don't validate for-in initializer as it is already an error
82445
82579
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -82466,7 +82600,7 @@ var ts;
82466
82600
  }
82467
82601
  // For a commonjs `const x = require`, validate the alias and exit
82468
82602
  var symbol = getSymbolOfNode(node);
82469
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82603
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82470
82604
  checkAliasSymbol(node);
82471
82605
  return;
82472
82606
  }
@@ -82592,7 +82726,7 @@ var ts;
82592
82726
  return;
82593
82727
  var type = checkTruthinessExpression(location);
82594
82728
  var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
82595
- if (getFalsyFlags(type) || isPropertyExpressionCast)
82729
+ if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
82596
82730
  return;
82597
82731
  // While it technically should be invalid for any known-truthy value
82598
82732
  // to be tested, we de-scope to functions and Promises unreferenced in
@@ -83731,7 +83865,7 @@ var ts;
83731
83865
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83732
83866
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83733
83867
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83734
- var _loop_28 = function (info) {
83868
+ var _loop_29 = function (info) {
83735
83869
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83736
83870
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83737
83871
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83744,7 +83878,7 @@ var ts;
83744
83878
  };
83745
83879
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83746
83880
  var info = indexInfos_9[_i];
83747
- _loop_28(info);
83881
+ _loop_29(info);
83748
83882
  }
83749
83883
  }
83750
83884
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83752,7 +83886,7 @@ var ts;
83752
83886
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83753
83887
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83754
83888
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83755
- var _loop_29 = function (info) {
83889
+ var _loop_30 = function (info) {
83756
83890
  if (info === checkInfo)
83757
83891
  return "continue";
83758
83892
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83767,7 +83901,7 @@ var ts;
83767
83901
  };
83768
83902
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83769
83903
  var info = indexInfos_10[_i];
83770
- _loop_29(info);
83904
+ _loop_30(info);
83771
83905
  }
83772
83906
  }
83773
83907
  function checkTypeNameIsReserved(name, message) {
@@ -84086,7 +84220,7 @@ var ts;
84086
84220
  var baseTypes = baseTypeNode && getBaseTypes(type);
84087
84221
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84088
84222
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84089
- var _loop_30 = function (member) {
84223
+ var _loop_31 = function (member) {
84090
84224
  if (ts.hasAmbientModifier(member)) {
84091
84225
  return "continue";
84092
84226
  }
@@ -84103,7 +84237,7 @@ var ts;
84103
84237
  };
84104
84238
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84105
84239
  var member = _a[_i];
84106
- _loop_30(member);
84240
+ _loop_31(member);
84107
84241
  }
84108
84242
  }
84109
84243
  /**
@@ -84191,7 +84325,7 @@ var ts;
84191
84325
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84192
84326
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84193
84327
  var issuedMemberError = false;
84194
- var _loop_31 = function (member) {
84328
+ var _loop_32 = function (member) {
84195
84329
  if (ts.isStatic(member)) {
84196
84330
  return "continue";
84197
84331
  }
@@ -84210,7 +84344,7 @@ var ts;
84210
84344
  };
84211
84345
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84212
84346
  var member = _a[_i];
84213
- _loop_31(member);
84347
+ _loop_32(member);
84214
84348
  }
84215
84349
  if (!issuedMemberError) {
84216
84350
  // check again with diagnostics to generate a less-specific error
@@ -84278,18 +84412,17 @@ var ts;
84278
84412
  // but not by other kinds of members.
84279
84413
  // Base class instance member variables and accessors can be overridden by
84280
84414
  // derived class instance member variables and accessors, but not by other kinds of members.
84281
- var _a, _b;
84415
+ var _a, _b, _c, _d;
84282
84416
  // NOTE: assignability is checked in checkClassDeclaration
84283
84417
  var baseProperties = getPropertiesOfType(baseType);
84284
- basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84285
- var baseProperty = baseProperties_1[_i];
84418
+ var _loop_33 = function (baseProperty) {
84286
84419
  var base = getTargetSymbol(baseProperty);
84287
84420
  if (base.flags & 4194304 /* Prototype */) {
84288
- continue;
84421
+ return "continue";
84289
84422
  }
84290
84423
  var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
84291
84424
  if (!baseSymbol) {
84292
- continue;
84425
+ return "continue";
84293
84426
  }
84294
84427
  var derived = getTargetSymbol(baseSymbol);
84295
84428
  var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
@@ -84307,14 +84440,14 @@ var ts;
84307
84440
  // Searches other base types for a declaration that would satisfy the inherited abstract member.
84308
84441
  // (The class may have more than one base type via declaration merging with an interface with the
84309
84442
  // same name.)
84310
- for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) {
84311
- var otherBaseType = _d[_c];
84443
+ for (var _e = 0, _f = getBaseTypes(type); _e < _f.length; _e++) {
84444
+ var otherBaseType = _f[_e];
84312
84445
  if (otherBaseType === baseType)
84313
84446
  continue;
84314
84447
  var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
84315
84448
  var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
84316
84449
  if (derivedElsewhere && derivedElsewhere !== base) {
84317
- continue basePropertyCheck;
84450
+ return "continue-basePropertyCheck";
84318
84451
  }
84319
84452
  }
84320
84453
  if (derivedClassDecl.kind === 226 /* ClassExpression */) {
@@ -84329,20 +84462,19 @@ var ts;
84329
84462
  // derived overrides base.
84330
84463
  var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
84331
84464
  if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) {
84332
- // either base or derived property is private - not override, skip it
84333
- continue;
84465
+ return "continue";
84334
84466
  }
84335
84467
  var errorMessage = void 0;
84336
84468
  var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */;
84337
84469
  var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */;
84338
84470
  if (basePropertyFlags && derivedPropertyFlags) {
84339
84471
  // property/accessor is overridden with property/accessor
84340
- if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
84341
- || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */
84472
+ if ((ts.getCheckFlags(base) & 6 /* Synthetic */
84473
+ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })
84474
+ : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }))
84475
+ || ts.getCheckFlags(base) & 262144 /* Mapped */
84342
84476
  || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
84343
- // when the base property is abstract or from an interface, base/derived flags don't need to match
84344
- // same when the derived property is from an assignment
84345
- continue;
84477
+ return "continue";
84346
84478
  }
84347
84479
  var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */;
84348
84480
  var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */;
@@ -84353,12 +84485,12 @@ var ts;
84353
84485
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
84354
84486
  }
84355
84487
  else if (useDefineForClassFields) {
84356
- var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84488
+ var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84357
84489
  if (uninitialized
84358
84490
  && !(derived.flags & 33554432 /* Transient */)
84359
84491
  && !(baseDeclarationFlags & 128 /* Abstract */)
84360
84492
  && !(derivedDeclarationFlags & 128 /* Abstract */)
84361
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84493
+ && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84362
84494
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
84363
84495
  var propName = uninitialized.name;
84364
84496
  if (uninitialized.exclamationToken
@@ -84371,13 +84503,11 @@ var ts;
84371
84503
  }
84372
84504
  }
84373
84505
  }
84374
- // correct case
84375
- continue;
84506
+ return "continue";
84376
84507
  }
84377
84508
  else if (isPrototypeProperty(base)) {
84378
84509
  if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) {
84379
- // method is overridden with method or property -- correct case
84380
- continue;
84510
+ return "continue";
84381
84511
  }
84382
84512
  else {
84383
84513
  ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */));
@@ -84392,9 +84522,20 @@ var ts;
84392
84522
  }
84393
84523
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
84394
84524
  }
84525
+ };
84526
+ basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84527
+ var baseProperty = baseProperties_1[_i];
84528
+ var state_10 = _loop_33(baseProperty);
84529
+ switch (state_10) {
84530
+ case "continue-basePropertyCheck": continue basePropertyCheck;
84531
+ }
84395
84532
  }
84396
84533
  }
84397
- function getNonInterhitedProperties(type, baseTypes, properties) {
84534
+ function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) {
84535
+ return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer)
84536
+ || ts.isInterfaceDeclaration(declaration.parent);
84537
+ }
84538
+ function getNonInheritedProperties(type, baseTypes, properties) {
84398
84539
  if (!ts.length(baseTypes)) {
84399
84540
  return properties;
84400
84541
  }
@@ -84463,7 +84604,7 @@ var ts;
84463
84604
  var propName = member.name;
84464
84605
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84465
84606
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84466
- if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
84607
+ if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84467
84608
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84468
84609
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84469
84610
  }
@@ -84488,7 +84629,7 @@ var ts;
84488
84629
  ts.setParent(reference, staticBlock);
84489
84630
  reference.flowNode = staticBlock.returnFlowNode;
84490
84631
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84491
- if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) {
84632
+ if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84492
84633
  return true;
84493
84634
  }
84494
84635
  }
@@ -84503,7 +84644,7 @@ var ts;
84503
84644
  ts.setParent(reference, constructor);
84504
84645
  reference.flowNode = constructor.returnFlowNode;
84505
84646
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84506
- return !(getFalsyFlags(flowType) & 32768 /* Undefined */);
84647
+ return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84507
84648
  }
84508
84649
  function checkInterfaceDeclaration(node) {
84509
84650
  // Grammar checking
@@ -89870,9 +90011,7 @@ var ts;
89870
90011
  var ts;
89871
90012
  (function (ts) {
89872
90013
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
89873
- var _a = generatorOptions.extendedDiagnostics
89874
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
89875
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90014
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
89876
90015
  // Current source map file and its index in the sources list
89877
90016
  var rawSources = [];
89878
90017
  var sources = [];
@@ -92793,8 +92932,8 @@ var ts;
92793
92932
  // Note when updating logic here also update getEntityNameForDecoratorMetadata
92794
92933
  // so that aliases can be marked as referenced
92795
92934
  var serializedUnion;
92796
- for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
92797
- var typeNode = types_23[_i];
92935
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
92936
+ var typeNode = types_22[_i];
92798
92937
  while (typeNode.kind === 191 /* ParenthesizedType */) {
92799
92938
  typeNode = typeNode.type; // Skip parens if need be
92800
92939
  }
@@ -113409,8 +113548,8 @@ var ts;
113409
113548
  bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName });
113410
113549
  writeLine();
113411
113550
  }
113412
- for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
113413
- var directive = types_24[_d];
113551
+ for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
113552
+ var directive = types_23[_d];
113414
113553
  var pos = writer.getTextPos();
113415
113554
  var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
113416
113555
  ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
@@ -122178,7 +122317,7 @@ var ts;
122178
122317
  });
122179
122318
  // Sort by paths closest to importing file Name directory
122180
122319
  var sortedPaths = [];
122181
- var _loop_32 = function (directory) {
122320
+ var _loop_34 = function (directory) {
122182
122321
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122183
122322
  var pathsInDirectory;
122184
122323
  allFileNames.forEach(function (_a, fileName) {
@@ -122202,9 +122341,9 @@ var ts;
122202
122341
  };
122203
122342
  var out_directory_1;
122204
122343
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122205
- var state_10 = _loop_32(directory);
122344
+ var state_11 = _loop_34(directory);
122206
122345
  directory = out_directory_1;
122207
- if (state_10 === "break")
122346
+ if (state_11 === "break")
122208
122347
  break;
122209
122348
  }
122210
122349
  if (allFileNames.size) {
@@ -124148,6 +124287,7 @@ var ts;
124148
124287
  if (value) {
124149
124288
  return isParsedCommandLine(value) ? value : undefined;
124150
124289
  }
124290
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124151
124291
  var diagnostic;
124152
124292
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124153
124293
  var parsed;
@@ -124162,6 +124302,8 @@ var ts;
124162
124302
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124163
124303
  }
124164
124304
  configFileCache.set(configFilePath, parsed || diagnostic);
124305
+ ts.solutionPerformance.mark("afterParseConfigFile");
124306
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124165
124307
  return parsed;
124166
124308
  }
124167
124309
  function resolveProjectName(state, name) {
@@ -124211,6 +124353,7 @@ var ts;
124211
124353
  return state.buildOrder || createStateBuildOrder(state);
124212
124354
  }
124213
124355
  function createStateBuildOrder(state) {
124356
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124214
124357
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124215
124358
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124216
124359
  state.resolvedConfigFilePaths.clear();
@@ -124240,6 +124383,8 @@ var ts;
124240
124383
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124241
124384
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124242
124385
  }
124386
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124387
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124243
124388
  return state.buildOrder = buildOrder;
124244
124389
  }
124245
124390
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124360,6 +124505,7 @@ var ts;
124360
124505
  if (updateOutputFileStampsPending) {
124361
124506
  updateOutputTimestamps(state, config, projectPath);
124362
124507
  }
124508
+ ts.solutionPerformance.mark("timestampUpdated");
124363
124509
  return doneInvalidatedProject(state, projectPath);
124364
124510
  }
124365
124511
  };
@@ -124453,6 +124599,10 @@ var ts;
124453
124599
  };
124454
124600
  function done(cancellationToken, writeFile, customTransformers) {
124455
124601
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124602
+ if (kind === InvalidatedProjectKind.Build)
124603
+ ts.solutionPerformance.mark("projectsBuilt");
124604
+ else
124605
+ ts.solutionPerformance.mark("bundlesUpdated");
124456
124606
  return doneInvalidatedProject(state, projectPath);
124457
124607
  }
124458
124608
  function withProgramOrUndefined(action) {
@@ -124542,6 +124692,7 @@ var ts;
124542
124692
  var anyDtsChanged = false;
124543
124693
  var emitterDiagnostics = ts.createDiagnosticCollection();
124544
124694
  var emittedOutputs = new ts.Map();
124695
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124545
124696
  outputFiles.forEach(function (_a) {
124546
124697
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124547
124698
  var priorChangeTime;
@@ -124561,6 +124712,8 @@ var ts;
124561
124712
  newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124562
124713
  }
124563
124714
  });
124715
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124716
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124564
124717
  finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124565
124718
  /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124566
124719
  return emitResult;
@@ -124690,6 +124843,13 @@ var ts;
124690
124843
  !ts.isIncrementalCompilation(config.options);
124691
124844
  }
124692
124845
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124846
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
124847
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
124848
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
124849
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
124850
+ return result;
124851
+ }
124852
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124693
124853
  if (!state.projectPendingBuild.size)
124694
124854
  return undefined;
124695
124855
  if (isCircularBuildOrder(buildOrder))
@@ -124789,9 +124949,7 @@ var ts;
124789
124949
  }
124790
124950
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124791
124951
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124792
- if (!info)
124793
- return info;
124794
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
124952
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124795
124953
  }
124796
124954
  function listEmittedFile(_a, proj, file) {
124797
124955
  var write = _a.write;
@@ -124799,14 +124957,17 @@ var ts;
124799
124957
  write("TSFILE: " + file);
124800
124958
  }
124801
124959
  }
124802
- function getOldProgram(_a, proj, parsed) {
124803
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
124804
- if (options.force)
124960
+ function getOldProgram(state, proj, parsed) {
124961
+ if (state.options.force)
124805
124962
  return undefined;
124806
- var value = builderPrograms.get(proj);
124963
+ var value = state.builderPrograms.get(proj);
124807
124964
  if (value)
124808
124965
  return value;
124809
- return ts.readBuilderProgram(parsed.options, compilerHost);
124966
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
124967
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
124968
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
124969
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
124970
+ return program;
124810
124971
  }
124811
124972
  function afterProgramDone(state, program, config) {
124812
124973
  if (program) {
@@ -125005,7 +125166,10 @@ var ts;
125005
125166
  state.buildInfoChecked.set(resolvedPath, true);
125006
125167
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125007
125168
  if (buildInfoPath) {
125169
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125008
125170
  var value = state.readFileWithCache(buildInfoPath);
125171
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125172
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125009
125173
  var buildInfo = value && ts.getBuildInfo(value);
125010
125174
  if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125011
125175
  return {
@@ -125041,13 +125205,17 @@ var ts;
125041
125205
  if (prior !== undefined) {
125042
125206
  return prior;
125043
125207
  }
125208
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125044
125209
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125210
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125211
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125045
125212
  state.projectStatus.set(resolvedPath, actual);
125046
125213
  return actual;
125047
125214
  }
125048
125215
  function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125049
125216
  if (proj.options.noEmit)
125050
125217
  return priorNewestUpdateTime;
125218
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125051
125219
  var host = state.host;
125052
125220
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125053
125221
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
@@ -125068,6 +125236,8 @@ var ts;
125068
125236
  host.setModifiedTime(file, now);
125069
125237
  }
125070
125238
  }
125239
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125240
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125071
125241
  return priorNewestUpdateTime;
125072
125242
  }
125073
125243
  function updateOutputTimestamps(state, proj, resolvedPath) {
@@ -125146,6 +125316,13 @@ var ts;
125146
125316
  }
125147
125317
  }
125148
125318
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125319
+ ts.solutionPerformance.mark("beforeBuild");
125320
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125321
+ ts.solutionPerformance.mark("afterBuild");
125322
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125323
+ return result;
125324
+ }
125325
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125149
125326
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125150
125327
  if (!buildOrder)
125151
125328
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125157,7 +125334,10 @@ var ts;
125157
125334
  if (!invalidatedProject)
125158
125335
  break;
125159
125336
  reportQueue = false;
125337
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125160
125338
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125339
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125340
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125161
125341
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125162
125342
  successfulProjects++;
125163
125343
  }
@@ -125246,6 +125426,14 @@ var ts;
125246
125426
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125247
125427
  }
125248
125428
  function buildNextInvalidatedProject(state, changeDetected) {
125429
+ ts.solutionPerformance.mark("beforeBuild");
125430
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125431
+ ts.solutionPerformance.mark("afterBuild");
125432
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125433
+ if (buildOrder)
125434
+ reportErrorSummary(state, buildOrder);
125435
+ }
125436
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125249
125437
  state.timerToBuildInvalidatedProject = undefined;
125250
125438
  if (state.reportFileChangeDetected) {
125251
125439
  state.reportFileChangeDetected = false;
@@ -125256,7 +125444,10 @@ var ts;
125256
125444
  var buildOrder = getBuildOrder(state);
125257
125445
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125258
125446
  if (invalidatedProject) {
125447
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125259
125448
  invalidatedProject.done();
125449
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125450
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125260
125451
  projectsBuilt++;
125261
125452
  while (state.projectPendingBuild.size) {
125262
125453
  // If already scheduled, skip
@@ -125272,13 +125463,16 @@ var ts;
125272
125463
  return;
125273
125464
  }
125274
125465
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125466
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125275
125467
  project.done();
125468
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125469
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125276
125470
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125277
125471
  projectsBuilt++;
125278
125472
  }
125279
125473
  }
125280
125474
  disableCache(state);
125281
- reportErrorSummary(state, buildOrder);
125475
+ return buildOrder;
125282
125476
  }
125283
125477
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125284
125478
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
@@ -125335,6 +125529,7 @@ var ts;
125335
125529
  function startWatching(state, buildOrder) {
125336
125530
  if (!state.watchAllProjectsPending)
125337
125531
  return;
125532
+ ts.solutionPerformance.mark("beforeStartWatching");
125338
125533
  state.watchAllProjectsPending = false;
125339
125534
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125340
125535
  var resolved = _a[_i];
@@ -125352,6 +125547,8 @@ var ts;
125352
125547
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125353
125548
  }
125354
125549
  }
125550
+ ts.solutionPerformance.mark("afterStartWatching");
125551
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125355
125552
  }
125356
125553
  function stopWatching(state) {
125357
125554
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);