@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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220601";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -3510,16 +3510,34 @@ var ts;
3510
3510
  /** Performance measurements for the compiler. */
3511
3511
  var ts;
3512
3512
  (function (ts) {
3513
- var performance;
3514
- (function (performance) {
3513
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3514
+ ts.performance = createPerformanceTracker();
3515
+ ts.solutionPerformance = createPerformanceTracker();
3516
+ function createPerformanceTracker() {
3515
3517
  var perfHooks;
3516
3518
  // when set, indicates the implementation of `Performance` to use for user timing.
3517
3519
  // when unset, indicates user timing is unavailable or disabled.
3518
3520
  var performanceImpl;
3521
+ var enabled = false;
3522
+ var timeorigin = ts.timestamp();
3523
+ var marks = new ts.Map();
3524
+ var counts = new ts.Map();
3525
+ var durations = new ts.Map();
3526
+ return {
3527
+ createTimerIf: createTimerIf,
3528
+ createTimer: createTimer,
3529
+ mark: mark,
3530
+ measure: measure,
3531
+ getCount: getCount,
3532
+ getDuration: getDuration,
3533
+ forEachMeasure: forEachMeasure,
3534
+ isEnabled: isEnabled,
3535
+ enable: enable,
3536
+ disable: disable,
3537
+ };
3519
3538
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3520
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3539
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3521
3540
  }
3522
- performance.createTimerIf = createTimerIf;
3523
3541
  function createTimer(measureName, startMarkName, endMarkName) {
3524
3542
  var enterCount = 0;
3525
3543
  return {
@@ -3541,13 +3559,6 @@ var ts;
3541
3559
  }
3542
3560
  }
3543
3561
  }
3544
- performance.createTimer = createTimer;
3545
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3546
- var enabled = false;
3547
- var timeorigin = ts.timestamp();
3548
- var marks = new ts.Map();
3549
- var counts = new ts.Map();
3550
- var durations = new ts.Map();
3551
3562
  /**
3552
3563
  * Marks a performance event.
3553
3564
  *
@@ -3562,7 +3573,6 @@ var ts;
3562
3573
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3563
3574
  }
3564
3575
  }
3565
- performance.mark = mark;
3566
3576
  /**
3567
3577
  * Adds a performance measurement with the specified name.
3568
3578
  *
@@ -3575,14 +3585,13 @@ var ts;
3575
3585
  function measure(measureName, startMarkName, endMarkName) {
3576
3586
  var _a, _b;
3577
3587
  if (enabled) {
3578
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3579
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3588
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3589
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3580
3590
  var previousDuration = durations.get(measureName) || 0;
3581
3591
  durations.set(measureName, previousDuration + (end - start));
3582
3592
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3583
3593
  }
3584
3594
  }
3585
- performance.measure = measure;
3586
3595
  /**
3587
3596
  * Gets the number of times a marker was encountered.
3588
3597
  *
@@ -3591,7 +3600,6 @@ var ts;
3591
3600
  function getCount(markName) {
3592
3601
  return counts.get(markName) || 0;
3593
3602
  }
3594
- performance.getCount = getCount;
3595
3603
  /**
3596
3604
  * Gets the total duration of all measurements with the supplied name.
3597
3605
  *
@@ -3600,7 +3608,6 @@ var ts;
3600
3608
  function getDuration(measureName) {
3601
3609
  return durations.get(measureName) || 0;
3602
3610
  }
3603
- performance.getDuration = getDuration;
3604
3611
  /**
3605
3612
  * Iterate over each measure, performing some action
3606
3613
  *
@@ -3609,14 +3616,12 @@ var ts;
3609
3616
  function forEachMeasure(cb) {
3610
3617
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3611
3618
  }
3612
- performance.forEachMeasure = forEachMeasure;
3613
3619
  /**
3614
3620
  * Indicates whether the performance API is enabled.
3615
3621
  */
3616
3622
  function isEnabled() {
3617
3623
  return enabled;
3618
3624
  }
3619
- performance.isEnabled = isEnabled;
3620
3625
  /** Enables (and resets) performance measurements for the compiler. */
3621
3626
  function enable(system) {
3622
3627
  var _a;
@@ -3637,7 +3642,6 @@ var ts;
3637
3642
  }
3638
3643
  return true;
3639
3644
  }
3640
- performance.enable = enable;
3641
3645
  /** Disables performance measurements for the compiler. */
3642
3646
  function disable() {
3643
3647
  if (enabled) {
@@ -3648,8 +3652,7 @@ var ts;
3648
3652
  enabled = false;
3649
3653
  }
3650
3654
  }
3651
- performance.disable = disable;
3652
- })(performance = ts.performance || (ts.performance = {}));
3655
+ }
3653
3656
  })(ts || (ts = {}));
3654
3657
  /* @internal */
3655
3658
  var ts;
@@ -5101,6 +5104,11 @@ var ts;
5101
5104
  // Flags that require TypeFlags.Union
5102
5105
  /* @internal */
5103
5106
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5107
+ /* @internal */
5108
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5109
+ /* @internal */
5110
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5111
+ /* @internal */
5104
5112
  // Flags that require TypeFlags.Intersection
5105
5113
  /* @internal */
5106
5114
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -6319,7 +6327,7 @@ var ts;
6319
6327
  */
6320
6328
  /*@internal*/
6321
6329
  function createDirectoryWatcherSupportingRecursive(_a) {
6322
- 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;
6330
+ 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;
6323
6331
  var cache = new ts.Map();
6324
6332
  var callbackCache = ts.createMultiMap();
6325
6333
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6419,7 +6427,7 @@ var ts;
6419
6427
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6420
6428
  // Iterate through existing children and update the watches if needed
6421
6429
  var parentWatcher = cache.get(dirPath);
6422
- if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6430
+ if (parentWatcher && directoryExists(dirName)) {
6423
6431
  // Schedule the update and postpone invoke for callbacks
6424
6432
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6425
6433
  return;
@@ -6492,7 +6500,7 @@ var ts;
6492
6500
  if (!parentWatcher)
6493
6501
  return false;
6494
6502
  var newChildWatches;
6495
- var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6503
+ var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6496
6504
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6497
6505
  // Filter our the symbolic link directories since those arent included in recursive watch
6498
6506
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6538,10 +6546,10 @@ var ts;
6538
6546
  return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6539
6547
  }
6540
6548
  ts.createFileWatcherCallback = createFileWatcherCallback;
6541
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists) {
6549
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6542
6550
  return function (eventName) {
6543
6551
  if (eventName === "rename") {
6544
- callback(fileName, fileSystemEntryExists(fileName, 0 /* File */) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6552
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6545
6553
  }
6546
6554
  else {
6547
6555
  // Change
@@ -6569,12 +6577,11 @@ var ts;
6569
6577
  }
6570
6578
  /*@internal*/
6571
6579
  function createSystemWatchFunctions(_a) {
6572
- 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;
6580
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6573
6581
  var dynamicPollingWatchFile;
6574
6582
  var fixedChunkSizePollingWatchFile;
6575
6583
  var nonPollingWatchFile;
6576
6584
  var hostRecursiveDirectoryWatcher;
6577
- var hitSystemWatcherLimit = false;
6578
6585
  return {
6579
6586
  watchFile: watchFile,
6580
6587
  watchDirectory: watchDirectory
@@ -6592,7 +6599,7 @@ var ts;
6592
6599
  case ts.WatchFileKind.FixedChunkSizePolling:
6593
6600
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6594
6601
  case ts.WatchFileKind.UseFsEvents:
6595
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists),
6602
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6596
6603
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6597
6604
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6598
6605
  if (!nonPollingWatchFile) {
@@ -6653,7 +6660,7 @@ var ts;
6653
6660
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6654
6661
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6655
6662
  getCurrentDirectory: getCurrentDirectory,
6656
- fileSystemEntryExists: fileSystemEntryExists,
6663
+ directoryExists: directoryExists,
6657
6664
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6658
6665
  watchDirectory: nonRecursiveWatchDirectory,
6659
6666
  realpath: realpath,
@@ -6704,114 +6711,6 @@ var ts;
6704
6711
  };
6705
6712
  }
6706
6713
  }
6707
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6708
- var lastDirectoryPartWithDirectorySeparator;
6709
- var lastDirectoryPart;
6710
- if (inodeWatching) {
6711
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6712
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6713
- }
6714
- /** Watcher for the file system entry depending on whether it is missing or present */
6715
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6716
- watchMissingFileSystemEntry() :
6717
- watchPresentFileSystemEntry();
6718
- return {
6719
- close: function () {
6720
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6721
- watcher.close();
6722
- watcher = undefined;
6723
- }
6724
- };
6725
- function updateWatcher(createWatcher) {
6726
- // If watcher is not closed, update it
6727
- if (watcher) {
6728
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6729
- watcher.close();
6730
- watcher = createWatcher();
6731
- }
6732
- }
6733
- /**
6734
- * Watch the file or directory that is currently present
6735
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
6736
- */
6737
- function watchPresentFileSystemEntry() {
6738
- if (hitSystemWatcherLimit) {
6739
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6740
- return watchPresentFileSystemEntryWithFsWatchFile();
6741
- }
6742
- try {
6743
- var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6744
- callbackChangingToMissingFileSystemEntry :
6745
- function (eventName, relativeFileName) {
6746
- sysLog("sysLog:: watchPresentFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6747
- callback(eventName, relativeFileName);
6748
- });
6749
- // Watch the missing file or directory or error
6750
- presentWatcher.on("error", function () {
6751
- sysLog("sysLog:: watchPresentFileSystemEntry:: on Error " + fileOrDirectory + " " + entryKind + " rename, \"\"");
6752
- callback("rename", "");
6753
- updateWatcher(watchMissingFileSystemEntry);
6754
- });
6755
- return presentWatcher;
6756
- }
6757
- catch (e) {
6758
- // Catch the exception and use polling instead
6759
- // 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
6760
- // so instead of throwing error, use fs.watchFile
6761
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6762
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6763
- return watchPresentFileSystemEntryWithFsWatchFile();
6764
- }
6765
- }
6766
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6767
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + event + ":: " + relativeName + " " + inodeWatching + " " + lastDirectoryPart + " " + lastDirectoryPartWithDirectorySeparator);
6768
- if (relativeName && ts.endsWith(relativeName, "~")) {
6769
- relativeName = relativeName.slice(0, relativeName.length - 1);
6770
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: changed the relative name to " + relativeName);
6771
- }
6772
- callback(event, relativeName);
6773
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6774
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6775
- if (event === "rename" &&
6776
- (!relativeName ||
6777
- relativeName === lastDirectoryPart ||
6778
- ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6779
- if (inodeWatching) {
6780
- updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6781
- }
6782
- else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
6783
- updateWatcher(watchMissingFileSystemEntry);
6784
- }
6785
- }
6786
- }
6787
- /**
6788
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
6789
- * 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
6790
- */
6791
- function watchPresentFileSystemEntryWithFsWatchFile() {
6792
- return watchFile(fileOrDirectory, createFileWatcherCallback(function (eventName, relativeFileName) {
6793
- sysLog("sysLog:: watchPresentFileSystemEntryWithFsWatchFile:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6794
- callback(eventName, relativeFileName);
6795
- }), fallbackPollingInterval, fallbackOptions);
6796
- }
6797
- /**
6798
- * Watch the file or directory that is missing
6799
- * and switch to existing file or directory when the missing filesystem entry is created
6800
- */
6801
- function watchMissingFileSystemEntry() {
6802
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
6803
- sysLog("sysLog:: watchMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + _fileName + ":: " + eventKind);
6804
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
6805
- sysLog("sysLog:: watchMissingFileSystemEntry:: Callback :: rename, \"\" and will update the watcher");
6806
- callback("rename", "");
6807
- // Call the callback for current file or directory
6808
- // For now it could be callback for the inner directory creation,
6809
- // but just return current directory, better than current no-op
6810
- updateWatcher(watchPresentFileSystemEntry);
6811
- }
6812
- }, fallbackPollingInterval, fallbackOptions);
6813
- }
6814
- }
6815
6714
  }
