@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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220601";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -3704,16 +3704,34 @@ var ts;
3704
3704
  /** Performance measurements for the compiler. */
3705
3705
  var ts;
3706
3706
  (function (ts) {
3707
- var performance;
3708
- (function (performance) {
3707
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3708
+ ts.performance = createPerformanceTracker();
3709
+ ts.solutionPerformance = createPerformanceTracker();
3710
+ function createPerformanceTracker() {
3709
3711
  var perfHooks;
3710
3712
  // when set, indicates the implementation of `Performance` to use for user timing.
3711
3713
  // when unset, indicates user timing is unavailable or disabled.
3712
3714
  var performanceImpl;
3715
+ var enabled = false;
3716
+ var timeorigin = ts.timestamp();
3717
+ var marks = new ts.Map();
3718
+ var counts = new ts.Map();
3719
+ var durations = new ts.Map();
3720
+ return {
3721
+ createTimerIf: createTimerIf,
3722
+ createTimer: createTimer,
3723
+ mark: mark,
3724
+ measure: measure,
3725
+ getCount: getCount,
3726
+ getDuration: getDuration,
3727
+ forEachMeasure: forEachMeasure,
3728
+ isEnabled: isEnabled,
3729
+ enable: enable,
3730
+ disable: disable,
3731
+ };
3713
3732
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3714
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3733
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3715
3734
  }
3716
- performance.createTimerIf = createTimerIf;
3717
3735
  function createTimer(measureName, startMarkName, endMarkName) {
3718
3736
  var enterCount = 0;
3719
3737
  return {
@@ -3735,13 +3753,6 @@ var ts;
3735
3753
  }
3736
3754
  }
3737
3755
  }
3738
- performance.createTimer = createTimer;
3739
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3740
- var enabled = false;
3741
- var timeorigin = ts.timestamp();
3742
- var marks = new ts.Map();
3743
- var counts = new ts.Map();
3744
- var durations = new ts.Map();
3745
3756
  /**
3746
3757
  * Marks a performance event.
3747
3758
  *
@@ -3756,7 +3767,6 @@ var ts;
3756
3767
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3757
3768
  }
3758
3769
  }
3759
- performance.mark = mark;
3760
3770
  /**
3761
3771
  * Adds a performance measurement with the specified name.
3762
3772
  *
@@ -3769,14 +3779,13 @@ var ts;
3769
3779
  function measure(measureName, startMarkName, endMarkName) {
3770
3780
  var _a, _b;
3771
3781
  if (enabled) {
3772
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3773
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3782
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3783
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3774
3784
  var previousDuration = durations.get(measureName) || 0;
3775
3785
  durations.set(measureName, previousDuration + (end - start));
3776
3786
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3777
3787
  }
3778
3788
  }
3779
- performance.measure = measure;
3780
3789
  /**
3781
3790
  * Gets the number of times a marker was encountered.
3782
3791
  *
@@ -3785,7 +3794,6 @@ var ts;
3785
3794
  function getCount(markName) {
3786
3795
  return counts.get(markName) || 0;
3787
3796
  }
3788
- performance.getCount = getCount;
3789
3797
  /**
3790
3798
  * Gets the total duration of all measurements with the supplied name.
3791
3799
  *
@@ -3794,7 +3802,6 @@ var ts;
3794
3802
  function getDuration(measureName) {
3795
3803
  return durations.get(measureName) || 0;
3796
3804
  }
3797
- performance.getDuration = getDuration;
3798
3805
  /**
3799
3806
  * Iterate over each measure, performing some action
3800
3807
  *
@@ -3803,14 +3810,12 @@ var ts;
3803
3810
  function forEachMeasure(cb) {
3804
3811
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3805
3812
  }
3806
- performance.forEachMeasure = forEachMeasure;
3807
3813
  /**
3808
3814
  * Indicates whether the performance API is enabled.
3809
3815
  */
3810
3816
  function isEnabled() {
3811
3817
  return enabled;
3812
3818
  }
3813
- performance.isEnabled = isEnabled;
3814
3819
  /** Enables (and resets) performance measurements for the compiler. */
3815
3820
  function enable(system) {
3816
3821
  var _a;
@@ -3831,7 +3836,6 @@ var ts;
3831
3836
  }
3832
3837
  return true;
3833
3838
  }
3834
- performance.enable = enable;
3835
3839
  /** Disables performance measurements for the compiler. */
3836
3840
  function disable() {
3837
3841
  if (enabled) {
@@ -3842,8 +3846,7 @@ var ts;
3842
3846
  enabled = false;
3843
3847
  }
3844
3848
  }
3845
- performance.disable = disable;
3846
- })(performance = ts.performance || (ts.performance = {}));
3849
+ }
3847
3850
  })(ts || (ts = {}));
3848
3851
  /* @internal */
3849
3852
  var ts;
@@ -5295,6 +5298,11 @@ var ts;
5295
5298
  // Flags that require TypeFlags.Union
5296
5299
  /* @internal */
5297
5300
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5301
+ /* @internal */
5302
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5303
+ /* @internal */
5304
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5305
+ /* @internal */
5298
5306
  // Flags that require TypeFlags.Intersection
5299
5307
  /* @internal */
5300
5308
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -6513,7 +6521,7 @@ var ts;
6513
6521
  */
6514
6522
  /*@internal*/
6515
6523
  function createDirectoryWatcherSupportingRecursive(_a) {
6516
- 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;
6524
+ 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;
6517
6525
  var cache = new ts.Map();
6518
6526
  var callbackCache = ts.createMultiMap();
6519
6527
  var cacheToUpdateChildWatches = new ts.Map();
@@ -6613,7 +6621,7 @@ var ts;
6613
6621
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
6614
6622
  // Iterate through existing children and update the watches if needed
6615
6623
  var parentWatcher = cache.get(dirPath);
6616
- if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
6624
+ if (parentWatcher && directoryExists(dirName)) {
6617
6625
  // Schedule the update and postpone invoke for callbacks
6618
6626
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
6619
6627
  return;
@@ -6686,7 +6694,7 @@ var ts;
6686
6694
  if (!parentWatcher)
6687
6695
  return false;
6688
6696
  var newChildWatches;
6689
- var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6697
+ var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
6690
6698
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
6691
6699
  // Filter our the symbolic link directories since those arent included in recursive watch
6692
6700
  // which is same behaviour when recursive: true is passed to fs.watch
@@ -6732,10 +6740,10 @@ var ts;
6732
6740
  return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
6733
6741
  }
6734
6742
  ts.createFileWatcherCallback = createFileWatcherCallback;
6735
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists) {
6743
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
6736
6744
  return function (eventName) {
6737
6745
  if (eventName === "rename") {
6738
- callback(fileName, fileSystemEntryExists(fileName, 0 /* File */) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6746
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
6739
6747
  }
6740
6748
  else {
6741
6749
  // Change
@@ -6763,12 +6771,11 @@ var ts;
6763
6771
  }
6764
6772
  /*@internal*/
6765
6773
  function createSystemWatchFunctions(_a) {
6766
- 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;
6774
+ var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6767
6775
  var dynamicPollingWatchFile;
6768
6776
  var fixedChunkSizePollingWatchFile;
6769
6777
  var nonPollingWatchFile;
6770
6778
  var hostRecursiveDirectoryWatcher;
6771
- var hitSystemWatcherLimit = false;
6772
6779
  return {
6773
6780
  watchFile: watchFile,
6774
6781
  watchDirectory: watchDirectory
@@ -6786,7 +6793,7 @@ var ts;
6786
6793
  case ts.WatchFileKind.FixedChunkSizePolling:
6787
6794
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6788
6795
  case ts.WatchFileKind.UseFsEvents:
6789
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists),
6796
+ return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6790
6797
  /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6791
6798
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6792
6799
  if (!nonPollingWatchFile) {
@@ -6847,7 +6854,7 @@ var ts;
6847
6854
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
6848
6855
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
6849
6856
  getCurrentDirectory: getCurrentDirectory,
6850
- fileSystemEntryExists: fileSystemEntryExists,
6857
+ directoryExists: directoryExists,
6851
6858
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
6852
6859
  watchDirectory: nonRecursiveWatchDirectory,
6853
6860
  realpath: realpath,
@@ -6898,114 +6905,6 @@ var ts;
6898
6905
  };
6899
6906
  }
6900
6907
  }
6901
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
6902
- var lastDirectoryPartWithDirectorySeparator;
6903
- var lastDirectoryPart;
6904
- if (inodeWatching) {
6905
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
6906
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
6907
- }
6908
- /** Watcher for the file system entry depending on whether it is missing or present */
6909
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
6910
- watchMissingFileSystemEntry() :
6911
- watchPresentFileSystemEntry();
6912
- return {
6913
- close: function () {
6914
- // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
6915
- watcher.close();
6916
- watcher = undefined;
6917
- }
6918
- };
6919
- function updateWatcher(createWatcher) {
6920
- // If watcher is not closed, update it
6921
- if (watcher) {
6922
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
6923
- watcher.close();
6924
- watcher = createWatcher();
6925
- }
6926
- }
6927
- /**
6928
- * Watch the file or directory that is currently present
6929
- * and when the watched file or directory is deleted, switch to missing file system entry watcher
6930
- */
6931
- function watchPresentFileSystemEntry() {
6932
- if (hitSystemWatcherLimit) {
6933
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
6934
- return watchPresentFileSystemEntryWithFsWatchFile();
6935
- }
6936
- try {
6937
- var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
6938
- callbackChangingToMissingFileSystemEntry :
6939
- function (eventName, relativeFileName) {
6940
- sysLog("sysLog:: watchPresentFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6941
- callback(eventName, relativeFileName);
6942
- });
6943
- // Watch the missing file or directory or error
6944
- presentWatcher.on("error", function () {
6945
- sysLog("sysLog:: watchPresentFileSystemEntry:: on Error " + fileOrDirectory + " " + entryKind + " rename, \"\"");
6946
- callback("rename", "");
6947
- updateWatcher(watchMissingFileSystemEntry);
6948
- });
6949
- return presentWatcher;
6950
- }
6951
- catch (e) {
6952
- // Catch the exception and use polling instead
6953
- // 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
6954
- // so instead of throwing error, use fs.watchFile
6955
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
6956
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
6957
- return watchPresentFileSystemEntryWithFsWatchFile();
6958
- }
6959
- }
6960
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
6961
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + event + ":: " + relativeName + " " + inodeWatching + " " + lastDirectoryPart + " " + lastDirectoryPartWithDirectorySeparator);
6962
- if (relativeName && ts.endsWith(relativeName, "~")) {
6963
- relativeName = relativeName.slice(0, relativeName.length - 1);
6964
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: changed the relative name to " + relativeName);
6965
- }
6966
- callback(event, relativeName);
6967
- // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
6968
- // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
6969
- if (event === "rename" &&
6970
- (!relativeName ||
6971
- relativeName === lastDirectoryPart ||
6972
- ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
6973
- if (inodeWatching) {
6974
- updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
6975
- }
6976
- else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
6977
- updateWatcher(watchMissingFileSystemEntry);
6978
- }
6979
- }
6980
- }
6981
- /**
6982
- * Watch the file or directory using fs.watchFile since fs.watch threw exception
6983
- * 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
6984
- */
6985
- function watchPresentFileSystemEntryWithFsWatchFile() {
6986
- return watchFile(fileOrDirectory, createFileWatcherCallback(function (eventName, relativeFileName) {
6987
- sysLog("sysLog:: watchPresentFileSystemEntryWithFsWatchFile:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
6988
- callback(eventName, relativeFileName);
6989
- }), fallbackPollingInterval, fallbackOptions);
6990
- }
6991
- /**
6992
- * Watch the file or directory that is missing
6993
- * and switch to existing file or directory when the missing filesystem entry is created
6994
- */
6995
- function watchMissingFileSystemEntry() {
6996
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
6997
- sysLog("sysLog:: watchMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + _fileName + ":: " + eventKind);
6998
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
6999
- sysLog("sysLog:: watchMissingFileSystemEntry:: Callback :: rename, \"\" and will update the watcher");
7000
- callback("rename", "");
7001
- // Call the callback for current file or directory
7002
- // For now it could be callback for the inner directory creation,
7003
- // but just return current directory, better than current no-op
7004
- updateWatcher(watchPresentFileSystemEntry);
7005
- }
7006
- }, fallbackPollingInterval, fallbackOptions);
7007
- }
7008
- }
7009
6908
  }
