typescript 4.8.0-dev.20220527 → 4.8.0-dev.20220528

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220527";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220528";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5101,6 +5101,11 @@ var ts;
5101
5101
  // Flags that require TypeFlags.Union
5102
5102
  /* @internal */
5103
5103
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5104
+ /* @internal */
5105
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5106
+ /* @internal */
5107
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5108
+ /* @internal */
5104
5109
  // Flags that require TypeFlags.Intersection
5105
5110
  /* @internal */
5106
5111
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -8414,6 +8419,7 @@ var ts;
8414
8419
  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),
8415
8420
  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."),
8416
8421
  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."),
8422
+ 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."),
8417
8423
  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."),
8418
8424
  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."),
8419
8425
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -48547,6 +48553,7 @@ var ts;
48547
48553
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48548
48554
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48549
48555
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48556
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48550
48557
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48551
48558
  emptyGenericType.instantiations = new ts.Map();
48552
48559
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -58717,7 +58724,7 @@ var ts;
58717
58724
  }
58718
58725
  }
58719
58726
  }
58720
- else if (t.flags & 469892092 /* DisjointDomains */) {
58727
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58721
58728
  hasDisjointDomainType = true;
58722
58729
  }
58723
58730
  }
@@ -58729,7 +58736,7 @@ var ts;
58729
58736
  // intersection operation to reduce the union constraints.
58730
58737
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58731
58738
  var t = types_6[_a];
58732
- if (t.flags & 469892092 /* DisjointDomains */) {
58739
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58733
58740
  constraints = ts.append(constraints, t);
58734
58741
  }
58735
58742
  }
@@ -61278,7 +61285,7 @@ var ts;
61278
61285
  }
61279
61286
  return includes;
61280
61287
  }
61281
- function removeRedundantPrimitiveTypes(types, includes) {
61288
+ function removeRedundantSupertypes(types, includes) {
61282
61289
  var i = types.length;
61283
61290
  while (i > 0) {
61284
61291
  i--;
@@ -61286,7 +61293,9 @@ var ts;
61286
61293
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61287
61294
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61288
61295
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61289
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61296
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61297
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61298
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61290
61299
  if (remove) {
61291
61300
  ts.orderedRemoveItemAt(types, i);
61292
61301
  }
@@ -61408,7 +61417,7 @@ var ts;
61408
61417
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61409
61418
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61410
61419
  // for intersections of types with signatures can be deterministic.
61411
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61420
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61412
61421
  var typeMembershipMap = new ts.Map();
61413
61422
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61414
61423
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61445,11 +61454,11 @@ var ts;
61445
61454
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61446
61455
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61447
61456
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61448
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61449
- removeRedundantPrimitiveTypes(typeSet, includes);
61450
- }
61451
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61452
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61457
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61458
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61459
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61460
+ if (!noSupertypeReduction)
61461
+ removeRedundantSupertypes(typeSet, includes);
61453
61462
  }
61454
61463
  if (includes & 262144 /* IncludesMissingType */) {
61455
61464
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61488,8 +61497,9 @@ var ts;
61488
61497
  }
61489
61498
  var constituents = getCrossProductIntersections(typeSet);
61490
61499
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61491
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61492
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61500
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61501
+ // the denormalized origin has fewer constituents than the union itself.
61502
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61493
61503
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61494
61504
  }
61495
61505
  }
@@ -61532,11 +61542,21 @@ var ts;
61532
61542
  }
61533
61543
  return intersections;
61534
61544
  }
61545
+ function getConstituentCount(type) {
61546
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61547
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61548
+ getConstituentCountOfTypes(type.types);
61549
+ }
61550
+ function getConstituentCountOfTypes(types) {
61551
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61552
+ }
61535
61553
  function getTypeFromIntersectionTypeNode(node) {
61536
61554
  var links = getNodeLinks(node);
61537
61555
  if (!links.resolvedType) {
61538
61556
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61539
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61557
+ var types = ts.map(node.types, getTypeFromTypeNode);
61558
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61559
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61540
61560
  }
61541
61561
  return links.resolvedType;
61542
61562
  }
@@ -64322,6 +64342,17 @@ var ts;
64322
64342
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64323
64343
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64324
64344
  }
