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/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220527";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220528";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5598,6 +5598,7 @@ var ts;
5598
5598
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true),
5599
5599
  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."),
5600
5600
  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."),
5601
+ 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."),
5601
5602
  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."),
5602
5603
  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."),
5603
5604
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -39751,6 +39752,7 @@ var ts;
39751
39752
  var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
39752
39753
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
39753
39754
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
39755
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
39754
39756
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
39755
39757
  emptyGenericType.instantiations = new ts.Map();
39756
39758
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -48560,7 +48562,7 @@ var ts;
48560
48562
  }
48561
48563
  }
48562
48564
  }
48563
- else if (t.flags & 469892092) {
48565
+ else if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) {
48564
48566
  hasDisjointDomainType = true;
48565
48567
  }
48566
48568
  }
@@ -48568,7 +48570,7 @@ var ts;
48568
48570
  if (hasDisjointDomainType) {
48569
48571
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
48570
48572
  var t = types_6[_a];
48571
- if (t.flags & 469892092) {
48573
+ if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) {
48572
48574
  constraints = ts.append(constraints, t);
48573
48575
  }
48574
48576
  }
@@ -50838,7 +50840,7 @@ var ts;
50838
50840
  }
50839
50841
  return includes;
50840
50842
  }
50841
- function removeRedundantPrimitiveTypes(types, includes) {
50843
+ function removeRedundantSupertypes(types, includes) {
50842
50844
  var i = types.length;
50843
50845
  while (i > 0) {
50844
50846
  i--;
@@ -50846,7 +50848,9 @@ var ts;
50846
50848
  var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) ||
50847
50849
  t.flags & 8 && includes & 256 ||
50848
50850
  t.flags & 64 && includes & 2048 ||
50849
- t.flags & 4096 && includes & 8192;
50851
+ t.flags & 4096 && includes & 8192 ||
50852
+ t.flags & 16384 && includes & 32768 ||
50853
+ isEmptyAnonymousObjectType(t) && includes & 470302716;
50850
50854
  if (remove) {
50851
50855
  ts.orderedRemoveItemAt(types, i);
50852
50856
  }
@@ -50941,7 +50945,7 @@ var ts;
50941
50945
  result.aliasTypeArguments = aliasTypeArguments;
50942
50946
  return result;
50943
50947
  }
50944
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
50948
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
50945
50949
  var typeMembershipMap = new ts.Map();
50946
50950
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
50947
50951
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -50969,11 +50973,11 @@ var ts;
50969
50973
  if (includes & 4 && includes & (128 | 134217728 | 268435456) ||
50970
50974
  includes & 8 && includes & 256 ||
50971
50975
  includes & 64 && includes & 2048 ||
50972
- includes & 4096 && includes & 8192) {
50973
- removeRedundantPrimitiveTypes(typeSet, includes);
50974
- }
50975
- if (includes & 16777216 && includes & 524288) {
50976
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
50976
+ includes & 4096 && includes & 8192 ||
50977
+ includes & 16384 && includes & 32768 ||
50978
+ includes & 16777216 && includes & 470302716) {
50979
+ if (!noSupertypeReduction)
50980
+ removeRedundantSupertypes(typeSet, includes);
50977
50981
  }
50978
50982
  if (includes & 262144) {
50979
50983
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -51005,7 +51009,7 @@ var ts;
51005
51009
  return errorType;
51006
51010
  }
51007
51011
  var constituents = getCrossProductIntersections(typeSet);
51008
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined;
51012
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined;
51009
51013
  result = getUnionType(constituents, 1, aliasSymbol, aliasTypeArguments, origin);
51010
51014
  }
51011
51015
  }
@@ -51048,11 +51052,21 @@ var ts;
51048
51052
  }
51049
51053
  return intersections;
51050
51054
  }
51055
+ function getConstituentCount(type) {
51056
+ return !(type.flags & 3145728) || type.aliasSymbol ? 1 :
51057
+ type.flags & 1048576 && type.origin ? getConstituentCount(type.origin) :
51058
+ getConstituentCountOfTypes(type.types);
51059
+ }
51060
+ function getConstituentCountOfTypes(types) {
51061
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
51062
+ }
51051
51063
  function getTypeFromIntersectionTypeNode(node) {
51052
51064
  var links = getNodeLinks(node);
51053
51065
  if (!links.resolvedType) {
51054
51066
  var aliasSymbol = getAliasSymbolForTypeNode(node);
51055
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
51067
+ var types = ts.map(node.types, getTypeFromTypeNode);
51068
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 | 8 | 64)) && types[1] === emptyTypeLiteralType;
51069
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
51056
51070
  }