7010
6909
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
7011
6910
  /**
@@ -7058,6 +6957,7 @@ var ts;
7058
6957
  }
7059
6958
  var activeSession;
7060
6959
  var profilePath = "./profile.cpuprofile";
6960
+ var hitSystemWatcherLimit = false;
7061
6961
  var Buffer = require("buffer").Buffer;
7062
6962
  var nodeVersion = getNodeMajorVersion();
7063
6963
  var isNode4OrLater = nodeVersion >= 4;
@@ -7072,21 +6972,20 @@ var ts;
7072
6972
  getModifiedTime: getModifiedTime,
7073
6973
  setTimeout: setTimeout,
7074
6974
  clearTimeout: clearTimeout,
7075
- fsWatchWorker: fsWatchWorker,
6975
+ fsWatch: fsWatch,
7076
6976
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
7077
6977
  getCurrentDirectory: getCurrentDirectory,
7078
- fileSystemEntryExists: fileSystemEntryExists,
6978
+ fileExists: fileExists,
7079
6979
  // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7080
6980
  // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7081
6981
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
6982
+ directoryExists: directoryExists,
7082
6983
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
7083
6984
  realpath: realpath,
7084
6985
  tscWatchFile: process.env.TSC_WATCHFILE,
7085
6986
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
7086
6987
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
7087
6988
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7088
- inodeWatching: isLinuxOrMacOs,
7089
- sysLog: sysLog,
7090
6989
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
7091
6990
  var nodeSystem = {
7092
6991
  args: process.argv.slice(2),
@@ -7339,11 +7238,107 @@ var ts;
7339
7238
  callback(fileName, eventKind);
7340
7239
  }
7341
7240
  }
7342
- function fsWatchWorker(fileOrDirectory, recursive, callback) {
7343
- // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7344
- // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7345
- return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
7346
- { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
7241
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
7242
+ var options;
7243
+ var lastDirectoryPartWithDirectorySeparator;
7244
+ var lastDirectoryPart;
7245
+ if (isLinuxOrMacOs) {
7246
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
7247
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
7248
+ }
7249
+ /** Watcher for the file system entry depending on whether it is missing or present */
7250
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7251
+ watchMissingFileSystemEntry() :
7252
+ watchPresentFileSystemEntry();
7253
+ return {
7254
+ close: function () {
7255
+ // Close the watcher (either existing file system entry watcher or missing file system entry watcher)
7256
+ watcher.close();
7257
+ watcher = undefined;
7258
+ }
7259
+ };
7260
+ /**
7261
+ * Invoke the callback with rename and update the watcher if not closed
7262
+ * @param createWatcher
7263
+ */
7264
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
7265
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7266
+ // Call the callback for current directory
7267
+ callback("rename", "");
7268
+ // If watcher is not closed, update it
7269
+ if (watcher) {
7270
+ watcher.close();
7271
+ watcher = createWatcher();
7272
+ }
7273
+ }
7274
+ /**
7275
+ * Watch the file or directory that is currently present
7276
+ * and when the watched file or directory is deleted, switch to missing file system entry watcher
7277
+ */
7278
+ function watchPresentFileSystemEntry() {
7279
+ // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
7280
+ // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
7281
+ if (options === undefined) {
7282
+ if (fsSupportsRecursiveFsWatch) {
7283
+ options = { persistent: true, recursive: !!recursive };
7284
+ }
7285
+ else {
7286
+ options = { persistent: true };
7287
+ }
7288
+ }
7289
+ if (hitSystemWatcherLimit) {
7290
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7291
+ return watchPresentFileSystemEntryWithFsWatchFile();
7292
+ }
7293
+ try {
7294
+ var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
7295
+ callbackChangingToMissingFileSystemEntry :
7296
+ callback);
7297
+ // Watch the missing file or directory or error
7298
+ presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
7299
+ return presentWatcher;
7300
+ }
7301
+ catch (e) {
7302
+ // Catch the exception and use polling instead
7303
+ // 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
7304
+ // so instead of throwing error, use fs.watchFile
7305
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7306
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7307
+ return watchPresentFileSystemEntryWithFsWatchFile();
7308
+ }
7309
+ }
7310
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
7311
+ // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
7312
+ // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
7313
+ return event === "rename" &&
7314
+ (!relativeName ||
7315
+ relativeName === lastDirectoryPart ||
7316
+ (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
7317
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
7318
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
7319
+ callback(event, relativeName);
7320
+ }
7321
+ /**
7322
+ * Watch the file or directory using fs.watchFile since fs.watch threw exception
7323
+ * 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
7324
+ */
7325
+ function watchPresentFileSystemEntryWithFsWatchFile() {
7326
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
7327
+ }
7328
+ /**
7329
+ * Watch the file or directory that is missing
7330
+ * and switch to existing file or directory when the missing filesystem entry is created
7331
+ */
7332
+ function watchMissingFileSystemEntry() {
7333
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
7334
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
7335
+ // Call the callback for current file or directory
7336
+ // For now it could be callback for the inner directory creation,
7337
+ // but just return current directory, better than current no-op
7338
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
7339
+ }
7340
+ }, fallbackPollingInterval, fallbackOptions);
7341
+ }
7347
7342
  }
7348
7343
  function readFileWorker(fileName, _encoding) {
7349
7344
  var buffer;
@@ -8621,6 +8616,7 @@ var ts;
8621
8616
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8622
8617
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8623
8618
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8619
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8624
8620
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8625
8621
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8626
8622
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -9106,6 +9102,7 @@ var ts;
9106
9102
  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."),
9107
9103
  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."),
9108
9104
  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."),
9105
+ 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"),
9109
9106
  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}'."),
9110
9107
  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}'."),
9111
9108
  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}'."),
@@ -16425,9 +16422,6 @@ var ts;
16425
16422
  }
16426
16423
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16427
16424
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16428
- if (node.kind === 203 /* BindingElement */) {
16429
- node = node.parent.parent;
16430
- }
16431
16425
  return ts.isVariableDeclaration(node) &&
16432
16426
  !!node.initializer &&
16433
16427
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20239,8 +20233,9 @@ var ts;
20239
20233
  */
20240
20234
  function isFileForcedToBeModuleByFormat(file) {
20241
20235
  // Excludes declaration files - they still require an explicit `export {}` or the like
20242
- // for back compat purposes.
20243
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20236
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20237
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20238
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20244
20239
  }
20245
20240
  function getSetExternalModuleIndicator(options) {
20246
20241
  // TODO: Should this callback be cached?
@@ -20248,7 +20243,7 @@ var ts;
20248
20243
  case ts.ModuleDetectionKind.Force:
20249
20244
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20250
20245
  return function (file) {
20251
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20246
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20252
20247
  };
20253
20248
  case ts.ModuleDetectionKind.Legacy:
20254
20249
  // Files are modules if they have imports, exports, or import.meta
@@ -20308,7 +20303,8 @@ var ts;
20308
20303
  }
20309
20304
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20310
20305
  function getEmitModuleDetectionKind(options) {
20311
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20306
+ return options.moduleDetection ||
20307
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20312
20308
  }
20313
20309
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20314
20310
  function hasJsonModuleEmitEnabled(options) {
@@ -43355,16 +43351,20 @@ var ts;
43355
43351
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43356
43352
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43357
43353
  }
43354
+ var jsOnlyExtensions = [Extensions.JavaScript];
43355
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43356
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43357
+ var tsconfigExtensions = [Extensions.TSConfig];
43358
43358
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43359
43359
  var containingDirectory = ts.getDirectoryPath(containingFile);
43360
43360
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43361
43361
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43362
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43362
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43363
+ if (compilerOptions.resolveJsonModule) {
43364
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43365
+ }
43366
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43363
43367
  }
43364
- var jsOnlyExtensions = [Extensions.JavaScript];
43365
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43366
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43367
- var tsconfigExtensions = [Extensions.TSConfig];
43368
43368
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43369
43369
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43370
43370
  }
@@ -44372,8 +44372,8 @@ var ts;
44372
44372
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
44373
44373
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
44374
44374
  if (!pathAndExtension && packageInfo
44375
- && packageInfo.packageJsonContent.exports === undefined
44376
- && packageInfo.packageJsonContent.main === undefined
44375
+ // eslint-disable-next-line no-null/no-null
44376
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
44377
44377
  && state.features & NodeResolutionFeatures.EsmMode) {
44378
44378
  // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
44379
44379
  // a default `index.js` entrypoint if no `main` or `exports` are present
@@ -47149,12 +47149,14 @@ var ts;
47149
47149
  }
47150
47150
  }
47151
47151
  function setCommonJsModuleIndicator(node) {
47152
- if (file.externalModuleIndicator) {
47152
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47153
47153
  return false;
47154
47154
  }
47155
47155
  if (!file.commonJsModuleIndicator) {
47156
47156
  file.commonJsModuleIndicator = node;
47157
- bindSourceFileAsExternalModule();
47157
+ if (!file.externalModuleIndicator) {
47158
+ bindSourceFileAsExternalModule();
47159
+ }
47158
47160
  }
47159
47161
  return true;
47160
47162
  }
