@typescript-deploys/pr-build 4.8.0-pr-49245-7 → 4.8.0-pr-49285-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220531";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -3704,16 +3704,34 @@ var ts;
3704
3704
  /** Performance measurements for the compiler. */
3705
3705
  var ts;
3706
3706
  (function (ts) {
3707
- var performance;
3708
- (function (performance) {
3707
+ var nullTimer = { enter: ts.noop, exit: ts.noop };
3708
+ ts.performance = createPerformanceTracker();
3709
+ ts.solutionPerformance = createPerformanceTracker();
3710
+ function createPerformanceTracker() {
3709
3711
  var perfHooks;
3710
3712
  // when set, indicates the implementation of `Performance` to use for user timing.
3711
3713
  // when unset, indicates user timing is unavailable or disabled.
3712
3714
  var performanceImpl;
3715
+ var enabled = false;
3716
+ var timeorigin = ts.timestamp();
3717
+ var marks = new ts.Map();
3718
+ var counts = new ts.Map();
3719
+ var durations = new ts.Map();
3720
+ return {
3721
+ createTimerIf: createTimerIf,
3722
+ createTimer: createTimer,
3723
+ mark: mark,
3724
+ measure: measure,
3725
+ getCount: getCount,
3726
+ getDuration: getDuration,
3727
+ forEachMeasure: forEachMeasure,
3728
+ isEnabled: isEnabled,
3729
+ enable: enable,
3730
+ disable: disable,
3731
+ };
3713
3732
  function createTimerIf(condition, measureName, startMarkName, endMarkName) {
3714
- return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
3733
+ return condition ? createTimer(measureName, startMarkName, endMarkName) : nullTimer;
3715
3734
  }
3716
- performance.createTimerIf = createTimerIf;
3717
3735
  function createTimer(measureName, startMarkName, endMarkName) {
3718
3736
  var enterCount = 0;
3719
3737
  return {
@@ -3735,13 +3753,6 @@ var ts;
3735
3753
  }
3736
3754
  }
3737
3755
  }
3738
- performance.createTimer = createTimer;
3739
- performance.nullTimer = { enter: ts.noop, exit: ts.noop };
3740
- var enabled = false;
3741
- var timeorigin = ts.timestamp();
3742
- var marks = new ts.Map();
3743
- var counts = new ts.Map();
3744
- var durations = new ts.Map();
3745
3756
  /**
3746
3757
  * Marks a performance event.
3747
3758
  *
@@ -3756,7 +3767,6 @@ var ts;
3756
3767
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
3757
3768
  }
3758
3769
  }
3759
- performance.mark = mark;
3760
3770
  /**
3761
3771
  * Adds a performance measurement with the specified name.
3762
3772
  *
@@ -3769,14 +3779,13 @@ var ts;
3769
3779
  function measure(measureName, startMarkName, endMarkName) {
3770
3780
  var _a, _b;
3771
3781
  if (enabled) {
3772
- var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
3773
- var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
3782
+ var end = (_a = marks.get(endMarkName)) !== null && _a !== void 0 ? _a : ts.timestamp();
3783
+ var start = (_b = marks.get(startMarkName)) !== null && _b !== void 0 ? _b : timeorigin;
3774
3784
  var previousDuration = durations.get(measureName) || 0;
3775
3785
  durations.set(measureName, previousDuration + (end - start));
3776
3786
  performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
3777
3787
  }
3778
3788
  }
3779
- performance.measure = measure;
3780
3789
  /**
3781
3790
  * Gets the number of times a marker was encountered.
3782
3791
  *
@@ -3785,7 +3794,6 @@ var ts;
3785
3794
  function getCount(markName) {
3786
3795
  return counts.get(markName) || 0;
3787
3796
  }
3788
- performance.getCount = getCount;
3789
3797
  /**
3790
3798
  * Gets the total duration of all measurements with the supplied name.
3791
3799
  *
@@ -3794,7 +3802,6 @@ var ts;
3794
3802
  function getDuration(measureName) {
3795
3803
  return durations.get(measureName) || 0;
3796
3804
  }
3797
- performance.getDuration = getDuration;
3798
3805
  /**
3799
3806
  * Iterate over each measure, performing some action
3800
3807
  *
@@ -3803,14 +3810,12 @@ var ts;
3803
3810
  function forEachMeasure(cb) {
3804
3811
  durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
3805
3812
  }
3806
- performance.forEachMeasure = forEachMeasure;
3807
3813
  /**
3808
3814
  * Indicates whether the performance API is enabled.
3809
3815
  */
3810
3816
  function isEnabled() {
3811
3817
  return enabled;
3812
3818
  }
3813
- performance.isEnabled = isEnabled;
3814
3819
  /** Enables (and resets) performance measurements for the compiler. */
3815
3820
  function enable(system) {
3816
3821
  var _a;
@@ -3831,7 +3836,6 @@ var ts;
3831
3836
  }
3832
3837
  return true;
3833
3838
  }
3834
- performance.enable = enable;
3835
3839
  /** Disables performance measurements for the compiler. */
3836
3840
  function disable() {
3837
3841
  if (enabled) {
@@ -3842,8 +3846,7 @@ var ts;
3842
3846
  enabled = false;
3843
3847
  }
3844
3848
  }
3845
- performance.disable = disable;
3846
- })(performance = ts.performance || (ts.performance = {}));
3849
+ }
3847
3850
  })(ts || (ts = {}));
3848
3851
  /* @internal */
3849
3852
  var ts;
@@ -5295,6 +5298,11 @@ var ts;
5295
5298
  // Flags that require TypeFlags.Union
5296
5299
  /* @internal */
5297
5300
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5301
+ /* @internal */
5302
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5303
+ /* @internal */
5304
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5305
+ /* @internal */
5298
5306
  // Flags that require TypeFlags.Intersection
5299
5307
  /* @internal */
5300
5308
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -8608,6 +8616,7 @@ var ts;
8608
8616
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8609
8617
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8610
8618
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8619
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8611
8620
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8612
8621
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8613
8622
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -16412,9 +16421,6 @@ var ts;
16412
16421
  }
16413
16422
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16423
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16424
  return ts.isVariableDeclaration(node) &&
16419
16425
  !!node.initializer &&
16420
16426
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20232,9 @@ var ts;
20226
20232
  */
20227
20233
  function isFileForcedToBeModuleByFormat(file) {
20228
20234
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20235
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20236
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20237
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20238
  }