51057
51071
  return links.resolvedType;
51058
51072
  }
@@ -53531,6 +53545,17 @@ var ts;
53531
53545
  return !!(ts.getObjectFlags(type) & 16 && (type.members && isEmptyResolvedType(type) ||
53532
53546
  type.symbol && type.symbol.flags & 2048 && getMembersOfSymbol(type.symbol).size === 0));
53533
53547
  }
53548
+ function isUnknownLikeUnionType(type) {
53549
+ if (strictNullChecks && type.flags & 1048576) {
53550
+ if (!(type.objectFlags & 33554432)) {
53551
+ var types = type.types;
53552
+ type.objectFlags |= 33554432 | (types.length >= 3 && types[0].flags & 32768 &&
53553
+ types[1].flags & 65536 && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 : 0);
53554
+ }
53555
+ return !!(type.objectFlags & 67108864);
53556
+ }
53557
+ return false;
53558
+ }
53534
53559
  function isStringIndexSignatureOnlyType(type) {
53535
53560
  return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
53536
53561
  type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -53608,13 +53633,15 @@ var ts;
53608
53633
  return true;
53609
53634
  if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536))
53610
53635
  return true;
53611
- if (s & 524288 && t & 67108864)
53636
+ if (s & 524288 && t & 67108864 && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
53612
53637
  return true;
53613
53638
  if (relation === assignableRelation || relation === comparableRelation) {
53614
53639
  if (s & 1)
53615
53640
  return true;
53616
53641
  if (s & (8 | 256) && !(s & 1024) && (t & 32 || relation === assignableRelation && t & 256 && t & 1024))
53617
53642
  return true;
53643
+ if (isUnknownLikeUnionType(target))
53644
+ return true;
53618
53645
  }
53619
53646
  return false;
53620
53647
  }
@@ -53656,16 +53683,27 @@ var ts;
53656
53683
  function getNormalizedType(type, writing) {
53657
53684
  while (true) {
53658
53685
  var t = isFreshLiteralType(type) ? type.regularType :
53659
- ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
53660
- type.flags & 3145728 ? getReducedType(type) :
53686
+ ts.getObjectFlags(type) & 4 ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
53687
+ type.flags & 3145728 ? getNormalizedUnionOrIntersectionType(type, writing) :
53661
53688
  type.flags & 33554432 ? writing ? type.baseType : type.substitute :
53662
53689
  type.flags & 25165824 ? getSimplifiedType(type, writing) :
53663
53690
  type;
53664
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
53665
53691
  if (t === type)
53666
- break;
53692
+ return t;
53667
53693
  type = t;
53668
53694
  }
53695
+ }
53696
+ function getNormalizedUnionOrIntersectionType(type, writing) {
53697
+ var reduced = getReducedType(type);
53698
+ if (reduced !== type) {
53699
+ return reduced;
53700
+ }
53701
+ if (type.flags & 2097152) {
53702
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
53703
+ if (normalizedTypes !== type.types) {
53704
+ return getIntersectionType(normalizedTypes);
53705
+ }
53706
+ }
53669
53707
  return type;
53670
53708
  }
53671
53709
  function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
@@ -54040,6 +54078,7 @@ var ts;
54040
54078
  return 0;
54041
54079
  }
54042
54080
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
54081
+ var _a, _b;
54043
54082
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
54044
54083
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
54045
54084
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -54078,6 +54117,9 @@ var ts;
54078
54117
  return;
54079
54118
  }
54080
54119
  reportRelationError(headMessage, source, target);
54120
+ if (strictNullChecks && source.flags & 8650752 && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
54121
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
54122
+ }
54081
54123
  }