6816
6715
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
6817
6716
  /**
@@ -6864,6 +6763,7 @@ var ts;
6864
6763
  }
6865
6764
  var activeSession;
6866
6765
  var profilePath = "./profile.cpuprofile";
6766
+ var hitSystemWatcherLimit = false;
6867
6767
  var Buffer = require("buffer").Buffer;
6868
6768
  var nodeVersion = getNodeMajorVersion();
6869
6769
  var isNode4OrLater = nodeVersion >= 4;
@@ -6878,21 +6778,20 @@ var ts;
6878
6778
  getModifiedTime: getModifiedTime,
6879
6779
  setTimeout: setTimeout,
6880
6780
  clearTimeout: clearTimeout,
6881
- fsWatchWorker: fsWatchWorker,
6781
+ fsWatch: fsWatch,
6882
6782
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6883
6783
  getCurrentDirectory: getCurrentDirectory,
6884
- fileSystemEntryExists: fileSystemEntryExists,
6784
+ fileExists: fileExists,
6885
6785
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
6886
6786
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
6887
6787
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6788
+ directoryExists: directoryExists,
6888
6789
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
6889
6790
  realpath: realpath,
6890
6791
  tscWatchFile: process.env.TSC_WATCHFILE,
6891
6792
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
6892
6793
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6893
6794
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
6894
- inodeWatching: isLinuxOrMacOs,
6895
- sysLog: sysLog,
6896
6795
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
6897
6796
  var nodeSystem = {
6898
6797
  args: process.argv.slice(2),
@@ -7145,11 +7044,107 @@ var ts;
7145
7044
  callback(fileName, eventKind);
7146
7045
  }
7147
7046
  }
7148
- function fsWatchWorker(fileOrDirectory, recursive, callback) {
7149
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7150
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7151
- return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7152
- { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7047
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7048
+ var options;
7049
+ var lastDirectoryPartWithDirectorySeparator;
7050
+ var lastDirectoryPart;
7051
+ if (isLinuxOrMacOs) {
7052
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7053
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7054
+ }
7055
+ /** Watcher for the file system entry depending on whether it is missing or present */
7056
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7057
+ watchMissingFileSystemEntry() :
7058
+ watchPresentFileSystemEntry();
7059
+ return {
7060
+ close: function () {
7061
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7062
+ watcher.close();
7063
+ watcher = undefined;
7064
+ }
7065
+ };
7066
+ /**
7067
+ * Invoke the callback with rename and update the watcher if not closed
7068
+ * @param createWatcher
7069
+ */
7070
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
7071
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7072
+ // Call the callback for current directory
7073
+ callback("rename", "");
7074
+ // If watcher is not closed, update it
7075
+ if (watcher) {
7076
+ watcher.close();
7077
+ watcher = createWatcher();
7078
+ }
7079
+ }
7080
+ /**
7081
+ * Watch the file or directory that is currently present
7082
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
7083
+ */
7084
+ function watchPresentFileSystemEntry() {
7085
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7086
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7087
+ if (options === undefined) {
7088
+ if (fsSupportsRecursiveFsWatch) {
7089
+ options = { persistent: true, recursive: !!recursive };
7090
+ }
7091
+ else {
7092
+ options = { persistent: true };
7093
+ }
7094
+ }
7095
+ if (hitSystemWatcherLimit) {
7096
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7097
+ return watchPresentFileSystemEntryWithFsWatchFile();
7098
+ }
7099
+ try {
7100
+ var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7101
+ callbackChangingToMissingFileSystemEntry :
7102
+ callback);
7103
+ // Watch the missing file or directory or error
7104
+ presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7105
+ return presentWatcher;
7106
+ }
7107
+ catch (e) {
7108
+ // Catch the exception and use polling instead
7109
+ // 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
7110
+ // so instead of throwing error, use fs.watchFile
7111
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7112
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7113
+ return watchPresentFileSystemEntryWithFsWatchFile();
7114
+ }
7115
+ }
7116
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7117
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7118
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7119
+ return event === "rename" &&
7120
+ (!relativeName ||
7121
+ relativeName === lastDirectoryPart ||
7122
+ (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7123
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7124
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7125
+ callback(event, relativeName);
7126
+ }
7127
+ /**
7128
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
7129
+ * 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
7130
+ */
7131
+ function watchPresentFileSystemEntryWithFsWatchFile() {
7132
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7133
+ }
7134
+ /**
7135
+ * Watch the file or directory that is missing
7136
+ * and switch to existing file or directory when the missing filesystem entry is created
7137
+ */
7138
+ function watchMissingFileSystemEntry() {
7139
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7140
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7141
+ // Call the callback for current file or directory
7142
+ // For now it could be callback for the inner directory creation,
7143
+ // but just return current directory, better than current no-op
7144
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7145
+ }
7146
+ }, fallbackPollingInterval, fallbackOptions);
7147
+ }
7153
7148
  }
7154
7149
  function readFileWorker(fileName, _encoding) {
7155
7150
  var buffer;
@@ -8427,6 +8422,7 @@ var ts;
8427
8422
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8428
8423
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8429
8424
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8425
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8430
8426
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8431
8427
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8432
8428
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -8912,6 +8908,7 @@ var ts;
8912
8908
  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."),
8913
8909
  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."),
8914
8910
  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."),
8911
+ 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"),
8915
8912
  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}'."),
8916
8913
  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}'."),
8917
8914
  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}'."),
@@ -16231,9 +16228,6 @@ var ts;
16231
16228
  }
16232
16229
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16233
16230
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16234
- if (node.kind === 203 /* BindingElement */) {
16235
- node = node.parent.parent;
16236
- }
16237
16231
  return ts.isVariableDeclaration(node) &&
16238
16232
  !!node.initializer &&
16239
16233
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20045,8 +20039,9 @@ var ts;
20045
20039
  */
20046
20040
  function isFileForcedToBeModuleByFormat(file) {
20047
20041
  // Excludes declaration files - they still require an explicit `export {}` or the like
20048
- // for back compat purposes.
20049
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20042
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20043
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20044
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20050
20045
  }
20051
20046
  function getSetExternalModuleIndicator(options) {
20052
20047
  // TODO: Should this callback be cached?
@@ -20054,7 +20049,7 @@ var ts;
20054
20049
  case ts.ModuleDetectionKind.Force:
20055
20050
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20056
20051
  return function (file) {
20057
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20052
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20058
20053
  };
20059
20054
  case ts.ModuleDetectionKind.Legacy:
20060
20055
  // Files are modules if they have imports, exports, or import.meta
@@ -20114,7 +20109,8 @@ var ts;
20114
20109
  }
20115
20110
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20116
20111
  function getEmitModuleDetectionKind(options) {
20117
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20112
+ return options.moduleDetection ||
20113
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20118
20114
  }
20119
20115
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20120
20116
  function hasJsonModuleEmitEnabled(options) {
@@ -43161,16 +43157,20 @@ var ts;
43161
43157
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43162
43158
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43163
43159
  }
43160
+ var jsOnlyExtensions = [Extensions.JavaScript];
43161
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43162
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43163
+ var tsconfigExtensions = [Extensions.TSConfig];
43164
43164
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43165
43165
  var containingDirectory = ts.getDirectoryPath(containingFile);
43166
43166
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43167
43167
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43168
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43168
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43169
+ if (compilerOptions.resolveJsonModule) {
43170
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43171
+ }
43172
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43169
43173
  }
43170
- var jsOnlyExtensions = [Extensions.JavaScript];
43171
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43172
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43173
- var tsconfigExtensions = [Extensions.TSConfig];
43174
43174
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43175
43175
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43176
43176
  }
@@ -44178,8 +44178,8 @@ var ts;
44178
44178
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
44179
44179
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
44180
44180
  if (!pathAndExtension && packageInfo
44181
- && packageInfo.packageJsonContent.exports === undefined
44182
- && packageInfo.packageJsonContent.main === undefined
44181
+ // eslint-disable-next-line no-null/no-null
44182
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
44183
44183
  && state.features & NodeResolutionFeatures.EsmMode) {
44184
44184
  // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
44185
44185
  // a default `index.js` entrypoint if no `main` or `exports` are present
@@ -46955,12 +46955,14 @@ var ts;
46955
46955
  }
46956
46956
  }
46957
46957
  function setCommonJsModuleIndicator(node) {
46958
- if (file.externalModuleIndicator) {
46958
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46959
46959
  return false;
46960
46960
  }
46961
46961
  if (!file.commonJsModuleIndicator) {
46962
46962
  file.commonJsModuleIndicator = node;
46963
- bindSourceFileAsExternalModule();
46963
+ if (!file.externalModuleIndicator) {
46964
+ bindSourceFileAsExternalModule();
46965
+ }
46964
46966
  }
46965
46967
  return true;
46966
46968
  }
@@ -47374,7 +47376,11 @@ var ts;
47374
47376
  checkStrictModeEvalOrArguments(node, node.name);
47375
47377
  }