20232
20239
  function getSetExternalModuleIndicator(options) {
20233
20240
  // TODO: Should this callback be cached?
@@ -20235,7 +20242,7 @@ var ts;
20235
20242
  case ts.ModuleDetectionKind.Force:
20236
20243
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20244
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20245
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20246
  };
20240
20247
  case ts.ModuleDetectionKind.Legacy:
20241
20248
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20302,8 @@ var ts;
20295
20302
  }
20296
20303
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20304
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20305
+ return options.moduleDetection ||
20306
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20307
  }
20300
20308
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20309
  function hasJsonModuleEmitEnabled(options) {
@@ -42237,7 +42245,7 @@ var ts;
42237
42245
  }
42238
42246
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42239
42247
  return {
42240
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42248
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42241
42249
  flags: 1 /* Recursive */
42242
42250
  };
42243
42251
  }
@@ -43342,16 +43350,20 @@ var ts;
43342
43350
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43343
43351
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43344
43352
  }
43353
+ var jsOnlyExtensions = [Extensions.JavaScript];
43354
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43355
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43356
+ var tsconfigExtensions = [Extensions.TSConfig];
43345
43357
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43346
43358
  var containingDirectory = ts.getDirectoryPath(containingFile);
43347
43359
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43348
43360
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43349
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43361
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43362
+ if (compilerOptions.resolveJsonModule) {
43363
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43364
+ }
43365
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43350
43366
  }
43351
- var jsOnlyExtensions = [Extensions.JavaScript];
43352
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43353
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43354
- var tsconfigExtensions = [Extensions.TSConfig];
43355
43367
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43356
43368
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43357
43369
  }
@@ -47136,12 +47148,14 @@ var ts;
47136
47148
  }
47137
47149
  }
47138
47150
  function setCommonJsModuleIndicator(node) {
47139
- if (file.externalModuleIndicator) {
47151
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47140
47152
  return false;
47141
47153
  }
47142
47154
  if (!file.commonJsModuleIndicator) {
47143
47155
  file.commonJsModuleIndicator = node;
47144
- bindSourceFileAsExternalModule();
47156
+ if (!file.externalModuleIndicator) {
47157
+ bindSourceFileAsExternalModule();
47158
+ }
47145
47159
  }
47146
47160
  return true;
47147
47161
  }
@@ -47555,7 +47569,11 @@ var ts;
47555
47569
  checkStrictModeEvalOrArguments(node, node.name);
47556
47570
  }
47557
47571
  if (!ts.isBindingPattern(node.name)) {
47558
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47572
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47573
+ if (ts.isInJSFile(node) &&
47574
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47575
+ !ts.getJSDocTypeTag(node) &&
47576
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47559
47577
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47560
47578
  }
47561
47579
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -48732,6 +48750,7 @@ var ts;
48732
48750
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48733
48751
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48734
48752
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48753
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48735
48754
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48736
48755
  emptyGenericType.instantiations = new ts.Map();
48737
48756
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50382,7 +50401,8 @@ var ts;
50382
50401
  && isAliasableOrJsExpression(node.parent.right)
50383
50402
  || node.kind === 297 /* ShorthandPropertyAssignment */
50384
50403
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50385
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50404
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50405
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50386
50406
  }
50387
50407
  function isAliasableOrJsExpression(e) {
50388
50408
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50475,7 +50495,7 @@ var ts;
50475
50495
  return hasExportAssignmentSymbol(moduleSymbol);
50476
50496
  }
50477
50497
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50478
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50498
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50479
50499
  }
50480
50500
  function getTargetOfImportClause(node, dontResolveAlias) {
50481
50501
  var _a;
@@ -58901,7 +58921,7 @@ var ts;
58901
58921
  }
58902
58922
  }
58903
58923
  }
58904
- else if (t.flags & 469892092 /* DisjointDomains */) {
58924
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58905
58925
  hasDisjointDomainType = true;
58906
58926
  }
58907
58927
  }
@@ -58913,7 +58933,7 @@ var ts;
58913
58933
  // intersection operation to reduce the union constraints.
58914
58934
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58915
58935
  var t = types_6[_a];
58916
- if (t.flags & 469892092 /* DisjointDomains */) {
58936
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58917
58937
  constraints = ts.append(constraints, t);
58918
58938
  }
58919
58939
  }
@@ -61462,7 +61482,7 @@ var ts;
61462
61482
  }
61463
61483
  return includes;
61464
61484
  }
61465
- function removeRedundantPrimitiveTypes(types, includes) {
61485
+ function removeRedundantSupertypes(types, includes) {
61466
61486
  var i = types.length;
61467
61487
  while (i > 0) {
61468
61488
  i--;
@@ -61470,7 +61490,9 @@ var ts;
61470
61490
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61471
61491
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61472
61492
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61473
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61493
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61494
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61495
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61474
61496
  if (remove) {
61475
61497
  ts.orderedRemoveItemAt(types, i);
61476
61498
  }
@@ -61592,7 +61614,7 @@ var ts;
61592
61614
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61593
61615
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61594
61616
  // for intersections of types with signatures can be deterministic.
61595
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61617
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61596
61618
  var typeMembershipMap = new ts.Map();
61597
61619
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61598
61620
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61629,11 +61651,11 @@ var ts;
61629
61651
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61630
61652
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61631
61653
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61632
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61633
- removeRedundantPrimitiveTypes(typeSet, includes);
61634
- }
61635
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61636
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61654
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61655
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61656
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61657
+ if (!noSupertypeReduction)
61658
+ removeRedundantSupertypes(typeSet, includes);
61637
61659
  }
61638
61660
  if (includes & 262144 /* IncludesMissingType */) {
61639
61661
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61672,8 +61694,9 @@ var ts;
61672
61694
  }
61673
61695
  var constituents = getCrossProductIntersections(typeSet);
61674
61696
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61675
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61676
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61697
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61698
+ // the denormalized origin has fewer constituents than the union itself.
61699
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61677
61700
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61678
61701
  }
61679
61702
  }
@@ -61716,11 +61739,21 @@ var ts;
61716
61739
  }
61717
61740
  return intersections;
61718
61741
  }
