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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220601";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -2970,14 +2970,32 @@ var ts;
2970
2970
  })(ts || (ts = {}));
2971
2971
  var ts;
2972
2972
  (function (ts) {
2973
- var performance;
2974
- (function (performance) {
2973
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
2974
+ ts.performance = createPerformanceTracker();
2975
+ ts.solutionPerformance = createPerformanceTracker();
2976
+ function createPerformanceTracker() {
2975
2977
  var perfHooks;
2976
2978
  var performanceImpl;
2979
+ var enabled = false;
2980
+ var timeorigin = ts.timestamp();
2981
+ var marks = new ts.Map();
2982
+ var counts = new ts.Map();
2983
+ var durations = new ts.Map();
2984
+ return {
2985
+ createTimerIf: createTimerIf,
2986
+ createTimer: createTimer,
2987
+ mark: mark,
2988
+ measure: measure,
2989
+ getCount: getCount,
2990
+ getDuration: getDuration,
2991
+ forEachMeasure: forEachMeasure,
2992
+ isEnabled: isEnabled,
2993
+ enable: enable,
2994
+ disable: disable,
2995
+ };
2977
2996
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
2978
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
2997
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
2979
2998
  }
2980
- performance.createTimerIf = createTimerIf;
2981
2999
  function createTimer(measureName, startMarkName, endMarkName) {
2982
3000
  var enterCount = 0;
2983
3001
  return {
@@ -2999,13 +3017,6 @@ var ts;
2999
3017
  }
3000
3018
  }
3001
3019
  }
3002
- performance.createTimer = createTimer;
3003
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3004
- var enabled = false;
3005
- var timeorigin = ts.timestamp();
3006
- var marks = new ts.Map();
3007
- var counts = new ts.Map();
3008
- var durations = new ts.Map();
3009
3020
  function mark(markName) {
3010
3021
  var _a;
3011
3022
  if (enabled) {
@@ -3015,34 +3026,28 @@ var ts;
3015
3026
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3016
3027
  }
3017
3028
  }
3018
- performance.mark = mark;
3019
3029
  function measure(measureName, startMarkName, endMarkName) {
3020
3030
  var _a, _b;
3021
3031
  if (enabled) {
3022
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3023
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3032
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3033
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3024
3034
  var previousDuration = durations.get(measureName) || 0;
3025
3035
  durations.set(measureName, previousDuration + (end - start));
3026
3036
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3027
3037
  }
3028
3038
  }
3029
- performance.measure = measure;
3030
3039
  function getCount(markName) {
3031
3040
  return counts.get(markName) || 0;
3032
3041
  }
3033
- performance.getCount = getCount;
3034
3042
  function getDuration(measureName) {
3035
3043
  return durations.get(measureName) || 0;
3036
3044
  }
3037
- performance.getDuration = getDuration;
3038
3045
  function forEachMeasure(cb) {
3039
3046
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3040
3047
  }
3041
- performance.forEachMeasure = forEachMeasure;
3042
3048
  function isEnabled() {
3043
3049
  return enabled;
3044
3050
  }
3045
- performance.isEnabled = isEnabled;
3046
3051
  function enable(system) {
3047
3052
  var _a;
3048
3053
  if (system === void 0) { system = ts.sys; }
@@ -3058,7 +3063,6 @@ var ts;
3058
3063
  }
3059
3064
  return true;
3060
3065
  }
3061
- performance.enable = enable;
3062
3066
  function disable() {
3063
3067
  if (enabled) {
3064
3068
  marks.clear();
@@ -3068,8 +3072,7 @@ var ts;
3068
3072
  enabled = false;
3069
3073
  }
3070
3074
  }
3071
- performance.disable = disable;
3072
- })(performance = ts.performance || (ts.performance = {}));
3075
+ }
3073
3076
  })(ts || (ts = {}));
3074
3077
  var ts;
3075
3078
  (function (ts) {
@@ -3855,7 +3858,7 @@ var ts;
3855
3858
  }
3856
3859
  ts.setSysLog = setSysLog;
3857
3860
  function createDirectoryWatcherSupportingRecursive(_a) {
3858
- 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;
3861
+ 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;
3859
3862
  var cache = new ts.Map();
3860
3863
  var callbackCache = ts.createMultiMap();
3861
3864
  var cacheToUpdateChildWatches = new ts.Map();
@@ -3948,7 +3951,7 @@ var ts;
3948
3951
  }
3949
3952
  function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
3950
3953
  var parentWatcher = cache.get(dirPath);
3951
- if (parentWatcher && fileSystemEntryExists(dirName, 1)) {
3954
+ if (parentWatcher && directoryExists(dirName)) {
3952
3955
  scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
3953
3956
  return;
3954
3957
  }
@@ -4016,7 +4019,7 @@ var ts;
4016
4019
  if (!parentWatcher)
4017
4020
  return false;
4018
4021
  var newChildWatches;
4019
- var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
4022
+ var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
4020
4023
  var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
4021
4024
  return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 ? childFullName : undefined;
4022
4025
  }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
@@ -4047,10 +4050,10 @@ var ts;
4047
4050
  return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
4048
4051
  }
4049
4052
  ts.createFileWatcherCallback = createFileWatcherCallback;
4050
- function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists) {
4053
+ function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
4051
4054
  return function (eventName) {
4052
4055
  if (eventName === "rename") {
4053
- callback(fileName, fileSystemEntryExists(fileName, 0) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
4056
+ callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
4054
4057
  }
4055
4058
  else {
4056
4059
  callback(fileName, FileWatcherEventKind.Changed);
@@ -4072,12 +4075,11 @@ var ts;
4072
4075
  };
4073
4076
  }
4074
4077
  function createSystemWatchFunctions(_a) {
4075
- 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;
4078
+ 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;
4076
4079
  var dynamicPollingWatchFile;
4077
4080
  var fixedChunkSizePollingWatchFile;
4078
4081
  var nonPollingWatchFile;
4079
4082
  var hostRecursiveDirectoryWatcher;
4080
- var hitSystemWatcherLimit = false;
4081
4083
  return {
4082
4084
  watchFile: watchFile,
4083
4085
  watchDirectory: watchDirectory
@@ -4095,7 +4097,7 @@ var ts;
4095
4097
  case ts.WatchFileKind.FixedChunkSizePolling:
4096
4098
  return ensureFixedChunkSizePollingWatchFile()(fileName, callback, undefined, undefined);
4097
4099
  case ts.WatchFileKind.UseFsEvents:
4098
- return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists), false, pollingInterval, ts.getFallbackOptions(options));
4100
+ return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
4099
4101
  case ts.WatchFileKind.UseFsEventsOnParentDirectory:
4100
4102
  if (!nonPollingWatchFile) {
4101
4103
  nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
@@ -4148,7 +4150,7 @@ var ts;
4148
4150
  hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
4149
4151
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4150
4152
  getCurrentDirectory: getCurrentDirectory,
4151
- fileSystemEntryExists: fileSystemEntryExists,
4153
+ directoryExists: directoryExists,
4152
4154
  getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
4153
4155
  watchDirectory: nonRecursiveWatchDirectory,
4154
4156
  realpath: realpath,
@@ -4193,90 +4195,6 @@ var ts;
4193
4195
  };
4194
4196
  }
4195
4197
  }
4196
- function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
4197
- var lastDirectoryPartWithDirectorySeparator;
4198
- var lastDirectoryPart;
4199
- if (inodeWatching) {
4200
- lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
4201
- lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
4202
- }
4203
- var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4204
- watchMissingFileSystemEntry() :
4205
- watchPresentFileSystemEntry();
4206
- return {
4207
- close: function () {
4208
- watcher.close();
4209
- watcher = undefined;
4210
- }
4211
- };
4212
- function updateWatcher(createWatcher) {
4213
- if (watcher) {
4214
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
4215
- watcher.close();
4216
- watcher = createWatcher();
4217
- }
4218
- }
4219
- function watchPresentFileSystemEntry() {
4220
- if (hitSystemWatcherLimit) {
4221
- sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
4222
- return watchPresentFileSystemEntryWithFsWatchFile();
4223
- }
4224
- try {
4225
- var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
4226
- callbackChangingToMissingFileSystemEntry :
4227
- function (eventName, relativeFileName) {
4228
- sysLog("sysLog:: watchPresentFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
4229
- callback(eventName, relativeFileName);
4230
- });
4231
- presentWatcher.on("error", function () {
4232
- sysLog("sysLog:: watchPresentFileSystemEntry:: on Error " + fileOrDirectory + " " + entryKind + " rename, \"\"");
4233
- callback("rename", "");
4234
- updateWatcher(watchMissingFileSystemEntry);
4235
- });
4236
- return presentWatcher;
4237
- }
4238
- catch (e) {
4239
- hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
4240
- sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
4241
- return watchPresentFileSystemEntryWithFsWatchFile();
4242
- }
4243
- }
4244
- function callbackChangingToMissingFileSystemEntry(event, relativeName) {
4245
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + event + ":: " + relativeName + " " + inodeWatching + " " + lastDirectoryPart + " " + lastDirectoryPartWithDirectorySeparator);
4246
- if (relativeName && ts.endsWith(relativeName, "~")) {
4247
- relativeName = relativeName.slice(0, relativeName.length - 1);
4248
- sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: changed the relative name to " + relativeName);
4249
- }
4250
- callback(event, relativeName);
4251
- if (event === "rename" &&
4252
- (!relativeName ||
4253
- relativeName === lastDirectoryPart ||
4254
- ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
4255
- if (inodeWatching) {
4256
- updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
4257
- }
4258
- else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
4259
- updateWatcher(watchMissingFileSystemEntry);
4260
- }
4261
- }
4262
- }
4263
- function watchPresentFileSystemEntryWithFsWatchFile() {
4264
- return watchFile(fileOrDirectory, createFileWatcherCallback(function (eventName, relativeFileName) {
4265
- sysLog("sysLog:: watchPresentFileSystemEntryWithFsWatchFile:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
4266
- callback(eventName, relativeFileName);
4267
- }), fallbackPollingInterval, fallbackOptions);
4268
- }
4269
- function watchMissingFileSystemEntry() {
4270
- return watchFile(fileOrDirectory, function (_fileName, eventKind) {
4271
- sysLog("sysLog:: watchMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + _fileName + ":: " + eventKind);
4272
- if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
4273
- sysLog("sysLog:: watchMissingFileSystemEntry:: Callback :: rename, \"\" and will update the watcher");
4274
- callback("rename", "");
4275
- updateWatcher(watchPresentFileSystemEntry);
4276
- }
4277
- }, fallbackPollingInterval, fallbackOptions);
4278
- }
4279
- }
4280
4198
  }
4281
4199
  ts.createSystemWatchFunctions = createSystemWatchFunctions;
4282
4200
  function patchWriteFileEnsuringDirectory(sys) {
@@ -4318,6 +4236,7 @@ var ts;
4318
4236
  }
4319
4237
  var activeSession;
4320
4238
  var profilePath = "./profile.cpuprofile";
4239
+ var hitSystemWatcherLimit = false;
4321
4240
  var Buffer = require("buffer").Buffer;
4322
4241
  var nodeVersion = getNodeMajorVersion();
4323
4242
  var isNode4OrLater = nodeVersion >= 4;
@@ -4332,19 +4251,18 @@ var ts;
4332
4251
  getModifiedTime: getModifiedTime,
4333
4252
  setTimeout: setTimeout,
4334
4253
  clearTimeout: clearTimeout,
4335
- fsWatchWorker: fsWatchWorker,
4254
+ fsWatch: fsWatch,
4336
4255
  useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4337
4256
  getCurrentDirectory: getCurrentDirectory,
4338
- fileSystemEntryExists: fileSystemEntryExists,
4257
+ fileExists: fileExists,
4339
4258
  fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
4259
+ directoryExists: directoryExists,
4340
4260
  getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
4341
4261
  realpath: realpath,
4342
4262
  tscWatchFile: process.env.TSC_WATCHFILE,
4343
4263
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
4344
4264
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4345
4265
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
4346
- inodeWatching: isLinuxOrMacOs,
4347
- sysLog: sysLog,
4348
4266
  }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
4349
4267
  var nodeSystem = {
4350
4268
  args: process.argv.slice(2),
@@ -4567,9 +4485,76 @@ var ts;
4567
4485
  callback(fileName, eventKind);
4568
4486
  }