64345
+ function isUnknownLikeUnionType(type) {
64346
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64347
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64348
+ var types = type.types;
64349
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64350
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64351
+ }
64352
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64353
+ }
64354
+ return false;
64355
+ }
64325
64356
  function isStringIndexSignatureOnlyType(type) {
64326
64357
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64327
64358
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64401,7 +64432,7 @@ var ts;
64401
64432
  return true;
64402
64433
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64403
64434
  return true;
64404
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64435
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64405
64436
  return true;
64406
64437
  if (relation === assignableRelation || relation === comparableRelation) {
64407
64438
  if (s & 1 /* Any */)
@@ -64411,6 +64442,9 @@ var ts;
64411
64442
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64412
64443
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64413
64444
  return true;
64445
+ // Anything is assignable to a union containing undefined, null, and {}
64446
+ if (isUnknownLikeUnionType(target))
64447
+ return true;
64414
64448
  }
64415
64449
  return false;
64416
64450
  }
@@ -64453,16 +64487,27 @@ var ts;
64453
64487
  function getNormalizedType(type, writing) {
64454
64488
  while (true) {
64455
64489
  var t = isFreshLiteralType(type) ? type.regularType :
64456
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64457
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64490
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64491
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64458
64492
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64459
64493
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64460
64494
  type;
64461
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64462
64495
  if (t === type)
64463
- break;
64496
+ return t;
64464
64497
  type = t;
64465
64498
  }
64499
+ }
64500
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64501
+ var reduced = getReducedType(type);
64502
+ if (reduced !== type) {
64503
+ return reduced;
64504
+ }
64505
+ if (type.flags & 2097152 /* Intersection */) {
64506
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64507
+ if (normalizedTypes !== type.types) {
64508
+ return getIntersectionType(normalizedTypes);
64509
+ }
64510
+ }
64466
64511
  return type;
64467
64512
  }
64468
64513
  /**
@@ -64909,6 +64954,7 @@ var ts;
64909
64954
  return 0 /* False */;
64910
64955
  }
64911
64956
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64957
+ var _a, _b;
64912
64958
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
64913
64959
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
64914
64960
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -64949,6 +64995,9 @@ var ts;
64949
64995
  return;
64950
64996
  }
64951
64997
  reportRelationError(headMessage, source, target);
64998
+ 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 */))) {
64999
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65000
+ }
64952
65001
  }
64953
65002
  function traceUnionsOrIntersectionsTooLarge(source, target) {
64954
65003
  if (!ts.tracing) {
@@ -65735,13 +65784,6 @@ var ts;
65735
65784
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65736
65785
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65737
65786
  var constraint = getConstraintOfType(source) || unknownType;
65738
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65739
- // A type variable with no constraint is not related to the non-primitive object type.
65740
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65741
- resetErrorInfo(saveErrorInfo);
65742
- return result;
65743
- }
65744
- }
65745
65787
  // 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
65746
65788
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65747
65789
  resetErrorInfo(saveErrorInfo);
@@ -67215,9 +67257,11 @@ var ts;
67215
67257
  return getSupertypeOrUnion(types);
67216
67258
  }
67217
67259
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67218
- return primaryTypes.length ?
67219
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67220
- getUnionType(types, 2 /* Subtype */);
67260
+ if (primaryTypes.length) {
67261
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67262
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67263
+ }
67264
+ return getUnionType(types, 2 /* Subtype */);
67221
67265
  }
67222
67266
  // Return the leftmost type for which no type to the right is a subtype.