61742
+ function getConstituentCount(type) {
61743
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61744
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61745
+ getConstituentCountOfTypes(type.types);
61746
+ }
61747
+ function getConstituentCountOfTypes(types) {
61748
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61749
+ }
61719
61750
  function getTypeFromIntersectionTypeNode(node) {
61720
61751
  var links = getNodeLinks(node);
61721
61752
  if (!links.resolvedType) {
61722
61753
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61723
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61754
+ var types = ts.map(node.types, getTypeFromTypeNode);
61755
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61756
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61724
61757
  }
61725
61758
  return links.resolvedType;
61726
61759
  }
@@ -64506,6 +64539,17 @@ var ts;
64506
64539
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64507
64540
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64508
64541
  }
64542
+ function isUnknownLikeUnionType(type) {
64543
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64544
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64545
+ var types = type.types;
64546
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64547
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64548
+ }
64549
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64550
+ }
64551
+ return false;
64552
+ }
64509
64553
  function isStringIndexSignatureOnlyType(type) {
64510
64554
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64511
64555
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64585,7 +64629,7 @@ var ts;
64585
64629
  return true;
64586
64630
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64587
64631
  return true;
64588
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64632
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64589
64633
  return true;
64590
64634
  if (relation === assignableRelation || relation === comparableRelation) {
64591
64635
  if (s & 1 /* Any */)
@@ -64595,6 +64639,9 @@ var ts;
64595
64639
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64596
64640
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64597
64641
  return true;
64642
+ // Anything is assignable to a union containing undefined, null, and {}
64643
+ if (isUnknownLikeUnionType(target))
64644
+ return true;
64598
64645
  }
64599
64646
  return false;
64600
64647
  }
@@ -64637,16 +64684,27 @@ var ts;
64637
64684
  function getNormalizedType(type, writing) {
64638
64685
  while (true) {
64639
64686
  var t = isFreshLiteralType(type) ? type.regularType :
64640
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64641
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64687
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64688
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64642
64689
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64643
64690
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64644
64691
  type;
64645
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64646
64692
  if (t === type)
64647
- break;
64693
+ return t;
64648
64694
  type = t;
64649
64695
  }
64696
+ }
64697
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64698
+ var reduced = getReducedType(type);
64699
+ if (reduced !== type) {
64700
+ return reduced;
64701
+ }
64702
+ if (type.flags & 2097152 /* Intersection */) {
64703
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64704
+ if (normalizedTypes !== type.types) {
64705
+ return getIntersectionType(normalizedTypes);
64706
+ }
64707
+ }
64650
64708
  return type;
64651
64709
  }
64652
64710
  /**
@@ -65093,6 +65151,7 @@ var ts;
65093
65151
  return 0 /* False */;
65094
65152
  }
65095
65153
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
65154
+ var _a, _b;
65096
65155
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
65097
65156
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
65098
65157
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -65133,6 +65192,9 @@ var ts;
65133
65192
  return;
65134
65193
  }
65135
65194
  reportRelationError(headMessage, source, target);
65195
+ if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65196
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65197
+ }
65136
65198
  }
65137
65199
  function traceUnionsOrIntersectionsTooLarge(source, target) {
65138
65200
  if (!ts.tracing) {
@@ -65919,13 +65981,6 @@ var ts;
65919
65981
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65920
65982
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65921
65983
  var constraint = getConstraintOfType(source) || unknownType;
65922
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65923
- // A type variable with no constraint is not related to the non-primitive object type.
65924
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65925
- resetErrorInfo(saveErrorInfo);
65926
- return result;
65927
- }
65928
- }
65929
65984
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
65930
65985
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65931
65986
  resetErrorInfo(saveErrorInfo);
@@ -67399,9 +67454,11 @@ var ts;
67399
67454
  return getSupertypeOrUnion(types);
67400
67455
  }
67401
67456
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67402
- return primaryTypes.length ?
67403
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67404
- getUnionType(types, 2 /* Subtype */);
67457
+ if (primaryTypes.length) {
67458
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67459
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67460
+ }
67461
+ return getUnionType(types, 2 /* Subtype */);
67405
67462
  }
67406
67463
  // Return the leftmost type for which no type to the right is a subtype.