47376
47378
  if (!ts.isBindingPattern(node.name)) {
47377
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47379
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47380
+ if (ts.isInJSFile(node) &&
47381
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47382
+ !ts.getJSDocTypeTag(node) &&
47383
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47378
47384
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47379
47385
  }
47380
47386
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -47838,7 +47844,10 @@ var ts;
47838
47844
  TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull";
47839
47845
  TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy";
47840
47846
  TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy";
47841
- TypeFacts[TypeFacts["All"] = 16777215] = "All";
47847
+ TypeFacts[TypeFacts["IsUndefined"] = 16777216] = "IsUndefined";
47848
+ TypeFacts[TypeFacts["IsNull"] = 33554432] = "IsNull";
47849
+ TypeFacts[TypeFacts["IsUndefinedOrNull"] = 50331648] = "IsUndefinedOrNull";
47850
+ TypeFacts[TypeFacts["All"] = 134217727] = "All";
47842
47851
  // The following members encode facts about particular kinds of types for use in the getTypeFacts function.
47843
47852
  // The presence of a particular fact means that the given test is true for some (and possibly all) values
47844
47853
  // of that kind of type.
@@ -47880,14 +47889,16 @@ var ts;
47880
47889
  TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts";
47881
47890
  TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts";
47882
47891
  TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts";
47883
- TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts";
47884
- TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts";
47885
- TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
47892
+ TypeFacts[TypeFacts["VoidFacts"] = 9830144] = "VoidFacts";
47893
+ TypeFacts[TypeFacts["UndefinedFacts"] = 26607360] = "UndefinedFacts";
47894
+ TypeFacts[TypeFacts["NullFacts"] = 42917664] = "NullFacts";
47895
+ TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 83427327] = "EmptyObjectStrictFacts";
47896
+ TypeFacts[TypeFacts["EmptyObjectFacts"] = 83886079] = "EmptyObjectFacts";
47897
+ TypeFacts[TypeFacts["UnknownFacts"] = 83886079] = "UnknownFacts";
47886
47898
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
47887
- TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
47888
47899
  // Masks
47889
47900
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47890
- TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
47901
+ TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
47891
47902
  })(TypeFacts || (TypeFacts = {}));
47892
47903
  var typeofEQFacts = new ts.Map(ts.getEntries({
47893
47904
  string: 1 /* TypeofEQString */,
@@ -48551,6 +48562,7 @@ var ts;
48551
48562
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48552
48563
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48553
48564
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48565
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48554
48566
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48555
48567
  emptyGenericType.instantiations = new ts.Map();
48556
48568
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50050,7 +50062,12 @@ var ts;
50050
50062
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
50051
50063
  if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) {
50052
50064
  if (isPrimitiveTypeName(name)) {
50053
- error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50065
+ if (isExtendedByInterface(errorLocation)) {
50066
+ 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));
50067
+ }
50068
+ else {
50069
+ error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50070
+ }
50054
50071
  return true;
50055
50072
  }
50056
50073
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
@@ -50070,6 +50087,16 @@ var ts;
50070
50087
  }
50071
50088
  return false;
50072
50089
  }
50090
+ function isExtendedByInterface(node) {
50091
+ var grandparent = node.parent.parent;
50092
+ var parentOfGrandparent = grandparent.parent;
50093
+ if (grandparent && parentOfGrandparent) {
50094
+ var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */;
50095
+ var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent);
50096
+ return isExtending && isInterface;
50097
+ }
50098
+ return false;
50099
+ }
50073
50100
  function maybeMappedType(node, symbol) {
50074
50101
  var container = ts.findAncestor(node.parent, function (n) {
50075
50102
  return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
@@ -50201,7 +50228,8 @@ var ts;
50201
50228
  && isAliasableOrJsExpression(node.parent.right)
50202
50229
  || node.kind === 297 /* ShorthandPropertyAssignment */
50203
50230
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50204
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50231
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50232
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50205
50233
  }
50206
50234
  function isAliasableOrJsExpression(e) {
50207
50235
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50294,7 +50322,7 @@ var ts;
50294
50322
  return hasExportAssignmentSymbol(moduleSymbol);
50295
50323
  }
50296
50324
  // 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
50297
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50325
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50298
50326
  }
50299
50327
  function getTargetOfImportClause(node, dontResolveAlias) {
50300
50328
  var _a;
@@ -52909,7 +52937,7 @@ var ts;
52909
52937
  anyType : getNonMissingTypeOfSymbol(propertySymbol);
52910
52938
  var saveEnclosingDeclaration = context.enclosingDeclaration;
52911
52939
  context.enclosingDeclaration = undefined;
52912
- if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) {
52940
+ if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) {
52913
52941
  if (propertySymbol.declarations) {
52914
52942
  var decl = ts.first(propertySymbol.declarations);
52915
52943
  if (hasLateBindableName(decl)) {
@@ -54593,7 +54621,7 @@ var ts;
54593
54621
  ? getBaseConstructorTypeOfClass(staticType)
54594
54622
  : anyType;
54595
54623
  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);
54596
- var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
54624
+ var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
54597
54625
  var publicSymbolProps = ts.filter(symbolProps, function (s) {
54598
54626
  // `valueDeclaration` could be undefined if inherited from
54599
54627
  // a union/intersection base type, but inherited properties
@@ -55731,7 +55759,7 @@ var ts;
55731
55759
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
55732
55760
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
55733
55761
  // undefined from the final type.
55734
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
55762
+ return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
55735
55763
  }
55736
55764
  return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
55737
55765
  }
@@ -58720,7 +58748,7 @@ var ts;
58720
58748
  }
58721
58749
  }
58722
58750
  }
58723
- else if (t.flags & 469892092 /* DisjointDomains */) {
58751
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58724
58752
  hasDisjointDomainType = true;
58725
58753
  }
58726
58754
  }
@@ -58732,7 +58760,7 @@ var ts;
58732
58760
  // intersection operation to reduce the union constraints.
58733
58761
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58734
58762
  var t = types_6[_a];
58735
- if (t.flags & 469892092 /* DisjointDomains */) {
58763
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58736
58764
  constraints = ts.append(constraints, t);
58737
58765
  }
58738
58766
  }
@@ -58934,7 +58962,7 @@ var ts;
58934
58962
  var objectType;
58935
58963
  return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58936
58964
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58937
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
58965
+ !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
58938
58966
  }
58939
58967
  /**
58940
58968
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -61281,7 +61309,7 @@ var ts;
61281
61309
  }
61282
61310
  return includes;
61283
61311
  }
61284
- function removeRedundantPrimitiveTypes(types, includes) {
61312
+ function removeRedundantSupertypes(types, includes) {
61285
61313
  var i = types.length;
61286
61314
  while (i > 0) {
61287
61315
  i--;
@@ -61289,7 +61317,9 @@ var ts;
61289
61317
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61290
61318
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61291
61319
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61292
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61320
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61321
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61322
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61293
61323
  if (remove) {
61294
61324
  ts.orderedRemoveItemAt(types, i);
61295
61325
  }
@@ -61411,7 +61441,7 @@ var ts;
61411
61441
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61412
61442
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61413
61443
  // for intersections of types with signatures can be deterministic.
61414
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61444
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61415
61445
  var typeMembershipMap = new ts.Map();
61416
61446
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61417
61447
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61448,11 +61478,11 @@ var ts;
61448
61478
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61449
61479
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61450
61480
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61451
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61452
- removeRedundantPrimitiveTypes(typeSet, includes);
61453
- }
61454
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61455
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61481
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61482
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61483
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61484
+ if (!noSupertypeReduction)
61485
+ removeRedundantSupertypes(typeSet, includes);
61456
61486
  }
61457
61487
  if (includes & 262144 /* IncludesMissingType */) {
61458
61488
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61491,8 +61521,9 @@ var ts;
61491
61521
  }
61492
61522
  var constituents = getCrossProductIntersections(typeSet);
61493
61523
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61494
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61495
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61524
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61525
+ // the denormalized origin has fewer constituents than the union itself.
61526
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61496
61527
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61497
61528
  }
61498
61529
  }
@@ -61535,11 +61566,21 @@ var ts;
61535
61566
  }
61536
61567
  return intersections;
61537
61568
  }
61569
+ function getConstituentCount(type) {
61570
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61571
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61572
+ getConstituentCountOfTypes(type.types);
61573
+ }
61574
+ function getConstituentCountOfTypes(types) {
61575
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61576
+ }
61538
61577
  function getTypeFromIntersectionTypeNode(node) {
61539
61578
  var links = getNodeLinks(node);
61540
61579
  if (!links.resolvedType) {
61541
61580
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61542
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61581
+ var types = ts.map(node.types, getTypeFromTypeNode);
61582
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61583
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61543
61584
  }
61544
61585
  return links.resolvedType;
61545
61586
  }
@@ -64213,7 +64254,7 @@ var ts;
64213
64254
  var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
64214
64255
  var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType));
64215
64256
  var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
64216
- (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */);
64257
+ (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
64217
64258
  var related = callbacks ?
64218
64259
  compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
64219
64260
  !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
@@ -64325,6 +64366,17 @@ var ts;
64325
64366
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64326
64367
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64327
64368
  }
64369
+ function isUnknownLikeUnionType(type) {
64370
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64371
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64372
+ var types = type.types;
64373
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64374
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64375
+ }
64376
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64377
+ }
64378
+ return false;
64379
+ }
64328
64380
  function isStringIndexSignatureOnlyType(type) {
64329
64381
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64330
64382
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64404,7 +64456,7 @@ var ts;
64404
64456
  return true;
64405
64457
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64406
64458
  return true;
64407
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64459
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64408
64460
  return true;
64409
64461
  if (relation === assignableRelation || relation === comparableRelation) {
64410
64462
  if (s & 1 /* Any */)
@@ -64414,6 +64466,9 @@ var ts;
64414
64466
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64415
64467
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64416
64468
  return true;
64469
+ // Anything is assignable to a union containing undefined, null, and {}
64470
+ if (isUnknownLikeUnionType(target))
64471
+ return true;
64417
64472
  }
64418
64473
  return false;
64419
64474
  }
@@ -64456,16 +64511,27 @@ var ts;
64456
64511
  function getNormalizedType(type, writing) {
64457
64512
  while (true) {
64458
64513
  var t = isFreshLiteralType(type) ? type.regularType :
64459
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64460
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64514
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64515
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64461
64516
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64462
64517
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64463
64518
  type;
64464
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64465
64519
  if (t === type)
64466
- break;
64520
+ return t;
64467
64521
  type = t;
64468
64522
  }
64523
+ }
64524
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64525
+ var reduced = getReducedType(type);
64526
+ if (reduced !== type) {
64527
+ return reduced;
64528
+ }
64529
+ if (type.flags & 2097152 /* Intersection */) {
64530
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64531
+ if (normalizedTypes !== type.types) {
64532
+ return getIntersectionType(normalizedTypes);
64533
+ }
64534
+ }
64469
64535
  return type;