54082
54124
  function traceUnionsOrIntersectionsTooLarge(source, target) {
54083
54125
  if (!ts.tracing) {
@@ -54719,12 +54761,6 @@ var ts;
54719
54761
  if (sourceFlags & 8650752) {
54720
54762
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54721
54763
  var constraint = getConstraintOfType(source) || unknownType;
54722
- if (!getConstraintOfType(source) || (sourceFlags & 262144 && constraint.flags & 1)) {
54723
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54724
- resetErrorInfo(saveErrorInfo);
54725
- return result;
54726
- }
54727
- }
54728
54764
  if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54729
54765
  resetErrorInfo(saveErrorInfo);
54730
54766
  return result;
@@ -55980,9 +56016,11 @@ var ts;
55980
56016
  return getSupertypeOrUnion(types);
55981
56017
  }
55982
56018
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
55983
- return primaryTypes.length ?
55984
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
55985
- getUnionType(types, 2);
56019
+ if (primaryTypes.length) {
56020
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
56021
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304); }), true));
56022
+ }
56023
+ return getUnionType(types, 2);
55986
56024
  }
55987
56025
  function getCommonSubtype(types) {
55988
56026
  return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
@@ -56169,12 +56207,13 @@ var ts;
56169
56207
  return result;
56170
56208
  }
56171
56209
  function getFalsyFlags(type) {
56172
- return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
56173
- type.flags & 128 ? type.value === "" ? 128 : 0 :
56174
- type.flags & 256 ? type.value === 0 ? 256 : 0 :
56175
- type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
56176
- type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
56177
- type.flags & 117724;
56210
+ var t = type.flags & 2097152 ? getBaseConstraintOrType(type) : type;
56211
+ return t.flags & 1048576 ? getFalsyFlagsOfTypes(t.types) :
56212
+ t.flags & 128 ? t.value === "" ? 128 : 0 :
56213
+ t.flags & 256 ? t.value === 0 ? 256 : 0 :
56214
+ t.flags & 2048 ? isZeroBigInt(t) ? 2048 : 0 :
56215
+ t.flags & 512 ? (t === falseType || t === regularFalseType) ? 512 : 0 :
56216
+ t.flags & 117724;
56178
56217
  }
56179
56218
  function removeDefinitelyFalsyTypes(type) {
56180
56219
  return getFalsyFlags(type) & 117632 ?
@@ -56209,16 +56248,19 @@ var ts;
56209
56248
  return type.flags & 32768 ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
56210
56249
  }
56211
56250
  function getGlobalNonNullableTypeInstantiation(type) {
56212
- var reducedType = getTypeWithFacts(type, 2097152);
56213
56251
  if (!deferredGlobalNonNullableTypeAlias) {
56214
56252
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
56215
56253
  }
56216
56254
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
56217
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
56218
- reducedType;
56255
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
56256
+ getIntersectionType([type, emptyObjectType]);
56219
56257
  }
56220
56258
  function getNonNullableType(type) {
56221
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
56259
+ if (strictNullChecks) {
56260
+ var reducedType = getTypeWithFacts(type, 2097152);
56261
+ return maybeTypeOfKind(reducedType, 465829888) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
56262
+ }
56263
+ return type;
56222
56264
  }
56223
56265
  function addOptionalTypeMarker(type) {
56224
56266
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -56812,17 +56854,32 @@ var ts;
56812
56854
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
56813
56855
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
56814
56856
  }
56815
- function isValidBigIntString(s) {
56857
+ function isValidNumberString(s, roundTripOnly) {
56858
+ if (s === "")
56859
+ return false;
56860
+ var n = +s;
56861
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
56862
+ }
56863
+ function parseBigIntLiteralType(text) {
56864
+ var negative = text.startsWith("-");
56865
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
56866
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
56867
+ }
56868
+ function isValidBigIntString(s, roundTripOnly) {
56869
+ if (s === "")
56870
+ return false;
56816
56871
  var scanner = ts.createScanner(99, false);
56817
56872
  var success = true;
56818
56873
  scanner.setOnError(function () { return success = false; });
56819
56874
  scanner.setText(s + "n");
56820
56875
  var result = scanner.scan();
56821
- if (result === 40) {
56876
+ var negative = result === 40;
56877
+ if (negative) {
56822
56878
  result = scanner.scan();
56823
56879
  }
56824
56880
  var flags = scanner.getTokenFlags();
56825
- return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512);
56881
+ return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512)
56882
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
56826
56883
  }
56827
56884
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
56828
56885
  if (source === target || target.flags & (1 | 4)) {
@@ -56830,8 +56887,8 @@ var ts;
56830
56887
  }
