@typescript-deploys/pr-build 4.7.0-pr-47461-10 → 4.7.0-pr-48861-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220425";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220427";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -17501,19 +17501,11 @@ var ts;
17501
17501
  return !!name && isDynamicName(name);
17502
17502
  }
17503
17503
  ts.hasDynamicName = hasDynamicName;
17504
- function getComputedPropertyNameExpression(name) {
17505
- return ts.isElementAccessExpression(name.expression)
17506
- ? skipParentheses(name.expression.argumentExpression)
17507
- : name.expression;
17508
- }
17509
- ts.getComputedPropertyNameExpression = getComputedPropertyNameExpression;
17510
17504
  function isDynamicName(name) {
17511
17505
  if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) {
17512
17506
  return false;
17513
17507
  }
17514
- var expr = ts.isElementAccessExpression(name)
17515
- ? skipParentheses(name.argumentExpression)
17516
- : getComputedPropertyNameExpression(name);
17508
+ var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
17517
17509
  return !isStringOrNumericLiteralLike(expr) &&
17518
17510
  !isSignedNumericLiteral(expr);
17519
17511
  }
@@ -17527,7 +17519,7 @@ var ts;
17527
17519
  case 8 /* NumericLiteral */:
17528
17520
  return ts.escapeLeadingUnderscores(name.text);
17529
17521
  case 162 /* ComputedPropertyName */:
17530
- var nameExpression = getComputedPropertyNameExpression(name);
17522
+ var nameExpression = name.expression;
17531
17523
  if (isStringOrNumericLiteralLike(nameExpression)) {
17532
17524
  return ts.escapeLeadingUnderscores(nameExpression.text);
17533
17525
  }
@@ -44649,7 +44641,7 @@ var ts;
44649
44641
  return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
44650
44642
  }
44651
44643
  if (name.kind === 162 /* ComputedPropertyName */) {
44652
- var nameExpression = ts.getComputedPropertyNameExpression(name);
44644
+ var nameExpression = name.expression;
44653
44645
  // treat computed property names where expression is string/numeric literal as just string/numeric literal
44654
44646
  if (ts.isStringOrNumericLiteralLike(nameExpression)) {
44655
44647
  return ts.escapeLeadingUnderscores(nameExpression.text);
@@ -48538,6 +48530,7 @@ var ts;
48538
48530
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48539
48531
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48540
48532
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48533
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48541
48534
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48542
48535
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48543
48536
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -51519,7 +51512,7 @@ var ts;
51519
51512
  }
51520
51513
  }
51521
51514
  function getExportSymbolOfValueSymbolIfExported(symbol) {
51522
- return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol);
51515
+ return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol);
51523
51516
  }
51524
51517
  function symbolIsValue(symbol) {
51525
51518
  return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol));
@@ -58922,7 +58915,7 @@ var ts;
58922
58915
  var typeVariable = getHomomorphicTypeVariable(type);
58923
58916
  if (typeVariable && !type.declaration.nameType) {
58924
58917
  var constraint = getConstraintOfTypeParameter(typeVariable);
58925
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58918
+ if (constraint && isArrayOrTupleType(constraint)) {
58926
58919
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58927
58920
  }
58928
58921
  }
@@ -59284,10 +59277,10 @@ var ts;
59284
59277
  }
59285
59278
  function isApplicableIndexType(source, target) {
59286
59279
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59287
- // signature applies to types assignable to 'number' and numeric string literal types.
59280
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59288
59281
  return isTypeAssignableTo(source, target) ||
59289
59282
  target === stringType && isTypeAssignableTo(source, numberType) ||
59290
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59283
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59291
59284
  }
59292
59285
  function getIndexInfosOfStructuredType(type) {
59293
59286
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60303,6 +60296,20 @@ var ts;
60303
60296
  constraints = ts.append(constraints, constraint);
60304
60297
  }
60305
60298
  }
60299
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60300
+ // template type XXX, K has an added constraint of number | `${number}`.
60301
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60302
+ var mappedType = getTypeFromTypeNode(parent);
60303
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60304
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60305
+ if (typeParameter) {
60306
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60307
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60308
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60309
+ }
60310
+ }
60311
+ }
60312
+ }
60306
60313
  node = parent;
60307
60314
  }
60308
60315
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61270,7 +61277,7 @@ var ts;
61270
61277
  while (i > 0) {
61271
61278
  i--;
61272
61279
  var t = types[i];
61273
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61280
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61274
61281
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61275
61282
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61276
61283
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61429,7 +61436,7 @@ var ts;
61429
61436
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61430
61437
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61431
61438
  }
61432
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61439
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61433
61440
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61434
61441
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61435
61442
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63313,7 +63320,7 @@ var ts;
63313
63320
  if (!type.declaration.nameType) {
63314
63321
  var constraint = void 0;
63315
63322
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63316
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63323
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63317
63324
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63318
63325
  }