67223
67267
  function getCommonSubtype(types) {
@@ -67416,12 +67460,13 @@ var ts;
67416
67460
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67417
67461
  // no flags for all other types (including non-falsy literal types).
67418
67462
  function getFalsyFlags(type) {
67419
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67420
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67421
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67422
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67423
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67424
- type.flags & 117724 /* PossiblyFalsy */;
67463
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67464
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67465
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67466
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67467
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67468
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67469
+ t.flags & 117724 /* PossiblyFalsy */;
67425
67470
  }
67426
67471
  function removeDefinitelyFalsyTypes(type) {
67427
67472
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67461,20 +67506,22 @@ var ts;
67461
67506
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67462
67507
  }
67463
67508
  function getGlobalNonNullableTypeInstantiation(type) {
67464
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67465
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67466
- // that isn't eliminated by a NonNullable<T> instantiation.
67467
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67468
67509
  if (!deferredGlobalNonNullableTypeAlias) {
67469
67510
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67470
67511
  }
67471
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67472
67512
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67473
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67474
- reducedType;
67513
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67514
+ getIntersectionType([type, emptyObjectType]);
67475
67515
  }
67476
67516
  function getNonNullableType(type) {
67477
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67517
+ if (strictNullChecks) {
67518
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67519
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67520
+ // that isn't eliminated by a NonNullable<T> instantiation.
67521
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67522
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67523
+ }
67524
+ return type;
67478
67525
  }
67479
67526
  function addOptionalTypeMarker(type) {
67480
67527
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68155,13 +68202,40 @@ var ts;
68155
68202
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68156
68203
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68157
68204
  }
68158
- function isValidBigIntString(s) {
68205
+ /**
68206
+ * Tests whether the provided string can be parsed as a number.
68207
+ * @param s The string to test.
68208
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68209
+ */
68210
+ function isValidNumberString(s, roundTripOnly) {
68211
+ if (s === "")
68212
+ return false;
68213
+ var n = +s;
68214
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68215
+ }
68216
+ /**
68217
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68218
+ */
68219
+ function parseBigIntLiteralType(text) {
68220
+ var negative = text.startsWith("-");
68221
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68222
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68223
+ }
68224
+ /**
68225
+ * Tests whether the provided string can be parsed as a bigint.
68226
+ * @param s The string to test.
68227
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68228
+ */
68229
+ function isValidBigIntString(s, roundTripOnly) {
68230
+ if (s === "")
68231
+ return false;
68159
68232
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68160
68233
  var success = true;
68161
68234
  scanner.setOnError(function () { return success = false; });
68162
68235
  scanner.setText(s + "n");
68163
68236
  var result = scanner.scan();
68164
- if (result === 40 /* MinusToken */) {
68237
+ var negative = result === 40 /* MinusToken */;
68238
+ if (negative) {
68165
68239
  result = scanner.scan();
68166
68240
  }
68167
68241
  var flags = scanner.getTokenFlags();
@@ -68170,7 +68244,8 @@ var ts;
68170
68244
  // * a bigint can be scanned, and that when it is scanned, it is
68171
68245
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68172
68246
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68173
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68247
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68248
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68174
68249
  }
68175
68250
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68176
68251
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68178,8 +68253,8 @@ var ts;
68178
68253
  }
68179
68254
  if (source.flags & 128 /* StringLiteral */) {
68180
68255
  var value = source.value;
68181
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68182
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68256
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68257
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68183
68258
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68184
68259
  }
68185
68260
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68752,8 +68827,57 @@ var ts;
68752
68827
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68753
68828
  // succeed. That would be a pointless and confusing outcome.
68754
68829
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68830
+ var _loop_23 = function (i) {
68831
+ var source_1 = matches ? matches[i] : neverType;
68832
+ var target_3 = types[i];
68833
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68834
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68835
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68836
+ var inferenceContext = getInferenceInfoForType(target_3);
68837
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68838
+ if (constraint && !isTypeAny(constraint)) {
68839
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68840
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68841
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68842
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68843
+ var str_1 = source_1.value;
68844
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68845
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68846
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68847
+ }
68848
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68849
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68850
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68851
+ }
68852
+ // for each type in the constraint, find the highest priority matching type
68853
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68854
+ return !(right.flags & allTypeFlags_1) ? left :
68855
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68856
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68857
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68858
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68859
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68860
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68861
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68862
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68863
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68864
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68865
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68866
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68867
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68868
+ left;
68869
+ }, neverType);
68870
+ if (!(matchingType.flags & 131072 /* Never */)) {
68871
+ inferFromTypes(matchingType, target_3);
68872
+ return "continue";
68873
+ }
68874
+ }
68875
+ }
68876
+ }
68877
+ inferFromTypes(source_1, target_3);
68878
+ };
68755
68879
  for (var i = 0; i < types.length; i++) {
68756
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68880
+ _loop_23(i);
68757
68881
  }
68758
68882
  }
68759
68883
  }