4569
4487
  }
4570
- function fsWatchWorker(fileOrDirectory, recursive, callback) {
4571
- return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
4572
- { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
4488
+ function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
4489
+ var options;
4490
+ var lastDirectoryPartWithDirectorySeparator;
4491
+ var lastDirectoryPart;
4492
+ if (isLinuxOrMacOs) {
4493
+ lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
4494
+ lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
4495
+ }
4496
+ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4497
+ watchMissingFileSystemEntry() :
4498
+ watchPresentFileSystemEntry();
4499
+ return {
4500
+ close: function () {
4501
+ watcher.close();
4502
+ watcher = undefined;
4503
+ }
4504
+ };
4505
+ function invokeCallbackAndUpdateWatcher(createWatcher) {
4506
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
4507
+ callback("rename", "");
4508
+ if (watcher) {
4509
+ watcher.close();
4510
+ watcher = createWatcher();
4511
+ }
4512
+ }
4513
+ function watchPresentFileSystemEntry() {
4514
+ if (options === undefined) {
4515
+ if (fsSupportsRecursiveFsWatch) {
4516
+ options = { persistent: true, recursive: !!recursive };
4517
+ }
4518
+ else {
4519
+ options = { persistent: true };
4520
+ }
4521
+ }
4522
+ if (hitSystemWatcherLimit) {
4523
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
4524
+ return watchPresentFileSystemEntryWithFsWatchFile();
4525
+ }
4526
+ try {
4527
+ var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
4528
+ callbackChangingToMissingFileSystemEntry :
4529
+ callback);
4530
+ presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
4531
+ return presentWatcher;
4532
+ }
4533
+ catch (e) {
4534
+ hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
4535
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
4536
+ return watchPresentFileSystemEntryWithFsWatchFile();
4537
+ }
4538
+ }
4539
+ function callbackChangingToMissingFileSystemEntry(event, relativeName) {
4540
+ return event === "rename" &&
4541
+ (!relativeName ||
4542
+ relativeName === lastDirectoryPart ||
4543
+ (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
4544
+ !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4545
+ invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
4546
+ callback(event, relativeName);
4547
+ }
4548
+ function watchPresentFileSystemEntryWithFsWatchFile() {
4549
+ return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
4550
+ }
4551
+ function watchMissingFileSystemEntry() {
4552
+ return watchFile(fileOrDirectory, function (_fileName, eventKind) {
4553
+ if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
4554
+ invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
4555
+ }
4556
+ }, fallbackPollingInterval, fallbackOptions);
4557
+ }
4573
4558
  }
4574
4559
  function readFileWorker(fileName, _encoding) {
4575
4560
  var buffer;
@@ -5616,6 +5601,7 @@ var ts;
5616
5601
  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}'.", undefined, true),
5617
5602
  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."),
5618
5603
  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."),
5604
+ 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."),
5619
5605
  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."),
5620
5606
  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."),
5621
5607
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -6101,6 +6087,7 @@ var ts;
6101
6087
  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."),
6102
6088
  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."),
6103
6089
  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."),
6090
+ 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"),
6104
6091
  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}'."),
6105
6092
  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}'."),
6106
6093
  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}'."),
@@ -12617,9 +12604,6 @@ var ts;
12617
12604
  }
12618
12605
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
12619
12606
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
12620
- if (node.kind === 203) {
12621
- node = node.parent.parent;
12622
- }
12623
12607
  return ts.isVariableDeclaration(node) &&
12624
12608
  !!node.initializer &&
12625
12609
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, true);
@@ -15879,13 +15863,13 @@ var ts;
15879
15863
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
15880
15864
  }
15881
15865
  function isFileForcedToBeModuleByFormat(file) {
15882
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
15866
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts"]))) && !file.isDeclarationFile ? true : undefined;
15883
15867
  }
15884
15868
  function getSetExternalModuleIndicator(options) {
15885
15869
  switch (getEmitModuleDetectionKind(options)) {
15886
15870
  case ts.ModuleDetectionKind.Force:
15887
15871
  return function (file) {
15888
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
15872
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
15889
15873
  };
15890
15874
  case ts.ModuleDetectionKind.Legacy:
15891
15875
  return function (file) {
@@ -15941,7 +15925,8 @@ var ts;
15941
15925
  }
15942
15926
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
15943
15927
  function getEmitModuleDetectionKind(options) {
15944
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
15928
+ return options.moduleDetection ||
15929
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
15945
15930
  }
15946
15931
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
15947
15932
  function hasJsonModuleEmitEnabled(options) {
@@ -35217,15 +35202,19 @@ var ts;
35217
35202
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35218
35203
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
35219
35204
  }
35220
- function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35221
- var containingDirectory = ts.getDirectoryPath(containingFile);
35222
- var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
35223
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
35224
- }
35225
35205
  var jsOnlyExtensions = [Extensions.JavaScript];
35226
35206
  var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
35227
35207
  var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
35228
35208
  var tsconfigExtensions = [Extensions.TSConfig];
35209
+ function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35210
+ var containingDirectory = ts.getDirectoryPath(containingFile);
35211
+ var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
35212
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
35213
+ if (compilerOptions.resolveJsonModule) {
35214
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
35215
+ }
35216
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
35217
+ }
35229
35218
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
35230
35219
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
35231
35220
  }
@@ -36129,8 +36118,7 @@ var ts;
36129
36118
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
36130
36119
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
36131
36120
  if (!pathAndExtension && packageInfo
36132
- && packageInfo.packageJsonContent.exports === undefined
36133
- && packageInfo.packageJsonContent.main === undefined
36121
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
36134
36122
  && state.features & NodeResolutionFeatures.EsmMode) {
36135
36123
  pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
36136
36124
  }
@@ -38505,12 +38493,14 @@ var ts;
38505
38493
  }
38506
38494
  }
38507
38495
  function setCommonJsModuleIndicator(node) {
38508
- if (file.externalModuleIndicator) {
38496
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
38509
38497
  return false;
38510
38498
  }
38511
38499
  if (!file.commonJsModuleIndicator) {
38512
38500
  file.commonJsModuleIndicator = node;
38513
- bindSourceFileAsExternalModule();
38501
+ if (!file.externalModuleIndicator) {
38502
+ bindSourceFileAsExternalModule();
38503
+ }
38514
38504
  }
38515
38505
  return true;
38516
38506
  }
@@ -38863,7 +38853,11 @@ var ts;
38863
38853
  checkStrictModeEvalOrArguments(node, node.name);
38864
38854
  }
38865
38855
  if (!ts.isBindingPattern(node.name)) {
38866
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1)) {
38856
+ var possibleVariableDecl = node.kind === 254 ? node : node.parent.parent;
38857
+ if (ts.isInJSFile(node) &&
38858
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
38859
+ !ts.getJSDocTypeTag(node) &&
38860
+ !(ts.getCombinedModifierFlags(node) & 1)) {
38867
38861
  declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
38868
38862
  }
38869
38863
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -39761,6 +39755,7 @@ var ts;
39761
39755
  var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
39762
39756
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
39763
39757
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
39758
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
39764
39759
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
39765
39760
  emptyGenericType.instantiations = new ts.Map();
39766
39761
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -41047,7 +41042,12 @@ var ts;
41047
41042
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
41048
41043
  if (meaning & (111551 & ~1024)) {
41049
41044
  if (isPrimitiveTypeName(name)) {
41050
- error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
41045
+ if (isExtendedByInterface(errorLocation)) {
41046
+ 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));
41047
+ }
41048
+ else {
41049
+ error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
41050
+ }
41051
41051
  return true;
41052
41052
  }
41053
41053
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
@@ -41067,6 +41067,16 @@ var ts;
41067
41067
  }
41068
41068
  return false;
41069
41069
  }
41070
+ function isExtendedByInterface(node) {
41071
+ var grandparent = node.parent.parent;
41072
+ var parentOfGrandparent = grandparent.parent;
41073
+ if (grandparent && parentOfGrandparent) {
41074
+ var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94;
41075
+ var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent);
41076
+ return isExtending && isInterface;
41077
+ }
41078
+ return false;
41079
+ }
41070
41080
  function maybeMappedType(node, symbol) {
41071
41081
  var container = ts.findAncestor(node.parent, function (n) {
41072
41082
  return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
@@ -41176,7 +41186,8 @@ var ts;
41176
41186
  && isAliasableOrJsExpression(node.parent.right)
41177
41187
  || node.kind === 297
41178
41188
  || node.kind === 296 && isAliasableOrJsExpression(node.initializer)
41179
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
41189
+ || node.kind === 254 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
41190
+ || node.kind === 203 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
41180
41191
  }
41181
41192
  function isAliasableOrJsExpression(e) {
41182
41193
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -41257,7 +41268,7 @@ var ts;
41257
41268
  if (!ts.isSourceFileJS(file)) {
41258
41269
  return hasExportAssignmentSymbol(moduleSymbol);
41259
41270
  }
41260
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41271
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41261
41272
  }
41262
41273
  function getTargetOfImportClause(node, dontResolveAlias) {
41263
41274
  var _a;
@@ -43592,7 +43603,7 @@ var ts;
43592
43603
  anyType : getNonMissingTypeOfSymbol(propertySymbol);
43593
43604
  var saveEnclosingDeclaration = context.enclosingDeclaration;
43594
43605
  context.enclosingDeclaration = undefined;
43595
- if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 && isLateBoundName(propertySymbol.escapedName)) {
43606
+ if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) {
43596
43607
  if (propertySymbol.declarations) {
43597
43608
  var decl = ts.first(propertySymbol.declarations);
43598
43609
  if (hasLateBindableName(decl)) {
@@ -45047,7 +45058,7 @@ var ts;
45047
45058
  ? getBaseConstructorTypeOfClass(staticType)
45048
45059
  : anyType;
45049
45060
  var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117, implementsExpressions)], true);
45050
- var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
45061
+ var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
45051
45062
  var publicSymbolProps = ts.filter(symbolProps, function (s) {
45052
45063
  var valueDecl = s.valueDeclaration;
45053
45064
  return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
@@ -45961,7 +45972,7 @@ var ts;
45961
45972
  return type;
45962
45973
  }
45963
45974
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
45964
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0)) & 32768) ? getNonUndefinedType(type) : type;
45975
+ return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0)) & 16777216) ? getNonUndefinedType(type) : type;
45965
45976
  }
45966
45977
  return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0)], 2));
45967
45978
  }
@@ -48569,7 +48580,7 @@ var ts;
48569
48580
  }
48570
48581
  }
48571
48582
  }
48572
- else if (t.flags & 469892092) {
48583
+ else if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) {
48573
48584
  hasDisjointDomainType = true;
48574
48585
  }
48575
48586
  }
@@ -48577,7 +48588,7 @@ var ts;
48577
48588
  if (hasDisjointDomainType) {
48578
48589
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
48579
48590
  var t = types_6[_a];
48580
- if (t.flags & 469892092) {
48591
+ if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) {
48581
48592
  constraints = ts.append(constraints, t);
48582
48593
  }
48583
48594
  }
@@ -48749,7 +48760,7 @@ var ts;
48749
48760
  var objectType;
48750
48761
  return !!(type.flags & 8388608 && ts.getObjectFlags(objectType = type.objectType) & 32 &&
48751
48762
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
48752
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
48763
+ !(getMappedTypeModifiers(objectType) & 8) && !objectType.declaration.nameType);
48753
48764
  }
48754
48765
  function getApparentType(type) {
48755
48766
  var t = !(type.flags & 465829888) ? type : getBaseConstraintOfType(type) || unknownType;
@@ -50847,7 +50858,7 @@ var ts;
50847
50858
  }
50848
50859
  return includes;
50849
50860
  }