63319
63326
  if (isGenericTupleType(t)) {
@@ -64751,7 +64758,7 @@ var ts;
64751
64758
  }
64752
64759
  return false;
64753
64760
  }
64754
- return isTupleType(target) || isArrayType(target);
64761
+ return isArrayOrTupleType(target);
64755
64762
  }
64756
64763
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64757
64764
  if (reportErrors) {
@@ -64881,7 +64888,7 @@ var ts;
64881
64888
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64882
64889
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64883
64890
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64884
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64891
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64885
64892
  inPropertyCheck = true;
64886
64893
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64887
64894
  inPropertyCheck = false;
@@ -65508,6 +65515,20 @@ var ts;
65508
65515
  }
65509
65516
  }
65510
65517
  }
65518
+ if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
65519
+ // This is a carve-out in comparability to essentially forbid comparing a type parameter
65520
+ // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
65521
+ var constraint = getConstraintOfTypeParameter(source);
65522
+ if (constraint && hasNonCircularBaseConstraint(source)) {
65523
+ while (constraint && constraint.flags & 262144 /* TypeParameter */) {
65524
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
65525
+ return result;
65526
+ }
65527
+ constraint = getConstraintOfTypeParameter(constraint);
65528
+ }
65529
+ }
65530
+ return 0 /* False */;
65531
+ }
65511
65532
  }
65512
65533
  else if (targetFlags & 4194304 /* Index */) {
65513
65534
  var targetType_1 = target.type;
@@ -65711,7 +65732,7 @@ var ts;
65711
65732
  if (sourceFlags & 8650752 /* TypeVariable */) {
65712
65733
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65713
65734
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65714
- var constraint = getConstraintOfType(source);
65735
+ var constraint = getConstraintOfType(source) || unknownType;
65715
65736
  if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) {
65716
65737
  // A type variable with no constraint is not related to the non-primitive object type.
65717
65738
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
@@ -65720,12 +65741,12 @@ var ts;
65720
65741
  }
65721
65742
  }
65722
65743
  // 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
65723
- else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) {
65744
+ else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65724
65745
  resetErrorInfo(saveErrorInfo);
65725
65746
  return result;
65726
65747
  }
65727
65748
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
65728
- else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) {
65749
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
65729
65750
  resetErrorInfo(saveErrorInfo);
65730
65751
  return result;
65731
65752
  }
@@ -65869,7 +65890,7 @@ var ts;
65869
65890
  return varianceResult;
65870
65891
  }
65871
65892
  }
65872
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65893
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65873
65894
  if (relation !== identityRelation) {
65874
65895
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65875
65896
  }
@@ -66245,7 +66266,7 @@ var ts;
66245
66266
  }
66246
66267
  var result = -1 /* True */;