@@ -47568,7 +47570,11 @@ var ts;
47568
47570
  checkStrictModeEvalOrArguments(node, node.name);
47569
47571
  }
47570
47572
  if (!ts.isBindingPattern(node.name)) {
47571
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47573
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47574
+ if (ts.isInJSFile(node) &&
47575
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47576
+ !ts.getJSDocTypeTag(node) &&
47577
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47572
47578
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47573
47579
  }
47574
47580
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -48032,7 +48038,10 @@ var ts;
48032
48038
  TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull";
48033
48039
  TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy";
48034
48040
  TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy";
48035
- TypeFacts[TypeFacts["All"] = 16777215] = "All";
48041
+ TypeFacts[TypeFacts["IsUndefined"] = 16777216] = "IsUndefined";
48042
+ TypeFacts[TypeFacts["IsNull"] = 33554432] = "IsNull";
48043
+ TypeFacts[TypeFacts["IsUndefinedOrNull"] = 50331648] = "IsUndefinedOrNull";
48044
+ TypeFacts[TypeFacts["All"] = 134217727] = "All";
48036
48045
  // The following members encode facts about particular kinds of types for use in the getTypeFacts function.
48037
48046
  // The presence of a particular fact means that the given test is true for some (and possibly all) values
48038
48047
  // of that kind of type.
@@ -48074,14 +48083,16 @@ var ts;
48074
48083
  TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts";
48075
48084
  TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts";
48076
48085
  TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts";
48077
- TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts";
48078
- TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts";
48079
- TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
48086
+ TypeFacts[TypeFacts["VoidFacts"] = 9830144] = "VoidFacts";
48087
+ TypeFacts[TypeFacts["UndefinedFacts"] = 26607360] = "UndefinedFacts";
48088
+ TypeFacts[TypeFacts["NullFacts"] = 42917664] = "NullFacts";
48089
+ TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 83427327] = "EmptyObjectStrictFacts";
48090
+ TypeFacts[TypeFacts["EmptyObjectFacts"] = 83886079] = "EmptyObjectFacts";
48091
+ TypeFacts[TypeFacts["UnknownFacts"] = 83886079] = "UnknownFacts";
48080
48092
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
48081
- TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
48082
48093
  // Masks
48083
48094
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
48084
- TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
48095
+ TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
48085
48096
  })(TypeFacts || (TypeFacts = {}));
48086
48097
  var typeofEQFacts = new ts.Map(ts.getEntries({
48087
48098
  string: 1 /* TypeofEQString */,
@@ -48745,6 +48756,7 @@ var ts;
48745
48756
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48746
48757
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48747
48758
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48759
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48748
48760
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48749
48761
  emptyGenericType.instantiations = new ts.Map();
48750
48762
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50244,7 +50256,12 @@ var ts;
50244
50256
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
50245
50257
  if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) {
50246
50258
  if (isPrimitiveTypeName(name)) {
50247
- error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50259
+ if (isExtendedByInterface(errorLocation)) {
50260
+ 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));
50261
+ }
50262
+ else {
50263
+ error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
50264
+ }
50248
50265
  return true;
50249
50266
  }
50250
50267
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
@@ -50264,6 +50281,16 @@ var ts;
50264
50281
  }
50265
50282
  return false;
50266
50283
  }
50284
+ function isExtendedByInterface(node) {
50285
+ var grandparent = node.parent.parent;
50286
+ var parentOfGrandparent = grandparent.parent;
50287
+ if (grandparent && parentOfGrandparent) {
50288
+ var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */;
50289
+ var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent);
50290
+ return isExtending && isInterface;
50291
+ }
50292
+ return false;
50293
+ }
50267
50294
  function maybeMappedType(node, symbol) {
50268
50295
  var container = ts.findAncestor(node.parent, function (n) {
50269
50296
  return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
@@ -50395,7 +50422,8 @@ var ts;
50395
50422
  && isAliasableOrJsExpression(node.parent.right)
50396
50423
  || node.kind === 297 /* ShorthandPropertyAssignment */
50397
50424
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50398
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50425
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50426
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50399
50427
  }
50400
50428
  function isAliasableOrJsExpression(e) {
50401
50429
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50488,7 +50516,7 @@ var ts;
50488
50516
  return hasExportAssignmentSymbol(moduleSymbol);
50489
50517
  }
50490
50518
  // 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
50491
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50519
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50492
50520
  }
50493
50521
  function getTargetOfImportClause(node, dontResolveAlias) {
50494
50522
  var _a;
@@ -53103,7 +53131,7 @@ var ts;
53103
53131
  anyType : getNonMissingTypeOfSymbol(propertySymbol);
53104
53132
  var saveEnclosingDeclaration = context.enclosingDeclaration;
53105
53133
  context.enclosingDeclaration = undefined;
53106
- if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) {
53134
+ if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) {
53107
53135
  if (propertySymbol.declarations) {
53108
53136
  var decl = ts.first(propertySymbol.declarations);
53109
53137
  if (hasLateBindableName(decl)) {
@@ -54787,7 +54815,7 @@ var ts;
54787
54815
  ? getBaseConstructorTypeOfClass(staticType)
54788
54816
  : anyType;
54789
54817
  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);
54790
- var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
54818
+ var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
54791
54819
  var publicSymbolProps = ts.filter(symbolProps, function (s) {
54792
54820
  // `valueDeclaration` could be undefined if inherited from
54793
54821
  // a union/intersection base type, but inherited properties
@@ -55925,7 +55953,7 @@ var ts;
55925
55953
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
55926
55954
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
55927
55955
  // undefined from the final type.
55928
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
55956
+ return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type;
55929
55957
  }
55930
55958
  return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
55931
55959
  }
@@ -58914,7 +58942,7 @@ var ts;
58914
58942
  }
58915
58943
  }
58916
58944
  }
58917
- else if (t.flags & 469892092 /* DisjointDomains */) {
58945
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58918
58946
  hasDisjointDomainType = true;
58919
58947
  }
58920
58948
  }
@@ -58926,7 +58954,7 @@ var ts;
58926
58954
  // intersection operation to reduce the union constraints.
58927
58955
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58928
58956
  var t = types_6[_a];
58929
- if (t.flags & 469892092 /* DisjointDomains */) {
58957
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58930
58958
  constraints = ts.append(constraints, t);
58931
58959
  }
58932
58960
  }
@@ -59128,7 +59156,7 @@ var ts;
59128
59156
  var objectType;
59129
59157
  return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
59130
59158
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
59131
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
59159
+ !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
59132
59160
  }
59133
59161
  /**
59134
59162
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -61475,7 +61503,7 @@ var ts;
61475
61503
  }
61476
61504
  return includes;
61477
61505
  }
61478
- function removeRedundantPrimitiveTypes(types, includes) {
61506
+ function removeRedundantSupertypes(types, includes) {
61479
61507
  var i = types.length;
61480
61508
  while (i > 0) {
61481
61509
  i--;
@@ -61483,7 +61511,9 @@ var ts;
61483
61511
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61484
61512
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61485
61513
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61486
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61514
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61515
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61516
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61487
61517
  if (remove) {
61488
61518
  ts.orderedRemoveItemAt(types, i);
61489
61519
  }
@@ -61605,7 +61635,7 @@ var ts;
61605
61635
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61606
61636
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61607
61637
  // for intersections of types with signatures can be deterministic.
61608
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61638
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61609
61639
  var typeMembershipMap = new ts.Map();
61610
61640
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61611
61641
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61642,11 +61672,11 @@ var ts;
61642
61672
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61643
61673
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61644
61674
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61645
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61646
- removeRedundantPrimitiveTypes(typeSet, includes);
61647
- }
61648
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61649
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61675
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61676
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61677
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61678
+ if (!noSupertypeReduction)
61679
+ removeRedundantSupertypes(typeSet, includes);
61650
61680
  }
61651
61681
  if (includes & 262144 /* IncludesMissingType */) {
61652
61682
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61685,8 +61715,9 @@ var ts;
61685
61715
  }
61686
61716
  var constituents = getCrossProductIntersections(typeSet);
61687
61717
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61688
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61689
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61718
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61719
+ // the denormalized origin has fewer constituents than the union itself.
61720
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61690
61721
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61691
61722
  }
61692
61723
  }
@@ -61729,11 +61760,21 @@ var ts;
61729
61760
  }
61730
61761
  return intersections;
61731
61762
  }
61763
+ function getConstituentCount(type) {
61764
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61765
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61766
+ getConstituentCountOfTypes(type.types);
61767
+ }
61768
+ function getConstituentCountOfTypes(types) {
61769
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61770
+ }
61732
61771
  function getTypeFromIntersectionTypeNode(node) {
61733
61772
  var links = getNodeLinks(node);
61734
61773
  if (!links.resolvedType) {
61735
61774
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61736
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61775
+ var types = ts.map(node.types, getTypeFromTypeNode);
61776
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61777
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61737
61778
  }
61738
61779
  return links.resolvedType;
61739
61780
  }
@@ -64407,7 +64448,7 @@ var ts;
64407
64448
  var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
64408
64449
  var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType));
64409
64450
  var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
64410
- (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */);
64451
+ (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */);
64411
64452
  var related = callbacks ?
64412
64453
  compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
64413
64454
  !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
@@ -64519,6 +64560,17 @@ var ts;
64519
64560
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64520
64561
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64521
64562
  }
64563
+ function isUnknownLikeUnionType(type) {
64564
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64565
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64566
+ var types = type.types;
64567
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64568
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64569
+ }
64570
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64571
+ }
64572
+ return false;
64573
+ }
64522
64574
  function isStringIndexSignatureOnlyType(type) {
64523
64575
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64524
64576
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64598,7 +64650,7 @@ var ts;
64598
64650
  return true;
64599
64651
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64600
64652
  return true;
64601
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64653
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64602
64654
  return true;
64603
64655
  if (relation === assignableRelation || relation === comparableRelation) {
64604
64656
  if (s & 1 /* Any */)
@@ -64608,6 +64660,9 @@ var ts;
64608
64660
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64609
64661
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64610
64662
  return true;
64663
+ // Anything is assignable to a union containing undefined, null, and {}
64664
+ if (isUnknownLikeUnionType(target))
64665
+ return true;
64611
64666
  }
64612
64667
  return false;
64613
64668
  }