50850
- function removeRedundantPrimitiveTypes(types, includes) {
50861
+ function removeRedundantSupertypes(types, includes) {
50851
50862
  var i = types.length;
50852
50863
  while (i > 0) {
50853
50864
  i--;
@@ -50855,7 +50866,9 @@ var ts;
50855
50866
  var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) ||
50856
50867
  t.flags & 8 && includes & 256 ||
50857
50868
  t.flags & 64 && includes & 2048 ||
50858
- t.flags & 4096 && includes & 8192;
50869
+ t.flags & 4096 && includes & 8192 ||
50870
+ t.flags & 16384 && includes & 32768 ||
50871
+ isEmptyAnonymousObjectType(t) && includes & 470302716;
50859
50872
  if (remove) {
50860
50873
  ts.orderedRemoveItemAt(types, i);
50861
50874
  }
@@ -50950,7 +50963,7 @@ var ts;
50950
50963
  result.aliasTypeArguments = aliasTypeArguments;
50951
50964
  return result;
50952
50965
  }
50953
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
50966
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
50954
50967
  var typeMembershipMap = new ts.Map();
50955
50968
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
50956
50969
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -50978,11 +50991,11 @@ var ts;
50978
50991
  if (includes & 4 && includes & (128 | 134217728 | 268435456) ||
50979
50992
  includes & 8 && includes & 256 ||
50980
50993
  includes & 64 && includes & 2048 ||
50981
- includes & 4096 && includes & 8192) {
50982
- removeRedundantPrimitiveTypes(typeSet, includes);
50983
- }
50984
- if (includes & 16777216 && includes & 524288) {
50985
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
50994
+ includes & 4096 && includes & 8192 ||
50995
+ includes & 16384 && includes & 32768 ||
50996
+ includes & 16777216 && includes & 470302716) {
50997
+ if (!noSupertypeReduction)
50998
+ removeRedundantSupertypes(typeSet, includes);
50986
50999
  }
50987
51000
  if (includes & 262144) {
50988
51001
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -51014,7 +51027,7 @@ var ts;
51014
51027
  return errorType;
51015
51028
  }
51016
51029
  var constituents = getCrossProductIntersections(typeSet);
51017
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined;
51030
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined;
51018
51031
  result = getUnionType(constituents, 1, aliasSymbol, aliasTypeArguments, origin);
51019
51032
  }
51020
51033
  }
@@ -51057,11 +51070,21 @@ var ts;
51057
51070
  }
51058
51071
  return intersections;
51059
51072
  }
51073
+ function getConstituentCount(type) {
51074
+ return !(type.flags & 3145728) || type.aliasSymbol ? 1 :
51075
+ type.flags & 1048576 && type.origin ? getConstituentCount(type.origin) :
51076
+ getConstituentCountOfTypes(type.types);
51077
+ }
51078
+ function getConstituentCountOfTypes(types) {
51079
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
51080
+ }
51060
51081
  function getTypeFromIntersectionTypeNode(node) {
51061
51082
  var links = getNodeLinks(node);
51062
51083
  if (!links.resolvedType) {
51063
51084
  var aliasSymbol = getAliasSymbolForTypeNode(node);
51064
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
51085
+ var types = ts.map(node.types, getTypeFromTypeNode);
51086
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 | 8 | 64)) && types[1] === emptyTypeLiteralType;
51087
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
51065
51088
  }
51066
51089
  return links.resolvedType;
51067
51090
  }
@@ -53436,7 +53459,7 @@ var ts;
53436
53459
  var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
53437
53460
  var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
53438
53461
  var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
53439
- (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
53462
+ (getTypeFacts(sourceType) & 50331648) === (getTypeFacts(targetType) & 50331648);
53440
53463
  var related = callbacks ?
53441
53464
  compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
53442
53465
  !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
@@ -53540,6 +53563,17 @@ var ts;
53540
53563
  return !!(ts.getObjectFlags(type) & 16 && (type.members && isEmptyResolvedType(type) ||
53541
53564
  type.symbol && type.symbol.flags & 2048 && getMembersOfSymbol(type.symbol).size === 0));
53542
53565
  }
53566
+ function isUnknownLikeUnionType(type) {
53567
+ if (strictNullChecks && type.flags & 1048576) {
53568
+ if (!(type.objectFlags & 33554432)) {
53569
+ var types = type.types;
53570
+ type.objectFlags |= 33554432 | (types.length >= 3 && types[0].flags & 32768 &&
53571
+ types[1].flags & 65536 && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 : 0);
53572
+ }
53573
+ return !!(type.objectFlags & 67108864);
53574
+ }
53575
+ return false;
53576
+ }
53543
53577
  function isStringIndexSignatureOnlyType(type) {
53544
53578
  return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
53545
53579
  type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -53617,13 +53651,15 @@ var ts;
53617
53651
  return true;
53618
53652
  if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536))
53619
53653
  return true;
53620
- if (s & 524288 && t & 67108864)
53654
+ if (s & 524288 && t & 67108864 && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
53621
53655
  return true;
53622
53656
  if (relation === assignableRelation || relation === comparableRelation) {
53623
53657
  if (s & 1)
53624
53658
  return true;
53625
53659
  if (s & (8 | 256) && !(s & 1024) && (t & 32 || relation === assignableRelation && t & 256 && t & 1024))
53626
53660
  return true;
53661
+ if (isUnknownLikeUnionType(target))
53662
+ return true;
53627
53663
  }
53628
53664
  return false;
53629
53665
  }
@@ -53665,16 +53701,27 @@ var ts;
53665
53701
  function getNormalizedType(type, writing) {
53666
53702
  while (true) {
53667
53703
  var t = isFreshLiteralType(type) ? type.regularType :
53668
- ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
53669
- type.flags & 3145728 ? getReducedType(type) :
53704
+ ts.getObjectFlags(type) & 4 ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
53705
+ type.flags & 3145728 ? getNormalizedUnionOrIntersectionType(type, writing) :
53670
53706
  type.flags & 33554432 ? writing ? type.baseType : type.substitute :
53671
53707
  type.flags & 25165824 ? getSimplifiedType(type, writing) :
53672
53708
  type;
53673
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
53674
53709
  if (t === type)
53675
- break;
53710
+ return t;
53676
53711
  type = t;
53677
53712
  }
53713
+ }
53714
+ function getNormalizedUnionOrIntersectionType(type, writing) {
53715
+ var reduced = getReducedType(type);
53716
+ if (reduced !== type) {
53717
+ return reduced;
53718
+ }
53719
+ if (type.flags & 2097152) {
53720
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
53721
+ if (normalizedTypes !== type.types) {
53722
+ return getIntersectionType(normalizedTypes);
53723
+ }
53724
+ }
53678
53725
  return type;
53679
53726
  }
53680
53727
  function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
@@ -54049,6 +54096,7 @@ var ts;
54049
54096
  return 0;
54050
54097
  }
54051
54098
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
54099
+ var _a, _b;
54052
54100
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
54053
54101
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
54054
54102
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -54087,6 +54135,9 @@ var ts;
54087
54135
  return;
54088
54136
  }
54089
54137
  reportRelationError(headMessage, source, target);
54138
+ if (strictNullChecks && source.flags & 8650752 && ((_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))) {
54139
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
54140
+ }
54090
54141
  }
54091
54142
  function traceUnionsOrIntersectionsTooLarge(source, target) {
54092
54143
  if (!ts.tracing) {
@@ -54728,12 +54779,6 @@ var ts;
54728
54779
  if (sourceFlags & 8650752) {
54729
54780
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54730
54781
  var constraint = getConstraintOfType(source) || unknownType;
54731
- if (!getConstraintOfType(source) || (sourceFlags & 262144 && constraint.flags & 1)) {
54732
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54733
- resetErrorInfo(saveErrorInfo);
54734
- return result;
54735
- }
54736
- }
54737
54782
  if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54738
54783
  resetErrorInfo(saveErrorInfo);
54739
54784
  return result;
@@ -55989,9 +56034,11 @@ var ts;
55989
56034
  return getSupertypeOrUnion(types);
55990
56035
  }
55991
56036
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
55992
- return primaryTypes.length ?
55993
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
55994
- getUnionType(types, 2);
56037
+ if (primaryTypes.length) {
56038
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
56039
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304); }), true));
56040
+ }
56041
+ return getUnionType(types, 2);
55995
56042
  }
55996
56043
  function getCommonSubtype(types) {
55997
56044
  return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
@@ -56169,26 +56216,8 @@ var ts;
56169
56216
  var value = _a.value;
56170
56217
  return value.base10Value === "0";
56171
56218
  }
56172
- function getFalsyFlagsOfTypes(types) {
56173
- var result = 0;
56174
- for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
56175
- var t = types_14[_i];
56176
- result |= getFalsyFlags(t);
56177
- }
56178
- return result;
56179
- }
56180
- function getFalsyFlags(type) {
56181
- return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
56182
- type.flags & 128 ? type.value === "" ? 128 : 0 :
56183
- type.flags & 256 ? type.value === 0 ? 256 : 0 :
56184
- type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
56185
- type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
56186
- type.flags & 117724;
56187
- }
56188
56219
  function removeDefinitelyFalsyTypes(type) {
56189
- return getFalsyFlags(type) & 117632 ?
56190
- filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
56191
- type;
56220
+ return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304); });
56192
56221
  }
56193
56222
  function extractDefinitelyFalsyTypes(type) {
56194
56223
  return mapType(type, getDefinitelyFalsyPartOfType);
@@ -56218,16 +56247,15 @@ var ts;
56218
56247
  return type.flags & 32768 ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
56219
56248
  }
56220
56249
  function getGlobalNonNullableTypeInstantiation(type) {
56221
- var reducedType = getTypeWithFacts(type, 2097152);
56222
56250
  if (!deferredGlobalNonNullableTypeAlias) {
56223
56251
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
56224
56252
  }
56225
56253
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
56226
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
56227
- reducedType;
56254
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
56255
+ getIntersectionType([type, emptyObjectType]);
56228
56256
  }
56229
56257
  function getNonNullableType(type) {
56230
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
56258
+ return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152) : type;
56231
56259
  }
56232
56260
  function addOptionalTypeMarker(type) {
56233
56261
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -56821,17 +56849,32 @@ var ts;
56821
56849
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
56822
56850
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
56823
56851
  }
56824
- function isValidBigIntString(s) {
56852
+ function isValidNumberString(s, roundTripOnly) {
56853
+ if (s === "")
56854
+ return false;
56855
+ var n = +s;
56856
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
56857
+ }
56858
+ function parseBigIntLiteralType(text) {
56859
+ var negative = text.startsWith("-");
56860
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
56861
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
56862
+ }
56863
+ function isValidBigIntString(s, roundTripOnly) {
56864
+ if (s === "")
56865
+ return false;
56825
56866
  var scanner = ts.createScanner(99, false);
56826
56867
  var success = true;
56827
56868
  scanner.setOnError(function () { return success = false; });
56828
56869
  scanner.setText(s + "n");
56829
56870
  var result = scanner.scan();
56830
- if (result === 40) {
56871
+ var negative = result === 40;
56872
+ if (negative) {
56831
56873
  result = scanner.scan();
56832
56874
  }
56833
56875
  var flags = scanner.getTokenFlags();
56834
- return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512);
56876
+ return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512)
56877
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
56835
56878
  }
56836
56879
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
56837
56880
  if (source === target || target.flags & (1 | 4)) {
@@ -56839,8 +56882,8 @@ var ts;
56839
56882
  }