66247
66268
  if (isTupleType(target)) {
66248
- if (isArrayType(source) || isTupleType(source)) {
66269
+ if (isArrayOrTupleType(source)) {
66249
66270
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66250
66271
  return 0 /* False */;
66251
66272
  }
@@ -67206,6 +67227,9 @@ var ts;
67206
67227
  function isReadonlyArrayType(type) {
67207
67228
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67208
67229
  }
67230
+ function isArrayOrTupleType(type) {
67231
+ return isArrayType(type) || isTupleType(type);
67232
+ }
67209
67233
  function isMutableArrayOrTuple(type) {
67210
67234
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67211
67235
  }
@@ -67657,7 +67681,7 @@ var ts;
67657
67681
  else if (type.flags & 2097152 /* Intersection */) {
67658
67682
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67659
67683
  }
67660
- else if (isArrayType(type) || isTupleType(type)) {
67684
+ else if (isArrayOrTupleType(type)) {
67661
67685
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67662
67686
  }
67663
67687
  if (result && context === undefined) {
@@ -67694,7 +67718,7 @@ var ts;
67694
67718
  }
67695
67719
  }
67696
67720
  }
67697
- if (isArrayType(type) || isTupleType(type)) {
67721
+ if (isArrayOrTupleType(type)) {
67698
67722
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67699
67723
  var t = _c[_b];
67700
67724
  if (reportWideningErrorsInType(t)) {
@@ -68755,7 +68779,7 @@ var ts;
68755
68779
  }
68756
68780
  // Infer from the members of source and target only if the two types are possibly related
68757
68781
  if (!typesDefinitelyUnrelated(source, target)) {
68758
- if (isArrayType(source) || isTupleType(source)) {
68782
+ if (isArrayOrTupleType(source)) {
68759
68783
  if (isTupleType(target)) {
68760
68784
  var sourceArity = getTypeReferenceArity(source);
68761
68785
  var targetArity = getTypeReferenceArity(target);
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220425";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220427";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -17501,19 +17501,11 @@ var ts;
17501
17501
  return !!name && isDynamicName(name);
17502
17502
  }
17503
17503
  ts.hasDynamicName = hasDynamicName;
17504
- function getComputedPropertyNameExpression(name) {
17505
- return ts.isElementAccessExpression(name.expression)
17506
- ? skipParentheses(name.expression.argumentExpression)
17507
- : name.expression;
17508
- }
17509
- ts.getComputedPropertyNameExpression = getComputedPropertyNameExpression;
17510
17504
  function isDynamicName(name) {
17511
17505
  if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) {
17512
17506
  return false;
17513
17507
  }
17514
- var expr = ts.isElementAccessExpression(name)
17515
- ? skipParentheses(name.argumentExpression)
17516
- : getComputedPropertyNameExpression(name);
17508
+ var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
17517
17509
  return !isStringOrNumericLiteralLike(expr) &&
17518
17510
  !isSignedNumericLiteral(expr);
17519
17511
  }
@@ -17527,7 +17519,7 @@ var ts;
17527
17519
  case 8 /* NumericLiteral */:
17528
17520
  return ts.escapeLeadingUnderscores(name.text);
17529
17521
  case 162 /* ComputedPropertyName */:
17530
- var nameExpression = getComputedPropertyNameExpression(name);
17522
+ var nameExpression = name.expression;
17531
17523
  if (isStringOrNumericLiteralLike(nameExpression)) {
17532
17524
  return ts.escapeLeadingUnderscores(nameExpression.text);
17533
17525
  }
@@ -44649,7 +44641,7 @@ var ts;
44649
44641
  return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
44650
44642
  }
44651
44643
  if (name.kind === 162 /* ComputedPropertyName */) {
44652
- var nameExpression = ts.getComputedPropertyNameExpression(name);
44644
+ var nameExpression = name.expression;
44653
44645
  // treat computed property names where expression is string/numeric literal as just string/numeric literal
44654
44646
  if (ts.isStringOrNumericLiteralLike(nameExpression)) {
44655
44647
  return ts.escapeLeadingUnderscores(nameExpression.text);
@@ -48538,6 +48530,7 @@ var ts;
48538
48530
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48539
48531
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48540
48532
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48533
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48541
48534
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48542
48535
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48543
48536
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -51519,7 +51512,7 @@ var ts;
51519
51512
  }
51520
51513
  }
51521
51514
  function getExportSymbolOfValueSymbolIfExported(symbol) {
51522
- return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol);
51515
+ return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol);
51523
51516
  }
51524
51517
  function symbolIsValue(symbol) {
51525
51518
  return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol));
@@ -58922,7 +58915,7 @@ var ts;
58922
58915
  var typeVariable = getHomomorphicTypeVariable(type);
58923
58916
  if (typeVariable && !type.declaration.nameType) {
58924
58917
  var constraint = getConstraintOfTypeParameter(typeVariable);
58925
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58918
+ if (constraint && isArrayOrTupleType(constraint)) {
58926
58919
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58927
58920
  }
58928
58921
  }
@@ -59284,10 +59277,10 @@ var ts;
59284
59277
  }
59285
59278
  function isApplicableIndexType(source, target) {
59286
59279
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59287
- // signature applies to types assignable to 'number' and numeric string literal types.
59280
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59288
59281
  return isTypeAssignableTo(source, target) ||
59289
59282
  target === stringType && isTypeAssignableTo(source, numberType) ||
59290
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59283
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59291
59284
  }
59292
59285
  function getIndexInfosOfStructuredType(type) {
59293
59286
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60303,6 +60296,20 @@ var ts;
60303
60296
  constraints = ts.append(constraints, constraint);
60304
60297
  }
60305
60298
  }
60299
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60300
+ // template type XXX, K has an added constraint of number | `${number}`.
60301
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60302
+ var mappedType = getTypeFromTypeNode(parent);
60303
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60304
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60305
+ if (typeParameter) {
60306
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60307
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60308
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60309
+ }
60310
+ }
60311
+ }
60312
+ }
60306
60313
  node = parent;
60307
60314
  }
60308
60315
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61270,7 +61277,7 @@ var ts;
61270
61277
  while (i > 0) {
61271
61278
  i--;
61272
61279
  var t = types[i];
61273
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61280
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61274
61281
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61275
61282
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61276
61283
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61429,7 +61436,7 @@ var ts;
61429
61436
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61430
61437
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61431
61438
  }
61432
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61439
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61433
61440
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61434
61441
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61435
61442
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63313,7 +63320,7 @@ var ts;
63313
63320
  if (!type.declaration.nameType) {
63314
63321
  var constraint = void 0;
63315
63322
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63316
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63323
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63317
63324
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63318
63325
  }