56831
56888
  if (source.flags & 128) {
56832
56889
  var value = source.value;
56833
- return !!(target.flags & 8 && value !== "" && isFinite(+value) ||
56834
- target.flags & 64 && value !== "" && isValidBigIntString(value) ||
56890
+ return !!(target.flags & 8 && isValidNumberString(value, false) ||
56891
+ target.flags & 64 && isValidBigIntString(value, false) ||
56835
56892
  target.flags & (512 | 98304) && value === target.intrinsicName);
56836
56893
  }
56837
56894
  if (source.flags & 134217728) {
@@ -57296,8 +57353,51 @@ var ts;
57296
57353
  var matches = inferTypesFromTemplateLiteralType(source, target);
57297
57354
  var types = target.types;
57298
57355
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
57356
+ var _loop_23 = function (i) {
57357
+ var source_1 = matches ? matches[i] : neverType;
57358
+ var target_3 = types[i];
57359
+ if (source_1.flags & 128 && target_3.flags & 8650752) {
57360
+ var inferenceContext = getInferenceInfoForType(target_3);
57361
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
57362
+ if (constraint && !isTypeAny(constraint)) {
57363
+ var constraintTypes = constraint.flags & 1048576 ? constraint.types : [constraint];
57364
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
57365
+ if (!(allTypeFlags_1 & 4)) {
57366
+ var str_1 = source_1.value;
57367
+ if (allTypeFlags_1 & 296 && !isValidNumberString(str_1, true)) {
57368
+ allTypeFlags_1 &= ~296;
57369
+ }
57370
+ if (allTypeFlags_1 & 2112 && !isValidBigIntString(str_1, true)) {
57371
+ allTypeFlags_1 &= ~2112;
57372
+ }
57373
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
57374
+ return !(right.flags & allTypeFlags_1) ? left :
57375
+ left.flags & 4 ? left : right.flags & 4 ? source_1 :
57376
+ left.flags & 134217728 ? left : right.flags & 134217728 && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
57377
+ left.flags & 268435456 ? left : right.flags & 268435456 && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
57378
+ left.flags & 128 ? left : right.flags & 128 && right.value === str_1 ? right :
57379
+ left.flags & 8 ? left : right.flags & 8 ? getNumberLiteralType(+str_1) :
57380
+ left.flags & 32 ? left : right.flags & 32 ? getNumberLiteralType(+str_1) :
57381
+ left.flags & 256 ? left : right.flags & 256 && right.value === +str_1 ? right :
57382
+ left.flags & 64 ? left : right.flags & 64 ? parseBigIntLiteralType(str_1) :
57383
+ left.flags & 2048 ? left : right.flags & 2048 && ts.pseudoBigIntToString(right.value) === str_1 ? right :
57384
+ left.flags & 16 ? left : right.flags & 16 ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
57385
+ left.flags & 512 ? left : right.flags & 512 && right.intrinsicName === str_1 ? right :
57386
+ left.flags & 32768 ? left : right.flags & 32768 && right.intrinsicName === str_1 ? right :
57387
+ left.flags & 65536 ? left : right.flags & 65536 && right.intrinsicName === str_1 ? right :
57388
+ left;
57389
+ }, neverType);
57390
+ if (!(matchingType.flags & 131072)) {
57391
+ inferFromTypes(matchingType, target_3);
57392
+ return "continue";
57393
+ }
57394
+ }
57395
+ }
57396
+ }
57397
+ inferFromTypes(source_1, target_3);
57398
+ };
57299
57399
  for (var i = 0; i < types.length; i++) {
57300
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
57400
+ _loop_23(i);
57301
57401
  }
57302
57402
  }
57303
57403
  }