56840
56883
  if (source.flags & 128) {
56841
56884
  var value = source.value;
56842
- return !!(target.flags & 8 && value !== "" && isFinite(+value) ||
56843
- target.flags & 64 && value !== "" && isValidBigIntString(value) ||
56885
+ return !!(target.flags & 8 && isValidNumberString(value, false) ||
56886
+ target.flags & 64 && isValidBigIntString(value, false) ||
56844
56887
  target.flags & (512 | 98304) && value === target.intrinsicName);
56845
56888
  }
56846
56889
  if (source.flags & 134217728) {
@@ -57182,8 +57225,8 @@ var ts;
57182
57225
  }
57183
57226
  function getSingleTypeVariableFromIntersectionTypes(types) {
57184
57227
  var typeVariable;
57185
- for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
57186
- var type = types_15[_i];
57228
+ for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
57229
+ var type = types_14[_i];
57187
57230
  var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
57188
57231
  if (!t || typeVariable && t !== typeVariable) {
57189
57232
  return undefined;
@@ -57305,8 +57348,51 @@ var ts;
57305
57348
  var matches = inferTypesFromTemplateLiteralType(source, target);
57306
57349
  var types = target.types;
57307
57350
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
57351
+ var _loop_23 = function (i) {
57352
+ var source_1 = matches ? matches[i] : neverType;
57353
+ var target_3 = types[i];
57354
+ if (source_1.flags & 128 && target_3.flags & 8650752) {
57355
+ var inferenceContext = getInferenceInfoForType(target_3);
57356
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
57357
+ if (constraint && !isTypeAny(constraint)) {
57358
+ var constraintTypes = constraint.flags & 1048576 ? constraint.types : [constraint];
57359
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
57360
+ if (!(allTypeFlags_1 & 4)) {
57361
+ var str_1 = source_1.value;
57362
+ if (allTypeFlags_1 & 296 && !isValidNumberString(str_1, true)) {
57363
+ allTypeFlags_1 &= ~296;
57364
+ }
57365
+ if (allTypeFlags_1 & 2112 && !isValidBigIntString(str_1, true)) {
57366
+ allTypeFlags_1 &= ~2112;
57367
+ }
57368
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
57369
+ return !(right.flags & allTypeFlags_1) ? left :
57370
+ left.flags & 4 ? left : right.flags & 4 ? source_1 :
57371
+ left.flags & 134217728 ? left : right.flags & 134217728 && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
57372
+ left.flags & 268435456 ? left : right.flags & 268435456 && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
57373
+ left.flags & 128 ? left : right.flags & 128 && right.value === str_1 ? right :
57374
+ left.flags & 8 ? left : right.flags & 8 ? getNumberLiteralType(+str_1) :
57375
+ left.flags & 32 ? left : right.flags & 32 ? getNumberLiteralType(+str_1) :
57376
+ left.flags & 256 ? left : right.flags & 256 && right.value === +str_1 ? right :
57377
+ left.flags & 64 ? left : right.flags & 64 ? parseBigIntLiteralType(str_1) :
57378
+ left.flags & 2048 ? left : right.flags & 2048 && ts.pseudoBigIntToString(right.value) === str_1 ? right :
57379
+ left.flags & 16 ? left : right.flags & 16 ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
57380
+ left.flags & 512 ? left : right.flags & 512 && right.intrinsicName === str_1 ? right :
57381
+ left.flags & 32768 ? left : right.flags & 32768 && right.intrinsicName === str_1 ? right :
57382
+ left.flags & 65536 ? left : right.flags & 65536 && right.intrinsicName === str_1 ? right :
57383
+ left;
57384
+ }, neverType);
57385
+ if (!(matchingType.flags & 131072)) {
57386
+ inferFromTypes(matchingType, target_3);
57387
+ return "continue";
57388
+ }
57389
+ }
57390
+ }
57391
+ }
57392
+ inferFromTypes(source_1, target_3);
57393
+ };
57308
57394
  for (var i = 0; i < types.length; i++) {
57309
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
57395
+ _loop_23(i);
57310
57396
  }
57311
57397
  }
57312
57398
  }
@@ -57776,7 +57862,7 @@ var ts;
57776
57862
  function mapTypesByKeyProperty(types, name) {
57777
57863
  var map = new ts.Map();
57778
57864
  var count = 0;
57779
- var _loop_23 = function (type) {
57865
+ var _loop_24 = function (type) {
57780
57866
  if (type.flags & (524288 | 2097152 | 58982400)) {
57781
57867
  var discriminant = getTypeOfPropertyOfType(type, name);
57782
57868
  if (discriminant) {
@@ -57800,9 +57886,9 @@ var ts;
57800
57886
  }
57801
57887
  }
57802
57888
  };
57803
- for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
57804
- var type = types_16[_i];
57805
- var state_9 = _loop_23(type);
57889
+ for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
57890
+ var type = types_15[_i];
57891
+ var state_9 = _loop_24(type);
57806
57892
  if (typeof state_9 === "object")
57807
57893
  return state_9.value;
57808
57894
  }
@@ -57900,14 +57986,16 @@ var ts;
57900
57986
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
57901
57987
  resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
57902
57988
  }
57903
- function getTypeFacts(type, ignoreObjects) {
57904
- if (ignoreObjects === void 0) { ignoreObjects = false; }
57989
+ function getTypeFacts(type) {
57990
+ if (type.flags & (2097152 | 465829888)) {
57991
+ type = getBaseConstraintOfType(type) || unknownType;
57992
+ }
57905
57993
  var flags = type.flags;
57906
- if (flags & 4) {
57994
+ if (flags & (4 | 268435456)) {
57907
57995
  return strictNullChecks ? 16317953 : 16776705;
57908
57996
  }
57909
- if (flags & 128) {
57910
- var isEmpty = type.value === "";
57997
+ if (flags & (128 | 134217728)) {
57998
+ var isEmpty = flags & 128 && type.value === "";
57911
57999
  return strictNullChecks ?
57912
58000
  isEmpty ? 12123649 : 7929345 :
57913
58001
  isEmpty ? 12582401 : 16776705;
@@ -57939,20 +58027,20 @@ var ts;
57939
58027
  (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
57940
58028
  }
57941
58029
  if (flags & 524288) {
57942
- if (ignoreObjects) {
57943
- return 16768959;
57944
- }
57945
58030
  return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
57946
- strictNullChecks ? 16318463 : 16777215 :
58031
+ strictNullChecks ? 83427327 : 83886079 :
57947
58032
  isFunctionObjectType(type) ?
57948
58033
  strictNullChecks ? 7880640 : 16728000 :
57949
58034
  strictNullChecks ? 7888800 : 16736160;
57950
58035
  }
57951
- if (flags & (16384 | 32768)) {
58036
+ if (flags & 16384) {
57952
58037
  return 9830144;
57953
58038
  }
58039
+ if (flags & 32768) {
58040
+ return 26607360;
58041
+ }
57954
58042
  if (flags & 65536) {
57955
- return 9363232;
58043
+ return 42917664;
57956
58044
  }
57957
58045
  if (flags & 12288) {
57958
58046
  return strictNullChecks ? 7925520 : 16772880;
@@ -57963,33 +58051,49 @@ var ts;
57963
58051
  if (flags & 131072) {
57964
58052
  return 0;
57965
58053
  }
57966
- if (flags & 465829888) {
57967
- return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
57968
- strictNullChecks ? 7929345 : 16776705;
57969
- }
57970
58054
  if (flags & 1048576) {
57971
- return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0);
58055
+ return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0);
57972
58056
  }
57973
58057
  if (flags & 2097152) {
57974
- ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068));
57975
- return getIntersectionTypeFacts(type, ignoreObjects);
58058
+ return getIntersectionTypeFacts(type);
57976
58059
  }
57977
- return 16777215;
58060
+ return 83886079;
57978
58061
  }
57979
- function getIntersectionTypeFacts(type, ignoreObjects) {
58062
+ function getIntersectionTypeFacts(type) {
58063
+ var ignoreObjects = maybeTypeOfKind(type, 131068);
57980
58064
  var oredFacts = 0;
57981
- var andedFacts = 16777215;
58065
+ var andedFacts = 134217727;
57982
58066
  for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
57983
58067
  var t = _a[_i];
57984
- var f = getTypeFacts(t, ignoreObjects);
57985
- oredFacts |= f;
57986
- andedFacts &= f;
58068
+ if (!(ignoreObjects && t.flags & 524288)) {
58069
+ var f = getTypeFacts(t);
58070
+ oredFacts |= f;
58071
+ andedFacts &= f;
58072
+ }
57987
58073
  }
57988
- return oredFacts & 8256 | andedFacts & 16768959;
58074
+ return oredFacts & 8256 | andedFacts & 134209471;
57989
58075
  }
57990
58076
  function getTypeWithFacts(type, include) {
57991
58077
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
57992
58078
  }
58079
+ function getAdjustedTypeWithFacts(type, facts) {
58080
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 ? unknownUnionType : type, facts));
58081
+ if (strictNullChecks) {
58082
+ switch (facts) {
58083
+ case 524288:
58084
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 ? getIntersectionType([t, getTypeFacts(t) & 131072 && !maybeTypeOfKind(reduced, 65536) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
58085
+ case 1048576:
58086
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 ? getIntersectionType([t, getTypeFacts(t) & 65536 && !maybeTypeOfKind(reduced, 32768) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
58087
+ case 2097152:
58088
+ case 4194304:
58089
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 ? getGlobalNonNullableTypeInstantiation(t) : t; });
58090
+ }
58091
+ }
58092
+ return reduced;
58093
+ }
58094
+ function recombineUnknownType(type) {
58095
+ return type === unknownUnionType ? unknownType : type;
58096
+ }
57993
58097
  function getTypeWithDefault(type, defaultExpression) {
57994
58098
  return defaultExpression ?
57995
58099
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -58230,8 +58334,8 @@ var ts;
58230
58334
  var types = origin && origin.flags & 1048576 ? origin.types : type.types;
58231
58335
  var mappedTypes;
58232
58336
  var changed = false;
58233
- for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
58234
- var t = types_17[_i];
58337
+ for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
58338
+ var t = types_16[_i];
58235
58339
  var mapped = t.flags & 1048576 ? mapType(t, mapper, noReductions) : mapper(t);
58236
58340
  changed || (changed = t !== mapped);
58237
58341
  if (mapped) {
@@ -58304,8 +58408,8 @@ var ts;
58304
58408
  }
58305
58409
  function isEvolvingArrayTypeList(types) {
58306
58410
  var hasEvolvingArrayType = false;
58307
- for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
58308
- var t = types_18[_i];
58411
+ for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
58412
+ var t = types_17[_i];
58309
58413
  if (!(t.flags & 131072)) {
58310
58414
  if (!(ts.getObjectFlags(t) & 256)) {
58311
58415
  return false;
@@ -58930,7 +59034,7 @@ var ts;
58930
59034
  if (isEvolvingArrayTypeList(types)) {
58931
59035
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
58932
59036
  }
58933
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
59037
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
58934
59038
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 && ts.arraysEqual(result.types, declaredType.types)) {
58935
59039
  return declaredType;
58936
59040
  }
@@ -59026,11 +59130,10 @@ var ts;
59026
59130
  }
59027
59131
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
59028
59132
  if (isMatchingReference(reference, expr)) {
59029
- return type.flags & 2 && assumeTrue ? nonNullUnknownType :
59030
- getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
59133
+ return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
59031
59134
  }
59032
59135
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
59033
- type = getTypeWithFacts(type, 2097152);
59136
+ type = getAdjustedTypeWithFacts(type, 2097152);
59034
59137
  }
59035
59138
  var access = getDiscriminantPropertyAccess(expr, type);
59036
59139
  if (access) {
@@ -59157,7 +59260,7 @@ var ts;
59157
59260
  var valueType = getTypeOfExpression(value);
59158
59261
  var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
59159
59262
  equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
59160
- return removeNullable ? getTypeWithFacts(type, 2097152) : type;
59263
+ return removeNullable ? getAdjustedTypeWithFacts(type, 2097152) : type;
59161
59264
  }
59162
59265
  function narrowTypeByEquality(type, operator, value, assumeTrue) {
59163
59266
  if (type.flags & 1) {
@@ -59167,9 +59270,6 @@ var ts;
59167
59270
  assumeTrue = !assumeTrue;
59168
59271
  }
59169
59272
  var valueType = getTypeOfExpression(value);
59170
- if (assumeTrue && (type.flags & 2) && (operator === 34 || operator === 35) && (valueType.flags & 65536)) {
59171
- return getUnionType([nullType, undefinedType]);
59172
- }
59173
59273
  if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
59174
59274
  if (valueType.flags & (131068 | 67108864)) {
59175
59275
  return valueType;
@@ -59189,7 +59289,7 @@ var ts;
59189
59289
  valueType.flags & 65536 ?
59190
59290
  assumeTrue ? 131072 : 1048576 :
59191
59291
  assumeTrue ? 65536 : 524288;
59192
- return type.flags & 2 && facts & (1048576 | 2097152) ? nonNullUnknownType : getTypeWithFacts(type, facts);
59292
+ return getAdjustedTypeWithFacts(type, facts);
59193
59293
  }
59194
59294
  if (assumeTrue) {
59195
59295
  var filterFn = operator === 34 ?
@@ -59209,21 +59309,18 @@ var ts;
59209
59309
  var target = getReferenceCandidate(typeOfExpr.expression);
59210
59310
  if (!isMatchingReference(reference, target)) {
59211
59311
  if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
59212
- return getTypeWithFacts(type, 2097152);
59312
+ return getAdjustedTypeWithFacts(type, 2097152);
59213
59313
  }
59214
59314
  return type;
59215
59315
  }
59216
59316
  if (type.flags & 1 && literal.text === "function") {
59217
59317
  return type;
59218
59318
  }
59219
- if (assumeTrue && type.flags & 2 && literal.text === "object") {
59220
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
59221
- }
59222
59319
  var facts = assumeTrue ?
59223
59320
  typeofEQFacts.get(literal.text) || 128 :
59224
59321
  typeofNEFacts.get(literal.text) || 32768;
59225
59322
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
59226
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
59323
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
59227
59324
  }
59228
59325
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
59229
59326
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -59268,30 +59365,35 @@ var ts;
59268
59365
  }
59269
59366
  function getImpliedTypeFromTypeofGuard(type, text) {
59270
59367
  switch (text) {
59368
+ case "object":
59369
+ return type.flags & 1 ? type : getUnionType([nullType, nonPrimitiveType]);
59271
59370
  case "function":
59272
59371
  return type.flags & 1 ? type : globalFunctionType;
59273
- case "object":
59274
- return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
59275
59372
  default:
59276
59373
  return typeofTypesByName.get(text);
59277
59374
  }
59278
59375
  }
59279
- function narrowUnionMemberByTypeof(candidate) {
59280
- return function (type) {
59281
- if (isTypeSubtypeOf(type, candidate)) {
59282
- return type;
59283
- }
59284
- if (isTypeSubtypeOf(candidate, type)) {
59285
- return candidate;
59376
+ function narrowTypeByImpliedType(type, candidate) {
59377
+ if (type.flags & 3) {
59378
+ return candidate;
59379
+ }
59380
+ return mapType(type, function (t) {
59381
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
59382
+ return t;
59286
59383
  }
59287
- if (type.flags & 465829888) {
59288
- var constraint = getBaseConstraintOfType(type) || anyType;
59289
- if (isTypeSubtypeOf(candidate, constraint)) {
59290
- return getIntersectionType([type, candidate]);
59384
+ return mapType(candidate, function (c) {
59385
+ if (!areTypesComparable(t, c)) {
59386
+ return neverType;
59291
59387
  }
59292
- }
59293
- return type;
59294
- };
59388
+ if (c.flags & 131068 && t.flags & 524288 && !isEmptyAnonymousObjectType(t)) {
59389
+ return isTypeSubtypeOf(c, t) ? c : neverType;
59390
+ }
59391
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
59392
+ return c;
59393
+ }
59394
+ return getIntersectionType([t, c]);
59395
+ });
59396
+ });
59295
59397
  }
59296
59398
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
59297
59399
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
@@ -59317,7 +59419,7 @@ var ts;
59317
59419
  return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
59318
59420
  }
59319
59421
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
59320
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
59422
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
59321
59423
  }
59322
59424
  function isMatchingConstructorReference(expr) {
59323
59425
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -59357,7 +59459,7 @@ var ts;
59357
59459
  var left = getReferenceCandidate(expr.left);
59358
59460
  if (!isMatchingReference(reference, left)) {
59359
59461
  if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
59360
- return getTypeWithFacts(type, 2097152);
59462
+ return getAdjustedTypeWithFacts(type, 2097152);
59361
59463
  }
59362
59464
  return type;
59363
59465
  }
@@ -59433,7 +59535,7 @@ var ts;
59433
59535
  }