64470
64536
  }
64471
64537
  /**
@@ -64912,6 +64978,7 @@ var ts;
64912
64978
  return 0 /* False */;
64913
64979
  }
64914
64980
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64981
+ var _a, _b;
64915
64982
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
64916
64983
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
64917
64984
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -64952,6 +65019,9 @@ var ts;
64952
65019
  return;
64953
65020
  }
64954
65021
  reportRelationError(headMessage, source, target);
65022
+ 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 */))) {
65023
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65024
+ }
64955
65025
  }
64956
65026
  function traceUnionsOrIntersectionsTooLarge(source, target) {
64957
65027
  if (!ts.tracing) {
@@ -65738,13 +65808,6 @@ var ts;
65738
65808
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65739
65809
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65740
65810
  var constraint = getConstraintOfType(source) || unknownType;
65741
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65742
- // A type variable with no constraint is not related to the non-primitive object type.
65743
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65744
- resetErrorInfo(saveErrorInfo);
65745
- return result;
65746
- }
65747
- }
65748
65811
  // 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
65749
65812
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65750
65813
  resetErrorInfo(saveErrorInfo);
@@ -67218,9 +67281,11 @@ var ts;
67218
67281
  return getSupertypeOrUnion(types);
67219
67282
  }
67220
67283
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67221
- return primaryTypes.length ?
67222
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67223
- getUnionType(types, 2 /* Subtype */);
67284
+ if (primaryTypes.length) {
67285
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67286
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67287
+ }
67288
+ return getUnionType(types, 2 /* Subtype */);
67224
67289
  }
67225
67290
  // Return the leftmost type for which no type to the right is a subtype.
67226
67291
  function getCommonSubtype(types) {
@@ -67407,29 +67472,8 @@ var ts;
67407
67472
  var value = _a.value;
67408
67473
  return value.base10Value === "0";
67409
67474
  }
67410
- function getFalsyFlagsOfTypes(types) {
67411
- var result = 0;
67412
- for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
67413
- var t = types_14[_i];
67414
- result |= getFalsyFlags(t);
67415
- }
67416
- return result;
67417
- }
67418
- // Returns the String, Number, Boolean, StringLiteral, NumberLiteral, BooleanLiteral, Void, Undefined, or Null
67419
- // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67420
- // no flags for all other types (including non-falsy literal types).
67421
- function getFalsyFlags(type) {
67422
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67423
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67424
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67425
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67426
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67427
- type.flags & 117724 /* PossiblyFalsy */;
67428
- }
67429
67475
  function removeDefinitelyFalsyTypes(type) {
67430
- return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
67431
- filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) :
67432
- type;
67476
+ return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); });
67433
67477
  }
67434
67478
  function extractDefinitelyFalsyTypes(type) {
67435
67479
  return mapType(type, getDefinitelyFalsyPartOfType);
@@ -67464,20 +67508,15 @@ var ts;
67464
67508
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67465
67509
  }
67466
67510
  function getGlobalNonNullableTypeInstantiation(type) {
67467
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67468
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67469
- // that isn't eliminated by a NonNullable<T> instantiation.
67470
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67471
67511
  if (!deferredGlobalNonNullableTypeAlias) {
67472
67512
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67473
67513
  }
67474
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67475
67514
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67476
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67477
- reducedType;
67515
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67516
+ getIntersectionType([type, emptyObjectType]);
67478
67517
  }
67479
67518
  function getNonNullableType(type) {
67480
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67519
+ return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
67481
67520
  }
67482
67521
  function addOptionalTypeMarker(type) {
67483
67522
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68158,13 +68197,40 @@ var ts;
68158
68197
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68159
68198
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68160
68199
  }
68161
- function isValidBigIntString(s) {
68200
+ /**
68201
+ * Tests whether the provided string can be parsed as a number.
68202
+ * @param s The string to test.
68203
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68204
+ */
68205
+ function isValidNumberString(s, roundTripOnly) {
68206
+ if (s === "")
68207
+ return false;
68208
+ var n = +s;
68209
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68210
+ }
68211
+ /**
68212
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68213
+ */
68214
+ function parseBigIntLiteralType(text) {
68215
+ var negative = text.startsWith("-");
68216
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68217
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68218
+ }
68219
+ /**
68220
+ * Tests whether the provided string can be parsed as a bigint.
68221
+ * @param s The string to test.
68222
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68223
+ */
68224
+ function isValidBigIntString(s, roundTripOnly) {
68225
+ if (s === "")
68226
+ return false;
68162
68227
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68163
68228
  var success = true;
68164
68229
  scanner.setOnError(function () { return success = false; });
68165
68230
  scanner.setText(s + "n");
68166
68231
  var result = scanner.scan();
68167
- if (result === 40 /* MinusToken */) {
68232
+ var negative = result === 40 /* MinusToken */;
68233
+ if (negative) {
68168
68234
  result = scanner.scan();
68169
68235
  }
68170
68236
  var flags = scanner.getTokenFlags();
@@ -68173,7 +68239,8 @@ var ts;
68173
68239
  // * a bigint can be scanned, and that when it is scanned, it is
68174
68240
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68175
68241
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68176
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68242
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68243
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68177
68244
  }
68178
68245
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68179
68246
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68181,8 +68248,8 @@ var ts;
68181
68248
  }
68182
68249
  if (source.flags & 128 /* StringLiteral */) {
68183
68250
  var value = source.value;
68184
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68185
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68251
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68252
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68186
68253
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68187
68254
  }
68188
68255
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68593,8 +68660,8 @@ var ts;
68593
68660
  }
68594
68661
  function getSingleTypeVariableFromIntersectionTypes(types) {
68595
68662
  var typeVariable;
68596
- for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
68597
- var type = types_15[_i];
68663
+ for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
68664
+ var type = types_14[_i];
68598
68665
  var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
68599
68666
  if (!t || typeVariable && t !== typeVariable) {
68600
68667
  return undefined;
@@ -68755,8 +68822,57 @@ var ts;
68755
68822
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68756
68823
  // succeed. That would be a pointless and confusing outcome.
68757
68824
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68825
+ var _loop_23 = function (i) {
68826
+ var source_1 = matches ? matches[i] : neverType;
68827
+ var target_3 = types[i];
68828
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68829
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68830
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68831
+ var inferenceContext = getInferenceInfoForType(target_3);
68832
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68833
+ if (constraint && !isTypeAny(constraint)) {
68834
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68835
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68836
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68837
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68838
+ var str_1 = source_1.value;
68839
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68840
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68841
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68842
+ }
68843
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68844
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68845
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68846
+ }
68847
+ // for each type in the constraint, find the highest priority matching type
68848
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68849
+ return !(right.flags & allTypeFlags_1) ? left :
68850
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68851
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68852
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68853
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68854
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68855
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68856
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68857
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68858
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68859
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68860
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68861
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68862
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68863
+ left;
68864
+ }, neverType);
68865
+ if (!(matchingType.flags & 131072 /* Never */)) {
68866
+ inferFromTypes(matchingType, target_3);
68867
+ return "continue";
68868
+ }
68869
+ }
68870
+ }
68871
+ }
68872
+ inferFromTypes(source_1, target_3);
68873
+ };
68758
68874
  for (var i = 0; i < types.length; i++) {
68759
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68875
+ _loop_23(i);
68760
68876
  }
68761
68877
  }
68762
68878
  }
@@ -69274,7 +69390,7 @@ var ts;
69274
69390
  function mapTypesByKeyProperty(types, name) {
69275
69391
  var map = new ts.Map();
69276
69392
  var count = 0;
69277
- var _loop_23 = function (type) {
69393
+ var _loop_24 = function (type) {
69278
69394
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69279
69395
  var discriminant = getTypeOfPropertyOfType(type, name);
69280
69396
  if (discriminant) {
@@ -69298,9 +69414,9 @@ var ts;
69298
69414
  }
69299
69415
  }
69300
69416
  };
69301
- for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69302
- var type = types_16[_i];
69303
- var state_9 = _loop_23(type);
69417
+ for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
69418
+ var type = types_15[_i];
69419
+ var state_9 = _loop_24(type);
69304
69420
  if (typeof state_9 === "object")
69305
69421
  return state_9.value;
69306
69422
  }
@@ -69414,14 +69530,16 @@ var ts;
69414
69530
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
69415
69531
  resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
69416
69532
  }
69417
- function getTypeFacts(type, ignoreObjects) {
69418
- if (ignoreObjects === void 0) { ignoreObjects = false; }
69533
+ function getTypeFacts(type) {
69534
+ if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
69535
+ type = getBaseConstraintOfType(type) || unknownType;
69536
+ }
69419
69537
  var flags = type.flags;
69420
- if (flags & 4 /* String */) {
69538
+ if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
69421
69539
  return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
69422
69540
  }
69423
- if (flags & 128 /* StringLiteral */) {
69424
- var isEmpty = type.value === "";
69541
+ if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
69542
+ var isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
69425
69543
  return strictNullChecks ?
69426
69544
  isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ :
69427
69545
  isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
@@ -69453,20 +69571,20 @@ var ts;
69453
69571
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
69454
69572
  }
69455
69573
  if (flags & 524288 /* Object */) {
69456
- if (ignoreObjects) {
69457
- return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
69458
- }
69459
69574
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
69460
- strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
69575
+ strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ :
69461
69576
  isFunctionObjectType(type) ?
69462
69577
  strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ :
69463
69578
  strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
69464
69579
  }
69465
- if (flags & (16384 /* Void */ | 32768 /* Undefined */)) {
69466
- return 9830144 /* UndefinedFacts */;
69580
+ if (flags & 16384 /* Void */) {
69581
+ return 9830144 /* VoidFacts */;
69582
+ }
69583
+ if (flags & 32768 /* Undefined */) {
69584
+ return 26607360 /* UndefinedFacts */;
69467
69585
  }
69468
69586
  if (flags & 65536 /* Null */) {
69469
- return 9363232 /* NullFacts */;
69587
+ return 42917664 /* NullFacts */;
69470
69588
  }
69471
69589
  if (flags & 12288 /* ESSymbolLike */) {
69472
69590
  return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
@@ -69477,37 +69595,56 @@ var ts;
69477
69595
  if (flags & 131072 /* Never */) {
69478
69596
  return 0 /* None */;
69479
69597
  }
69480
- if (flags & 465829888 /* Instantiable */) {
69481
- return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
69482
- strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */;
69483
- }
69484
69598
  if (flags & 1048576 /* Union */) {
69485
- return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */);
69599
+ return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */);
69486
69600
  }
69487
69601
  if (flags & 2097152 /* Intersection */) {
69488
- // When an intersection contains a primitive type we ignore object type constituents as they are
69489
- // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69490
- ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
69491
- return getIntersectionTypeFacts(type, ignoreObjects);
69602
+ return getIntersectionTypeFacts(type);
69492
69603
  }
69493
- return 16777215 /* All */;
69604
+ return 83886079 /* UnknownFacts */;
69494
69605
  }