67407
67464
  function getCommonSubtype(types) {
@@ -67600,12 +67657,13 @@ var ts;
67600
67657
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67601
67658
  // no flags for all other types (including non-falsy literal types).
67602
67659
  function getFalsyFlags(type) {
67603
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67604
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67605
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67606
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67607
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67608
- type.flags & 117724 /* PossiblyFalsy */;
67660
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67661
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67662
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67663
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67664
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67665
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67666
+ t.flags & 117724 /* PossiblyFalsy */;
67609
67667
  }
67610
67668
  function removeDefinitelyFalsyTypes(type) {
67611
67669
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67645,20 +67703,22 @@ var ts;
67645
67703
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67646
67704
  }
67647
67705
  function getGlobalNonNullableTypeInstantiation(type) {
67648
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67649
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67650
- // that isn't eliminated by a NonNullable<T> instantiation.
67651
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67652
67706
  if (!deferredGlobalNonNullableTypeAlias) {
67653
67707
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67654
67708
  }
67655
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67656
67709
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67657
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67658
- reducedType;
67710
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67711
+ getIntersectionType([type, emptyObjectType]);
67659
67712
  }
67660
67713
  function getNonNullableType(type) {
67661
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67714
+ if (strictNullChecks) {
67715
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67716
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67717
+ // that isn't eliminated by a NonNullable<T> instantiation.
67718
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67719
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67720
+ }
67721
+ return type;
67662
67722
  }
67663
67723
  function addOptionalTypeMarker(type) {
67664
67724
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68339,13 +68399,40 @@ var ts;
68339
68399
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68340
68400
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68341
68401
  }
68342
- function isValidBigIntString(s) {
68402
+ /**
68403
+ * Tests whether the provided string can be parsed as a number.
68404
+ * @param s The string to test.
68405
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68406
+ */
68407
+ function isValidNumberString(s, roundTripOnly) {
68408
+ if (s === "")
68409
+ return false;
68410
+ var n = +s;
68411
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68412
+ }
68413
+ /**
68414
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68415
+ */
68416
+ function parseBigIntLiteralType(text) {
68417
+ var negative = text.startsWith("-");
68418
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68419
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68420
+ }
68421
+ /**
68422
+ * Tests whether the provided string can be parsed as a bigint.
68423
+ * @param s The string to test.
68424
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68425
+ */
68426
+ function isValidBigIntString(s, roundTripOnly) {
68427
+ if (s === "")
68428
+ return false;
68343
68429
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68344
68430
  var success = true;
68345
68431
  scanner.setOnError(function () { return success = false; });
68346
68432
  scanner.setText(s + "n");
68347
68433
  var result = scanner.scan();
68348
- if (result === 40 /* MinusToken */) {
68434
+ var negative = result === 40 /* MinusToken */;
68435
+ if (negative) {
68349
68436
  result = scanner.scan();
68350
68437
  }
68351
68438
  var flags = scanner.getTokenFlags();
@@ -68354,7 +68441,8 @@ var ts;
68354
68441
  // * a bigint can be scanned, and that when it is scanned, it is
68355
68442
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68356
68443
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68357
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68444
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68445
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68358
68446
  }
68359
68447
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68360
68448
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68362,8 +68450,8 @@ var ts;
68362
68450
  }
68363
68451
  if (source.flags & 128 /* StringLiteral */) {
68364
68452
  var value = source.value;
68365
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68366
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68453
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68454
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68367
68455
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68368
68456
  }
68369
68457
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68936,8 +69024,57 @@ var ts;
68936
69024
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68937
69025
  // succeed. That would be a pointless and confusing outcome.
68938
69026
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69027
+ var _loop_23 = function (i) {
69028
+ var source_1 = matches ? matches[i] : neverType;
69029
+ var target_3 = types[i];
69030
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
69031
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
69032
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
69033
+ var inferenceContext = getInferenceInfoForType(target_3);
69034
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
69035
+ if (constraint && !isTypeAny(constraint)) {
69036
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
69037
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
69038
+ // If the constraint contains `string`, we don't need to look for a more preferred type
69039
+ if (!(allTypeFlags_1 & 4 /* String */)) {
69040
+ var str_1 = source_1.value;
69041
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
69042
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
69043
+ allTypeFlags_1 &= ~296 /* NumberLike */;
69044
+ }
69045
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
69046
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
69047
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
69048
+ }
69049
+ // for each type in the constraint, find the highest priority matching type
69050
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
69051
+ return !(right.flags & allTypeFlags_1) ? left :
69052
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
69053
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
69054
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
69055
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
69056
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
69057
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
69058
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
69059
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
69060
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
69061
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
69062
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
69063
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
69064
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
69065
+ left;
69066
+ }, neverType);
69067
+ if (!(matchingType.flags & 131072 /* Never */)) {
69068
+ inferFromTypes(matchingType, target_3);
69069
+ return "continue";
69070
+ }
69071
+ }
69072
+ }
69073
+ }
69074
+ inferFromTypes(source_1, target_3);
69075
+ };
68939
69076
  for (var i = 0; i < types.length; i++) {
68940
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
69077
+ _loop_23(i);
68941
69078
  }
68942
69079
  }
68943
69080
  }
@@ -69455,7 +69592,7 @@ var ts;
69455
69592
  function mapTypesByKeyProperty(types, name) {
69456
69593
  var map = new ts.Map();
69457
69594
  var count = 0;
69458
- var _loop_23 = function (type) {
69595
+ var _loop_24 = function (type) {
69459
69596
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69460
69597
  var discriminant = getTypeOfPropertyOfType(type, name);
69461
69598
  if (discriminant) {
@@ -69481,7 +69618,7 @@ var ts;
69481
69618
  };
69482
69619
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69483
69620
  var type = types_16[_i];
69484
- var state_9 = _loop_23(type);
69621
+ var state_9 = _loop_24(type);
69485
69622
  if (typeof state_9 === "object")
69486
69623
  return state_9.value;
69487
69624
  }
@@ -69689,6 +69826,24 @@ var ts;
69689
69826
  function getTypeWithFacts(type, include) {
69690
69827
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69691
69828
  }
69829
+ function getIntersectionWithFacts(type, facts) {
69830
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69831
+ if (strictNullChecks) {
69832
+ switch (facts) {
69833
+ case 524288 /* NEUndefined */:
69834
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
69835
+ case 1048576 /* NENull */:
69836
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
69837
+ case 2097152 /* NEUndefinedOrNull */:
69838
+ case 4194304 /* Truthy */:
69839
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69840
+ }
69841
+ }
69842
+ return reduced;
69843
+ }
69844
+ function recombineUnknownType(type) {
69845
+ return type === unknownUnionType ? unknownType : type;
69846
+ }
69692
69847
  function getTypeWithDefault(type, defaultExpression) {
69693
69848
  return defaultExpression ?
69694
69849
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70746,7 +70901,7 @@ var ts;
70746
70901
  if (isEvolvingArrayTypeList(types)) {
70747
70902
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70748
70903
  }
70749
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70904
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70750
70905
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70751
70906
  return declaredType;
70752
70907
  }
@@ -70848,8 +71003,7 @@ var ts;
70848
71003
  }
70849
71004
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70850
71005
  if (isMatchingReference(reference, expr)) {
70851
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70852
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
71006
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70853
71007
  }
70854
71008
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70855
71009
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -71002,9 +71156,6 @@ var ts;
71002
71156
  assumeTrue = !assumeTrue;
71003
71157
  }
71004
71158
  var valueType = getTypeOfExpression(value);
71005
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
71006
- return getUnionType([nullType, undefinedType]);
71007
- }
71008
71159
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
71009
71160
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
71010
71161
  return valueType;
@@ -71024,7 +71175,7 @@ var ts;
71024
71175
  valueType.flags & 65536 /* Null */ ?
71025
71176
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
71026
71177
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
71027
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
71178
+ return getIntersectionWithFacts(type, facts);
71028
71179
  }
71029
71180
  if (assumeTrue) {
71030
71181
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -71052,17 +71203,11 @@ var ts;
71052
71203
  if (type.flags & 1 /* Any */ && literal.text === "function") {
71053
71204
  return type;
71054
71205
  }
71055
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
71056
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
71057
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
71058
- // unknown type, and then narrows that to the non-primitive type.
71059
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
71060
- }
71061
71206
  var facts = assumeTrue ?
71062
71207
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71063
71208
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71064
71209
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71065
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71210
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71066
71211
  }
71067
71212
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71068
71213
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71111,10 +71256,10 @@ var ts;
71111
71256
  }