59434
59536
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
59435
59537
  !(getTypeFacts(predicate.type) & 65536)) {
59436
- type = getTypeWithFacts(type, 2097152);
59538
+ type = getAdjustedTypeWithFacts(type, 2097152);
59437
59539
  }
59438
59540
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
59439
59541
  if (access) {
@@ -59484,7 +59586,7 @@ var ts;
59484
59586
  }
59485
59587
  function narrowTypeByOptionality(type, expr, assumePresent) {
59486
59588
  if (isMatchingReference(reference, expr)) {
59487
- return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
59589
+ return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 : 262144);
59488
59590
  }
59489
59591
  var access = getDiscriminantPropertyAccess(expr, type);
59490
59592
  if (access) {
@@ -59559,8 +59661,8 @@ var ts;
59559
59661
  var annotationIncludesUndefined = strictNullChecks &&
59560
59662
  declaration.kind === 164 &&
59561
59663
  declaration.initializer &&
59562
- getFalsyFlags(declaredType) & 32768 &&
59563
- !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
59664
+ getTypeFacts(declaredType) & 16777216 &&
59665
+ !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216);
59564
59666
  popTypeResolution();
59565
59667
  return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
59566
59668
  }
@@ -59578,7 +59680,9 @@ var ts;
59578
59680
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
59579
59681
  }
59580
59682
  function isGenericTypeWithUnionConstraint(type) {
59581
- return !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576));
59683
+ return type.flags & 2097152 ?
59684
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
59685
+ !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576));
59582
59686
  }
59583
59687
  function isGenericTypeWithoutNullableConstraint(type) {
59584
59688
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
@@ -59595,7 +59699,7 @@ var ts;
59595
59699
  var substituteConstraints = !(checkMode && checkMode & 2) &&
59596
59700
  someType(type, isGenericTypeWithUnionConstraint) &&
59597
59701
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
59598
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type;
59702
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
59599
59703
  }
59600
59704
  function isExportOrExportExpression(location) {
59601
59705
  return !!ts.findAncestor(location, function (n) {
@@ -59798,7 +59902,7 @@ var ts;
59798
59902
  return convertAutoToAny(flowType);
59799
59903
  }
59800
59904
  }
59801
- else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
59905
+ else if (!assumeInitialized && !(getTypeFacts(type) & 16777216) && getTypeFacts(flowType) & 16777216) {
59802
59906
  error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
59803
59907
  return type;
59804
59908
  }
@@ -61076,8 +61180,8 @@ var ts;
61076
61180
  }
61077
61181
  var signatureList;
61078
61182
  var types = type.types;
61079
- for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
61080
- var current = types_19[_i];
61183
+ for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
61184
+ var current = types_18[_i];
61081
61185
  var signature = getContextualCallSignature(current, node);