@@ -64650,16 +64705,27 @@ var ts;
64650
64705
  function getNormalizedType(type, writing) {
64651
64706
  while (true) {
64652
64707
  var t = isFreshLiteralType(type) ? type.regularType :
64653
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64654
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64708
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64709
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64655
64710
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64656
64711
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64657
64712
  type;
64658
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64659
64713
  if (t === type)
64660
- break;
64714
+ return t;
64661
64715
  type = t;
64662
64716
  }
64717
+ }
64718
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64719
+ var reduced = getReducedType(type);
64720
+ if (reduced !== type) {
64721
+ return reduced;
64722
+ }
64723
+ if (type.flags & 2097152 /* Intersection */) {
64724
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64725
+ if (normalizedTypes !== type.types) {
64726
+ return getIntersectionType(normalizedTypes);
64727
+ }
64728
+ }
64663
64729
  return type;
64664
64730
  }
64665
64731
  /**
@@ -65106,6 +65172,7 @@ var ts;
65106
65172
  return 0 /* False */;
65107
65173
  }
65108
65174
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
65175
+ var _a, _b;
65109
65176
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
65110
65177
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
65111
65178
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -65146,6 +65213,9 @@ var ts;
65146
65213
  return;
65147
65214
  }
65148
65215
  reportRelationError(headMessage, source, target);
65216
+ 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 */))) {
65217
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65218
+ }
65149
65219
  }
65150
65220
  function traceUnionsOrIntersectionsTooLarge(source, target) {
65151
65221
  if (!ts.tracing) {
@@ -65932,13 +66002,6 @@ var ts;
65932
66002
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65933
66003
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65934
66004
  var constraint = getConstraintOfType(source) || unknownType;
65935
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65936
- // A type variable with no constraint is not related to the non-primitive object type.
65937
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65938
- resetErrorInfo(saveErrorInfo);
65939
- return result;
65940
- }
65941
- }
65942
66005
  // 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
65943
66006
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65944
66007
  resetErrorInfo(saveErrorInfo);
@@ -67412,9 +67475,11 @@ var ts;
67412
67475
  return getSupertypeOrUnion(types);
67413
67476
  }
67414
67477
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67415
- return primaryTypes.length ?
67416
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67417
- getUnionType(types, 2 /* Subtype */);
67478
+ if (primaryTypes.length) {
67479
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67480
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67481
+ }
67482
+ return getUnionType(types, 2 /* Subtype */);
67418
67483
  }
67419
67484
  // Return the leftmost type for which no type to the right is a subtype.
67420
67485
  function getCommonSubtype(types) {
@@ -67601,29 +67666,8 @@ var ts;
67601
67666
  var value = _a.value;
67602
67667
  return value.base10Value === "0";
67603
67668
  }
67604
- function getFalsyFlagsOfTypes(types) {
67605
- var result = 0;
67606
- for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
67607
- var t = types_14[_i];
67608
- result |= getFalsyFlags(t);
67609
- }
67610
- return result;
67611
- }
67612
- // Returns the String, Number, Boolean, StringLiteral, NumberLiteral, BooleanLiteral, Void, Undefined, or Null
67613
- // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67614
- // no flags for all other types (including non-falsy literal types).
67615
- function getFalsyFlags(type) {
67616
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67617
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67618
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67619
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67620
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67621
- type.flags & 117724 /* PossiblyFalsy */;
67622
- }
67623
67669
  function removeDefinitelyFalsyTypes(type) {
67624
- return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
67625
- filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) :
67626
- type;
67670
+ return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); });
67627
67671
  }
67628
67672
  function extractDefinitelyFalsyTypes(type) {
67629
67673
  return mapType(type, getDefinitelyFalsyPartOfType);
@@ -67658,20 +67702,15 @@ var ts;
67658
67702
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67659
67703
  }
67660
67704
  function getGlobalNonNullableTypeInstantiation(type) {
67661
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67662
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67663
- // that isn't eliminated by a NonNullable<T> instantiation.
67664
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67665
67705
  if (!deferredGlobalNonNullableTypeAlias) {
67666
67706
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67667
67707
  }
67668
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67669
67708
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67670
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67671
- reducedType;
67709
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67710
+ getIntersectionType([type, emptyObjectType]);
67672
67711
  }
67673
67712
  function getNonNullableType(type) {
67674
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67713
+ return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
67675
67714
  }
67676
67715
  function addOptionalTypeMarker(type) {
67677
67716
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68352,13 +68391,40 @@ var ts;
68352
68391
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68353
68392
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68354
68393
  }
68355
- function isValidBigIntString(s) {
68394
+ /**
68395
+ * Tests whether the provided string can be parsed as a number.
68396
+ * @param s The string to test.
68397
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68398
+ */
68399
+ function isValidNumberString(s, roundTripOnly) {
68400
+ if (s === "")
68401
+ return false;
68402
+ var n = +s;
68403
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68404
+ }
68405
+ /**
68406
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68407
+ */
68408
+ function parseBigIntLiteralType(text) {
68409
+ var negative = text.startsWith("-");
68410
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68411
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68412
+ }
68413
+ /**
68414
+ * Tests whether the provided string can be parsed as a bigint.
68415
+ * @param s The string to test.
68416
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68417
+ */
68418
+ function isValidBigIntString(s, roundTripOnly) {
68419
+ if (s === "")
68420
+ return false;
68356
68421
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68357
68422
  var success = true;
68358
68423
  scanner.setOnError(function () { return success = false; });
68359
68424
  scanner.setText(s + "n");
68360
68425
  var result = scanner.scan();
68361
- if (result === 40 /* MinusToken */) {
68426
+ var negative = result === 40 /* MinusToken */;
68427
+ if (negative) {
68362
68428
  result = scanner.scan();
68363
68429
  }
68364
68430
  var flags = scanner.getTokenFlags();
@@ -68367,7 +68433,8 @@ var ts;
68367
68433
  // * a bigint can be scanned, and that when it is scanned, it is
68368
68434
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68369
68435
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68370
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68436
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68437
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68371
68438
  }
68372
68439
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68373
68440
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68375,8 +68442,8 @@ var ts;
68375
68442
  }
68376
68443
  if (source.flags & 128 /* StringLiteral */) {
68377
68444
  var value = source.value;
68378
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68379
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68445
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68446
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68380
68447
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68381
68448
  }
68382
68449
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68787,8 +68854,8 @@ var ts;
68787
68854
  }
68788
68855
  function getSingleTypeVariableFromIntersectionTypes(types) {
68789
68856
  var typeVariable;
68790
- for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
68791
- var type = types_15[_i];
68857
+ for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
68858
+ var type = types_14[_i];
68792
68859
  var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
68793
68860
  if (!t || typeVariable && t !== typeVariable) {
68794
68861
  return undefined;
@@ -68949,8 +69016,57 @@ var ts;
68949
69016
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68950
69017
  // succeed. That would be a pointless and confusing outcome.
68951
69018
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69019
+ var _loop_23 = function (i) {
69020
+ var source_1 = matches ? matches[i] : neverType;
69021
+ var target_3 = types[i];
69022
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
69023
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
69024
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
69025
+ var inferenceContext = getInferenceInfoForType(target_3);
69026
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
69027
+ if (constraint && !isTypeAny(constraint)) {
69028
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
69029
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
69030
+ // If the constraint contains `string`, we don't need to look for a more preferred type
69031
+ if (!(allTypeFlags_1 & 4 /* String */)) {
69032
+ var str_1 = source_1.value;
69033
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
69034
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
69035
+ allTypeFlags_1 &= ~296 /* NumberLike */;
69036
+ }
69037
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
69038
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
69039
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
69040
+ }
69041
+ // for each type in the constraint, find the highest priority matching type
69042
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
69043
+ return !(right.flags & allTypeFlags_1) ? left :
69044
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
69045
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
69046
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
69047
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
69048
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
69049
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
69050
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
69051
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
69052
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
69053
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
69054
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
69055
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
69056
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
69057
+ left;
69058
+ }, neverType);
69059
+ if (!(matchingType.flags & 131072 /* Never */)) {
69060
+ inferFromTypes(matchingType, target_3);
69061
+ return "continue";
69062
+ }
69063
+ }
69064
+ }
69065
+ }
69066
+ inferFromTypes(source_1, target_3);
69067
+ };
68952
69068
  for (var i = 0; i < types.length; i++) {
68953
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
69069
+ _loop_23(i);
68954
69070
  }
68955
69071
  }
68956
69072
  }
@@ -69468,7 +69584,7 @@ var ts;
69468
69584
  function mapTypesByKeyProperty(types, name) {
69469
69585
  var map = new ts.Map();
69470
69586
  var count = 0;
69471
- var _loop_23 = function (type) {
69587
+ var _loop_24 = function (type) {
69472
69588
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69473
69589
  var discriminant = getTypeOfPropertyOfType(type, name);
69474
69590
  if (discriminant) {
@@ -69492,9 +69608,9 @@ var ts;
69492
69608
  }
69493
69609
  }
69494
69610
  };
69495
- for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69496
- var type = types_16[_i];
69497
- var state_9 = _loop_23(type);
69611
+ for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
69612
+ var type = types_15[_i];
69613
+ var state_9 = _loop_24(type);
69498
69614
  if (typeof state_9 === "object")
69499
69615
  return state_9.value;
69500
69616
  }
@@ -69608,14 +69724,16 @@ var ts;
69608
69724
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
69609
69725
  resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
69610
69726
  }
69611
- function getTypeFacts(type, ignoreObjects) {
69612
- if (ignoreObjects === void 0) { ignoreObjects = false; }
69727
+ function getTypeFacts(type) {
69728
+ if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) {
69729
+ type = getBaseConstraintOfType(type) || unknownType;
69730
+ }
69613
69731
  var flags = type.flags;
69614
- if (flags & 4 /* String */) {
69732
+ if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
69615
69733
  return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
69616
69734
  }
69617
- if (flags & 128 /* StringLiteral */) {
69618
- var isEmpty = type.value === "";
69735
+ if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
69736
+ var isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
69619
69737
  return strictNullChecks ?
69620
69738
  isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ :
69621
69739
  isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
@@ -69647,20 +69765,20 @@ var ts;
69647
69765
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
69648
69766
  }
69649
69767
  if (flags & 524288 /* Object */) {
69650
- if (ignoreObjects) {
69651
- return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
69652
- }
69653
69768
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
69654
- strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
69769
+ strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ :
69655
69770
  isFunctionObjectType(type) ?
69656
69771
  strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ :
69657
69772
  strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
69658
69773
  }
69659
- if (flags & (16384 /* Void */ | 32768 /* Undefined */)) {
69660
- return 9830144 /* UndefinedFacts */;
69774
+ if (flags & 16384 /* Void */) {
69775
+ return 9830144 /* VoidFacts */;
69776
+ }
69777
+ if (flags & 32768 /* Undefined */) {
69778
+ return 26607360 /* UndefinedFacts */;
69661
69779
  }
69662
69780
  if (flags & 65536 /* Null */) {
69663
- return 9363232 /* NullFacts */;
69781
+ return 42917664 /* NullFacts */;
69664
69782
  }
69665
69783
  if (flags & 12288 /* ESSymbolLike */) {
69666
69784
  return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
@@ -69671,37 +69789,56 @@ var ts;
69671
69789
  if (flags & 131072 /* Never */) {
69672
69790
  return 0 /* None */;
69673
69791
  }
69674
- if (flags & 465829888 /* Instantiable */) {
69675
- return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
69676
- strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */;
69677
- }
69678
69792
  if (flags & 1048576 /* Union */) {
69679
- return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */);
69793
+ return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */);
69680
69794
  }
69681
69795
  if (flags & 2097152 /* Intersection */) {
69682
- // When an intersection contains a primitive type we ignore object type constituents as they are
69683
- // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69684
- ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
69685
- return getIntersectionTypeFacts(type, ignoreObjects);
69796
+ return getIntersectionTypeFacts(type);
69686
69797
  }
69687
- return 16777215 /* All */;
69798
+ return 83886079 /* UnknownFacts */;
69688
69799
  }