@@ -57767,7 +57867,7 @@ var ts;
57767
57867
  function mapTypesByKeyProperty(types, name) {
57768
57868
  var map = new ts.Map();
57769
57869
  var count = 0;
57770
- var _loop_23 = function (type) {
57870
+ var _loop_24 = function (type) {
57771
57871
  if (type.flags & (524288 | 2097152 | 58982400)) {
57772
57872
  var discriminant = getTypeOfPropertyOfType(type, name);
57773
57873
  if (discriminant) {
@@ -57793,7 +57893,7 @@ var ts;
57793
57893
  };
57794
57894
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
57795
57895
  var type = types_16[_i];
57796
- var state_9 = _loop_23(type);
57896
+ var state_9 = _loop_24(type);
57797
57897
  if (typeof state_9 === "object")
57798
57898
  return state_9.value;
57799
57899
  }
@@ -57981,6 +58081,24 @@ var ts;
57981
58081
  function getTypeWithFacts(type, include) {
57982
58082
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
57983
58083
  }
58084
+ function getIntersectionWithFacts(type, facts) {
58085
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 ? unknownUnionType : type, facts));
58086
+ if (strictNullChecks) {
58087
+ switch (facts) {
58088
+ case 524288:
58089
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 ? getIntersectionType([t, getTypeFacts(t) & 131072 && !maybeTypeOfKind(reduced, 65536) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
58090
+ case 1048576:
58091
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 ? getIntersectionType([t, getTypeFacts(t) & 65536 && !maybeTypeOfKind(reduced, 32768) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
58092
+ case 2097152:
58093
+ case 4194304:
58094
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 ? getGlobalNonNullableTypeInstantiation(t) : t; });
58095
+ }
58096
+ }
58097
+ return reduced;
58098
+ }
58099
+ function recombineUnknownType(type) {
58100
+ return type === unknownUnionType ? unknownType : type;
58101
+ }
57984
58102
  function getTypeWithDefault(type, defaultExpression) {
57985
58103
  return defaultExpression ?
57986
58104
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -58921,7 +59039,7 @@ var ts;
58921
59039
  if (isEvolvingArrayTypeList(types)) {
58922
59040
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
58923
59041
  }
58924
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
59042
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
58925
59043
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 && ts.arraysEqual(result.types, declaredType.types)) {
58926
59044
  return declaredType;
58927
59045
  }
@@ -59017,8 +59135,7 @@ var ts;
59017
59135
  }
59018
59136
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
59019
59137
  if (isMatchingReference(reference, expr)) {
59020
- return type.flags & 2 && assumeTrue ? nonNullUnknownType :
59021
- getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
59138
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 : 8388608);
59022
59139
  }
59023
59140
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
59024
59141
  type = getTypeWithFacts(type, 2097152);
@@ -59158,9 +59275,6 @@ var ts;
59158
59275
  assumeTrue = !assumeTrue;
59159
59276
  }
59160
59277
  var valueType = getTypeOfExpression(value);
59161
- if (assumeTrue && (type.flags & 2) && (operator === 34 || operator === 35) && (valueType.flags & 65536)) {
59162
- return getUnionType([nullType, undefinedType]);
59163
- }
59164
59278
  if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
59165
59279
  if (valueType.flags & (131068 | 67108864)) {
59166
59280
  return valueType;
@@ -59180,7 +59294,7 @@ var ts;
59180
59294
  valueType.flags & 65536 ?
59181
59295
  assumeTrue ? 131072 : 1048576 :
59182
59296
  assumeTrue ? 65536 : 524288;
59183
- return type.flags & 2 && facts & (1048576 | 2097152) ? nonNullUnknownType : getTypeWithFacts(type, facts);
59297
+ return getIntersectionWithFacts(type, facts);
59184
59298
  }
59185
59299
  if (assumeTrue) {
59186
59300
  var filterFn = operator === 34 ?
@@ -59207,14 +59321,11 @@ var ts;
59207
59321
  if (type.flags & 1 && literal.text === "function") {
59208
59322
  return type;
59209
59323
  }
59210
- if (assumeTrue && type.flags & 2 && literal.text === "object") {
59211
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
59212
- }
59213
59324
  var facts = assumeTrue ?
59214
59325
  typeofEQFacts.get(literal.text) || 128 :
59215
59326
  typeofNEFacts.get(literal.text) || 32768;
59216
59327
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
59217
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
59328
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
59218
59329
  }
59219
59330
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
59220
59331
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -59259,30 +59370,35 @@ var ts;
59259
59370
  }
59260
59371
  function getImpliedTypeFromTypeofGuard(type, text) {
59261
59372
  switch (text) {
59373
+ case "object":
59374
+ return type.flags & 1 ? type : getUnionType([nullType, nonPrimitiveType]);
59262
59375
  case "function":
59263
59376
  return type.flags & 1 ? type : globalFunctionType;
59264
- case "object":
59265
- return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
59266
59377
  default:
59267
59378
  return typeofTypesByName.get(text);
59268
59379
  }
59269
59380
  }