61082
61186
  if (signature) {
61083
61187
  if (!signatureList) {
@@ -62040,19 +62144,19 @@ var ts;
62040
62144
  return checkNonNullType(checkExpression(node), node);
62041
62145
  }
62042
62146
  function isNullableType(type) {
62043
- return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
62147
+ return !!(getTypeFacts(type) & 50331648);
62044
62148
  }
62045
62149
  function getNonNullableTypeIfNeeded(type) {
62046
62150
  return isNullableType(type) ? getNonNullableType(type) : type;
62047
62151
  }
62048
- function reportObjectPossiblyNullOrUndefinedError(node, flags) {
62049
- error(node, flags & 32768 ? flags & 65536 ?
62152
+ function reportObjectPossiblyNullOrUndefinedError(node, facts) {
62153
+ error(node, facts & 16777216 ? facts & 33554432 ?
62050
62154
  ts.Diagnostics.Object_is_possibly_null_or_undefined :
62051
62155
  ts.Diagnostics.Object_is_possibly_undefined :
62052
62156
  ts.Diagnostics.Object_is_possibly_null);
62053
62157
  }
62054
- function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
62055
- error(node, flags & 32768 ? flags & 65536 ?
62158
+ function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) {
62159
+ error(node, facts & 16777216 ? facts & 33554432 ?
62056
62160
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
62057
62161
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
62058
62162
  ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
@@ -62062,9 +62166,9 @@ var ts;
62062
62166
  error(node, ts.Diagnostics.Object_is_of_type_unknown);
62063
62167
  return errorType;
62064
62168
  }
62065
- var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
62066
- if (kind) {
62067
- reportError(node, kind);
62169
+ var facts = getTypeFacts(type);
62170
+ if (facts & 50331648) {
62171
+ reportError(node, facts);
62068
62172
  var t = getNonNullableType(type);
62069
62173
  return t.flags & (98304 | 131072) ? errorType : t;
62070
62174
  }
@@ -62330,7 +62434,7 @@ var ts;
62330
62434
  assumeUninitialized = true;
62331
62435
  }
62332
62436
  var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
62333
- if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
62437
+ if (assumeUninitialized && !(getTypeFacts(propType) & 16777216) && getTypeFacts(flowType) & 16777216) {
62334
62438
  error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
62335
62439
  return propType;
62336
62440
  }
@@ -63225,7 +63329,7 @@ var ts;
63225
63329
  var spreadIndex = getSpreadArgumentIndex(args);
63226
63330
  if (spreadIndex >= 0) {
63227
63331
  var effectiveArgs_1 = args.slice(0, spreadIndex);
63228
- var _loop_24 = function (i) {
63332
+ var _loop_25 = function (i) {
63229
63333
  var arg = args[i];
63230
63334
  var spreadType = arg.kind === 225 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
63231
63335
  if (spreadType && isTupleType(spreadType)) {
@@ -63241,7 +63345,7 @@ var ts;
63241
63345
  }
63242
63346
  };
63243
63347
  for (var i = spreadIndex; i < args.length; i++) {
63244
- _loop_24(i);
63348
+ _loop_25(i);
63245
63349
  }
63246
63350
  return effectiveArgs_1;
63247
63351
  }
@@ -63489,7 +63593,7 @@ var ts;
63489
63593
  var min_3 = Number.MAX_VALUE;
63490
63594
  var minIndex = 0;
63491
63595
  var i_1 = 0;
63492
- var _loop_25 = function (c) {
63596
+ var _loop_26 = function (c) {
63493
63597
  var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
63494
63598
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
63495
63599
  if (diags_2) {
@@ -63507,7 +63611,7 @@ var ts;
63507
63611
  };
63508
63612
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
63509
63613
  var c = candidatesForArgumentError_1[_a];
63510
- _loop_25(c);
63614
+ _loop_26(c);
63511
63615
  }
63512
63616
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
63513
63617
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -63650,7 +63754,7 @@ var ts;
63650
63754
  }
63651
63755
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
63652
63756
  var parameters = [];
63653
- var _loop_26 = function (i) {
63757
+ var _loop_27 = function (i) {
63654
63758
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
63655
63759
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
63656
63760
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -63658,7 +63762,7 @@ var ts;
63658
63762
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
63659
63763
  };
63660
63764
  for (var i = 0; i < maxNonRestParam; i++) {
63661
- _loop_26(i);
63765
+ _loop_27(i);
63662
63766
  }
63663
63767
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
63664
63768
  var flags = 0;
@@ -63934,8 +64038,8 @@ var ts;
63934
64038
  if (apparentType.flags & 1048576) {
63935
64039
  var types = apparentType.types;
63936
64040
  var hasSignatures = false;
63937
- for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
63938
- var constituent = types_20[_i];
64041
+ for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
64042
+ var constituent = types_19[_i];
63939
64043
  var signatures = getSignaturesOfType(constituent, kind);
63940
64044
  if (signatures.length !== 0) {
63941
64045
  hasSignatures = true;
@@ -65443,7 +65547,7 @@ var ts;
65443
65547
  var type = getTypeOfSymbol(symbol);
65444
65548
  if (strictNullChecks &&
65445
65549
  !(type.flags & (3 | 131072)) &&
65446
- !(exactOptionalPropertyTypes ? symbol.flags & 16777216 : getFalsyFlags(type) & 32768)) {
65550
+ !(exactOptionalPropertyTypes ? symbol.flags & 16777216 : getTypeFacts(type) & 16777216)) {
65447
65551
  error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
65448
65552
  }
65449
65553
  }
@@ -65602,8 +65706,8 @@ var ts;
65602
65706
  }
65603
65707
  if (type.flags & 3145728) {
65604
65708
  var types = type.types;
65605
- for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
65606
- var t = types_21[_i];
65709
+ for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
65710
+ var t = types_20[_i];
65607
65711
  if (maybeTypeOfKind(t, kind)) {
65608
65712
  return true;
65609
65713
  }
@@ -65793,7 +65897,7 @@ var ts;
65793
65897
  var prop = exprOrAssignment;
65794
65898
  if (prop.objectAssignmentInitializer) {
65795
65899
  if (strictNullChecks &&
65796
- !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
65900
+ !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216)) {
65797
65901
  sourceType = getTypeWithFacts(sourceType, 524288);
65798
65902
  }
65799
65903
  checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
@@ -66158,7 +66262,7 @@ var ts;
66158
66262
  case 56:
66159
66263
  case 75: {
66160
66264
  var resultType_3 = getTypeFacts(leftType) & 8388608 ?
66161
- getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
66265
+ getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2) :
66162
66266
  leftType;
66163
66267
  if (operator === 75) {
66164
66268
  checkAssignmentOperator(rightType);
@@ -67254,7 +67358,7 @@ var ts;
67254
67358
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
67255
67359
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
67256
67360
  var indexSignatureMap_1 = new ts.Map();
67257
- var _loop_27 = function (declaration) {
67361
+ var _loop_28 = function (declaration) {
67258
67362
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
67259
67363
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
67260
67364
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -67269,7 +67373,7 @@ var ts;
67269
67373
  };
67270
67374
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
67271
67375
  var declaration = _a[_i];
67272
- _loop_27(declaration);
67376
+ _loop_28(declaration);
67273
67377
  }
67274
67378
  indexSignatureMap_1.forEach(function (entry) {
67275
67379
  if (entry.declarations.length > 1) {
@@ -68320,8 +68424,8 @@ var ts;
68320
68424
  }
68321
68425
  function getEntityNameForDecoratorMetadataFromTypeList(types) {
68322
68426
  var commonEntityName;
68323
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
68324
- var typeNode = types_22[_i];
68427
+ for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
68428
+ var typeNode = types_21[_i];
68325
68429
  while (typeNode.kind === 191 || typeNode.kind === 197) {
68326
68430
  typeNode = typeNode.type;
68327
68431
  }
@@ -69071,7 +69175,7 @@ var ts;
69071
69175
  }
69072
69176
  if (ts.isBindingPattern(node.name)) {
69073
69177
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243;
69074
- var needCheckWidenedType = node.name.elements.length === 0;
69178
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
69075
69179
  if (needCheckInitializer || needCheckWidenedType) {
69076
69180
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
69077
69181
  if (needCheckInitializer) {
@@ -69095,7 +69199,7 @@ var ts;
69095
69199
  return;
69096
69200
  }
69097
69201
  var symbol = getSymbolOfNode(node);
69098
- if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
69202
+ if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 ? node.parent.parent : node)) {
69099
69203
  checkAliasSymbol(node);
69100
69204
  return;
69101
69205
  }
@@ -69212,7 +69316,7 @@ var ts;
69212
69316
  return;
69213
69317
  var type = checkTruthinessExpression(location);
69214
69318
  var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
69215
- if (getFalsyFlags(type) || isPropertyExpressionCast)
69319
+ if (!(getTypeFacts(type) & 4194304) || isPropertyExpressionCast)
69216
69320
  return;
69217
69321
  var callSignatures = getSignaturesOfType(type, 0);
69218
69322
  var isPromise = !!getAwaitedTypeOfPromise(type);
@@ -70089,7 +70193,7 @@ var ts;
70089
70193
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70090
70194
  var localPropDeclaration = declaration && declaration.kind === 221 ||
70091
70195
  name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
70092
- var _loop_28 = function (info) {
70196
+ var _loop_29 = function (info) {
70093
70197
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
70094
70198
  var errorNode = localPropDeclaration || localIndexDeclaration ||
70095
70199
  (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
@@ -70099,7 +70203,7 @@ var ts;
70099
70203
  };
70100
70204
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
70101
70205
  var info = indexInfos_9[_i];
70102
- _loop_28(info);
70206
+ _loop_29(info);
70103
70207
  }
70104
70208
  }
70105
70209
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -70107,7 +70211,7 @@ var ts;
70107
70211
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
70108
70212
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70109
70213
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
70110
- var _loop_29 = function (info) {
70214
+ var _loop_30 = function (info) {
70111
70215
  if (info === checkInfo)
70112
70216
  return "continue";
70113
70217
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -70119,7 +70223,7 @@ var ts;
70119
70223
  };
70120
70224
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
70121
70225
  var info = indexInfos_10[_i];
70122
- _loop_29(info);
70226
+ _loop_30(info);
70123
70227
  }
70124
70228
  }
70125
70229
  function checkTypeNameIsReserved(name, message) {
@@ -70413,7 +70517,7 @@ var ts;
70413
70517
  var baseTypes = baseTypeNode && getBaseTypes(type);
70414
70518
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
70415
70519
  var baseStaticType = getBaseConstructorTypeOfClass(type);
70416
- var _loop_30 = function (member) {
70520
+ var _loop_31 = function (member) {
70417
70521
  if (ts.hasAmbientModifier(member)) {
70418
70522
  return "continue";
70419
70523
  }
@@ -70428,7 +70532,7 @@ var ts;
70428
70532
  };
70429
70533
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70430
70534
  var member = _a[_i];
70431
- _loop_30(member);
70535
+ _loop_31(member);
70432
70536
  }
70433
70537
  }
70434
70538
  function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
@@ -70503,7 +70607,7 @@ var ts;
70503
70607
  }
70504
70608
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
70505
70609
  var issuedMemberError = false;
70506
- var _loop_31 = function (member) {
70610
+ var _loop_32 = function (member) {
70507
70611
  if (ts.isStatic(member)) {
70508
70612
  return "continue";
70509
70613
  }
@@ -70521,7 +70625,7 @@ var ts;
70521
70625
  };
70522
70626
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70523
70627
  var member = _a[_i];
70524
- _loop_31(member);
70628
+ _loop_32(member);
70525
70629
  }
70526
70630
  if (!issuedMemberError) {
70527
70631
  checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
@@ -70566,17 +70670,16 @@ var ts;
70566
70670
  });
70567
70671
  }
70568
70672
  function checkKindsOfPropertyMemberOverrides(type, baseType) {
70569
- var _a, _b;
70673
+ var _a, _b, _c, _d;
70570
70674
  var baseProperties = getPropertiesOfType(baseType);
70571
- basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
70572
- var baseProperty = baseProperties_1[_i];
70675
+ var _loop_33 = function (baseProperty) {
70573
70676
  var base = getTargetSymbol(baseProperty);
70574
70677
  if (base.flags & 4194304) {
70575
- continue;
70678
+ return "continue";
70576
70679
  }
70577
70680
  var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
70578
70681
  if (!baseSymbol) {
70579
- continue;
70682
+ return "continue";
70580
70683
  }
70581
70684
  var derived = getTargetSymbol(baseSymbol);
70582
70685
  var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
@@ -70584,14 +70687,14 @@ var ts;
70584
70687
  if (derived === base) {
70585
70688
  var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
70586
70689
  if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) {
70587
- for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) {
70588
- var otherBaseType = _d[_c];
70690
+ for (var _e = 0, _f = getBaseTypes(type); _e < _f.length; _e++) {
70691
+ var otherBaseType = _f[_e];
70589
70692
  if (otherBaseType === baseType)
70590
70693
  continue;
70591
70694
  var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
70592
70695
  var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
70593
70696
  if (derivedElsewhere && derivedElsewhere !== base) {
70594
- continue basePropertyCheck;
70697
+ return "continue-basePropertyCheck";
70595
70698
  }
70596
70699
  }
70597
70700
  if (derivedClassDecl.kind === 226) {
@@ -70605,16 +70708,18 @@ var ts;
70605
70708
  else {
70606
70709
  var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
70607
70710
  if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
70608
- continue;
70711
+ return "continue";
70609
70712
  }
70610
70713
  var errorMessage = void 0;
70611
70714
  var basePropertyFlags = base.flags & 98308;
70612
70715
  var derivedPropertyFlags = derived.flags & 98308;
70613
70716
  if (basePropertyFlags && derivedPropertyFlags) {
70614
- if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
70615
- || base.valueDeclaration && base.valueDeclaration.parent.kind === 258
70717
+ if ((ts.getCheckFlags(base) & 6
70718
+ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })
70719
+ : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }))
70720
+ || ts.getCheckFlags(base) & 262144
70616
70721
  || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
70617
- continue;
70722
+ return "continue";
70618
70723
  }
70619
70724
  var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
70620
70725
  var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
@@ -70625,12 +70730,12 @@ var ts;
70625
70730
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
70626
70731
  }
70627
70732
  else if (useDefineForClassFields) {
70628
- var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 && !d.initializer; });
70733
+ var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 && !d.initializer; });
70629
70734
  if (uninitialized
70630
70735
  && !(derived.flags & 33554432)
70631
70736
  && !(baseDeclarationFlags & 128)
70632
70737
  && !(derivedDeclarationFlags & 128)
70633
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216); }))) {
70738
+ && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216); }))) {
70634
70739
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
70635
70740
  var propName = uninitialized.name;
70636
70741
  if (uninitialized.exclamationToken
@@ -70643,11 +70748,11 @@ var ts;
70643
70748
  }
70644
70749
  }
70645
70750
  }
70646
- continue;
70751
+ return "continue";
70647
70752
  }
70648
70753
  else if (isPrototypeProperty(base)) {
70649
70754
  if (isPrototypeProperty(derived) || derived.flags & 4) {
70650
- continue;
70755
+ return "continue";
70651
70756
  }
70652
70757
  else {
70653
70758
  ts.Debug.assert(!!(derived.flags & 98304));
@@ -70662,9 +70767,20 @@ var ts;
70662
70767
  }
70663
70768
  error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
70664
70769
  }
70770
+ };
70771
+ basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
70772
+ var baseProperty = baseProperties_1[_i];
70773
+ var state_10 = _loop_33(baseProperty);
70774
+ switch (state_10) {
70775
+ case "continue-basePropertyCheck": continue basePropertyCheck;
70776
+ }
70665
70777
  }
70666
70778
  }
70667
- function getNonInterhitedProperties(type, baseTypes, properties) {
70779
+ function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) {
70780
+ return baseDeclarationFlags & 128 && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer)
70781
+ || ts.isInterfaceDeclaration(declaration.parent);
70782
+ }
70783
+ function getNonInheritedProperties(type, baseTypes, properties) {
70668
70784
  if (!ts.length(baseTypes)) {
70669
70785
  return properties;
70670
70786
  }
@@ -70733,7 +70849,7 @@ var ts;
70733
70849
  var propName = member.name;
70734
70850
  if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
70735
70851
  var type = getTypeOfSymbol(getSymbolOfNode(member));
70736
- if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
70852
+ if (!(type.flags & 3 || getTypeFacts(type) & 16777216)) {
70737
70853
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
70738
70854
  error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
70739
70855
  }
@@ -70757,7 +70873,7 @@ var ts;
70757
70873
  ts.setParent(reference, staticBlock);
70758
70874
  reference.flowNode = staticBlock.returnFlowNode;
70759
70875
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
70760
- if (!(getFalsyFlags(flowType) & 32768)) {
70876
+ if (!(getTypeFacts(flowType) & 16777216)) {
70761
70877
  return true;
70762
70878
  }
70763
70879
  }
@@ -70772,7 +70888,7 @@ var ts;
70772
70888
  ts.setParent(reference, constructor);
70773
70889
  reference.flowNode = constructor.returnFlowNode;
70774
70890
  var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
70775
- return !(getFalsyFlags(flowType) & 32768);
70891
+ return !(getTypeFacts(flowType) & 16777216);
70776
70892
  }
70777
70893
  function checkInterfaceDeclaration(node) {
70778
70894
  if (!checkGrammarDecoratorsAndModifiers(node))
@@ -75651,9 +75767,7 @@ var ts;
75651
75767
  var ts;
75652
75768
  (function (ts) {
75653
75769
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
75654
- var _a = generatorOptions.extendedDiagnostics
75655
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
75656
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
75770
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
75657
75771
  var rawSources = [];
75658
75772
  var sources = [];
75659
75773
  var sourceToSourceIndexMap = new ts.Map();
@@ -77793,8 +77907,8 @@ var ts;
77793
77907
  }
77794
77908
  function serializeTypeList(types) {
77795
77909
  var serializedUnion;
77796
- for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
77797
- var typeNode = types_23[_i];
77910
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
77911
+ var typeNode = types_22[_i];
77798
77912
  while (typeNode.kind === 191) {
77799
77913
  typeNode = typeNode.type;
77800
77914
  }
@@ -93419,8 +93533,8 @@ var ts;
93419
93533
  bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
93420
93534
  writeLine();
93421
93535
  }
93422
- for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
93423
- var directive = types_24[_d];
93536
+ for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
93537
+ var directive = types_23[_d];
93424
93538
  var pos = writer.getTextPos();
93425
93539
  var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
93426
93540
  ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
@@ -101013,7 +101127,7 @@ var ts;
101013
101127
  importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
101014
101128
  });