69689
- function getIntersectionTypeFacts(type, ignoreObjects) {
69800
+ function getIntersectionTypeFacts(type) {
69801
+ // When an intersection contains a primitive type we ignore object type constituents as they are
69802
+ // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
69803
+ var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */);
69690
69804
  // When computing the type facts of an intersection type, certain type facts are computed as `and`
69691
69805
  // and others are computed as `or`.
69692
69806
  var oredFacts = 0 /* None */;
69693
- var andedFacts = 16777215 /* All */;
69807
+ var andedFacts = 134217727 /* All */;
69694
69808
  for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
69695
69809
  var t = _a[_i];
69696
- var f = getTypeFacts(t, ignoreObjects);
69697
- oredFacts |= f;
69698
- andedFacts &= f;
69810
+ if (!(ignoreObjects && t.flags & 524288 /* Object */)) {
69811
+ var f = getTypeFacts(t);
69812
+ oredFacts |= f;
69813
+ andedFacts &= f;
69814
+ }
69699
69815
  }
69700
- return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
69816
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */;
69701
69817
  }
69702
69818
  function getTypeWithFacts(type, include) {
69703
69819
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69704
69820
  }
69821
+ // This function is similar to getTypeWithFacts, except that in strictNullChecks mode it replaces type
69822
+ // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining
69823
+ // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined.
69824
+ function getAdjustedTypeWithFacts(type, facts) {
69825
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69826
+ if (strictNullChecks) {
69827
+ switch (facts) {
69828
+ case 524288 /* NEUndefined */:
69829
+ 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; });
69830
+ case 1048576 /* NENull */:
69831
+ 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; });
69832
+ case 2097152 /* NEUndefinedOrNull */:
69833
+ case 4194304 /* Truthy */:
69834
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69835
+ }
69836
+ }
69837
+ return reduced;
69838
+ }
69839
+ function recombineUnknownType(type) {
69840
+ return type === unknownUnionType ? unknownType : type;
69841
+ }
69705
69842
  function getTypeWithDefault(type, defaultExpression) {
69706
69843
  return defaultExpression ?
69707
69844
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -69950,8 +70087,8 @@ var ts;
69950
70087
  var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
69951
70088
  var mappedTypes;
69952
70089
  var changed = false;
69953
- for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
69954
- var t = types_17[_i];
70090
+ for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
70091
+ var t = types_16[_i];
69955
70092
  var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t);
69956
70093
  changed || (changed = t !== mapped);
69957
70094
  if (mapped) {
@@ -70037,8 +70174,8 @@ var ts;
70037
70174
  }
70038
70175
  function isEvolvingArrayTypeList(types) {
70039
70176
  var hasEvolvingArrayType = false;
70040
- for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
70041
- var t = types_18[_i];
70177
+ for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
70178
+ var t = types_17[_i];
70042
70179
  if (!(t.flags & 131072 /* Never */)) {
70043
70180
  if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) {
70044
70181
  return false;
@@ -70759,7 +70896,7 @@ var ts;
70759
70896
  if (isEvolvingArrayTypeList(types)) {
70760
70897
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70761
70898
  }
70762
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70899
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70763
70900
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70764
70901
  return declaredType;
70765
70902
  }
@@ -70861,11 +70998,10 @@ var ts;
70861
70998
  }
70862
70999
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70863
71000
  if (isMatchingReference(reference, expr)) {
70864
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70865
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
71001
+ return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70866
71002
  }
70867
71003
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70868
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71004
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
70869
71005
  }
70870
71006
  var access = getDiscriminantPropertyAccess(expr, type);
70871
71007
  if (access) {
@@ -71005,7 +71141,7 @@ var ts;
71005
71141
  // Note that we include any and unknown in the exclusion test because their domain includes null and undefined.
71006
71142
  var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
71007
71143
  equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); });
71008
- return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
71144
+ return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
71009
71145
  }
71010
71146
  function narrowTypeByEquality(type, operator, value, assumeTrue) {
71011
71147
  if (type.flags & 1 /* Any */) {
@@ -71015,9 +71151,6 @@ var ts;
71015
71151
  assumeTrue = !assumeTrue;
71016
71152
  }
71017
71153
  var valueType = getTypeOfExpression(value);
71018
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
71019
- return getUnionType([nullType, undefinedType]);
71020
- }
71021
71154
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
71022
71155
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
71023
71156
  return valueType;
@@ -71037,7 +71170,7 @@ var ts;
71037
71170
  valueType.flags & 65536 /* Null */ ?
71038
71171
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
71039
71172
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
71040
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
71173
+ return getAdjustedTypeWithFacts(type, facts);
71041
71174
  }
71042
71175
  if (assumeTrue) {
71043
71176
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -71058,24 +71191,18 @@ var ts;
71058
71191
  var target = getReferenceCandidate(typeOfExpr.expression);
71059
71192
  if (!isMatchingReference(reference, target)) {
71060
71193
  if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
71061
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71194
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71062
71195
  }
71063
71196
  return type;
71064
71197
  }
71065
71198
  if (type.flags & 1 /* Any */ && literal.text === "function") {
71066
71199
  return type;
71067
71200
  }
71068
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
71069
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
71070
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
71071
- // unknown type, and then narrows that to the non-primitive type.
71072
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
71073
- }
71074
71201
  var facts = assumeTrue ?
71075
71202
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71076
71203
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71077
71204
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71078
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71205
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71079
71206
  }
71080
71207
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71081
71208
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71124,10 +71251,10 @@ var ts;
71124
71251
  }
71125
71252
  function getImpliedTypeFromTypeofGuard(type, text) {
71126
71253
  switch (text) {
71254
+ case "object":
71255
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71127
71256
  case "function":
71128
71257
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
71129
- case "object":
71130
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71131
71258
  default:
71132
71259
  return typeofTypesByName.get(text);
71133
71260
  }
@@ -71138,22 +71265,27 @@ var ts;
71138
71265
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71139
71266
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71140
71267
  // filtering by type-facts.
71141
- function narrowUnionMemberByTypeof(candidate) {
71142
- return function (type) {
71143
- if (isTypeSubtypeOf(type, candidate)) {
71144
- return type;
71145
- }
71146
- if (isTypeSubtypeOf(candidate, type)) {
71147
- return candidate;
71268
+ function narrowTypeByImpliedType(type, candidate) {
71269
+ if (type.flags & 3 /* AnyOrUnknown */) {
71270
+ return candidate;
71271
+ }
71272
+ return mapType(type, function (t) {
71273
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71274
+ return t;
71148
71275
  }
71149
- if (type.flags & 465829888 /* Instantiable */) {
71150
- var constraint = getBaseConstraintOfType(type) || anyType;
71151
- if (isTypeSubtypeOf(candidate, constraint)) {
71152
- return getIntersectionType([type, candidate]);
71276
+ return mapType(candidate, function (c) {
71277
+ if (!areTypesComparable(t, c)) {
71278
+ return neverType;
71153
71279
  }
71154
- }
71155
- return type;
71156
- };
71280
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71281
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71282
+ }
71283
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71284
+ return c;
71285
+ }
71286
+ return getIntersectionType([t, c]);
71287
+ });
71288
+ });
71157
71289
  }
71158
71290
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71159
71291
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71212,7 +71344,7 @@ var ts;
71212
71344
  because it is caught in the first clause.
71213
71345
  */
71214
71346
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71215
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71347
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71216
71348
  }
71217
71349
  function isMatchingConstructorReference(expr) {
71218
71350
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71263,7 +71395,7 @@ var ts;
71263
71395
  var left = getReferenceCandidate(expr.left);
71264
71396
  if (!isMatchingReference(reference, left)) {
71265
71397
  if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
71266
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71398
+ return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71267
71399
  }
71268
71400
  return type;
71269
71401
  }
@@ -71351,7 +71483,7 @@ var ts;
71351
71483
  }
71352
71484
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
71353
71485
  !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
71354
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71486
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
71355
71487
  }
71356
71488
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
71357
71489
  if (access) {
@@ -71408,7 +71540,7 @@ var ts;
71408
71540
  }
71409
71541
  function narrowTypeByOptionality(type, expr, assumePresent) {
71410
71542
  if (isMatchingReference(reference, expr)) {
71411
- return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71543
+ return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
71412
71544
  }
71413
71545
  var access = getDiscriminantPropertyAccess(expr, type);
71414
71546
  if (access) {
@@ -71494,8 +71626,8 @@ var ts;
71494
71626
  var annotationIncludesUndefined = strictNullChecks &&
71495
71627
  declaration.kind === 164 /* Parameter */ &&
71496
71628
  declaration.initializer &&
71497
- getFalsyFlags(declaredType) & 32768 /* Undefined */ &&
71498
- !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */);
71629
+ getTypeFacts(declaredType) & 16777216 /* IsUndefined */ &&
71630
+ !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */);
71499
71631
  popTypeResolution();
71500
71632
  return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
71501
71633
  }
@@ -71516,7 +71648,9 @@ var ts;
71516
71648
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71517
71649
  }
71518
71650
  function isGenericTypeWithUnionConstraint(type) {
71519
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71651
+ return type.flags & 2097152 /* Intersection */ ?
71652
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71653
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71520
71654
  }
71521
71655
  function isGenericTypeWithoutNullableConstraint(type) {
71522
71656
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71544,7 +71678,7 @@ var ts;
71544
71678
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71545
71679
  someType(type, isGenericTypeWithUnionConstraint) &&
71546
71680
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71547
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71681
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71548
71682
  }