69495
- function getIntersectionTypeFacts(type, ignoreObjects) {
69606
+ function getIntersectionTypeFacts(type) {
69607
+ // When an intersection contains a primitive type we ignore object type constituents as they are
69608
+ // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69609
+ var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */);
69496
69610
  // When computing the type facts of an intersection type, certain type facts are computed as `and`
69497
69611
  // and others are computed as `or`.
69498
69612
  var oredFacts = 0 /* None */;
69499
- var andedFacts = 16777215 /* All */;
69613
+ var andedFacts = 134217727 /* All */;
69500
69614
  for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
69501
69615
  var t = _a[_i];
69502
- var f = getTypeFacts(t, ignoreObjects);
69503
- oredFacts |= f;
69504
- andedFacts &= f;
69616
+ if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
69617
+ var f = getTypeFacts(t);
69618
+ oredFacts |= f;
69619
+ andedFacts &= f;
69620
+ }
69505
69621
  }
69506
- return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
69622
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
69507
69623
  }
69508
69624
  function getTypeWithFacts(type, include) {
69509
69625
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69510
69626
  }
69627
+ // This function is similar to getTypeWithFacts, except that in strictNullChecks mode it replaces type
69628
+ // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining
69629
+ // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined.
69630
+ function getAdjustedTypeWithFacts(type, facts) {
69631
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69632
+ if (strictNullChecks) {
69633
+ switch (facts) {
69634
+ case 524288 /* NEUndefined */:
69635
+ 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; });
69636
+ case 1048576 /* NENull */:
69637
+ 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; });
69638
+ case 2097152 /* NEUndefinedOrNull */:
69639
+ case 4194304 /* Truthy */:
69640
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69641
+ }
69642
+ }
69643
+ return reduced;
69644
+ }
69645
+ function recombineUnknownType(type) {
69646
+ return type === unknownUnionType ? unknownType : type;
69647
+ }
69511
69648
  function getTypeWithDefault(type, defaultExpression) {
69512
69649
  return defaultExpression ?
69513
69650
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -69756,8 +69893,8 @@ var ts;
69756
69893
  var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
69757
69894
  var mappedTypes;
69758
69895
  var changed = false;
69759
- for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69760
- var t = types_17[_i];
69896
+ for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69897
+ var t = types_16[_i];
69761
69898
  var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t);
69762
69899
  changed || (changed = t !== mapped);
69763
69900
  if (mapped) {
@@ -69843,8 +69980,8 @@ var ts;
69843
69980
  }
69844
69981
  function isEvolvingArrayTypeList(types) {
69845
69982
  var hasEvolvingArrayType = false;
69846
- for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
69847
- var t = types_18[_i];
69983
+ for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69984
+ var t = types_17[_i];
69848
69985
  if (!(t.flags & 131072 /* Never */)) {
69849
69986
  if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) {
69850
69987
  return false;
@@ -70565,7 +70702,7 @@ var ts;
70565
70702
  if (isEvolvingArrayTypeList(types)) {
70566
70703
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70567
70704
  }
70568
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70705
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70569
70706
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70570
70707
  return declaredType;
70571
70708
  }
@@ -70667,11 +70804,10 @@ var ts;
70667
70804
  }
70668
70805
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70669
70806
  if (isMatchingReference(reference, expr)) {
70670
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70671
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70807
+ return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70672
70808
  }
70673
70809
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70674
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70810
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70675
70811
  }
70676
70812
  var access = getDiscriminantPropertyAccess(expr, type);
70677
70813
  if (access) {
@@ -70811,7 +70947,7 @@ var ts;
70811
70947
  // Note that we include any and unknown in the exclusion test because their domain includes null and undefined.
70812
70948
  var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
70813
70949
  equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); });
70814
- return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
70950
+ return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
70815
70951
  }
70816
70952
  function narrowTypeByEquality(type, operator, value, assumeTrue) {
70817
70953
  if (type.flags & 1 /* Any */) {
@@ -70821,9 +70957,6 @@ var ts;
70821
70957
  assumeTrue = !assumeTrue;
70822
70958
  }
70823
70959
  var valueType = getTypeOfExpression(value);
70824
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
70825
- return getUnionType([nullType, undefinedType]);
70826
- }
70827
70960
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
70828
70961
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
70829
70962
  return valueType;
@@ -70843,7 +70976,7 @@ var ts;
70843
70976
  valueType.flags & 65536 /* Null */ ?
70844
70977
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
70845
70978
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
70846
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
70979
+ return getAdjustedTypeWithFacts(type, facts);
70847
70980
  }
70848
70981
  if (assumeTrue) {
70849
70982
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -70864,24 +70997,18 @@ var ts;
70864
70997
  var target = getReferenceCandidate(typeOfExpr.expression);
70865
70998
  if (!isMatchingReference(reference, target)) {
70866
70999
  if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
70867
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71000
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70868
71001
  }
70869
71002
  return type;
70870
71003
  }
70871
71004
  if (type.flags & 1 /* Any */ && literal.text === "function") {
70872
71005
  return type;
70873
71006
  }
70874
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
70875
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
70876
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
70877
- // unknown type, and then narrows that to the non-primitive type.
70878
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
70879
- }
70880
71007
  var facts = assumeTrue ?
70881
71008
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
70882
71009
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
70883
71010
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
70884
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71011
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
70885
71012
  }
70886
71013
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
70887
71014
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -70930,10 +71057,10 @@ var ts;
70930
71057
  }
70931
71058
  function getImpliedTypeFromTypeofGuard(type, text) {
70932
71059
  switch (text) {
71060
+ case "object":
71061
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
70933
71062
  case "function":
70934
71063
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
70935
- case "object":
70936
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
70937
71064
  default:
70938
71065
  return typeofTypesByName.get(text);
70939
71066
  }
@@ -70944,22 +71071,27 @@ var ts;
70944
71071
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
70945
71072
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
70946
71073
  // filtering by type-facts.
70947
- function narrowUnionMemberByTypeof(candidate) {
70948
- return function (type) {
70949
- if (isTypeSubtypeOf(type, candidate)) {
70950
- return type;
70951
- }
70952
- if (isTypeSubtypeOf(candidate, type)) {
70953
- return candidate;
71074
+ function narrowTypeByImpliedType(type, candidate) {
71075
+ if (type.flags & 3 /* AnyOrUnknown */) {
71076
+ return candidate;
71077
+ }
71078
+ return mapType(type, function (t) {
71079
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71080
+ return t;
70954
71081
  }
70955
- if (type.flags & 465829888 /* Instantiable */) {
70956
- var constraint = getBaseConstraintOfType(type) || anyType;
70957
- if (isTypeSubtypeOf(candidate, constraint)) {
70958
- return getIntersectionType([type, candidate]);
71082
+ return mapType(candidate, function (c) {
71083
+ if (!areTypesComparable(t, c)) {
71084
+ return neverType;
70959
71085
  }
70960
- }
70961
- return type;
70962
- };
71086
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71087
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71088
+ }
71089
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71090
+ return c;
71091
+ }
71092
+ return getIntersectionType([t, c]);
71093
+ });
71094
+ });
70963
71095
  }
70964
71096
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
70965
71097
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71018,7 +71150,7 @@ var ts;
71018
71150
  because it is caught in the first clause.
71019
71151
  */
71020
71152
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71021
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71153
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71022
71154
  }
71023
71155
  function isMatchingConstructorReference(expr) {
71024
71156
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71069,7 +71201,7 @@ var ts;
71069
71201
  var left = getReferenceCandidate(expr.left);
71070
71202
  if (!isMatchingReference(reference, left)) {
71071
71203
  if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
71072
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71204
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71073
71205
  }
71074
71206
  return type;
71075
71207
  }
@@ -71157,7 +71289,7 @@ var ts;
71157
71289
  }
71158
71290
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
71159
71291
  !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
71160
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71292
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71161
71293
  }
71162
71294
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
71163
71295
  if (access) {
@@ -71214,7 +71346,7 @@ var ts;
71214
71346
  }
71215
71347
  function narrowTypeByOptionality(type, expr, assumePresent) {
71216
71348
  if (isMatchingReference(reference, expr)) {
71217
- return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71349
+ return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71218
71350
  }
71219
71351
  var access = getDiscriminantPropertyAccess(expr, type);
71220
71352
  if (access) {
@@ -71300,8 +71432,8 @@ var ts;
71300
71432
  var annotationIncludesUndefined = strictNullChecks &&
71301
71433
  declaration.kind === 164 /* Parameter */ &&
71302
71434
  declaration.initializer &&
71303
- getFalsyFlags(declaredType) & 32768 /* Undefined */ &&
71304
- !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */);
71435
+ getTypeFacts(declaredType) & 16777216 /* IsUndefined */ &&
71436
+ !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */);
71305
71437
  popTypeResolution();
71306
71438
  return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
71307
71439
  }
@@ -71322,7 +71454,9 @@ var ts;
71322
71454
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71323
71455
  }
71324
71456
  function isGenericTypeWithUnionConstraint(type) {
71325
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71457
+ return type.flags & 2097152 /* Intersection */ ?
71458
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71459
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71326
71460
  }
71327
71461
  function isGenericTypeWithoutNullableConstraint(type) {
71328
71462
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71350,7 +71484,7 @@ var ts;
71350
71484
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71351
71485
  someType(type, isGenericTypeWithUnionConstraint) &&
71352
71486
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71353
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71487
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71354
71488
  }
71355
71489
  function isExportOrExportExpression(location) {
71356
71490
  return !!ts.findAncestor(location, function (n) {
@@ -71627,7 +71761,7 @@ var ts;
71627
71761
  return convertAutoToAny(flowType);
71628
71762
  }
71629
71763
  }
71630
- else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
71764
+ else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
71631
71765
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
71632
71766
  // Return the declared type to reduce follow-on errors
71633
71767
  return type;
@@ -73156,8 +73290,8 @@ var ts;
73156
73290
  }
73157
73291
  var signatureList;
73158
73292
  var types = type.types;
73159
- for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
73160
- var current = types_19[_i];
73293
+ for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
73294
+ var current = types_18[_i];
73161
73295
  var signature = getContextualCallSignature(current, node);
73162
73296
  if (signature) {
73163
73297
  if (!signatureList) {
@@ -74319,19 +74453,19 @@ var ts;
74319
74453
  return checkNonNullType(checkExpression(node), node);
74320
74454
  }
74321
74455
  function isNullableType(type) {
74322
- return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */);
74456
+ return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
74323
74457
  }