59270
- function narrowUnionMemberByTypeof(candidate) {
59271
- return function (type) {
59272
- if (isTypeSubtypeOf(type, candidate)) {
59273
- return type;
59274
- }
59275
- if (isTypeSubtypeOf(candidate, type)) {
59276
- return candidate;
59381
+ function narrowTypeByImpliedType(type, candidate) {
59382
+ if (type.flags & 3) {
59383
+ return candidate;
59384
+ }
59385
+ return mapType(type, function (t) {
59386
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
59387
+ return t;
59277
59388
  }
59278
- if (type.flags & 465829888) {
59279
- var constraint = getBaseConstraintOfType(type) || anyType;
59280
- if (isTypeSubtypeOf(candidate, constraint)) {
59281
- return getIntersectionType([type, candidate]);
59389
+ return mapType(candidate, function (c) {
59390
+ if (!areTypesComparable(t, c)) {
59391
+ return neverType;
59282
59392
  }
59283
- }
59284
- return type;
59285
- };
59393
+ if (c.flags & 131068 && t.flags & 524288 && !isEmptyAnonymousObjectType(t)) {
59394
+ return isTypeSubtypeOf(c, t) ? c : neverType;
59395
+ }
59396
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
59397
+ return c;
59398
+ }
59399
+ return getIntersectionType([t, c]);
59400
+ });
59401
+ });
59286
59402
  }
59287
59403
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
59288
59404
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
@@ -59308,7 +59424,7 @@ var ts;
59308
59424
  return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
59309
59425
  }
59310
59426
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
59311
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
59427
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
59312
59428
  }
59313
59429
  function isMatchingConstructorReference(expr) {
59314
59430
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -59569,7 +59685,9 @@ var ts;
59569
59685
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
59570
59686
  }
59571
59687
  function isGenericTypeWithUnionConstraint(type) {
59572
- return !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576));
59688
+ return type.flags & 2097152 ?
59689
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
59690
+ !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576));
59573
59691
  }
59574
59692
  function isGenericTypeWithoutNullableConstraint(type) {
59575
59693
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
@@ -59586,7 +59704,7 @@ var ts;
59586
59704
  var substituteConstraints = !(checkMode && checkMode & 2) &&
59587
59705
  someType(type, isGenericTypeWithUnionConstraint) &&
59588
59706
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
59589
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type;
59707
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
59590
59708
  }