101015
101129
  var sortedPaths = [];
101016
- var _loop_32 = function (directory) {
101130
+ var _loop_34 = function (directory) {
101017
101131
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
101018
101132
  var pathsInDirectory;
101019
101133
  allFileNames.forEach(function (_a, fileName) {
@@ -101037,9 +101151,9 @@ var ts;
101037
101151
  };
101038
101152
  var out_directory_1;
101039
101153
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
101040
- var state_10 = _loop_32(directory);
101154
+ var state_11 = _loop_34(directory);
101041
101155
  directory = out_directory_1;
101042
- if (state_10 === "break")
101156
+ if (state_11 === "break")
101043
101157
  break;
101044
101158
  }
101045
101159
  if (allFileNames.size) {
@@ -102803,6 +102917,7 @@ var ts;
102803
102917
  if (value) {
102804
102918
  return isParsedCommandLine(value) ? value : undefined;
102805
102919
  }
102920
+ ts.solutionPerformance.mark("beforeParseConfigFile");
102806
102921
  var diagnostic;
102807
102922
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
102808
102923
  var parsed;
@@ -102817,6 +102932,8 @@ var ts;
102817
102932
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
102818
102933
  }
102819
102934
  configFileCache.set(configFilePath, parsed || diagnostic);
102935
+ ts.solutionPerformance.mark("afterParseConfigFile");
102936
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
102820
102937
  return parsed;
102821
102938
  }
102822
102939
  function resolveProjectName(state, name) {
@@ -102864,6 +102981,7 @@ var ts;
102864
102981
  return state.buildOrder || createStateBuildOrder(state);
102865
102982
  }
102866
102983
  function createStateBuildOrder(state) {
102984
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
102867
102985
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
102868
102986
  state.resolvedConfigFilePaths.clear();
102869
102987
  var currentProjects = new ts.Map(getBuildOrderFromAnyBuildOrder(buildOrder).map(function (resolved) { return [toResolvedConfigFilePath(state, resolved), true]; }));
@@ -102889,6 +103007,8 @@ var ts;
102889
103007
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
102890
103008
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
102891
103009
  }
103010
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
103011
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
102892
103012
  return state.buildOrder = buildOrder;
102893
103013
  }
102894
103014
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -103008,6 +103128,7 @@ var ts;
103008
103128
  if (updateOutputFileStampsPending) {
103009
103129
  updateOutputTimestamps(state, config, projectPath);
103010
103130
  }
103131
+ ts.solutionPerformance.mark("timestampUpdated");
103011
103132
  return doneInvalidatedProject(state, projectPath);
103012
103133
  }
103013
103134
  };
@@ -103101,6 +103222,10 @@ var ts;
103101
103222
  };
103102
103223
  function done(cancellationToken, writeFile, customTransformers) {
103103
103224
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
103225
+ if (kind === InvalidatedProjectKind.Build)
103226
+ ts.solutionPerformance.mark("projectsBuilt");
103227
+ else
103228
+ ts.solutionPerformance.mark("bundlesUpdated");
103104
103229
  return doneInvalidatedProject(state, projectPath);
103105
103230
  }
103106
103231
  function withProgramOrUndefined(action) {
@@ -103181,6 +103306,7 @@ var ts;
103181
103306
  var anyDtsChanged = false;
103182
103307
  var emitterDiagnostics = ts.createDiagnosticCollection();
103183
103308
  var emittedOutputs = new ts.Map();
103309
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
103184
103310
  outputFiles.forEach(function (_a) {
103185
103311
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
103186
103312
  var priorChangeTime;
@@ -103199,6 +103325,8 @@ var ts;
103199
103325
  newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
103200
103326
  }
103201
103327
  });
103328
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
103329
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
103202
103330
  finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
103203
103331
  return emitResult;
103204
103332
  }
@@ -103322,6 +103450,13 @@ var ts;
103322
103450
  !ts.isIncrementalCompilation(config.options);
103323
103451
  }
103324
103452
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
103453
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
103454
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
103455
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
103456
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
103457
+ return result;
103458
+ }
103459
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
103325
103460
  if (!state.projectPendingBuild.size)
103326
103461
  return undefined;
103327
103462
  if (isCircularBuildOrder(buildOrder))
@@ -103417,9 +103552,7 @@ var ts;
103417
103552
  }
103418
103553
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
103419
103554
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
103420
- if (!info)
103421
- return info;
103422
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
103555
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
103423
103556
  }
103424
103557
  function listEmittedFile(_a, proj, file) {
103425
103558
  var write = _a.write;
@@ -103427,14 +103560,17 @@ var ts;
103427
103560
  write("TSFILE: " + file);
103428
103561
  }
103429
103562
  }
103430
- function getOldProgram(_a, proj, parsed) {
103431
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
103432
- if (options.force)
103563
+ function getOldProgram(state, proj, parsed) {
103564
+ if (state.options.force)
103433
103565
  return undefined;
103434
- var value = builderPrograms.get(proj);
103566
+ var value = state.builderPrograms.get(proj);
103435
103567
  if (value)
103436
103568
  return value;
103437
- return ts.readBuilderProgram(parsed.options, compilerHost);
103569
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
103570
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
103571
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
103572
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
103573
+ return program;
103438
103574
  }
103439
103575
  function afterProgramDone(state, program, config) {
103440
103576
  if (program) {
@@ -103607,7 +103743,10 @@ var ts;
103607
103743
  state.buildInfoChecked.set(resolvedPath, true);
103608
103744
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
103609
103745
  if (buildInfoPath) {
103746
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
103610
103747
  var value = state.readFileWithCache(buildInfoPath);
103748
+ ts.solutionPerformance.mark("afterBuildInfoRead");
103749
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
103611
103750
  var buildInfo = value && ts.getBuildInfo(value);
103612
103751
  if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
103613
103752
  return {
@@ -103642,13 +103781,17 @@ var ts;
103642
103781
  if (prior !== undefined) {
103643
103782
  return prior;
103644
103783
  }
103784
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
103645
103785
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
103786
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
103787
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
103646
103788
  state.projectStatus.set(resolvedPath, actual);
103647
103789
  return actual;
103648
103790
  }
103649
103791
  function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
103650
103792
  if (proj.options.noEmit)
103651
103793
  return priorNewestUpdateTime;
103794
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
103652
103795
  var host = state.host;
103653
103796
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
103654
103797
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
@@ -103669,6 +103812,8 @@ var ts;
103669
103812
  host.setModifiedTime(file, now);
103670
103813
  }
103671
103814
  }
103815
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
103816
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
103672
103817
  return priorNewestUpdateTime;
103673
103818
  }
103674
103819
  function updateOutputTimestamps(state, proj, resolvedPath) {
@@ -103740,6 +103885,13 @@ var ts;
103740
103885
  }
103741
103886
  }
103742
103887
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
103888
+ ts.solutionPerformance.mark("beforeBuild");
103889
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
103890
+ ts.solutionPerformance.mark("afterBuild");
103891
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
103892
+ return result;
103893
+ }
103894
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
103743
103895
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
103744
103896
  if (!buildOrder)
103745
103897
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -103751,7 +103903,10 @@ var ts;
103751
103903
  if (!invalidatedProject)
103752
103904
  break;
103753
103905
  reportQueue = false;
103906
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
103754
103907
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
103908
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
103909
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
103755
103910
  if (!state.diagnostics.has(invalidatedProject.projectPath))
103756
103911
  successfulProjects++;
103757
103912
  }
@@ -103837,6 +103992,14 @@ var ts;
103837
103992
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
103838
103993
  }
103839
103994
  function buildNextInvalidatedProject(state, changeDetected) {
103995
+ ts.solutionPerformance.mark("beforeBuild");
103996
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
103997
+ ts.solutionPerformance.mark("afterBuild");
103998
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
103999
+ if (buildOrder)
104000
+ reportErrorSummary(state, buildOrder);
104001
+ }
104002
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
103840
104003
  state.timerToBuildInvalidatedProject = undefined;
103841
104004
  if (state.reportFileChangeDetected) {
103842
104005
  state.reportFileChangeDetected = false;
@@ -103847,7 +104010,10 @@ var ts;
103847
104010
  var buildOrder = getBuildOrder(state);
103848
104011
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
103849
104012
  if (invalidatedProject) {
104013
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
103850
104014
  invalidatedProject.done();
104015
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
104016
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
103851
104017
  projectsBuilt++;
103852
104018
  while (state.projectPendingBuild.size) {
103853
104019
  if (state.timerToBuildInvalidatedProject)
@@ -103860,13 +104026,16 @@ var ts;
103860
104026
  return;
103861
104027
  }
103862
104028
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
104029
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
103863
104030
  project.done();
104031
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
104032
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
103864
104033
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
103865
104034
  projectsBuilt++;
103866
104035
  }
103867
104036
  }
103868
104037
  disableCache(state);
103869
- reportErrorSummary(state, buildOrder);
104038
+ return buildOrder;
103870
104039
  }
103871
104040
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
103872
104041
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
@@ -103923,6 +104092,7 @@ var ts;
103923
104092
  function startWatching(state, buildOrder) {
103924
104093
  if (!state.watchAllProjectsPending)
103925
104094
  return;
104095
+ ts.solutionPerformance.mark("beforeStartWatching");
103926
104096
  state.watchAllProjectsPending = false;
103927
104097
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
103928
104098
  var resolved = _a[_i];
@@ -103936,6 +104106,8 @@ var ts;
103936
104106
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
103937
104107
  }
103938
104108
  }
104109
+ ts.solutionPerformance.mark("afterStartWatching");
104110
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
103939
104111
  }
103940
104112
  function stopWatching(state) {
103941
104113
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -104082,6 +104254,12 @@ var ts;
104082
104254
  })(ts || (ts = {}));
104083
104255
  var ts;