71112
71257
  function getImpliedTypeFromTypeofGuard(type, text) {
71113
71258
  switch (text) {
71259
+ case "object":
71260
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71114
71261
  case "function":
71115
71262
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
71116
- case "object":
71117
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71118
71263
  default:
71119
71264
  return typeofTypesByName.get(text);
71120
71265
  }
@@ -71125,22 +71270,27 @@ var ts;
71125
71270
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71126
71271
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71127
71272
  // filtering by type-facts.
71128
- function narrowUnionMemberByTypeof(candidate) {
71129
- return function (type) {
71130
- if (isTypeSubtypeOf(type, candidate)) {
71131
- return type;
71132
- }
71133
- if (isTypeSubtypeOf(candidate, type)) {
71134
- return candidate;
71273
+ function narrowTypeByImpliedType(type, candidate) {
71274
+ if (type.flags & 3 /* AnyOrUnknown */) {
71275
+ return candidate;
71276
+ }
71277
+ return mapType(type, function (t) {
71278
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71279
+ return t;
71135
71280
  }
71136
- if (type.flags & 465829888 /* Instantiable */) {
71137
- var constraint = getBaseConstraintOfType(type) || anyType;
71138
- if (isTypeSubtypeOf(candidate, constraint)) {
71139
- return getIntersectionType([type, candidate]);
71281
+ return mapType(candidate, function (c) {
71282
+ if (!areTypesComparable(t, c)) {
71283
+ return neverType;
71140
71284
  }
71141
- }
71142
- return type;
71143
- };
71285
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71286
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71287
+ }
71288
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71289
+ return c;
71290
+ }
71291
+ return getIntersectionType([t, c]);
71292
+ });
71293
+ });
71144
71294
  }
71145
71295
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71146
71296
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71199,7 +71349,7 @@ var ts;
71199
71349
  because it is caught in the first clause.
71200
71350
  */
71201
71351
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71202
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71352
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71203
71353
  }
71204
71354
  function isMatchingConstructorReference(expr) {
71205
71355
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71503,7 +71653,9 @@ var ts;
71503
71653
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71504
71654
  }
71505
71655
  function isGenericTypeWithUnionConstraint(type) {
71506
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71656
+ return type.flags & 2097152 /* Intersection */ ?
71657
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71658
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71507
71659
  }
71508
71660
  function isGenericTypeWithoutNullableConstraint(type) {
71509
71661
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71531,7 +71683,7 @@ var ts;
71531
71683
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71532
71684
  someType(type, isGenericTypeWithUnionConstraint) &&
71533
71685
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71534
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71686
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71535
71687
  }
71536
71688
  function isExportOrExportExpression(location) {
71537
71689
  return !!ts.findAncestor(location, function (n) {
@@ -75869,7 +76021,7 @@ var ts;
75869
76021
  if (spreadIndex >= 0) {
75870
76022
  // Create synthetic arguments from spreads of tuple types.
75871
76023
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75872
- var _loop_24 = function (i) {
76024
+ var _loop_25 = function (i) {
75873
76025
  var arg = args[i];
75874
76026
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75875
76027
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75886,7 +76038,7 @@ var ts;
75886
76038
  }
75887
76039
  };
75888
76040
  for (var i = spreadIndex; i < args.length; i++) {
75889
- _loop_24(i);
76041
+ _loop_25(i);
75890
76042
  }
75891
76043
  return effectiveArgs_1;
75892
76044
  }
@@ -76206,7 +76358,7 @@ var ts;
76206
76358
  var min_3 = Number.MAX_VALUE;
76207
76359
  var minIndex = 0;
76208
76360
  var i_1 = 0;
76209
- var _loop_25 = function (c) {
76361
+ var _loop_26 = function (c) {
76210
76362
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76211
76363
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76212
76364
  if (diags_2) {
@@ -76224,7 +76376,7 @@ var ts;
76224
76376
  };
76225
76377
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76226
76378
  var c = candidatesForArgumentError_1[_a];
76227
- _loop_25(c);
76379
+ _loop_26(c);
76228
76380
  }
76229
76381
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76230
76382
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76382,7 +76534,7 @@ var ts;
76382
76534
  }
76383
76535
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76384
76536
  var parameters = [];
76385
- var _loop_26 = function (i) {
76537
+ var _loop_27 = function (i) {
76386
76538
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76387
76539
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76388
76540
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76390,7 +76542,7 @@ var ts;
76390
76542
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76391
76543
  };
76392
76544
  for (var i = 0; i < maxNonRestParam; i++) {
76393
- _loop_26(i);
76545
+ _loop_27(i);
76394
76546
  }
76395
76547
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76396
76548
  var flags = 0 /* None */;
@@ -78627,11 +78779,6 @@ var ts;
78627
78779
  ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
78628
78780
  isTypeAssignableToKind(source, kind, strict);
78629
78781
  }
78630
- function anyTypesAssignableToKind(source, kind, strict) {
78631
- return source.flags & 1048576 /* Union */ ?
78632
- ts.some(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
78633
- isTypeAssignableToKind(source, kind, strict);
78634
- }
78635
78782
  function isConstEnumObjectType(type) {
78636
78783
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol);
78637
78784
  }
@@ -80452,7 +80599,7 @@ var ts;
80452
80599
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80453
80600
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80454
80601
  var indexSignatureMap_1 = new ts.Map();
80455
- var _loop_27 = function (declaration) {
80602
+ var _loop_28 = function (declaration) {
80456
80603
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80457
80604
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80458
80605
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80467,7 +80614,7 @@ var ts;
80467
80614
  };
80468
80615
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80469
80616
  var declaration = _a[_i];
80470
- _loop_27(declaration);
80617
+ _loop_28(declaration);
80471
80618
  }
80472
80619
  indexSignatureMap_1.forEach(function (entry) {
80473
80620
  if (entry.declarations.length > 1) {
@@ -82636,7 +82783,7 @@ var ts;
82636
82783
  // For a binding pattern, validate the initializer and exit
82637
82784
  if (ts.isBindingPattern(node.name)) {
82638
82785
  var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */;
82639
- var needCheckWidenedType = node.name.elements.length === 0;
82786
+ var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression));
82640
82787
  if (needCheckInitializer || needCheckWidenedType) {
82641
82788
  // Don't validate for-in initializer as it is already an error
82642
82789
  var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
@@ -82663,7 +82810,7 @@ var ts;
82663
82810
  }
82664
82811
  // For a commonjs `const x = require`, validate the alias and exit
82665
82812
  var symbol = getSymbolOfNode(node);
82666
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82813
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82667
82814
  checkAliasSymbol(node);
82668
82815
  return;
82669
82816
  }
@@ -83012,9 +83159,7 @@ var ts;
83012
83159
  }
83013
83160
  // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
83014
83161
  // in this case error about missing name is already reported - do not report extra one
83015
- // TypeFlags.Nullable must be explicitly checked for in rightType for this check for non-strict modes, where
83016
- // `getNonNullableTypeIfNeeded` is a noop (and the nullable types as any-ish).
83017
- if (!isTypeAny(rightType) && !(rightType.flags & 98304 /* Nullable */) && anyTypesAssignableToKind(getBaseConstraintOrType(rightType), (131068 /* Primitive */ | 131072 /* Never */) & ~98304 /* Nullable */)) {
83162
+ if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) {
83018
83163
  error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType));
83019
83164
  }
83020
83165
  checkSourceElement(node.statement);
@@ -83930,7 +84075,7 @@ var ts;
83930
84075
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83931
84076
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83932
84077
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83933
- var _loop_28 = function (info) {
84078
+ var _loop_29 = function (info) {
83934
84079
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83935
84080
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83936
84081
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83943,7 +84088,7 @@ var ts;
83943
84088
  };
83944
84089
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83945
84090
  var info = indexInfos_9[_i];
83946
- _loop_28(info);
84091
+ _loop_29(info);
83947
84092
  }
83948
84093
  }