74324
74458
  function getNonNullableTypeIfNeeded(type) {
74325
74459
  return isNullableType(type) ? getNonNullableType(type) : type;
74326
74460
  }
74327
- function reportObjectPossiblyNullOrUndefinedError(node, flags) {
74328
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74461
+ function reportObjectPossiblyNullOrUndefinedError(node, facts) {
74462
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74329
74463
  ts.Diagnostics.Object_is_possibly_null_or_undefined :
74330
74464
  ts.Diagnostics.Object_is_possibly_undefined :
74331
74465
  ts.Diagnostics.Object_is_possibly_null);
74332
74466
  }
74333
- function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
74334
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74467
+ function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) {
74468
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74335
74469
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
74336
74470
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
74337
74471
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
@@ -74341,9 +74475,9 @@ var ts;
74341
74475
  error(node, ts.Diagnostics.Object_is_of_type_unknown);
74342
74476
  return errorType;
74343
74477
  }
74344
- var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */;
74345
- if (kind) {
74346
- reportError(node, kind);
74478
+ var facts = getTypeFacts(type);
74479
+ if (facts & 50331648 /* IsUndefinedOrNull */) {
74480
+ reportError(node, facts);
74347
74481
  var t = getNonNullableType(type);
74348
74482
  return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
74349
74483
  }
@@ -74638,7 +74772,7 @@ var ts;
74638
74772
  assumeUninitialized = true;
74639
74773
  }
74640
74774
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
74641
- if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
74775
+ if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
74642
74776
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
74643
74777
  // Return the declared type to reduce follow-on errors
74644
74778
  return propType;
@@ -75688,7 +75822,7 @@ var ts;
75688
75822
  if (spreadIndex >= 0) {
75689
75823
  // Create synthetic arguments from spreads of tuple types.
75690
75824
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75691
- var _loop_24 = function (i) {
75825
+ var _loop_25 = function (i) {
75692
75826
  var arg = args[i];
75693
75827
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75694
75828
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75705,7 +75839,7 @@ var ts;
75705
75839
  }
75706
75840
  };
75707
75841
  for (var i = spreadIndex; i < args.length; i++) {
75708
- _loop_24(i);
75842
+ _loop_25(i);
75709
75843
  }
75710
75844
  return effectiveArgs_1;
75711
75845
  }
@@ -76025,7 +76159,7 @@ var ts;
76025
76159
  var min_3 = Number.MAX_VALUE;
76026
76160
  var minIndex = 0;
76027
76161
  var i_1 = 0;
76028
- var _loop_25 = function (c) {
76162
+ var _loop_26 = function (c) {
76029
76163
  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)); };
76030
76164
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76031
76165
  if (diags_2) {
@@ -76043,7 +76177,7 @@ var ts;
76043
76177
  };
76044
76178
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76045
76179
  var c = candidatesForArgumentError_1[_a];
76046
- _loop_25(c);
76180
+ _loop_26(c);
76047
76181
  }
76048
76182
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76049
76183
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76201,7 +76335,7 @@ var ts;
76201
76335
  }
76202
76336
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76203
76337
  var parameters = [];
76204
- var _loop_26 = function (i) {
76338
+ var _loop_27 = function (i) {
76205
76339
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76206
76340
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76207
76341
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76209,7 +76343,7 @@ var ts;
76209
76343
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76210
76344
  };
76211
76345
  for (var i = 0; i < maxNonRestParam; i++) {
76212
- _loop_26(i);
76346
+ _loop_27(i);
76213
76347
  }
76214
76348
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76215
76349
  var flags = 0 /* None */;
@@ -76554,8 +76688,8 @@ var ts;
76554
76688
  if (apparentType.flags & 1048576 /* Union */) {
76555
76689
  var types = apparentType.types;
76556
76690
  var hasSignatures = false;
76557
- for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
76558
- var constituent = types_20[_i];
76691
+ for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
76692
+ var constituent = types_19[_i];
76559
76693
  var signatures = getSignaturesOfType(constituent, kind);
76560
76694
  if (signatures.length !== 0) {
76561
76695
  hasSignatures = true;
@@ -78246,7 +78380,7 @@ var ts;
78246
78380
  var type = getTypeOfSymbol(symbol);
78247
78381
  if (strictNullChecks &&
78248
78382
  !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) &&
78249
- !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) {
78383
+ !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
78250
78384
  error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
78251
78385
  }
78252
78386
  }
@@ -78414,8 +78548,8 @@ var ts;
78414
78548
  }
78415
78549
  if (type.flags & 3145728 /* UnionOrIntersection */) {
78416
78550
  var types = type.types;
78417
- for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
78418
- var t = types_21[_i];
78551
+ for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
78552
+ var t = types_20[_i];
78419
78553
  if (maybeTypeOfKind(t, kind)) {
78420
78554
  return true;
78421
78555
  }
@@ -78642,7 +78776,7 @@ var ts;
78642
78776
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
78643
78777
  // undefined from the final type.
78644
78778
  if (strictNullChecks &&
78645
- !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) {
78779
+ !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
78646
78780
  sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
78647
78781
  }
78648
78782
  checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
@@ -79042,7 +79176,7 @@ var ts;
79042
79176
  case 56 /* BarBarToken */:
79043
79177
  case 75 /* BarBarEqualsToken */: {
79044
79178
  var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ?
79045
- getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) :
79179
+ getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) :
79046
79180
  leftType;
79047
79181
  if (operator === 75 /* BarBarEqualsToken */) {
79048
79182
  checkAssignmentOperator(rightType);
@@ -80266,7 +80400,7 @@ var ts;
80266
80400
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80267
80401
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80268
80402
  var indexSignatureMap_1 = new ts.Map();
80269
- var _loop_27 = function (declaration) {
80403
+ var _loop_28 = function (declaration) {
80270
80404
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80271
80405
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80272
80406
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80281,7 +80415,7 @@ var ts;
80281
80415
  };
80282
80416
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80283
80417
  var declaration = _a[_i];
80284
- _loop_27(declaration);
80418
+ _loop_28(declaration);
80285
80419
  }
80286
80420
  indexSignatureMap_1.forEach(function (entry) {
80287
80421
  if (entry.declarations.length > 1) {
@@ -81583,8 +81717,8 @@ var ts;
81583
81717
  }
81584
81718
  function getEntityNameForDecoratorMetadataFromTypeList(types) {
81585
81719
  var commonEntityName;
81586
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
81587
- var typeNode = types_22[_i];
81720
+ for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
81721
+ var typeNode = types_21[_i];
81588
81722
  while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) {
81589
81723
  typeNode = typeNode.type; // Skip parens if need be
81590
81724
  }
@@ -82450,7 +82584,7 @@ var ts;
82450
82584
  // For a binding pattern, validate the initializer and exit
82451
82585
  if (ts.isBindingPattern(node.name)) {
82452
82586
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82453
- var needCheckWidenedType = node.name.elements.length === 0;
82587
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82454
82588
  if (needCheckInitializer || needCheckWidenedType) {
82455
82589
  // Don't validate for-in initializer as it is already an error
82456
82590
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -82477,7 +82611,7 @@ var ts;
82477
82611
  }
82478
82612
  // For a commonjs `const x = require`, validate the alias and exit
82479
82613
  var symbol = getSymbolOfNode(node);
82480
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82614
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82481
82615
  checkAliasSymbol(node);
82482
82616
  return;
82483
82617
  }
@@ -82603,7 +82737,7 @@ var ts;
82603
82737
  return;
82604
82738
  var type = checkTruthinessExpression(location);
82605
82739
  var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
82606
- if (getFalsyFlags(type) || isPropertyExpressionCast)
82740
+ if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
82607
82741
  return;
82608
82742
  // While it technically should be invalid for any known-truthy value
82609
82743
  // to be tested, we de-scope to functions and Promises unreferenced in
@@ -83742,7 +83876,7 @@ var ts;
83742
83876
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83743
83877
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83744
83878
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83745
- var _loop_28 = function (info) {
83879
+ var _loop_29 = function (info) {
83746
83880
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83747
83881
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83748
83882
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83755,7 +83889,7 @@ var ts;
83755
83889
  };
83756
83890
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83757
83891
  var info = indexInfos_9[_i];
83758
- _loop_28(info);
83892
+ _loop_29(info);
83759
83893
  }
83760
83894
  }
83761
83895
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83763,7 +83897,7 @@ var ts;
83763
83897
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83764
83898
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83765
83899
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83766
- var _loop_29 = function (info) {
83900
+ var _loop_30 = function (info) {
83767
83901
  if (info === checkInfo)
83768
83902
  return "continue";
83769
83903
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83778,7 +83912,7 @@ var ts;
83778
83912
  };
83779
83913
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83780
83914
  var info = indexInfos_10[_i];
83781
- _loop_29(info);
83915
+ _loop_30(info);
83782
83916
  }
83783
83917
  }
83784
83918
  function checkTypeNameIsReserved(name, message) {
@@ -84097,7 +84231,7 @@ var ts;
84097
84231
  var baseTypes = baseTypeNode && getBaseTypes(type);
84098
84232
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84099
84233
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84100
- var _loop_30 = function (member) {
84234
+ var _loop_31 = function (member) {
84101
84235
  if (ts.hasAmbientModifier(member)) {
84102
84236
  return "continue";
84103
84237
  }
@@ -84114,7 +84248,7 @@ var ts;
84114
84248
  };
84115
84249
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84116
84250
  var member = _a[_i];
84117
- _loop_30(member);
84251
+ _loop_31(member);
84118
84252
  }
84119
84253
  }
84120
84254
  /**
@@ -84202,7 +84336,7 @@ var ts;
84202
84336
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84203
84337
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84204
84338
  var issuedMemberError = false;
84205
- var _loop_31 = function (member) {
84339
+ var _loop_32 = function (member) {
84206
84340
  if (ts.isStatic(member)) {
84207
84341
  return "continue";
84208
84342
  }
@@ -84221,7 +84355,7 @@ var ts;
84221
84355
  };
84222
84356
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84223
84357
  var member = _a[_i];
84224
- _loop_31(member);
84358
+ _loop_32(member);
84225
84359
  }
84226
84360
  if (!issuedMemberError) {
84227
84361
  // check again with diagnostics to generate a less-specific error
@@ -84289,18 +84423,17 @@ var ts;
84289
84423
  // but not by other kinds of members.
84290
84424
  // Base class instance member variables and accessors can be overridden by
84291
84425
  // derived class instance member variables and accessors, but not by other kinds of members.
84292
- var _a, _b;
84426
+ var _a, _b, _c, _d;
84293
84427
  // NOTE: assignability is checked in checkClassDeclaration
84294
84428
  var baseProperties = getPropertiesOfType(baseType);
84295
- basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84296
- var baseProperty = baseProperties_1[_i];
84429
+ var _loop_33 = function (baseProperty) {
84297
84430
  var base = getTargetSymbol(baseProperty);
84298
84431
  if (base.flags & 4194304 /* Prototype */) {
84299
- continue;
84432
+ return "continue";
84300
84433
  }