71549
71683
  function isExportOrExportExpression(location) {
71550
71684
  return !!ts.findAncestor(location, function (n) {
@@ -71821,7 +71955,7 @@ var ts;
71821
71955
  return convertAutoToAny(flowType);
71822
71956
  }
71823
71957
  }
71824
- else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
71958
+ else if (!assumeInitialized && !(getTypeFacts(type) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
71825
71959
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
71826
71960
  // Return the declared type to reduce follow-on errors
71827
71961
  return type;
@@ -73350,8 +73484,8 @@ var ts;
73350
73484
  }
73351
73485
  var signatureList;
73352
73486
  var types = type.types;
73353
- for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
73354
- var current = types_19[_i];
73487
+ for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
73488
+ var current = types_18[_i];
73355
73489
  var signature = getContextualCallSignature(current, node);
73356
73490
  if (signature) {
73357
73491
  if (!signatureList) {
@@ -74513,19 +74647,19 @@ var ts;
74513
74647
  return checkNonNullType(checkExpression(node), node);
74514
74648
  }
74515
74649
  function isNullableType(type) {
74516
- return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */);
74650
+ return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */);
74517
74651
  }
74518
74652
  function getNonNullableTypeIfNeeded(type) {
74519
74653
  return isNullableType(type) ? getNonNullableType(type) : type;
74520
74654
  }
74521
- function reportObjectPossiblyNullOrUndefinedError(node, flags) {
74522
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74655
+ function reportObjectPossiblyNullOrUndefinedError(node, facts) {
74656
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74523
74657
  ts.Diagnostics.Object_is_possibly_null_or_undefined :
74524
74658
  ts.Diagnostics.Object_is_possibly_undefined :
74525
74659
  ts.Diagnostics.Object_is_possibly_null);
74526
74660
  }
74527
- function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
74528
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
74661
+ function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) {
74662
+ error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ?
74529
74663
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
74530
74664
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
74531
74665
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
@@ -74535,9 +74669,9 @@ var ts;
74535
74669
  error(node, ts.Diagnostics.Object_is_of_type_unknown);
74536
74670
  return errorType;
74537
74671
  }
74538
- var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */;
74539
- if (kind) {
74540
- reportError(node, kind);
74672
+ var facts = getTypeFacts(type);
74673
+ if (facts & 50331648 /* IsUndefinedOrNull */) {
74674
+ reportError(node, facts);
74541
74675
  var t = getNonNullableType(type);
74542
74676
  return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
74543
74677
  }
@@ -74832,7 +74966,7 @@ var ts;
74832
74966
  assumeUninitialized = true;
74833
74967
  }
74834
74968
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
74835
- if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
74969
+ if (assumeUninitialized && !(getTypeFacts(propType) & 16777216 /* IsUndefined */) && getTypeFacts(flowType) & 16777216 /* IsUndefined */) {
74836
74970
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
74837
74971
  // Return the declared type to reduce follow-on errors
74838
74972
  return propType;
@@ -75882,7 +76016,7 @@ var ts;
75882
76016
  if (spreadIndex >= 0) {
75883
76017
  // Create synthetic arguments from spreads of tuple types.
75884
76018
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75885
- var _loop_24 = function (i) {
76019
+ var _loop_25 = function (i) {
75886
76020
  var arg = args[i];
75887
76021
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75888
76022
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75899,7 +76033,7 @@ var ts;
75899
76033
  }
75900
76034
  };
75901
76035
  for (var i = spreadIndex; i < args.length; i++) {
75902
- _loop_24(i);
76036
+ _loop_25(i);
75903
76037
  }
75904
76038
  return effectiveArgs_1;
75905
76039
  }
@@ -76219,7 +76353,7 @@ var ts;
76219
76353
  var min_3 = Number.MAX_VALUE;
76220
76354
  var minIndex = 0;
76221
76355
  var i_1 = 0;
76222
- var _loop_25 = function (c) {
76356
+ var _loop_26 = function (c) {
76223
76357
  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)); };
76224
76358
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76225
76359
  if (diags_2) {
@@ -76237,7 +76371,7 @@ var ts;
76237
76371
  };
76238
76372
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76239
76373
  var c = candidatesForArgumentError_1[_a];
76240
- _loop_25(c);
76374
+ _loop_26(c);
76241
76375
  }
76242
76376
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76243
76377
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76395,7 +76529,7 @@ var ts;
76395
76529
  }
76396
76530
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76397
76531
  var parameters = [];
76398
- var _loop_26 = function (i) {
76532
+ var _loop_27 = function (i) {
76399
76533
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76400
76534
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76401
76535
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76403,7 +76537,7 @@ var ts;
76403
76537
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76404
76538
  };
76405
76539
  for (var i = 0; i < maxNonRestParam; i++) {
76406
- _loop_26(i);
76540
+ _loop_27(i);
76407
76541
  }
76408
76542
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76409
76543
  var flags = 0 /* None */;
@@ -76748,8 +76882,8 @@ var ts;
76748
76882
  if (apparentType.flags & 1048576 /* Union */) {
76749
76883
  var types = apparentType.types;
76750
76884
  var hasSignatures = false;
76751
- for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
76752
- var constituent = types_20[_i];
76885
+ for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
76886
+ var constituent = types_19[_i];
76753
76887
  var signatures = getSignaturesOfType(constituent, kind);
76754
76888
  if (signatures.length !== 0) {
76755
76889
  hasSignatures = true;
@@ -78440,7 +78574,7 @@ var ts;
78440
78574
  var type = getTypeOfSymbol(symbol);
78441
78575
  if (strictNullChecks &&
78442
78576
  !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) &&
78443
- !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) {
78577
+ !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
78444
78578
  error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
78445
78579
  }
78446
78580
  }
@@ -78608,8 +78742,8 @@ var ts;
78608
78742
  }
78609
78743
  if (type.flags & 3145728 /* UnionOrIntersection */) {
78610
78744
  var types = type.types;
78611
- for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
78612
- var t = types_21[_i];
78745
+ for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
78746
+ var t = types_20[_i];
78613
78747
  if (maybeTypeOfKind(t, kind)) {
78614
78748
  return true;
78615
78749
  }
@@ -78836,7 +78970,7 @@ var ts;
78836
78970
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
78837
78971
  // undefined from the final type.
78838
78972
  if (strictNullChecks &&
78839
- !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) {
78973
+ !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) {
78840
78974
  sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
78841
78975
  }
78842
78976
  checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
@@ -79236,7 +79370,7 @@ var ts;
79236
79370
  case 56 /* BarBarToken */:
79237
79371
  case 75 /* BarBarEqualsToken */: {
79238
79372
  var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ?
79239
- getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) :
79373
+ getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) :
79240
79374
  leftType;
79241
79375
  if (operator === 75 /* BarBarEqualsToken */) {
79242
79376
  checkAssignmentOperator(rightType);
@@ -80460,7 +80594,7 @@ var ts;
80460
80594
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80461
80595
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80462
80596
  var indexSignatureMap_1 = new ts.Map();
80463
- var _loop_27 = function (declaration) {
80597
+ var _loop_28 = function (declaration) {
80464
80598
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80465
80599
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80466
80600
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80475,7 +80609,7 @@ var ts;
80475
80609
  };
80476
80610
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80477
80611
  var declaration = _a[_i];
80478
- _loop_27(declaration);
80612
+ _loop_28(declaration);
80479
80613
  }
80480
80614
  indexSignatureMap_1.forEach(function (entry) {
80481
80615
  if (entry.declarations.length > 1) {
@@ -81777,8 +81911,8 @@ var ts;
81777
81911
  }
81778
81912
  function getEntityNameForDecoratorMetadataFromTypeList(types) {
81779
81913
  var commonEntityName;
81780
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
81781
- var typeNode = types_22[_i];
81914
+ for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
81915
+ var typeNode = types_21[_i];
81782
81916
  while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) {
81783
81917
  typeNode = typeNode.type; // Skip parens if need be
81784
81918
  }
@@ -82644,7 +82778,7 @@ var ts;
82644
82778
  // For a binding pattern, validate the initializer and exit
82645
82779
  if (ts.isBindingPattern(node.name)) {
82646
82780
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82647
- var needCheckWidenedType = node.name.elements.length === 0;
82781
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82648
82782
  if (needCheckInitializer || needCheckWidenedType) {
82649
82783
  // Don't validate for-in initializer as it is already an error
82650
82784
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -82671,7 +82805,7 @@ var ts;
82671
82805
  }
82672
82806
  // For a commonjs `const x = require`, validate the alias and exit
82673
82807
  var symbol = getSymbolOfNode(node);
82674
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82808
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82675
82809
  checkAliasSymbol(node);
82676
82810
  return;
82677
82811
  }
@@ -82797,7 +82931,7 @@ var ts;
82797
82931
  return;
82798
82932
  var type = checkTruthinessExpression(location);
82799
82933
  var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
82800
- if (getFalsyFlags(type) || isPropertyExpressionCast)
82934
+ if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast)
82801
82935
  return;
82802
82936
  // While it technically should be invalid for any known-truthy value
82803
82937
  // to be tested, we de-scope to functions and Promises unreferenced in
@@ -83936,7 +84070,7 @@ var ts;
83936
84070
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83937
84071
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83938
84072
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83939
- var _loop_28 = function (info) {
84073
+ var _loop_29 = function (info) {
83940
84074
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83941
84075
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83942
84076
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83949,7 +84083,7 @@ var ts;
83949
84083
  };
83950
84084
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83951
84085
  var info = indexInfos_9[_i];
83952
- _loop_28(info);
84086
+ _loop_29(info);
83953
84087
  }
83954
84088
  }
83955
84089
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83957,7 +84091,7 @@ var ts;
83957
84091
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83958
84092
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83959
84093
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83960
- var _loop_29 = function (info) {
84094
+ var _loop_30 = function (info) {
83961
84095
  if (info === checkInfo)
83962
84096
  return "continue";
83963
84097
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83972,7 +84106,7 @@ var ts;
83972
84106
  };
83973
84107
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83974
84108
  var info = indexInfos_10[_i];
83975
- _loop_29(info);
84109
+ _loop_30(info);
83976
84110
  }
83977
84111
  }
83978
84112
  function checkTypeNameIsReserved(name, message) {
@@ -84291,7 +84425,7 @@ var ts;
84291
84425
  var baseTypes = baseTypeNode && getBaseTypes(type);
84292
84426
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84293
84427
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84294
- var _loop_30 = function (member) {
84428
+ var _loop_31 = function (member) {
84295
84429
  if (ts.hasAmbientModifier(member)) {
84296
84430
  return "continue";
84297
84431
  }
@@ -84308,7 +84442,7 @@ var ts;
84308
84442
  };
84309
84443
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84310
84444
  var member = _a[_i];
84311
- _loop_30(member);
84445
+ _loop_31(member);
84312
84446
  }
84313
84447
  }