83949
84094
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83951,7 +84096,7 @@ var ts;
83951
84096
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83952
84097
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83953
84098
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83954
- var _loop_29 = function (info) {
84099
+ var _loop_30 = function (info) {
83955
84100
  if (info === checkInfo)
83956
84101
  return "continue";
83957
84102
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83966,7 +84111,7 @@ var ts;
83966
84111
  };
83967
84112
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83968
84113
  var info = indexInfos_10[_i];
83969
- _loop_29(info);
84114
+ _loop_30(info);
83970
84115
  }
83971
84116
  }
83972
84117
  function checkTypeNameIsReserved(name, message) {
@@ -84285,7 +84430,7 @@ var ts;
84285
84430
  var baseTypes = baseTypeNode && getBaseTypes(type);
84286
84431
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84287
84432
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84288
- var _loop_30 = function (member) {
84433
+ var _loop_31 = function (member) {
84289
84434
  if (ts.hasAmbientModifier(member)) {
84290
84435
  return "continue";
84291
84436
  }
@@ -84302,7 +84447,7 @@ var ts;
84302
84447
  };
84303
84448
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84304
84449
  var member = _a[_i];
84305
- _loop_30(member);
84450
+ _loop_31(member);
84306
84451
  }
84307
84452
  }
84308
84453
  /**
@@ -84390,7 +84535,7 @@ var ts;
84390
84535
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84391
84536
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84392
84537
  var issuedMemberError = false;
84393
- var _loop_31 = function (member) {
84538
+ var _loop_32 = function (member) {
84394
84539
  if (ts.isStatic(member)) {
84395
84540
  return "continue";
84396
84541
  }
@@ -84409,7 +84554,7 @@ var ts;
84409
84554
  };
84410
84555
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84411
84556
  var member = _a[_i];
84412
- _loop_31(member);
84557
+ _loop_32(member);
84413
84558
  }
84414
84559
  if (!issuedMemberError) {
84415
84560
  // check again with diagnostics to generate a less-specific error
@@ -90069,9 +90214,7 @@ var ts;
90069
90214
  var ts;
90070
90215
  (function (ts) {
90071
90216
  function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
90072
- var _a = generatorOptions.extendedDiagnostics
90073
- ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
90074
- : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
90217
+ var _a = ts.performance.createTimerIf(!!generatorOptions.extendedDiagnostics, "Source Map", "beforeSourcemap", "afterSourcemap"), enter = _a.enter, exit = _a.exit;
90075
90218
  // Current source map file and its index in the sources list
90076
90219
  var rawSources = [];
90077
90220
  var sources = [];
@@ -122377,7 +122520,7 @@ var ts;
122377
122520
  });
122378
122521
  // Sort by paths closest to importing file Name directory
122379
122522
  var sortedPaths = [];
122380
- var _loop_32 = function (directory) {
122523
+ var _loop_33 = function (directory) {
122381
122524
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122382
122525
  var pathsInDirectory;
122383
122526
  allFileNames.forEach(function (_a, fileName) {
@@ -122401,7 +122544,7 @@ var ts;
122401
122544
  };
122402
122545
  var out_directory_1;
122403
122546
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122404
- var state_10 = _loop_32(directory);
122547
+ var state_10 = _loop_33(directory);
122405
122548
  directory = out_directory_1;
122406
122549
  if (state_10 === "break")
122407
122550
  break;
@@ -123848,6 +123991,7 @@ var ts;
123848
123991
  }
123849
123992
  function reloadFileNamesFromConfigFile() {
123850
123993
  writeLog("Reloading new file names and options");
123994
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123851
123995
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123852
123996
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123853
123997
  hasChangedConfigFileParsingErrors = true;
@@ -124346,6 +124490,7 @@ var ts;
124346
124490
  if (value) {
124347
124491
  return isParsedCommandLine(value) ? value : undefined;
124348
124492
  }
124493
+ ts.solutionPerformance.mark("beforeParseConfigFile");
124349
124494
  var diagnostic;
124350
124495
  var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
124351
124496
  var parsed;
@@ -124360,6 +124505,8 @@ var ts;
124360
124505
  parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
124361
124506
  }
124362
124507
  configFileCache.set(configFilePath, parsed || diagnostic);
124508
+ ts.solutionPerformance.mark("afterParseConfigFile");
124509
+ ts.solutionPerformance.measure("ParseConfigFile", "beforeParseConfigFile", "afterParseConfigFile");
124363
124510
  return parsed;
124364
124511
  }
124365
124512
  function resolveProjectName(state, name) {
@@ -124409,6 +124556,7 @@ var ts;
124409
124556
  return state.buildOrder || createStateBuildOrder(state);
124410
124557
  }
124411
124558
  function createStateBuildOrder(state) {
124559
+ ts.solutionPerformance.mark("beforeCreateBuildOrder");
124412
124560
  var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
124413
124561
  // Clear all to ResolvedConfigFilePaths cache to start fresh
124414
124562
  state.resolvedConfigFilePaths.clear();
@@ -124438,6 +124586,8 @@ var ts;
124438
124586
  ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124439
124587
  ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
124440
124588
  }
124589
+ ts.solutionPerformance.mark("afterCreateBuildOrder");
124590
+ ts.solutionPerformance.measure("CreateBuildOrder", "beforeCreateBuildOrder", "afterCreateBuildOrder");
124441
124591
  return state.buildOrder = buildOrder;
124442
124592
  }
124443
124593
  function getBuildOrderFor(state, project, onlyReferences) {
@@ -124558,6 +124708,7 @@ var ts;
124558
124708
  if (updateOutputFileStampsPending) {
124559
124709
  updateOutputTimestamps(state, config, projectPath);
124560
124710
  }
124711
+ ts.solutionPerformance.mark("timestampUpdated");
124561
124712
  return doneInvalidatedProject(state, projectPath);
124562
124713
  }
124563
124714
  };
@@ -124651,6 +124802,10 @@ var ts;
124651
124802
  };
124652
124803
  function done(cancellationToken, writeFile, customTransformers) {
124653
124804
  executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
124805
+ if (kind === InvalidatedProjectKind.Build)
124806
+ ts.solutionPerformance.mark("projectsBuilt");
124807
+ else
124808
+ ts.solutionPerformance.mark("bundlesUpdated");
124654
124809
  return doneInvalidatedProject(state, projectPath);
124655
124810
  }
124656
124811
  function withProgramOrUndefined(action) {
@@ -124740,6 +124895,7 @@ var ts;
124740
124895
  var anyDtsChanged = false;
124741
124896
  var emitterDiagnostics = ts.createDiagnosticCollection();
124742
124897
  var emittedOutputs = new ts.Map();
124898
+ ts.solutionPerformance.mark("beforeOutputFilesWrite");
124743
124899
  outputFiles.forEach(function (_a) {
124744
124900
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124745
124901
  var priorChangeTime;
@@ -124759,6 +124915,8 @@ var ts;
124759
124915
  newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
124760
124916
  }
124761
124917
  });
124918
+ ts.solutionPerformance.mark("afterOutputFilesWrite");
124919
+ ts.solutionPerformance.measure("OutputFilesWrite", "beforeOutputFilesWrite", "afterOutputFilesWrite");
124762
124920
  finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime,
124763
124921
  /*newestDeclarationFileContentChangedTimeIsMaximumDate*/ anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