@@ -69271,7 +69395,7 @@ var ts;
69271
69395
  function mapTypesByKeyProperty(types, name) {
69272
69396
  var map = new ts.Map();
69273
69397
  var count = 0;
69274
- var _loop_23 = function (type) {
69398
+ var _loop_24 = function (type) {
69275
69399
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69276
69400
  var discriminant = getTypeOfPropertyOfType(type, name);
69277
69401
  if (discriminant) {
@@ -69297,7 +69421,7 @@ var ts;
69297
69421
  };
69298
69422
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69299
69423
  var type = types_16[_i];
69300
- var state_9 = _loop_23(type);
69424
+ var state_9 = _loop_24(type);
69301
69425
  if (typeof state_9 === "object")
69302
69426
  return state_9.value;
69303
69427
  }
@@ -69505,6 +69629,24 @@ var ts;
69505
69629
  function getTypeWithFacts(type, include) {
69506
69630
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69507
69631
  }
69632
+ function getIntersectionWithFacts(type, facts) {
69633
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69634
+ if (strictNullChecks) {
69635
+ switch (facts) {
69636
+ case 524288 /* NEUndefined */:
69637
+ 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; });
69638
+ case 1048576 /* NENull */:
69639
+ 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; });
69640
+ case 2097152 /* NEUndefinedOrNull */:
69641
+ case 4194304 /* Truthy */:
69642
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69643
+ }
69644
+ }
69645
+ return reduced;
69646
+ }
69647
+ function recombineUnknownType(type) {
69648
+ return type === unknownUnionType ? unknownType : type;
69649
+ }
69508
69650
  function getTypeWithDefault(type, defaultExpression) {
69509
69651
  return defaultExpression ?
69510
69652
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70562,7 +70704,7 @@ var ts;
70562
70704
  if (isEvolvingArrayTypeList(types)) {
70563
70705
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70564
70706
  }
70565
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70707
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70566
70708
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70567
70709
  return declaredType;
70568
70710
  }
@@ -70664,8 +70806,7 @@ var ts;
70664
70806
  }
70665
70807
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70666
70808
  if (isMatchingReference(reference, expr)) {
70667
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70668
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70809
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70669
70810
  }
70670
70811
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70671
70812
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -70818,9 +70959,6 @@ var ts;
70818
70959
  assumeTrue = !assumeTrue;
70819
70960
  }
70820
70961
  var valueType = getTypeOfExpression(value);
70821
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
70822
- return getUnionType([nullType, undefinedType]);
70823
- }
70824
70962
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
70825
70963
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
70826
70964
  return valueType;
@@ -70840,7 +70978,7 @@ var ts;
70840
70978
  valueType.flags & 65536 /* Null */ ?
70841
70979
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
70842
70980
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
70843
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
70981
+ return getIntersectionWithFacts(type, facts);
70844
70982
  }
70845
70983
  if (assumeTrue) {
70846
70984
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -70868,17 +71006,11 @@ var ts;
70868
71006
  if (type.flags & 1 /* Any */ && literal.text === "function") {
70869
71007
  return type;
70870
71008
  }
70871
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
70872
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
70873
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
70874
- // unknown type, and then narrows that to the non-primitive type.
70875
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
70876
- }
70877
71009
  var facts = assumeTrue ?
70878
71010
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
70879
71011
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
70880
71012
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
70881
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71013
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
70882
71014
  }
70883
71015
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
70884
71016
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -70927,10 +71059,10 @@ var ts;
70927
71059
  }
70928
71060
  function getImpliedTypeFromTypeofGuard(type, text) {
70929
71061
  switch (text) {
71062
+ case "object":
71063
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
70930
71064
  case "function":
70931
71065
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
70932
- case "object":
70933
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
70934
71066
  default:
70935
71067
  return typeofTypesByName.get(text);
70936
71068
  }
@@ -70941,22 +71073,27 @@ var ts;
70941
71073
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
70942
71074
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
70943
71075
  // filtering by type-facts.
70944
- function narrowUnionMemberByTypeof(candidate) {
70945
- return function (type) {
70946
- if (isTypeSubtypeOf(type, candidate)) {
70947
- return type;
70948
- }
70949
- if (isTypeSubtypeOf(candidate, type)) {
70950
- return candidate;
71076
+ function narrowTypeByImpliedType(type, candidate) {
71077
+ if (type.flags & 3 /* AnyOrUnknown */) {
71078
+ return candidate;
71079
+ }
71080
+ return mapType(type, function (t) {
71081
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71082
+ return t;
70951
71083
  }
70952
- if (type.flags & 465829888 /* Instantiable */) {
70953
- var constraint = getBaseConstraintOfType(type) || anyType;
70954
- if (isTypeSubtypeOf(candidate, constraint)) {
70955
- return getIntersectionType([type, candidate]);
71084
+ return mapType(candidate, function (c) {
71085
+ if (!areTypesComparable(t, c)) {
71086
+ return neverType;
70956
71087
  }
70957
- }
70958
- return type;
70959
- };
71088
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71089
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71090
+ }
71091
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71092
+ return c;
71093
+ }
71094
+ return getIntersectionType([t, c]);
71095
+ });
71096
+ });
70960
71097
  }
70961
71098
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
70962
71099
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71015,7 +71152,7 @@ var ts;
71015
71152
  because it is caught in the first clause.
71016
71153
  */
71017
71154
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71018
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71155
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71019
71156
  }