104084
104256
  (function (ts) {
104257
+ var StatisticType;
104258
+ (function (StatisticType) {
104259
+ StatisticType[StatisticType["time"] = 0] = "time";
104260
+ StatisticType[StatisticType["count"] = 1] = "count";
104261
+ StatisticType[StatisticType["memory"] = 2] = "memory";
104262
+ })(StatisticType = ts.StatisticType || (ts.StatisticType = {}));
104085
104263
  function countLines(program) {
104086
104264
  var counts = getCountsMap();
104087
104265
  ts.forEach(program.getSourceFiles(), function (file) {
@@ -104642,18 +104820,73 @@ var ts;
104642
104820
  if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
104643
104821
  return;
104644
104822
  var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
104823
+ var onWatchStatusChange_1 = buildHost_1.onWatchStatusChange;
104824
+ var reportWatchStatistics_1 = false;
104825
+ buildHost_1.onWatchStatusChange = function (d, newLine, options, errorCount) {
104826
+ onWatchStatusChange_1 === null || onWatchStatusChange_1 === void 0 ? void 0 : onWatchStatusChange_1(d, newLine, options, errorCount);
104827
+ if (!reportWatchStatistics_1)
104828
+ return;
104829
+ if (d.code === ts.Diagnostics.Found_0_errors_Watching_for_file_changes.code ||
104830
+ d.code === ts.Diagnostics.Found_1_error_Watching_for_file_changes.code) {
104831
+ reportSolutionBuilderTimes(sys, builder_1, buildHost_1);
104832
+ }
104833
+ };
104645
104834
  updateSolutionBuilderHost(sys, cb, buildHost_1);
104835
+ enableSolutionPerformance(sys, buildOptions);
104646
104836
  var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
104647
104837
  builder_1.build();
104838
+ reportSolutionBuilderTimes(sys, builder_1, buildHost_1);
104839
+ reportWatchStatistics_1 = true;
104648
104840
  return builder_1;
104649
104841
  }
104650
104842
  var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
104651
104843
  updateSolutionBuilderHost(sys, cb, buildHost);
104844
+ enableSolutionPerformance(sys, buildOptions);
104652
104845
  var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
104653
104846
  var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
104847
+ reportSolutionBuilderTimes(sys, builder, buildHost);
104654
104848
  ts.dumpTracingLegend();
104655
104849
  return sys.exit(exitStatus);
104656
104850
  }
104851
+ function enableSolutionPerformance(system, options) {
104852
+ if (system === ts.sys && (options.diagnostics || options.extendedDiagnostics))
104853
+ ts.solutionPerformance.enable();
104854
+ }
104855
+ function reportSolutionBuilderTimes(system, builder, buildHost) {
104856
+ if (system !== ts.sys)
104857
+ return;
104858
+ if (ts.solutionPerformance.isEnabled()) {
104859
+ var solutionStatistics_1 = [];
104860
+ ts.solutionPerformance.forEachMeasure(function (name, duration) { return solutionStatistics_1.push({ name: name + " time", value: duration, type: StatisticType.time }); });
104861
+ solutionStatistics_1.push({ name: "projectsBuilt", value: ts.solutionPerformance.getCount("projectsBuilt"), type: StatisticType.count }, { name: "timestampUpdated", value: ts.solutionPerformance.getCount("timestampUpdated"), type: StatisticType.count }, { name: "bundlesUpdated", value: ts.solutionPerformance.getCount("bundlesUpdated"), type: StatisticType.count }, { name: "projects", value: ts.getBuildOrderFromAnyBuildOrder(builder.getBuildOrder()).length, type: StatisticType.count });
104862
+ buildHost.statistics = ts.append(buildHost.statistics, solutionStatistics_1);
104863
+ ts.solutionPerformance.disable();
104864
+ ts.solutionPerformance.enable();
104865
+ }
104866
+ if (!buildHost.statistics)
104867
+ return;
104868
+ var statistics = [];
104869
+ var map = new ts.Map();
104870
+ for (var _i = 0, _a = buildHost.statistics; _i < _a.length; _i++) {
104871
+ var statistic = _a[_i];
104872
+ for (var _b = 0, statistic_1 = statistic; _b < statistic_1.length; _b++) {
104873
+ var s = statistic_1[_b];
104874
+ var existing = map.get(s.name);
104875
+ if (existing) {
104876
+ if (existing.type === StatisticType.memory)
104877
+ existing.value = Math.max(existing.value, s.value);
104878
+ else
104879
+ existing.value += s.value;
104880
+ }
104881
+ else {
104882
+ map.set(s.name, s);
104883
+ statistics.push(s);
104884
+ }
104885
+ }
104886
+ }
104887
+ buildHost.statistics = undefined;
104888
+ reportAllStatistics(system, statistics);
104889
+ }
104657
104890
  function createReportErrorSummary(sys, options) {
104658
104891
  return shouldBePretty(sys, options) ?
104659
104892
  function (errorCount, filesInError) { return sys.write(ts.getErrorSummaryText(errorCount, filesInError, sys.newLine, sys)); } :
@@ -104702,10 +104935,13 @@ var ts;
104702
104935
  function updateSolutionBuilderHost(sys, cb, buildHost) {
104703
104936
  updateCreateProgram(sys, buildHost);
104704
104937
  buildHost.afterProgramEmitAndDiagnostics = function (program) {
104705
- reportStatistics(sys, program.getProgram());
104938
+ buildHost.statistics = ts.append(buildHost.statistics, reportStatistics(sys, program.getProgram()));
104706
104939
  cb(program);
104707
104940
  };
104708
- buildHost.afterEmitBundle = cb;
104941
+ buildHost.afterEmitBundle = function (config) {
104942
+ buildHost.statistics = ts.append(buildHost.statistics, reportStatistics(sys, config));
104943
+ cb(config);
104944
+ };
104709
104945
  }
104710
104946
  function updateCreateProgram(sys, host) {
104711
104947
  var compileUsingBuilder = host.createProgram;
@@ -104769,8 +105005,13 @@ var ts;
104769
105005
  ts.startTracing(isBuildMode ? "build" : "project", compilerOptions.generateTrace, compilerOptions.configFilePath);
104770
105006
  }
104771
105007
  }
104772
- function reportStatistics(sys, program) {
104773
- var compilerOptions = program.getCompilerOptions();
105008
+ function isProgram(programOrConfig) {
105009
+ return !!programOrConfig.getCompilerOptions;
105010
+ }
105011
+ function reportStatistics(sys, programOrConfig) {
105012
+ var program = isProgram(programOrConfig) ? programOrConfig : undefined;
105013
+ var config = !isProgram(programOrConfig) ? programOrConfig : undefined;
105014
+ var compilerOptions = (program === null || program === void 0 ? void 0 : program.getCompilerOptions()) || (config === null || config === void 0 ? void 0 : config.options);
104774
105015
  if (canTrace(sys, compilerOptions)) {
104775
105016
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.stopTracing();
104776
105017
  }
@@ -104778,29 +105019,31 @@ var ts;
104778
105019
  if (canReportDiagnostics(sys, compilerOptions)) {
104779
105020
  statistics = [];
104780
105021
  var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
104781
- reportCountStatistic("Files", program.getSourceFiles().length);
104782
- var lineCounts = countLines(program);
104783
- var nodeCounts = countNodes(program);
104784
- if (compilerOptions.extendedDiagnostics) {
104785
- for (var _i = 0, _a = ts.arrayFrom(lineCounts.keys()); _i < _a.length; _i++) {
104786
- var key = _a[_i];
104787
- reportCountStatistic("Lines of " + key, lineCounts.get(key));
105022
+ if (program) {
105023
+ reportCountStatistic("Files", program.getSourceFiles().length);
105024
+ var lineCounts = countLines(program);
105025
+ var nodeCounts = countNodes(program);
105026
+ if (compilerOptions.extendedDiagnostics) {
105027
+ for (var _i = 0, _a = ts.arrayFrom(lineCounts.keys()); _i < _a.length; _i++) {
105028
+ var key = _a[_i];
105029
+ reportCountStatistic("Lines of " + key, lineCounts.get(key));
105030
+ }
105031
+ for (var _b = 0, _c = ts.arrayFrom(nodeCounts.keys()); _b < _c.length; _b++) {
105032
+ var key = _c[_b];
105033
+ reportCountStatistic("Nodes of " + key, nodeCounts.get(key));
105034
+ }
104788
105035
  }
104789
- for (var _b = 0, _c = ts.arrayFrom(nodeCounts.keys()); _b < _c.length; _b++) {
104790
- var key = _c[_b];
104791
- reportCountStatistic("Nodes of " + key, nodeCounts.get(key));
105036
+ else {
105037
+ reportCountStatistic("Lines", ts.reduceLeftIterator(lineCounts.values(), function (sum, count) { return sum + count; }, 0));
105038
+ reportCountStatistic("Nodes", ts.reduceLeftIterator(nodeCounts.values(), function (sum, count) { return sum + count; }, 0));
104792
105039
  }
105040
+ reportCountStatistic("Identifiers", program.getIdentifierCount());
105041
+ reportCountStatistic("Symbols", program.getSymbolCount());
105042
+ reportCountStatistic("Types", program.getTypeCount());
105043
+ reportCountStatistic("Instantiations", program.getInstantiationCount());
104793
105044
  }
104794
- else {
104795
- reportCountStatistic("Lines", ts.reduceLeftIterator(lineCounts.values(), function (sum, count) { return sum + count; }, 0));
104796
- reportCountStatistic("Nodes", ts.reduceLeftIterator(nodeCounts.values(), function (sum, count) { return sum + count; }, 0));
104797
- }
104798
- reportCountStatistic("Identifiers", program.getIdentifierCount());
104799
- reportCountStatistic("Symbols", program.getSymbolCount());
104800
- reportCountStatistic("Types", program.getTypeCount());
104801
- reportCountStatistic("Instantiations", program.getInstantiationCount());
104802
105045
  if (memoryUsed >= 0) {
104803
- reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
105046
+ reportMemoryStatistic("Memory used", memoryUsed);
104804
105047
  }
104805
105048
  var isPerformanceEnabled = ts.performance.isEnabled();
104806
105049
  var programTime = isPerformanceEnabled ? ts.performance.getDuration("Program") : 0;
@@ -104808,11 +105051,13 @@ var ts;
104808
105051
  var checkTime = isPerformanceEnabled ? ts.performance.getDuration("Check") : 0;
104809
105052
  var emitTime = isPerformanceEnabled ? ts.performance.getDuration("Emit") : 0;
104810
105053
  if (compilerOptions.extendedDiagnostics) {
104811
- var caches = program.getRelationCacheSizes();
104812
- reportCountStatistic("Assignability cache size", caches.assignable);
104813
- reportCountStatistic("Identity cache size", caches.identity);
104814
- reportCountStatistic("Subtype cache size", caches.subtype);
104815
- reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
105054
+ if (program) {
105055
+ var caches = program.getRelationCacheSizes();
105056
+ reportCountStatistic("Assignability cache size", caches.assignable);
105057
+ reportCountStatistic("Identity cache size", caches.identity);
105058
+ reportCountStatistic("Subtype cache size", caches.subtype);
105059
+ reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
105060
+ }
104816
105061
  if (isPerformanceEnabled) {
104817
105062
  ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
104818
105063
  }
@@ -104828,39 +105073,54 @@ var ts;
104828
105073
  if (isPerformanceEnabled) {
104829
105074
  reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
104830
105075
  }
104831
- reportStatistics();
105076
+ reportAllStatistics(sys, statistics);
104832
105077
  if (!isPerformanceEnabled) {
104833
105078
  sys.write(ts.Diagnostics.Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found.message + "\n");
104834
105079
  }
104835
105080
  else {
104836
105081
  ts.performance.disable();
104837
105082
  }
105083
+ return statistics;
104838
105084
  }
104839
- function reportStatistics() {
104840
- var nameSize = 0;
104841
- var valueSize = 0;
104842
- for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
104843
- var _a = statistics_1[_i], name = _a.name, value = _a.value;
104844
- if (name.length > nameSize) {
104845
- nameSize = name.length;
104846
- }
104847
- if (value.length > valueSize) {
104848
- valueSize = value.length;
104849
- }
104850
- }
104851
- for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
104852
- var _c = statistics_2[_b], name = _c.name, value = _c.value;
104853
- sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
104854
- }
104855
- }
104856
- function reportStatisticalValue(name, value) {
104857
- statistics.push({ name: name, value: value });
105085
+ function reportMemoryStatistic(name, memoryUsed) {
105086
+ statistics.push({ name: name, value: memoryUsed, type: StatisticType.memory });
104858
105087
  }
104859
105088
  function reportCountStatistic(name, count) {
104860
- reportStatisticalValue(name, "" + count);
105089
+ statistics.push({ name: name, value: count, type: StatisticType.count });
104861
105090
  }
104862
105091
  function reportTimeStatistic(name, time) {
104863
- reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
105092
+ statistics.push({ name: name, value: time, type: StatisticType.time });
105093
+ }
105094
+ }
105095
+ function reportAllStatistics(sys, statistics) {
105096
+ var nameSize = 0;
105097
+ var valueSize = 0;
105098
+ for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
105099
+ var s = statistics_1[_i];
105100
+ if (s.name.length > nameSize) {
105101
+ nameSize = s.name.length;
105102
+ }
105103
+ var valueString = statisticValue(s);
105104
+ if (valueString.length > valueSize) {
105105
+ valueSize = valueString.length;
105106
+ }
105107
+ }
105108
+ for (var _a = 0, statistics_2 = statistics; _a < statistics_2.length; _a++) {
105109
+ var s = statistics_2[_a];
105110
+ sys.write(ts.padRight(s.name + ":", nameSize + 2) + ts.padLeft(statisticValue(s).toString(), valueSize) + sys.newLine);
105111
+ }
105112
+ }
105113
+ function statisticValue(s) {
105114
+ switch (s.type) {
105115
+ case StatisticType.count:
105116
+ return "" + s.value;
105117
+ case StatisticType.time:
105118
+ return (s.value / 1000).toFixed(2) + "s";
105119
+ case StatisticType.memory:
105120
+ return Math.round(s.value / 1000) + "K";
105121
+ break;
105122
+ default:
105123
+ ts.Debug.assertNever(s.type);
104864
105124
  }
104865
105125
  }
104866
105126
  function writeConfigFile(sys, reportDiagnostic, options, fileNames) {