124764
124922
  return emitResult;
@@ -124888,6 +125046,13 @@ var ts;
124888
125046
  !ts.isIncrementalCompilation(config.options);
124889
125047
  }
124890
125048
  function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
125049
+ ts.solutionPerformance.mark("beforeGetNextInvalidatedProjectCreateInfo");
125050
+ var result = getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue);
125051
+ ts.solutionPerformance.mark("afterGetNextInvalidatedProjectCreateInfo");
125052
+ ts.solutionPerformance.measure("GetNextInvalidatedProjectCreateInfo", "beforeGetNextInvalidatedProjectCreateInfo", "afterGetNextInvalidatedProjectCreateInfo");
125053
+ return result;
125054
+ }
125055
+ function getNextInvalidatedProjectCreateInfoWorker(state, buildOrder, reportQueue) {
124891
125056
  if (!state.projectPendingBuild.size)
124892
125057
  return undefined;
124893
125058
  if (isCircularBuildOrder(buildOrder))
@@ -124987,9 +125152,7 @@ var ts;
124987
125152
  }
124988
125153
  function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124989
125154
  var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124990
- if (!info)
124991
- return info;
124992
- return createInvalidatedProjectWithInfo(state, info, buildOrder);
125155
+ return info && createInvalidatedProjectWithInfo(state, info, buildOrder);
124993
125156
  }
124994
125157
  function listEmittedFile(_a, proj, file) {
124995
125158
  var write = _a.write;
@@ -124997,14 +125160,17 @@ var ts;
124997
125160
  write("TSFILE: " + file);
124998
125161
  }
124999
125162
  }
125000
- function getOldProgram(_a, proj, parsed) {
125001
- var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
125002
- if (options.force)
125163
+ function getOldProgram(state, proj, parsed) {
125164
+ if (state.options.force)
125003
125165
  return undefined;
125004
- var value = builderPrograms.get(proj);
125166
+ var value = state.builderPrograms.get(proj);
125005
125167
  if (value)
125006
125168
  return value;
125007
- return ts.readBuilderProgram(parsed.options, compilerHost);
125169
+ ts.solutionPerformance.mark("beforeReadBuilderProgram");
125170
+ var program = ts.readBuilderProgram(parsed.options, state.compilerHost);
125171
+ ts.solutionPerformance.mark("afterReadBuilderProgram");
125172
+ ts.solutionPerformance.measure("ReadBuilderProgram", "beforeReadBuilderProgram", "afterReadBuilderProgram");
125173
+ return program;
125008
125174
  }
125009
125175
  function afterProgramDone(state, program, config) {
125010
125176
  if (program) {
@@ -125203,7 +125369,10 @@ var ts;
125203
125369
  state.buildInfoChecked.set(resolvedPath, true);
125204
125370
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
125205
125371
  if (buildInfoPath) {
125372
+ ts.solutionPerformance.mark("beforeBuildInfoRead");
125206
125373
  var value = state.readFileWithCache(buildInfoPath);
125374
+ ts.solutionPerformance.mark("afterBuildInfoRead");
125375
+ ts.solutionPerformance.measure("BuildInfoRead", "beforeBuildInfoRead", "afterBuildInfoRead");
125207
125376
  var buildInfo = value && ts.getBuildInfo(value);
125208
125377
  if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
125209
125378
  return {
@@ -125239,13 +125408,17 @@ var ts;
125239
125408
  if (prior !== undefined) {
125240
125409
  return prior;
125241
125410
  }
125411
+ ts.solutionPerformance.mark("beforeGetUpToDateStatus");
125242
125412
  var actual = getUpToDateStatusWorker(state, project, resolvedPath);
125413
+ ts.solutionPerformance.mark("afterGetUpToDateStatus");
125414
+ ts.solutionPerformance.measure("GetUpToDateStatus", "beforeGetUpToDateStatus", "afterGetUpToDateStatus");
125243
125415
  state.projectStatus.set(resolvedPath, actual);
125244
125416
  return actual;
125245
125417
  }
125246
125418
  function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
125247
125419
  if (proj.options.noEmit)
125248
125420
  return priorNewestUpdateTime;
125421
+ ts.solutionPerformance.mark("beforeUpdateOutputTimestamps");
125249
125422
  var host = state.host;
125250
125423
  var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
125251
125424
  if (!skipOutputs || outputs.length !== skipOutputs.size) {
@@ -125266,6 +125439,8 @@ var ts;
125266
125439
  host.setModifiedTime(file, now);
125267
125440
  }
125268
125441
  }
125442
+ ts.solutionPerformance.mark("afterUpdateOutputTimestamps");
125443
+ ts.solutionPerformance.measure("UpdateOutputTimestamps", "beforeUpdateOutputTimestamps", "afterUpdateOutputTimestamps");
125269
125444
  return priorNewestUpdateTime;
125270
125445
  }
125271
125446
  function updateOutputTimestamps(state, proj, resolvedPath) {
@@ -125344,6 +125519,13 @@ var ts;
125344
125519
  }
125345
125520
  }
125346
125521
  function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125522
+ ts.solutionPerformance.mark("beforeBuild");
125523
+ var result = buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences);
125524
+ ts.solutionPerformance.mark("afterBuild");
125525
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125526
+ return result;
125527
+ }
125528
+ function buildWorker(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) {
125347
125529
  var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125348
125530
  if (!buildOrder)
125349
125531
  return ts.ExitStatus.InvalidProject_OutputsSkipped;
@@ -125355,7 +125537,10 @@ var ts;
125355
125537
  if (!invalidatedProject)
125356
125538
  break;
125357
125539
  reportQueue = false;
125540
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125358
125541
  invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project));