71020
71157
  function isMatchingConstructorReference(expr) {
71021
71158
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71319,7 +71456,9 @@ var ts;
71319
71456
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71320
71457
  }
71321
71458
  function isGenericTypeWithUnionConstraint(type) {
71322
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71459
+ return type.flags & 2097152 /* Intersection */ ?
71460
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71461
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71323
71462
  }
71324
71463
  function isGenericTypeWithoutNullableConstraint(type) {
71325
71464
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71347,7 +71486,7 @@ var ts;
71347
71486
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71348
71487
  someType(type, isGenericTypeWithUnionConstraint) &&
71349
71488
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71350
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71489
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71351
71490
  }
71352
71491
  function isExportOrExportExpression(location) {
71353
71492
  return !!ts.findAncestor(location, function (n) {
@@ -75685,7 +75824,7 @@ var ts;
75685
75824
  if (spreadIndex >= 0) {
75686
75825
  // Create synthetic arguments from spreads of tuple types.
75687
75826
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75688
- var _loop_24 = function (i) {
75827
+ var _loop_25 = function (i) {
75689
75828
  var arg = args[i];
75690
75829
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75691
75830
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75702,7 +75841,7 @@ var ts;
75702
75841
  }
75703
75842
  };
75704
75843
  for (var i = spreadIndex; i < args.length; i++) {
75705
- _loop_24(i);
75844
+ _loop_25(i);
75706
75845
  }
75707
75846
  return effectiveArgs_1;
75708
75847
  }
@@ -76022,7 +76161,7 @@ var ts;
76022
76161
  var min_3 = Number.MAX_VALUE;
76023
76162
  var minIndex = 0;
76024
76163
  var i_1 = 0;
76025
- var _loop_25 = function (c) {
76164
+ var _loop_26 = function (c) {
76026
76165
  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)); };
76027
76166
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76028
76167
  if (diags_2) {
@@ -76040,7 +76179,7 @@ var ts;
76040
76179
  };
76041
76180
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76042
76181
  var c = candidatesForArgumentError_1[_a];
76043
- _loop_25(c);
76182
+ _loop_26(c);
76044
76183
  }
76045
76184
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76046
76185
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76198,7 +76337,7 @@ var ts;
76198
76337
  }
76199
76338
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76200
76339
  var parameters = [];