59591
59709
  function isExportOrExportExpression(location) {
59592
59710
  return !!ts.findAncestor(location, function (n) {
@@ -63216,7 +63334,7 @@ var ts;
63216
63334
  var spreadIndex = getSpreadArgumentIndex(args);
63217
63335
  if (spreadIndex >= 0) {
63218
63336
  var effectiveArgs_1 = args.slice(0, spreadIndex);
63219
- var _loop_24 = function (i) {
63337
+ var _loop_25 = function (i) {
63220
63338
  var arg = args[i];
63221
63339
  var spreadType = arg.kind === 225 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
63222
63340
  if (spreadType && isTupleType(spreadType)) {
@@ -63232,7 +63350,7 @@ var ts;
63232
63350
  }
63233
63351
  };
63234
63352
  for (var i = spreadIndex; i < args.length; i++) {
63235
- _loop_24(i);
63353
+ _loop_25(i);
63236
63354
  }
63237
63355
  return effectiveArgs_1;
63238
63356
  }
@@ -63480,7 +63598,7 @@ var ts;
63480
63598
  var min_3 = Number.MAX_VALUE;
63481
63599
  var minIndex = 0;
63482
63600
  var i_1 = 0;
63483
- var _loop_25 = function (c) {
63601
+ var _loop_26 = function (c) {
63484
63602
  var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
63485
63603
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
63486
63604
  if (diags_2) {
@@ -63498,7 +63616,7 @@ var ts;
63498
63616
  };
63499
63617
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
63500
63618
  var c = candidatesForArgumentError_1[_a];
63501
- _loop_25(c);
63619
+ _loop_26(c);
63502
63620
  }
63503
63621
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
63504
63622
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -63641,7 +63759,7 @@ var ts;
63641
63759
  }
63642
63760
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
63643
63761
  var parameters = [];
63644
- var _loop_26 = function (i) {
63762
+ var _loop_27 = function (i) {
63645
63763
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
63646
63764
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
63647
63765
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -63649,7 +63767,7 @@ var ts;
63649
63767
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
63650
63768
  };
63651
63769
  for (var i = 0; i < maxNonRestParam; i++) {
63652
- _loop_26(i);
63770
+ _loop_27(i);
63653
63771
  }
63654
63772
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
63655
63773
  var flags = 0;
@@ -67245,7 +67363,7 @@ var ts;
67245
67363
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
67246
67364
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
67247
67365
  var indexSignatureMap_1 = new ts.Map();
67248
- var _loop_27 = function (declaration) {
67366
+ var _loop_28 = function (declaration) {
67249
67367
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
67250
67368
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
67251
67369
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -67260,7 +67378,7 @@ var ts;
67260
67378
  };
67261
67379
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
67262
67380
  var declaration = _a[_i];
67263
- _loop_27(declaration);
67381
+ _loop_28(declaration);
67264
67382
  }
67265
67383
  indexSignatureMap_1.forEach(function (entry) {
67266
67384
  if (entry.declarations.length > 1) {
@@ -70080,7 +70198,7 @@ var ts;
70080
70198
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70081
70199
  var localPropDeclaration = declaration && declaration.kind === 221 ||
70082
70200
  name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
70083
- var _loop_28 = function (info) {
70201
+ var _loop_29 = function (info) {
70084
70202
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
70085
70203
  var errorNode = localPropDeclaration || localIndexDeclaration ||
70086
70204
  (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
@@ -70090,7 +70208,7 @@ var ts;
70090
70208
  };
70091
70209
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
70092
70210
  var info = indexInfos_9[_i];
70093
- _loop_28(info);
70211
+ _loop_29(info);
70094
70212
  }
70095
70213
  }
70096
70214
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -70098,7 +70216,7 @@ var ts;
70098
70216
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
70099
70217
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70100
70218
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
70101
- var _loop_29 = function (info) {
70219
+ var _loop_30 = function (info) {
70102
70220
  if (info === checkInfo)
70103
70221
  return "continue";
70104
70222
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -70110,7 +70228,7 @@ var ts;
70110
70228
  };
70111
70229
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
70112
70230
  var info = indexInfos_10[_i];
70113
- _loop_29(info);
70231
+ _loop_30(info);
70114
70232
  }
70115
70233
  }
70116
70234
  function checkTypeNameIsReserved(name, message) {
@@ -70404,7 +70522,7 @@ var ts;
70404
70522
  var baseTypes = baseTypeNode && getBaseTypes(type);
70405
70523
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
70406
70524
  var baseStaticType = getBaseConstructorTypeOfClass(type);
70407
- var _loop_30 = function (member) {
70525
+ var _loop_31 = function (member) {
70408
70526
  if (ts.hasAmbientModifier(member)) {
70409
70527
  return "continue";
70410
70528
  }
@@ -70419,7 +70537,7 @@ var ts;
70419
70537
  };
70420
70538
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70421
70539
  var member = _a[_i];
70422
- _loop_30(member);
70540
+ _loop_31(member);
70423
70541
  }
70424
70542
  }
70425
70543
  function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
@@ -70494,7 +70612,7 @@ var ts;
70494
70612
  }
70495
70613
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
70496
70614
  var issuedMemberError = false;
70497
- var _loop_31 = function (member) {
70615
+ var _loop_32 = function (member) {
70498
70616
  if (ts.isStatic(member)) {
70499
70617
  return "continue";
70500
70618
  }
@@ -70512,7 +70630,7 @@ var ts;
70512
70630
  };
70513
70631
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70514
70632
  var member = _a[_i];
70515
- _loop_31(member);
70633
+ _loop_32(member);
70516
70634
  }
70517
70635
  if (!issuedMemberError) {
70518
70636
  checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
@@ -101004,7 +101122,7 @@ var ts;
101004
101122
  importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
101005
101123
  });
101006
101124
  var sortedPaths = [];
101007
- var _loop_32 = function (directory) {
101125
+ var _loop_33 = function (directory) {
101008
101126
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
101009
101127
  var pathsInDirectory;
101010
101128
  allFileNames.forEach(function (_a, fileName) {
@@ -101028,7 +101146,7 @@ var ts;
101028
101146
  };
101029
101147
  var out_directory_1;
101030
101148
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
101031
- var state_10 = _loop_32(directory);
101149
+ var state_10 = _loop_33(directory);
101032
101150
  directory = out_directory_1;
101033
101151
  if (state_10 === "break")
101034
101152
  break;