125542
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125543
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125359
125544
  if (!state.diagnostics.has(invalidatedProject.projectPath))
125360
125545
  successfulProjects++;
125361
125546
  }
@@ -125444,6 +125629,14 @@ var ts;
125444
125629
  state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125445
125630
  }
125446
125631
  function buildNextInvalidatedProject(state, changeDetected) {
125632
+ ts.solutionPerformance.mark("beforeBuild");
125633
+ var buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
125634
+ ts.solutionPerformance.mark("afterBuild");
125635
+ ts.solutionPerformance.measure("Build", "beforeBuild", "afterBuild");
125636
+ if (buildOrder)
125637
+ reportErrorSummary(state, buildOrder);
125638
+ }
125639
+ function buildNextInvalidatedProjectWorker(state, changeDetected) {
125447
125640
  state.timerToBuildInvalidatedProject = undefined;
125448
125641
  if (state.reportFileChangeDetected) {
125449
125642
  state.reportFileChangeDetected = false;
@@ -125454,7 +125647,10 @@ var ts;
125454
125647
  var buildOrder = getBuildOrder(state);
125455
125648
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125456
125649
  if (invalidatedProject) {
125650
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125457
125651
  invalidatedProject.done();
125652
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125653
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125458
125654
  projectsBuilt++;
125459
125655
  while (state.projectPendingBuild.size) {
125460
125656
  // If already scheduled, skip
@@ -125470,13 +125666,16 @@ var ts;
125470
125666
  return;
125471
125667
  }
125472
125668
  var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125669
+ ts.solutionPerformance.mark("beforeInvalidatedProjectBuild");
125473
125670
  project.done();
125671
+ ts.solutionPerformance.mark("afterInvalidatedProjectBuild");
125672
+ ts.solutionPerformance.measure("InvalidatedProjectBuild", "beforeInvalidatedProjectBuild", "afterInvalidatedProjectBuild");
125474
125673
  if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125475
125674
  projectsBuilt++;
125476
125675
  }
125477
125676
  }
125478
125677
  disableCache(state);
125479
- reportErrorSummary(state, buildOrder);
125678
+ return buildOrder;
125480
125679
  }
125481
125680
  function watchConfigFile(state, resolved, resolvedPath, parsed) {
125482
125681
  if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
@@ -125533,6 +125732,7 @@ var ts;
125533
125732
  function startWatching(state, buildOrder) {
125534
125733
  if (!state.watchAllProjectsPending)
125535
125734
  return;
125735
+ ts.solutionPerformance.mark("beforeStartWatching");
125536
125736
  state.watchAllProjectsPending = false;
125537
125737
  for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
125538
125738
  var resolved = _a[_i];
@@ -125550,6 +125750,8 @@ var ts;
125550
125750
  watchPackageJsonFiles(state, resolved, resolvedPath, cfg);
125551
125751
  }
125552
125752
  }
125753
+ ts.solutionPerformance.mark("afterStartWatching");
125754
+ ts.solutionPerformance.measure("StartWatching", "beforeStartWatching", "afterStartWatching");
125553
125755
  }
125554
125756
  function stopWatching(state) {
125555
125757
  ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
@@ -136945,7 +137147,7 @@ var ts;
136945
137147
  ts.Debug.assert(parent.name === node);
136946
137148
  return true;
136947
137149
  case 203 /* BindingElement */:
136948
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
137150
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136949
137151
  default:
136950
137152
  return false;
136951
137153
  }
@@ -138411,7 +138613,7 @@ var ts;
138411
138613
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138412
138614
  if (ts.isInJSFile(referenceLocation)
138413
138615
  && referenceLocation.parent.kind === 203 /* BindingElement */
138414
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138616
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138415
138617
  referenceSymbol = referenceLocation.parent.symbol;
138416
138618
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138417
138619
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -144583,6 +144785,10 @@ var ts;
144583
144785
  }
144584
144786
  var typeDisplayString = printTypeInSingleLine(declarationType);
144585
144787
  if (typeDisplayString) {
144788
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
144789
+ if (isVariableNameMatchesType) {
144790
+ return;
144791
+ }
144586
144792
  addTypeHints(typeDisplayString, decl.name.end);
144587
144793
  }
144588
144794
  }
@@ -147783,11 +147989,9 @@ var ts;
147783
147989
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147784
147990
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147785
147991
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147786
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147787
- if (startLine !== commaTokenLine) {
147788
- formattingScanner.advance();
147789
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147790
- }
147992
+ // consume the comma
147993
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147994
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147791
147995
  }
147792
147996
  // consume the list end token only if it is still belong to the parent
147793
147997
  // there might be the case when current token matches end token but does not considered as one