76201
- var _loop_26 = function (i) {
76340
+ var _loop_27 = function (i) {
76202
76341
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76203
76342
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76204
76343
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76206,7 +76345,7 @@ var ts;
76206
76345
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76207
76346
  };
76208
76347
  for (var i = 0; i < maxNonRestParam; i++) {
76209
- _loop_26(i);
76348
+ _loop_27(i);
76210
76349
  }
76211
76350
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76212
76351
  var flags = 0 /* None */;
@@ -80263,7 +80402,7 @@ var ts;
80263
80402
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80264
80403
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80265
80404
  var indexSignatureMap_1 = new ts.Map();
80266
- var _loop_27 = function (declaration) {
80405
+ var _loop_28 = function (declaration) {
80267
80406
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80268
80407
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80269
80408
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80278,7 +80417,7 @@ var ts;
80278
80417
  };
80279
80418
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80280
80419
  var declaration = _a[_i];
80281
- _loop_27(declaration);
80420
+ _loop_28(declaration);
80282
80421
  }
80283
80422
  indexSignatureMap_1.forEach(function (entry) {
80284
80423
  if (entry.declarations.length > 1) {
@@ -83739,7 +83878,7 @@ var ts;
83739
83878
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83740
83879
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83741
83880
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83742
- var _loop_28 = function (info) {
83881
+ var _loop_29 = function (info) {
83743
83882
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83744
83883
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83745
83884
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83752,7 +83891,7 @@ var ts;
83752
83891
  };
83753
83892
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83754
83893
  var info = indexInfos_9[_i];
83755
- _loop_28(info);
83894
+ _loop_29(info);
83756
83895
  }
83757
83896
  }
83758
83897
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83760,7 +83899,7 @@ var ts;
83760
83899
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83761
83900
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83762
83901
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83763
- var _loop_29 = function (info) {
83902
+ var _loop_30 = function (info) {
83764
83903
  if (info === checkInfo)
83765
83904
  return "continue";
83766
83905
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83775,7 +83914,7 @@ var ts;
83775
83914
  };
83776
83915
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83777
83916
  var info = indexInfos_10[_i];
83778
- _loop_29(info);
83917
+ _loop_30(info);
83779
83918
  }
83780
83919
  }
83781
83920
  function checkTypeNameIsReserved(name, message) {
@@ -84094,7 +84233,7 @@ var ts;
84094
84233
  var baseTypes = baseTypeNode && getBaseTypes(type);
84095
84234
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84096
84235
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84097
- var _loop_30 = function (member) {
84236
+ var _loop_31 = function (member) {
84098
84237
  if (ts.hasAmbientModifier(member)) {
84099
84238
  return "continue";
84100
84239
  }
@@ -84111,7 +84250,7 @@ var ts;
84111
84250
  };
84112
84251
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84113
84252
  var member = _a[_i];
84114
- _loop_30(member);
84253
+ _loop_31(member);
84115
84254
  }
84116
84255
  }
84117
84256
  /**
@@ -84199,7 +84338,7 @@ var ts;
84199
84338
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84200
84339
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84201
84340
  var issuedMemberError = false;
84202
- var _loop_31 = function (member) {
84341
+ var _loop_32 = function (member) {
84203
84342
  if (ts.isStatic(member)) {
84204
84343
  return "continue";
84205
84344
  }
@@ -84218,7 +84357,7 @@ var ts;
84218
84357
  };
84219
84358
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84220
84359
  var member = _a[_i];
84221
- _loop_31(member);
84360
+ _loop_32(member);
84222
84361
  }
84223
84362
  if (!issuedMemberError) {
84224
84363
  // check again with diagnostics to generate a less-specific error
@@ -122186,7 +122325,7 @@ var ts;
122186
122325
  });
122187
122326
  // Sort by paths closest to importing file Name directory
122188
122327
  var sortedPaths = [];
122189
- var _loop_32 = function (directory) {
122328
+ var _loop_33 = function (directory) {
122190
122329
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122191
122330
  var pathsInDirectory;
122192
122331
  allFileNames.forEach(function (_a, fileName) {
@@ -122210,7 +122349,7 @@ var ts;
122210
122349
  };
122211
122350
  var out_directory_1;
122212
122351
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122213
- var state_10 = _loop_32(directory);
122352
+ var state_10 = _loop_33(directory);
122214
122353
  directory = out_directory_1;
122215
122354
  if (state_10 === "break")
122216
122355
  break;
@@ -147180,11 +147319,9 @@ var ts;
147180
147319
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147181
147320
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147182
147321
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147183
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147184
- if (startLine !== commaTokenLine) {
147185
- formattingScanner.advance();
147186
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147187
- }
147322
+ // consume the comma
147323
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147324
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147188
147325
  }
147189
147326
  // consume the list end token only if it is still belong to the parent
147190
147327
  // there might be the case when current token matches end token but does not considered as one
@@ -174890,6 +175027,7 @@ var ts;
174890
175027
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174891
175028
  }
174892
175029
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
175030
+ var _a;
174893
175031
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174894
175032
  /*isForRename*/ false, function (project, position) {
174895
175033
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -174909,7 +175047,7 @@ var ts;
174909
175047
  // have started the other project searches from related symbols. Propagate the
174910
175048
  // correct results to all other projects.
174911
175049
  var defaultProjectResults = perProjectResults.get(defaultProject);
174912
- if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175050
+ if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
174913
175051
  // Clear all isDefinition properties
174914
175052
  perProjectResults.forEach(function (projectResults) {
174915
175053
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -174926,8 +175064,8 @@ var ts;
174926
175064
  var knownSymbolSpans_1 = createDocumentSpanSet();
174927
175065
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
174928
175066
  var referencedSymbol = defaultProjectResults_1[_i];
174929
- for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174930
- var ref = _b[_a];
175067
+ for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
175068
+ var ref = _c[_b];
174931
175069
  if (ref.isDefinition) {
174932
175070
  knownSymbolSpans_1.add(ref);
174933
175071
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -175090,7 +175228,6 @@ var ts;
175090
175228
  return it.done ? server.emptyArray : it.value; // There may not be any results at all
175091
175229
  }
175092
175230
  return resultsMap;
175093
- // May enqueue to otherPositionQueue
175094
175231
  function searchPosition(project, location) {
175095
175232
  var projectResults = getResultsForPosition(project, location);
175096
175233
  if (!projectResults)