63319
63326
  if (isGenericTupleType(t)) {
@@ -64751,7 +64758,7 @@ var ts;
64751
64758
  }
64752
64759
  return false;
64753
64760
  }
64754
- return isTupleType(target) || isArrayType(target);
64761
+ return isArrayOrTupleType(target);
64755
64762
  }
64756
64763
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64757
64764
  if (reportErrors) {
@@ -64881,7 +64888,7 @@ var ts;
64881
64888
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64882
64889
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64883
64890
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64884
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64891
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64885
64892
  inPropertyCheck = true;
64886
64893
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64887
64894
  inPropertyCheck = false;
@@ -65508,6 +65515,20 @@ var ts;
65508
65515
  }
65509
65516
  }
65510
65517
  }
65518
+ if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
65519
+ // This is a carve-out in comparability to essentially forbid comparing a type parameter
65520
+ // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
65521
+ var constraint = getConstraintOfTypeParameter(source);
65522
+ if (constraint && hasNonCircularBaseConstraint(source)) {
65523
+ while (constraint && constraint.flags & 262144 /* TypeParameter */) {
65524
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
65525
+ return result;
65526
+ }
65527
+ constraint = getConstraintOfTypeParameter(constraint);
65528
+ }
65529
+ }
65530
+ return 0 /* False */;
65531
+ }
65511
65532
  }
65512
65533
  else if (targetFlags & 4194304 /* Index */) {
65513
65534
  var targetType_1 = target.type;
@@ -65711,7 +65732,7 @@ var ts;
65711
65732
  if (sourceFlags & 8650752 /* TypeVariable */) {
65712
65733
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65713
65734
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65714
- var constraint = getConstraintOfType(source);
65735
+ var constraint = getConstraintOfType(source) || unknownType;
65715
65736
  if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) {
65716
65737
  // A type variable with no constraint is not related to the non-primitive object type.
65717
65738
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
@@ -65720,12 +65741,12 @@ var ts;
65720
65741
  }
65721
65742
  }
65722
65743
  // 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
65723
- else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) {
65744
+ else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65724
65745
  resetErrorInfo(saveErrorInfo);
65725
65746
  return result;
65726
65747
  }
65727
65748
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
65728
- else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) {
65749
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
65729
65750
  resetErrorInfo(saveErrorInfo);
65730
65751
  return result;
65731
65752
  }
@@ -65869,7 +65890,7 @@ var ts;
65869
65890
  return varianceResult;
65870
65891
  }
65871
65892
  }
65872
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65893
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65873
65894
  if (relation !== identityRelation) {
65874
65895
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65875
65896
  }
@@ -66245,7 +66266,7 @@ var ts;
66245
66266
  }
66246
66267
  var result = -1 /* True */;
66247
66268
  if (isTupleType(target)) {
66248
- if (isArrayType(source) || isTupleType(source)) {
66269
+ if (isArrayOrTupleType(source)) {
66249
66270
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66250
66271
  return 0 /* False */;
66251
66272
  }
@@ -67206,6 +67227,9 @@ var ts;
67206
67227
  function isReadonlyArrayType(type) {
67207
67228
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67208
67229
  }
67230
+ function isArrayOrTupleType(type) {
67231
+ return isArrayType(type) || isTupleType(type);
67232
+ }
67209
67233
  function isMutableArrayOrTuple(type) {
67210
67234
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67211
67235
  }
@@ -67657,7 +67681,7 @@ var ts;
67657
67681
  else if (type.flags & 2097152 /* Intersection */) {
67658
67682
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67659
67683
  }
67660
- else if (isArrayType(type) || isTupleType(type)) {
67684
+ else if (isArrayOrTupleType(type)) {
67661
67685
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67662
67686
  }
67663
67687
  if (result && context === undefined) {
@@ -67694,7 +67718,7 @@ var ts;
67694
67718
  }
67695
67719
  }
67696
67720
  }
67697
- if (isArrayType(type) || isTupleType(type)) {
67721
+ if (isArrayOrTupleType(type)) {
67698
67722
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67699
67723
  var t = _c[_b];
67700
67724
  if (reportWideningErrorsInType(t)) {
@@ -68755,7 +68779,7 @@ var ts;
68755
68779
  }
68756
68780
  // Infer from the members of source and target only if the two types are possibly related
68757
68781
  if (!typesDefinitelyUnrelated(source, target)) {
68758
- if (isArrayType(source) || isTupleType(source)) {
68782
+ if (isArrayOrTupleType(source)) {
68759
68783
  if (isTupleType(target)) {
68760
68784
  var sourceArity = getTypeReferenceArity(source);
68761
68785
  var targetArity = getTypeReferenceArity(target);