84314
84448
  /**
@@ -84396,7 +84530,7 @@ var ts;
84396
84530
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84397
84531
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84398
84532
  var issuedMemberError = false;
84399
- var _loop_31 = function (member) {
84533
+ var _loop_32 = function (member) {
84400
84534
  if (ts.isStatic(member)) {
84401
84535
  return "continue";
84402
84536
  }
@@ -84415,7 +84549,7 @@ var ts;
84415
84549
  };
84416
84550
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84417
84551
  var member = _a[_i];
84418
- _loop_31(member);
84552
+ _loop_32(member);
84419
84553
  }
84420
84554
  if (!issuedMemberError) {
84421
84555
  // check again with diagnostics to generate a less-specific error
@@ -84483,18 +84617,17 @@ var ts;
84483
84617
  // but not by other kinds of members.
84484
84618
  // Base class instance member variables and accessors can be overridden by
84485
84619
  // derived class instance member variables and accessors, but not by other kinds of members.
84486
- var _a, _b;
84620
+ var _a, _b, _c, _d;
84487
84621
  // NOTE: assignability is checked in checkClassDeclaration
84488
84622
  var baseProperties = getPropertiesOfType(baseType);
84489
- basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84490
- var baseProperty = baseProperties_1[_i];
84623
+ var _loop_33 = function (baseProperty) {
84491
84624
  var base = getTargetSymbol(baseProperty);
84492
84625
  if (base.flags & 4194304 /* Prototype */) {
84493
- continue;
84626
+ return "continue";
84494
84627
  }
84495
84628
  var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
84496
84629
  if (!baseSymbol) {
84497
- continue;
84630
+ return "continue";
84498
84631
  }
84499
84632
  var derived = getTargetSymbol(baseSymbol);
84500
84633
  var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
@@ -84512,14 +84645,14 @@ var ts;
84512
84645
  // Searches other base types for a declaration that would satisfy the inherited abstract member.
84513
84646
  // (The class may have more than one base type via declaration merging with an interface with the
84514
84647
  // same name.)
84515
- for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) {
84516
- var otherBaseType = _d[_c];
84648
+ for (var _e = 0, _f = getBaseTypes(type); _e < _f.length; _e++) {
84649
+ var otherBaseType = _f[_e];
84517
84650
  if (otherBaseType === baseType)
84518
84651
  continue;
84519
84652
  var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
84520
84653
  var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
84521
84654
  if (derivedElsewhere && derivedElsewhere !== base) {
84522
- continue basePropertyCheck;
84655
+ return "continue-basePropertyCheck";
84523
84656
  }
84524
84657
  }
84525
84658
  if (derivedClassDecl.kind === 226 /* ClassExpression */) {
@@ -84534,20 +84667,19 @@ var ts;
84534
84667
  // derived overrides base.
84535
84668
  var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
84536
84669
  if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) {
84537
- // either base or derived property is private - not override, skip it
84538
- continue;
84670
+ return "continue";
84539
84671
  }
84540
84672
  var errorMessage = void 0;
84541
84673
  var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */;
84542
84674
  var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */;
84543
84675
  if (basePropertyFlags && derivedPropertyFlags) {
84544
84676
  // property/accessor is overridden with property/accessor
84545
- if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
84546
- || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */
84677
+ if ((ts.getCheckFlags(base) & 6 /* Synthetic */
84678
+ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })
84679
+ : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }))
84680
+ || ts.getCheckFlags(base) & 262144 /* Mapped */
84547
84681
  || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
84548
- // when the base property is abstract or from an interface, base/derived flags don't need to match
84549
- // same when the derived property is from an assignment
84550
- continue;
84682
+ return "continue";
84551
84683
  }
84552
84684
  var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */;
84553
84685
  var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */;
@@ -84558,12 +84690,12 @@ var ts;
84558
84690
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
84559
84691
  }
84560
84692
  else if (useDefineForClassFields) {
84561
- var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84693
+ var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; });
84562
84694
  if (uninitialized
84563
84695
  && !(derived.flags & 33554432 /* Transient */)
84564
84696
  && !(baseDeclarationFlags & 128 /* Abstract */)
84565
84697
  && !(derivedDeclarationFlags & 128 /* Abstract */)
84566
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84698
+ && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
84567
84699
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
84568
84700
  var propName = uninitialized.name;
84569
84701
  if (uninitialized.exclamationToken
@@ -84576,13 +84708,11 @@ var ts;
84576
84708
  }
84577
84709
  }
84578
84710
  }
84579
- // correct case
84580
- continue;
84711
+ return "continue";
84581
84712
  }
84582
84713
  else if (isPrototypeProperty(base)) {
84583
84714
  if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) {
84584
- // method is overridden with method or property -- correct case
84585
- continue;
84715
+ return "continue";
84586
84716
  }
84587
84717
  else {
84588
84718
  ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */));
@@ -84597,9 +84727,20 @@ var ts;
84597
84727
  }
84598
84728
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
84599
84729
  }
84730
+ };
84731
+ basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
84732
+ var baseProperty = baseProperties_1[_i];
84733
+ var state_10 = _loop_33(baseProperty);
84734
+ switch (state_10) {
84735
+ case "continue-basePropertyCheck": continue basePropertyCheck;
84736
+ }
84600
84737
  }
84601
84738
  }
84602
- function getNonInterhitedProperties(type, baseTypes, properties) {
84739
+ function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) {
84740
+ return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer)
84741
+ || ts.isInterfaceDeclaration(declaration.parent);
84742
+ }
84743
+ function getNonInheritedProperties(type, baseTypes, properties) {
84603
84744
  if (!ts.length(baseTypes)) {
84604
84745
  return properties;
84605
84746
  }
@@ -84668,7 +84809,7 @@ var ts;
84668
84809
  var propName = member.name;
84669
84810
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
84670
84811
  var type = getTypeOfSymbol(getSymbolOfNode(member));
84671
- if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
84812
+ if (!(type.flags & 3 /* AnyOrUnknown */ || getTypeFacts(type) & 16777216 /* IsUndefined */)) {
84672
84813
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
84673
84814
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
84674
84815
  }
@@ -84693,7 +84834,7 @@ var ts;
84693
84834
  ts.setParent(reference, staticBlock);
84694
84835
  reference.flowNode = staticBlock.returnFlowNode;
84695
84836
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84696
- if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) {
84837
+ if (!(getTypeFacts(flowType) & 16777216 /* IsUndefined */)) {
84697
84838
  return true;
84698
84839
  }
84699
84840
  }
@@ -84708,7 +84849,7 @@ var ts;
84708
84849
  ts.setParent(reference, constructor);
84709
84850
  reference.flowNode = constructor.returnFlowNode;
84710
84851
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
84711
- return !(getFalsyFlags(flowType) & 32768 /* Undefined */);
84852
+ return !(getTypeFacts(flowType) & 16777216 /* IsUndefined */);
84712
84853
  }
84713
84854
  function checkInterfaceDeclaration(node) {
84714
84855
  // Grammar checking
@@ -90075,9 +90216,7 @@ var ts;
90075
90216
  var ts;
90076
90217
  (function (ts) {
90077
90218
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
90078
- var _a = generatorOptions.extendedDiagnostics
90079
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
90080
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90219
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
90081
90220
  // Current source map file and its index in the sources list
90082
90221
  var rawSources = [];
90083
90222
  var sources = [];
@@ -92998,8 +93137,8 @@ var ts;
92998
93137
  // Note when updating logic here also update getEntityNameForDecoratorMetadata
92999
93138
  // so that aliases can be marked as referenced
93000
93139
  var serializedUnion;
93001
- for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
93002
- var typeNode = types_23[_i];
93140
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
93141
+ var typeNode = types_22[_i];
93003
93142
  while (typeNode.kind === 191 /* ParenthesizedType */) {
93004
93143
  typeNode = typeNode.type; // Skip parens if need be
93005
93144
  }
@@ -113614,8 +113753,8 @@ var ts;
113614
113753
  bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName });
113615
113754
  writeLine();
113616
113755
  }
113617
- for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
113618
- var directive = types_24[_d];
113756
+ for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
113757
+ var directive = types_23[_d];
113619
113758
  var pos = writer.getTextPos();
113620
113759
  var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
113621
113760
  ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
@@ -122383,7 +122522,7 @@ var ts;
122383
122522
  });
122384
122523
  // Sort by paths closest to importing file Name directory
122385
122524
  var sortedPaths = [];
122386
- var _loop_32 = function (directory) {
122525
+ var _loop_34 = function (directory) {
122387
122526
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122388
122527
  var pathsInDirectory;
122389
122528
  allFileNames.forEach(function (_a, fileName) {
@@ -122407,9 +122546,9 @@ var ts;
122407
122546
  };
122408
122547
  var out_directory_1;
122409
122548
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122410
- var state_10 = _loop_32(directory);
122549
+ var state_11 = _loop_34(directory);
122411
122550
  directory = out_directory_1;
122412
- if (state_10 === "break")
122551
+ if (state_11 === "break")
122413
122552
  break;
122414
122553
  }
122415
122554
  if (allFileNames.size) {
@@ -124353,6 +124492,7 @@ var ts;
124353
124492
  if (value) {
124354
124493
  return isParsedCommandLine(value) ? value : undefined;
124355
124494
  }
124495
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124356
124496
  var diagnostic;
124357
124497
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124358
124498
  var parsed;
@@ -124367,6 +124507,8 @@ var ts;
124367
124507
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124368
124508
  }
124369
124509
  configFileCache.set(configFilePath, parsed || diagnostic);
124510
+ ts.solutionPerformance.mark("afterParseConfigFile");
124511
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124370
124512
  return parsed;
124371
124513
  }
124372
124514
  function resolveProjectName(state, name) {
@@ -124416,6 +124558,7 @@ var ts;
124416
124558
  return state.buildOrder || createStateBuildOrder(state);
124417
124559
  }
124418
124560
  function createStateBuildOrder(state) {
124561
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124419
124562
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124420
124563
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124421
124564
  state.resolvedConfigFilePaths.clear();
@@ -124445,6 +124588,8 @@ var ts;
124445
124588
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124446
124589
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124447
124590
  }
124591
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124592
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124448
124593
  return state.buildOrder = buildOrder;
124449
124594
  }
124450
124595
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124565,6 +124710,7 @@ var ts;
124565
124710
  if (updateOutputFileStampsPending) {
124566
124711
  updateOutputTimestamps(state, config, projectPath);
124567
124712
  }