84301
84434
  var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
84302
84435
  if (!baseSymbol) {
84303
- continue;
84436
+ return "continue";
84304
84437
  }
84305
84438
  var derived = getTargetSymbol(baseSymbol);
84306
84439
  var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
@@ -84318,14 +84451,14 @@ var ts;
84318
84451
  // Searches other base types for a declaration that would satisfy the inherited abstract member.
84319
84452
  // (The class may have more than one base type via declaration merging with an interface with the
84320
84453
  // same name.)
84321
- for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) {
84322
- var otherBaseType = _d[_c];
84454
+ for (var _e = 0, _f = getBaseTypes(type); _e < _f.length; _e++) {
84455
+ var otherBaseType = _f[_e];
84323
84456
  if (otherBaseType === baseType)
84324
84457
  continue;
84325
84458
  var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
84326
84459
  var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
84327
84460
  if (derivedElsewhere && derivedElsewhere !== base) {
84328
- continue basePropertyCheck;
84461
+ return "continue-basePropertyCheck";
84329
84462
  }
84330
84463
  }
84331
84464
  if (derivedClassDecl.kind === 226 /* ClassExpression */) {
@@ -84340,20 +84473,19 @@ var ts;
84340
84473
  // derived overrides base.
84341
84474
  var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
84342
84475
  if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) {
84343
- // either base or derived property is private - not override, skip it
84344
- continue;
84476
+ return "continue";
84345
84477
  }
84346
84478
  var errorMessage = void 0;
84347
84479
  var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */;
84348
84480
  var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */;
84349
84481
  if (basePropertyFlags && derivedPropertyFlags) {
84350
84482
  // property/accessor is overridden with property/accessor
84351
- if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
84352
- || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */
84483
+ if ((ts.getCheckFlags(base) & 6 /* Synthetic */
84484
+ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })
84485
+ : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }))
84486
+ || ts.getCheckFlags(base) & 262144 /* Mapped */
84353
84487
  || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
84354
- // when the base property is abstract or from an interface, base/derived flags don't need to match
84355
- // same when the derived property is from an assignment
84356
- continue;
84488
+ return "continue";
84357
84489
  }
84358
84490
  var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */;
84359
84491
  var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */;
@@ -84364,12 +84496,12 @@ var ts;
84364
84496
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
84365
84497
  }
84366
84498
  else if (useDefineForClassFields) {
84367
- var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84499
+ var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84368
84500
  if (uninitialized
84369
84501
  && !(derived.flags & 33554432 /* Transient */)
84370
84502
  && !(baseDeclarationFlags & 128 /* Abstract */)
84371
84503
  && !(derivedDeclarationFlags & 128 /* Abstract */)
84372
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84504
+ && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84373
84505
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
84374
84506
  var propName = uninitialized.name;
84375
84507
  if (uninitialized.exclamationToken
@@ -84382,13 +84514,11 @@ var ts;
84382
84514
  }
84383
84515
  }
84384
84516
  }
84385
- // correct case
84386
- continue;
84517
+ return "continue";
84387
84518
  }
84388
84519
  else if (isPrototypeProperty(base)) {
84389
84520
  if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) {
84390
- // method is overridden with method or property -- correct case
84391
- continue;
84521
+ return "continue";
84392
84522
  }
84393
84523
  else {
84394
84524
  ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */));
@@ -84403,9 +84533,20 @@ var ts;
84403
84533
  }
84404
84534
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
84405
84535
  }
84536
+ };
84537
+ basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84538
+ var baseProperty = baseProperties_1[_i];
84539
+ var state_10 = _loop_33(baseProperty);
84540
+ switch (state_10) {
84541
+ case "continue-basePropertyCheck": continue basePropertyCheck;
84542
+ }
84406
84543
  }
84407
84544
  }
84408
- function getNonInterhitedProperties(type, baseTypes, properties) {
84545
+ function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) {
84546
+ return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer)
84547
+ || ts.isInterfaceDeclaration(declaration.parent);
84548
+ }
84549
+ function getNonInheritedProperties(type, baseTypes, properties) {
84409
84550
  if (!ts.length(baseTypes)) {
84410
84551
  return properties;
84411
84552
  }
@@ -84474,7 +84615,7 @@ var ts;
84474
84615
  var propName = member.name;
84475
84616
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84476
84617
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84477
- if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
84618
+ if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84478
84619
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84479
84620
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84480
84621
  }
@@ -84499,7 +84640,7 @@ var ts;
84499
84640
  ts.setParent(reference, staticBlock);
84500
84641
  reference.flowNode = staticBlock.returnFlowNode;
84501
84642
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84502
- if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) {
84643
+ if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84503
84644
  return true;
84504
84645
  }
84505
84646
  }
@@ -84514,7 +84655,7 @@ var ts;
84514
84655
  ts.setParent(reference, constructor);
84515
84656
  reference.flowNode = constructor.returnFlowNode;
84516
84657
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84517
- return !(getFalsyFlags(flowType) & 32768 /* Undefined */);
84658
+ return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84518
84659
  }
84519
84660
  function checkInterfaceDeclaration(node) {
84520
84661
  // Grammar checking
@@ -89881,9 +90022,7 @@ var ts;
89881
90022
  var ts;
89882
90023
  (function (ts) {
89883
90024
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
89884
- var _a = generatorOptions.extendedDiagnostics
89885
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
89886
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90025
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
89887
90026
  // Current source map file and its index in the sources list
89888
90027
  var rawSources = [];
89889
90028
  var sources = [];
@@ -92804,8 +92943,8 @@ var ts;
92804
92943
  // Note when updating logic here also update getEntityNameForDecoratorMetadata
92805
92944
  // so that aliases can be marked as referenced
92806
92945
  var serializedUnion;
92807
- for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
92808
- var typeNode = types_23[_i];
92946
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
92947
+ var typeNode = types_22[_i];
92809
92948
  while (typeNode.kind === 191 /* ParenthesizedType */) {
92810
92949
  typeNode = typeNode.type; // Skip parens if need be
92811
92950
  }
@@ -113420,8 +113559,8 @@ var ts;
113420
113559
  bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName });
113421
113560
  writeLine();
113422
113561
  }
113423
- for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
113424
- var directive = types_24[_d];
113562
+ for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
113563
+ var directive = types_23[_d];
113425
113564
  var pos = writer.getTextPos();
113426
113565
  var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
113427
113566
  ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
@@ -122189,7 +122328,7 @@ var ts;
122189
122328
  });
122190
122329
  // Sort by paths closest to importing file Name directory
122191
122330
  var sortedPaths = [];
122192
- var _loop_32 = function (directory) {
122331
+ var _loop_34 = function (directory) {
122193
122332
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122194
122333
  var pathsInDirectory;
122195
122334
  allFileNames.forEach(function (_a, fileName) {
@@ -122213,9 +122352,9 @@ var ts;
122213
122352
  };
122214
122353
  var out_directory_1;
122215
122354
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122216
- var state_10 = _loop_32(directory);
122355
+ var state_11 = _loop_34(directory);
122217
122356
  directory = out_directory_1;
122218
- if (state_10 === "break")
122357
+ if (state_11 === "break")
122219
122358
  break;
122220
122359
  }
122221
122360
  if (allFileNames.size) {
@@ -124159,6 +124298,7 @@ var ts;
124159
124298
  if (value) {
124160
124299
  return isParsedCommandLine(value) ? value : undefined;
124161
124300
  }
124301
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124162
124302
  var diagnostic;
124163
124303
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124164
124304
  var parsed;
@@ -124173,6 +124313,8 @@ var ts;
124173
124313
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124174
124314
  }
124175
124315
  configFileCache.set(configFilePath, parsed || diagnostic);
124316
+ ts.solutionPerformance.mark("afterParseConfigFile");
124317
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124176
124318
  return parsed;
124177
124319
  }
124178
124320
  function resolveProjectName(state, name) {
@@ -124222,6 +124364,7 @@ var ts;
124222
124364
  return state.buildOrder || createStateBuildOrder(state);
124223
124365
  }
124224
124366
  function createStateBuildOrder(state) {
124367
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124225
124368
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124226
124369
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124227
124370
  state.resolvedConfigFilePaths.clear();
@@ -124251,6 +124394,8 @@ var ts;
124251
124394
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124252
124395
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124253
124396
  }
124397
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124398
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124254
124399
  return state.buildOrder = buildOrder;
124255
124400
  }
124256
124401
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124371,6 +124516,7 @@ var ts;
124371
124516
  if (updateOutputFileStampsPending) {
124372
124517
  updateOutputTimestamps(state, config, projectPath);
124373
124518
  }
124519
+ ts.solutionPerformance.mark("timestampUpdated");
124374
124520
  return doneInvalidatedProject(state, projectPath);
124375
124521
  }
124376
124522
  };
@@ -124464,6 +124610,10 @@ var ts;
124464
124610
  };
124465
124611
  function done(cancellationToken, writeFile, customTransformers) {
124466
124612
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124613
+ if (kind === InvalidatedProjectKind.Build)
124614
+ ts.solutionPerformance.mark("projectsBuilt");
124615
+ else
124616
+ ts.solutionPerformance.mark("bundlesUpdated");
124467
124617
  return doneInvalidatedProject(state, projectPath);
124468
124618
  }
124469
124619
  function withProgramOrUndefined(action) {
@@ -124553,6 +124703,7 @@ var ts;
124553
124703
  var anyDtsChanged = false;
124554
124704
  var emitterDiagnostics = ts.createDiagnosticCollection();
124555
124705
  var emittedOutputs = new ts.Map();
124706
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124556
124707
  outputFiles.forEach(function (_a) {
124557
124708
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124558
124709
  var priorChangeTime;
@@ -124572,6 +124723,8 @@ var ts;
124572
124723
  newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124573
124724
  }
124574
124725
  });
124726
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124727
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124575
124728
  finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124576
124729
  /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124577
124730
  return emitResult;
@@ -124701,6 +124854,13 @@ var ts;
124701
124854
  !ts.isIncrementalCompilation(config.options);
124702
124855
  }
124703
124856
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124857
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
124858
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
124859
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
124860
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
124861
+ return result;
124862
+ }
124863
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124704
124864
  if (!state.projectPendingBuild.size)
124705
124865
  return undefined;
124706
124866
  if (isCircularBuildOrder(buildOrder))
@@ -124800,9 +124960,7 @@ var ts;
124800
124960
  }
124801
124961
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124802
124962
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124803
- if (!info)
124804
- return info;
124805
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
124963
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124806
124964
  }
124807
124965
  function listEmittedFile(_a, proj, file) {
124808
124966
  var write = _a.write;
@@ -124810,14 +124968,17 @@ var ts;
124810
124968
  write("TSFILE: " + file);
124811
124969
  }
124812
124970
  }
124813
- function getOldProgram(_a, proj, parsed) {
124814
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
124815
- if (options.force)
124971
+ function getOldProgram(state, proj, parsed) {
124972
+ if (state.options.force)
124816
124973
  return undefined;
124817
- var value = builderPrograms.get(proj);
124974
+ var value = state.builderPrograms.get(proj);
124818
124975
  if (value)
124819
124976
  return value;
124820
- return ts.readBuilderProgram(parsed.options, compilerHost);
124977
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
124978
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
124979
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
124980
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
124981
+ return program;
124821
124982
  }
124822
124983
  function afterProgramDone(state, program, config) {
124823
124984
  if (program) {
@@ -125016,7 +125177,10 @@ var ts;
125016
125177
  state.buildInfoChecked.set(resolvedPath, true);
125017
125178
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125018
125179
  if (buildInfoPath) {
125180
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125019
125181
  var value = state.readFileWithCache(buildInfoPath);
125182
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125183
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125020
125184
  var buildInfo = value && ts.getBuildInfo(value);
125021
125185
  if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125022
125186
  return {
@@ -125052,13 +125216,17 @@ var ts;
125052
125216
  if (prior !== undefined) {
125053
125217
  return prior;
125054
125218
  }
125219
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125055
125220
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125221
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125222
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125056
125223
  state.projectStatus.set(resolvedPath, actual);
125057
125224
  return actual;
125058
125225
  }
125059
125226
  function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125060
125227
  if (proj.options.noEmit)
125061
125228
  return priorNewestUpdateTime;
125229
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125062
125230
  var host = state.host;
125063
125231
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125064
125232
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
@@ -125079,6 +125247,8 @@ var ts;
125079
125247
  host.setModifiedTime(file, now);
125080
125248
  }
125081
125249
  }
125250
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125251
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125082
125252
  return priorNewestUpdateTime;
125083
125253
  }
125084
125254
  function updateOutputTimestamps(state, proj, resolvedPath) {
@@ -125157,6 +125327,13 @@ var ts;
125157
125327
  }
125158
125328
  }
125159
125329
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125330
+ ts.solutionPerformance.mark("beforeBuild");
125331
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125332
+ ts.solutionPerformance.mark("afterBuild");
125333
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125334
+ return result;
125335
+ }
125336
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125160
125337
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125161
125338
  if (!buildOrder)
125162
125339
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125168,7 +125345,10 @@ var ts;
125168
125345
  if (!invalidatedProject)
125169
125346
  break;
125170
125347
  reportQueue = false;
125348
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125171
125349
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125350
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125351
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125172
125352
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125173
125353
  successfulProjects++;
125174
125354
  }
@@ -125257,6 +125437,14 @@ var ts;
125257
125437
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125258
125438
  }
125259
125439
  function buildNextInvalidatedProject(state, changeDetected) {
125440
+ ts.solutionPerformance.mark("beforeBuild");
125441
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125442
+ ts.solutionPerformance.mark("afterBuild");
125443
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125444
+ if (buildOrder)
125445
+ reportErrorSummary(state, buildOrder);
125446
+ }
125447
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125260
125448
  state.timerToBuildInvalidatedProject = undefined;
125261
125449
  if (state.reportFileChangeDetected) {
125262
125450
  state.reportFileChangeDetected = false;
@@ -125267,7 +125455,10 @@ var ts;
125267
125455
  var buildOrder = getBuildOrder(state);
125268
125456
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125269
125457
  if (invalidatedProject) {
125458
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125270
125459
  invalidatedProject.done();
125460
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125461
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125271
125462
  projectsBuilt++;
125272
125463
  while (state.projectPendingBuild.size) {
125273
125464
  // If already scheduled, skip
@@ -125283,13 +125474,16 @@ var ts;
125283
125474
  return;
125284
125475
  }
125285
125476
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125477
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125286
125478
  project.done();
125479
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125480
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125287
125481
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125288
125482
  projectsBuilt++;
125289
125483
  }
125290
125484
  }
125291
125485
  disableCache(state);
125292
- reportErrorSummary(state, buildOrder);
125486
+ return buildOrder;
125293
125487
  }
125294
125488
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125295
125489
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
@@ -125346,6 +125540,7 @@ var ts;
125346
125540
  function startWatching(state, buildOrder) {
125347
125541
  if (!state.watchAllProjectsPending)
125348
125542
  return;
125543
+ ts.solutionPerformance.mark("beforeStartWatching");
125349
125544
  state.watchAllProjectsPending = false;
125350
125545
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125351
125546
  var resolved = _a[_i];
@@ -125363,6 +125558,8 @@ var ts;
125363
125558
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125364
125559
  }
125365
125560
  }
125561
+ ts.solutionPerformance.mark("afterStartWatching");
125562
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125366
125563
  }
125367
125564
  function stopWatching(state) {
125368
125565
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -136341,7 +136538,7 @@ var ts;
136341
136538
  ts.Debug.assert(parent.name === node);
136342
136539
  return true;
136343
136540
  case 203 /* BindingElement */:
136344
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136541
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136345
136542
  default:
136346
136543
  return false;
136347
136544
  }
@@ -137807,7 +138004,7 @@ var ts;
137807
138004
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137808
138005
  if (ts.isInJSFile(referenceLocation)
137809
138006
  && referenceLocation.parent.kind === 203 /* BindingElement */
137810
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138007
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137811
138008
  referenceSymbol = referenceLocation.parent.symbol;
137812
138009
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137813
138010
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -143901,7 +144098,7 @@ var ts;
143901
144098
  if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) {
143902
144099
  return;
143903
144100
  }
143904
- if (ts.isTypeNode(node)) {
144101
+ if (ts.isTypeNode(node) && !ts.isExpressionWithTypeArguments(node)) {
143905
144102
  return;
143906
144103
  }
143907
144104
  if (preferences.includeInlayVariableTypeHints && ts.isVariableDeclaration(node)) {
@@ -147012,7 +147209,6 @@ var ts;
147012
147209
  case 280 /* JsxOpeningElement */:
147013
147210
  case 281 /* JsxClosingElement */:
147014
147211
  case 279 /* JsxSelfClosingElement */:
147015
- case 228 /* ExpressionWithTypeArguments */:
147016
147212
  return false;
147017
147213
  }
147018
147214
  break;
@@ -147182,12 +147378,10 @@ var ts;
147182
147378
  var listEndToken = getCloseTokenForOpenToken(listStartToken);
147183
147379
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147184
147380
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147185
- if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147186
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147187
- if (startLine !== commaTokenLine) {
147188
- formattingScanner.advance();
147189
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147190
- }
147381
+ if (tokenInfo.token.kind === 27 /* CommaToken */) {
147382
+ // consume the comma
147383
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147384
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147191
147385
  }
147192
147386
  // consume the list end token only if it is still belong to the parent
147193
147387
  // there might be the case when current token matches end token but does not considered as one
@@ -147588,6 +147782,12 @@ var ts;
147588
147782
  case 169 /* MethodDeclaration */:
147589
147783
  case 168 /* MethodSignature */:
147590
147784
  case 214 /* ArrowFunction */:
147785
+ case 174 /* CallSignature */:
147786
+ case 175 /* ConstructSignature */:
147787
+ case 179 /* FunctionType */:
147788
+ case 180 /* ConstructorType */:
147789
+ case 172 /* GetAccessor */:
147790
+ case 173 /* SetAccessor */:
147591
147791
  if (node.typeParameters === list) {
147592
147792
  return 29 /* LessThanToken */;
147593
147793
  }
@@ -147604,7 +147804,19 @@ var ts;
147604
147804
  return 20 /* OpenParenToken */;
147605
147805
  }
147606
147806
  break;
147807
+ case 257 /* ClassDeclaration */:
147808
+ case 226 /* ClassExpression */:
147809
+ case 258 /* InterfaceDeclaration */:
147810
+ case 259 /* TypeAliasDeclaration */:
147811
+ if (node.typeParameters === list) {
147812
+ return 29 /* LessThanToken */;
147813
+ }
147814
+ break;
147607
147815
  case 178 /* TypeReference */:
147816
+ case 210 /* TaggedTemplateExpression */:
147817
+ case 181 /* TypeQuery */:
147818
+ case 228 /* ExpressionWithTypeArguments */:
147819
+ case 200 /* ImportType */:
147608
147820
  if (node.typeArguments === list) {
147609
147821
  return 29 /* LessThanToken */;
147610
147822
  }
@@ -174893,6 +175105,7 @@ var ts;
174893
175105
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174894
175106
  }
174895
175107
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
175108
+ var _a;
174896
175109
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174897
175110
  /*isForRename*/ false, function (project, position) {
174898
175111
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -174912,7 +175125,7 @@ var ts;
174912
175125
  // have started the other project searches from related symbols. Propagate the
174913
175126
  // correct results to all other projects.
174914
175127
  var defaultProjectResults = perProjectResults.get(defaultProject);
174915
- if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175128
+ if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
174916
175129
  // Clear all isDefinition properties
174917
175130
  perProjectResults.forEach(function (projectResults) {
174918
175131
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -174929,8 +175142,8 @@ var ts;
174929
175142
  var knownSymbolSpans_1 = createDocumentSpanSet();
174930
175143
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
174931
175144
  var referencedSymbol = defaultProjectResults_1[_i];
174932
- for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174933
- var ref = _b[_a];
175145
+ for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
175146
+ var ref = _c[_b];
174934
175147
  if (ref.isDefinition) {
174935
175148
  knownSymbolSpans_1.add(ref);
174936
175149
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -175090,11 +175303,9 @@ var ts;
175090
175303
  // it easier for the caller to skip post-processing.
175091
175304
  if (searchedProjects.size === 1) {
175092
175305
  var it = resultsMap.values().next();
175093
- ts.Debug.assert(!it.done);
175094
- return it.value;
175306
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175095
175307
  }
175096
175308
  return resultsMap;
175097
- // May enqueue to otherPositionQueue
175098
175309
  function searchPosition(project, location) {
175099
175310
  var projectResults = getResultsForPosition(project, location);
175100
175311
  if (!projectResults)