124713
+ ts.solutionPerformance.mark("timestampUpdated");
124568
124714
  return doneInvalidatedProject(state, projectPath);
124569
124715
  }
124570
124716
  };
@@ -124658,6 +124804,10 @@ var ts;
124658
124804
  };
124659
124805
  function done(cancellationToken, writeFile, customTransformers) {
124660
124806
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124807
+ if (kind === InvalidatedProjectKind.Build)
124808
+ ts.solutionPerformance.mark("projectsBuilt");
124809
+ else
124810
+ ts.solutionPerformance.mark("bundlesUpdated");
124661
124811
  return doneInvalidatedProject(state, projectPath);
124662
124812
  }
124663
124813
  function withProgramOrUndefined(action) {
@@ -124747,6 +124897,7 @@ var ts;
124747
124897
  var anyDtsChanged = false;
124748
124898
  var emitterDiagnostics = ts.createDiagnosticCollection();
124749
124899
  var emittedOutputs = new ts.Map();
124900
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124750
124901
  outputFiles.forEach(function (_a) {
124751
124902
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124752
124903
  var priorChangeTime;
@@ -124766,6 +124917,8 @@ var ts;
124766
124917
  newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124767
124918
  }
124768
124919
  });
124920
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124921
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124769
124922
  finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124770
124923
  /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124771
124924
  return emitResult;
@@ -124895,6 +125048,13 @@ var ts;
124895
125048
  !ts.isIncrementalCompilation(config.options);
124896
125049
  }
124897
125050
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
125051
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
125052
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
125053
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
125054
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
125055
+ return result;
125056
+ }
125057
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124898
125058
  if (!state.projectPendingBuild.size)
124899
125059
  return undefined;
124900
125060
  if (isCircularBuildOrder(buildOrder))
@@ -124994,9 +125154,7 @@ var ts;
124994
125154
  }
124995
125155
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124996
125156
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124997
- if (!info)
124998
- return info;
124999
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
125157
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
125000
125158
  }
125001
125159
  function listEmittedFile(_a, proj, file) {
125002
125160
  var write = _a.write;
@@ -125004,14 +125162,17 @@ var ts;
125004
125162
  write("TSFILE: " + file);
125005
125163
  }
125006
125164
  }
125007
- function getOldProgram(_a, proj, parsed) {
125008
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
125009
- if (options.force)
125165
+ function getOldProgram(state, proj, parsed) {
125166
+ if (state.options.force)
125010
125167
  return undefined;
125011
- var value = builderPrograms.get(proj);
125168
+ var value = state.builderPrograms.get(proj);
125012
125169
  if (value)
125013
125170
  return value;
125014
- return ts.readBuilderProgram(parsed.options, compilerHost);
125171
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
125172
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
125173
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
125174
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
125175
+ return program;
125015
125176
  }
125016
125177
  function afterProgramDone(state, program, config) {
125017
125178
  if (program) {
@@ -125210,7 +125371,10 @@ var ts;
125210
125371
  state.buildInfoChecked.set(resolvedPath, true);
125211
125372
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125212
125373
  if (buildInfoPath) {
125374
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125213
125375
  var value = state.readFileWithCache(buildInfoPath);
125376
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125377
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125214
125378
  var buildInfo = value && ts.getBuildInfo(value);
125215
125379
  if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125216
125380
  return {
@@ -125246,13 +125410,17 @@ var ts;
125246
125410
  if (prior !== undefined) {
125247
125411
  return prior;
125248
125412
  }
125413
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125249
125414
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125415
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125416
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125250
125417
  state.projectStatus.set(resolvedPath, actual);
125251
125418
  return actual;
125252
125419
  }
125253
125420
  function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125254
125421
  if (proj.options.noEmit)
125255
125422
  return priorNewestUpdateTime;
125423
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125256
125424
  var host = state.host;
125257
125425
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125258
125426
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
@@ -125273,6 +125441,8 @@ var ts;
125273
125441
  host.setModifiedTime(file, now);
125274
125442
  }
125275
125443
  }
125444
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125445
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125276
125446
  return priorNewestUpdateTime;
125277
125447
  }
125278
125448
  function updateOutputTimestamps(state, proj, resolvedPath) {
@@ -125351,6 +125521,13 @@ var ts;
125351
125521
  }
125352
125522
  }
125353
125523
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125524
+ ts.solutionPerformance.mark("beforeBuild");
125525
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125526
+ ts.solutionPerformance.mark("afterBuild");
125527
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125528
+ return result;
125529
+ }
125530
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125354
125531
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125355
125532
  if (!buildOrder)
125356
125533
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125362,7 +125539,10 @@ var ts;
125362
125539
  if (!invalidatedProject)
125363
125540
  break;
125364
125541
  reportQueue = false;
125542
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125365
125543
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125544
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125545
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125366
125546
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125367
125547
  successfulProjects++;
125368
125548
  }
@@ -125451,6 +125631,14 @@ var ts;
125451
125631
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125452
125632
  }
125453
125633
  function buildNextInvalidatedProject(state, changeDetected) {
125634
+ ts.solutionPerformance.mark("beforeBuild");
125635
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125636
+ ts.solutionPerformance.mark("afterBuild");
125637
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125638
+ if (buildOrder)
125639
+ reportErrorSummary(state, buildOrder);
125640
+ }
125641
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125454
125642
  state.timerToBuildInvalidatedProject = undefined;
125455
125643
  if (state.reportFileChangeDetected) {
125456
125644
  state.reportFileChangeDetected = false;
@@ -125461,7 +125649,10 @@ var ts;
125461
125649
  var buildOrder = getBuildOrder(state);
125462
125650
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125463
125651
  if (invalidatedProject) {
125652
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125464
125653
  invalidatedProject.done();
125654
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125655
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125465
125656
  projectsBuilt++;
125466
125657
  while (state.projectPendingBuild.size) {
125467
125658
  // If already scheduled, skip
@@ -125477,13 +125668,16 @@ var ts;
125477
125668
  return;
125478
125669
  }
125479
125670
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125671
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125480
125672
  project.done();
125673
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125674
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125481
125675
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125482
125676
  projectsBuilt++;
125483
125677
  }
125484
125678
  }
125485
125679
  disableCache(state);
125486
- reportErrorSummary(state, buildOrder);
125680
+ return buildOrder;
125487
125681
  }
125488
125682
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125489
125683
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
@@ -125540,6 +125734,7 @@ var ts;
125540
125734
  function startWatching(state, buildOrder) {
125541
125735
  if (!state.watchAllProjectsPending)
125542
125736
  return;
125737
+ ts.solutionPerformance.mark("beforeStartWatching");
125543
125738
  state.watchAllProjectsPending = false;
125544
125739
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125545
125740
  var resolved = _a[_i];
@@ -125557,6 +125752,8 @@ var ts;
125557
125752
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125558
125753
  }
125559
125754
  }
125755
+ ts.solutionPerformance.mark("afterStartWatching");
125756
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125560
125757
  }
125561
125758
  function stopWatching(state) {
125562
125759
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -136952,7 +137149,7 @@ var ts;
136952
137149
  ts.Debug.assert(parent.name === node);
136953
137150
  return true;
136954
137151
  case 203 /* BindingElement */:
136955
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
137152
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136956
137153
  default:
136957
137154
  return false;
136958
137155
  }
@@ -138418,7 +138615,7 @@ var ts;
138418
138615
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138419
138616
  if (ts.isInJSFile(referenceLocation)
138420
138617
  && referenceLocation.parent.kind === 203 /* BindingElement */
138421
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138618
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138422
138619
  referenceSymbol = referenceLocation.parent.symbol;
138423
138620
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138424
138621
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -144512,7 +144709,7 @@ var ts;
144512
144709
  if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) {
144513
144710
  return;
144514
144711
  }
144515
- if (ts.isTypeNode(node)) {
144712
+ if (ts.isTypeNode(node) && !ts.isExpressionWithTypeArguments(node)) {
144516
144713
  return;
144517
144714
  }
144518
144715
  if (preferences.includeInlayVariableTypeHints && ts.isVariableDeclaration(node)) {
@@ -147623,7 +147820,6 @@ var ts;
147623
147820
  case 280 /* JsxOpeningElement */:
147624
147821
  case 281 /* JsxClosingElement */:
147625
147822
  case 279 /* JsxSelfClosingElement */:
147626
- case 228 /* ExpressionWithTypeArguments */:
147627
147823
  return false;
147628
147824
  }
147629
147825
  break;
@@ -147793,12 +147989,10 @@ var ts;
147793
147989
  var listEndToken = getCloseTokenForOpenToken(listStartToken);
147794
147990
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147795
147991
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147796
- if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147797
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147798
- if (startLine !== commaTokenLine) {
147799
- formattingScanner.advance();
147800
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147801
- }
147992
+ if (tokenInfo.token.kind === 27 /* CommaToken */) {
147993
+ // consume the comma
147994
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147995
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147802
147996
  }
147803
147997
  // consume the list end token only if it is still belong to the parent
147804
147998
  // there might be the case when current token matches end token but does not considered as one
@@ -148199,6 +148393,12 @@ var ts;
148199
148393
  case 169 /* MethodDeclaration */:
148200
148394
  case 168 /* MethodSignature */:
148201
148395
  case 214 /* ArrowFunction */:
148396
+ case 174 /* CallSignature */:
148397
+ case 175 /* ConstructSignature */:
148398
+ case 179 /* FunctionType */:
148399
+ case 180 /* ConstructorType */:
148400
+ case 172 /* GetAccessor */:
148401
+ case 173 /* SetAccessor */:
148202
148402
  if (node.typeParameters === list) {
148203
148403
  return 29 /* LessThanToken */;
148204
148404
  }
@@ -148215,7 +148415,19 @@ var ts;
148215
148415
  return 20 /* OpenParenToken */;
148216
148416
  }
148217
148417
  break;
148418
+ case 257 /* ClassDeclaration */:
148419
+ case 226 /* ClassExpression */:
148420
+ case 258 /* InterfaceDeclaration */:
148421
+ case 259 /* TypeAliasDeclaration */:
148422
+ if (node.typeParameters === list) {
148423
+ return 29 /* LessThanToken */;
148424
+ }
148425
+ break;
148218
148426
  case 178 /* TypeReference */:
148427
+ case 210 /* TaggedTemplateExpression */:
148428
+ case 181 /* TypeQuery */:
148429
+ case 228 /* ExpressionWithTypeArguments */:
148430
+ case 200 /* ImportType */:
148219
148431
  if (node.typeArguments === list) {
148220
148432
  return 29 /* LessThanToken */;
148221
148433
  }