typescript 4.7.0-dev.20220425 → 4.7.0-dev.20220426

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.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220425";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -39568,6 +39568,7 @@ var ts;
39568
39568
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
39569
39569
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
39570
39570
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
39571
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]);
39571
39572
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
39572
39573
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
39573
39574
  var uniqueLiteralType = createIntrinsicType(131072, "never");
@@ -48557,7 +48558,7 @@ var ts;
48557
48558
  var typeVariable = getHomomorphicTypeVariable(type);
48558
48559
  if (typeVariable && !type.declaration.nameType) {
48559
48560
  var constraint = getConstraintOfTypeParameter(typeVariable);
48560
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
48561
+ if (constraint && isArrayOrTupleType(constraint)) {
48561
48562
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
48562
48563
  }
48563
48564
  }
@@ -48866,7 +48867,7 @@ var ts;
48866
48867
  function isApplicableIndexType(source, target) {
48867
48868
  return isTypeAssignableTo(source, target) ||
48868
48869
  target === stringType && isTypeAssignableTo(source, numberType) ||
48869
- target === numberType && !!(source.flags & 128) && ts.isNumericLiteralName(source.value);
48870
+ target === numberType && (source === numericStringType || !!(source.flags & 128) && ts.isNumericLiteralName(source.value));
48870
48871
  }
48871
48872
  function getIndexInfosOfStructuredType(type) {
48872
48873
  if (type.flags & 3670016) {
@@ -49772,6 +49773,18 @@ var ts;
49772
49773
  constraints = ts.append(constraints, constraint);
49773
49774
  }
49774
49775
  }
49776
+ else if (type.flags & 262144 && parent.kind === 195 && node === parent.type) {
49777
+ var mappedType = getTypeFromTypeNode(parent);
49778
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
49779
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
49780
+ if (typeParameter) {
49781
+ var constraint = getConstraintOfTypeParameter(typeParameter);
49782
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
49783
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
49784
+ }
49785
+ }
49786
+ }
49787
+ }
49775
49788
  node = parent;
49776
49789
  }
49777
49790
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -50658,7 +50671,7 @@ var ts;
50658
50671
  while (i > 0) {
50659
50672
  i--;
50660
50673
  var t = types[i];
50661
- var remove = t.flags & 4 && includes & 128 ||
50674
+ var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) ||
50662
50675
  t.flags & 8 && includes & 256 ||
50663
50676
  t.flags & 64 && includes & 2048 ||
50664
50677
  t.flags & 4096 && includes & 8192;
@@ -50781,7 +50794,7 @@ var ts;
50781
50794
  if (!strictNullChecks && includes & 98304) {
50782
50795
  return includes & 32768 ? undefinedType : nullType;
50783
50796
  }
50784
- if (includes & 4 && includes & 128 ||
50797
+ if (includes & 4 && includes & (128 | 134217728 | 268435456) ||
50785
50798
  includes & 8 && includes & 256 ||
50786
50799
  includes & 64 && includes & 2048 ||
50787
50800
  includes & 4096 && includes & 8192) {
@@ -52449,7 +52462,7 @@ var ts;
52449
52462
  if (!type.declaration.nameType) {
52450
52463
  var constraint = void 0;
52451
52464
  if (isArrayType(t) || t.flags & 1 && findResolutionCycleStartIndex(typeVariable, 4) < 0 &&
52452
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
52465
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
52453
52466
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
52454
52467
  }
52455
52468
  if (isGenericTupleType(t)) {
@@ -53744,7 +53757,7 @@ var ts;
53744
53757
  }
53745
53758
  return false;
53746
53759
  }
53747
- return isTupleType(target) || isArrayType(target);
53760
+ return isArrayOrTupleType(target);
53748
53761
  }
53749
53762
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
53750
53763
  if (reportErrors) {
@@ -53840,7 +53853,7 @@ var ts;
53840
53853
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
53841
53854
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
53842
53855
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53843
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) {
53856
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) {
53844
53857
  inPropertyCheck = true;
53845
53858
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53846
53859
  inPropertyCheck = false;
@@ -54659,7 +54672,7 @@ var ts;
54659
54672
  return varianceResult;
54660
54673
  }
54661
54674
  }
54662
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54675
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54663
54676
  if (relation !== identityRelation) {
54664
54677
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3, reportErrors);
54665
54678
  }
@@ -54953,7 +54966,7 @@ var ts;
54953
54966
  }
54954
54967
  var result = -1;
54955
54968
  if (isTupleType(target)) {
54956
- if (isArrayType(source) || isTupleType(source)) {
54969
+ if (isArrayOrTupleType(source)) {
54957
54970
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
54958
54971
  return 0;
54959
54972
  }
@@ -55800,6 +55813,9 @@ var ts;
55800
55813
  function isReadonlyArrayType(type) {
55801
55814
  return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
55802
55815
  }
55816
+ function isArrayOrTupleType(type) {
55817
+ return isArrayType(type) || isTupleType(type);
55818
+ }
55803
55819
  function isMutableArrayOrTuple(type) {
55804
55820
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
55805
55821
  }
@@ -56197,7 +56213,7 @@ var ts;
56197
56213
  else if (type.flags & 2097152) {
56198
56214
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
56199
56215
  }
56200
- else if (isArrayType(type) || isTupleType(type)) {
56216
+ else if (isArrayOrTupleType(type)) {
56201
56217
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
56202
56218
  }
56203
56219
  if (result && context === undefined) {
@@ -56223,7 +56239,7 @@ var ts;
56223
56239
  }
56224
56240
  }
56225
56241
  }
56226
- if (isArrayType(type) || isTupleType(type)) {
56242
+ if (isArrayOrTupleType(type)) {
56227
56243
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
56228
56244
  var t = _c[_b];
56229
56245
  if (reportWideningErrorsInType(t)) {
@@ -57125,7 +57141,7 @@ var ts;
57125
57141
  }
57126
57142
  }
57127
57143
  if (!typesDefinitelyUnrelated(source, target)) {
57128
- if (isArrayType(source) || isTupleType(source)) {
57144
+ if (isArrayOrTupleType(source)) {
57129
57145
  if (isTupleType(target)) {
57130
57146
  var sourceArity = getTypeReferenceArity(source);
57131
57147
  var targetArity = getTypeReferenceArity(target);
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.20220425";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -48336,6 +48336,7 @@ var ts;
48336
48336
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48337
48337
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48338
48338
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48339
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48339
48340
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48340
48341
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48341
48342
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -58720,7 +58721,7 @@ var ts;
58720
58721
  var typeVariable = getHomomorphicTypeVariable(type);
58721
58722
  if (typeVariable && !type.declaration.nameType) {
58722
58723
  var constraint = getConstraintOfTypeParameter(typeVariable);
58723
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58724
+ if (constraint && isArrayOrTupleType(constraint)) {
58724
58725
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58725
58726
  }
58726
58727
  }
@@ -59082,10 +59083,10 @@ var ts;
59082
59083
  }
59083
59084
  function isApplicableIndexType(source, target) {
59084
59085
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59085
- // signature applies to types assignable to 'number' and numeric string literal types.
59086
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59086
59087
  return isTypeAssignableTo(source, target) ||
59087
59088
  target === stringType && isTypeAssignableTo(source, numberType) ||
59088
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59089
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59089
59090
  }
59090
59091
  function getIndexInfosOfStructuredType(type) {
59091
59092
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60101,6 +60102,20 @@ var ts;
60101
60102
  constraints = ts.append(constraints, constraint);
60102
60103
  }
60103
60104
  }
60105
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60106
+ // template type XXX, K has an added constraint of number | `${number}`.
60107
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60108
+ var mappedType = getTypeFromTypeNode(parent);
60109
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60110
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60111
+ if (typeParameter) {
60112
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60113
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60114
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60115
+ }
60116
+ }
60117
+ }
60118
+ }
60104
60119
  node = parent;
60105
60120
  }
60106
60121
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61068,7 +61083,7 @@ var ts;
61068
61083
  while (i > 0) {
61069
61084
  i--;
61070
61085
  var t = types[i];
61071
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61086
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61072
61087
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61073
61088
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61074
61089
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61227,7 +61242,7 @@ var ts;
61227
61242
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61228
61243
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61229
61244
  }
61230
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61245
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61231
61246
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61232
61247
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61233
61248
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63111,7 +63126,7 @@ var ts;
63111
63126
  if (!type.declaration.nameType) {
63112
63127
  var constraint = void 0;
63113
63128
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63114
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63129
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63115
63130
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63116
63131
  }
63117
63132
  if (isGenericTupleType(t)) {
@@ -64549,7 +64564,7 @@ var ts;
64549
64564
  }
64550
64565
  return false;
64551
64566
  }
64552
- return isTupleType(target) || isArrayType(target);
64567
+ return isArrayOrTupleType(target);
64553
64568
  }
64554
64569
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64555
64570
  if (reportErrors) {
@@ -64679,7 +64694,7 @@ var ts;
64679
64694
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64680
64695
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64681
64696
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64682
- 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 */); }))) {
64697
+ 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 */); }))) {
64683
64698
  inPropertyCheck = true;
64684
64699
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64685
64700
  inPropertyCheck = false;
@@ -65667,7 +65682,7 @@ var ts;
65667
65682
  return varianceResult;
65668
65683
  }
65669
65684
  }
65670
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65685
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65671
65686
  if (relation !== identityRelation) {
65672
65687
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65673
65688
  }
@@ -66043,7 +66058,7 @@ var ts;
66043
66058
  }
66044
66059
  var result = -1 /* True */;
66045
66060
  if (isTupleType(target)) {
66046
- if (isArrayType(source) || isTupleType(source)) {
66061
+ if (isArrayOrTupleType(source)) {
66047
66062
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66048
66063
  return 0 /* False */;
66049
66064
  }
@@ -67004,6 +67019,9 @@ var ts;
67004
67019
  function isReadonlyArrayType(type) {
67005
67020
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67006
67021
  }
67022
+ function isArrayOrTupleType(type) {
67023
+ return isArrayType(type) || isTupleType(type);
67024
+ }
67007
67025
  function isMutableArrayOrTuple(type) {
67008
67026
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67009
67027
  }
@@ -67455,7 +67473,7 @@ var ts;
67455
67473
  else if (type.flags & 2097152 /* Intersection */) {
67456
67474
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67457
67475
  }
67458
- else if (isArrayType(type) || isTupleType(type)) {
67476
+ else if (isArrayOrTupleType(type)) {
67459
67477
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67460
67478
  }
67461
67479
  if (result && context === undefined) {
@@ -67492,7 +67510,7 @@ var ts;
67492
67510
  }
67493
67511
  }
67494
67512
  }
67495
- if (isArrayType(type) || isTupleType(type)) {
67513
+ if (isArrayOrTupleType(type)) {
67496
67514
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67497
67515
  var t = _c[_b];
67498
67516
  if (reportWideningErrorsInType(t)) {
@@ -68553,7 +68571,7 @@ var ts;
68553
68571
  }
68554
68572
  // Infer from the members of source and target only if the two types are possibly related
68555
68573
  if (!typesDefinitelyUnrelated(source, target)) {
68556
- if (isArrayType(source) || isTupleType(source)) {
68574
+ if (isArrayOrTupleType(source)) {
68557
68575
  if (isTupleType(target)) {
68558
68576
  var sourceArity = getTypeReferenceArity(source);
68559
68577
  var targetArity = getTypeReferenceArity(target);
@@ -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-dev.20220425";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -48530,6 +48530,7 @@ var ts;
48530
48530
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48531
48531
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48532
48532
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48533
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48533
48534
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48534
48535
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48535
48536
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -58914,7 +58915,7 @@ var ts;
58914
58915
  var typeVariable = getHomomorphicTypeVariable(type);
58915
58916
  if (typeVariable && !type.declaration.nameType) {
58916
58917
  var constraint = getConstraintOfTypeParameter(typeVariable);
58917
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58918
+ if (constraint && isArrayOrTupleType(constraint)) {
58918
58919
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58919
58920
  }
58920
58921
  }
@@ -59276,10 +59277,10 @@ var ts;
59276
59277
  }
59277
59278
  function isApplicableIndexType(source, target) {
59278
59279
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59279
- // 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.
59280
59281
  return isTypeAssignableTo(source, target) ||
59281
59282
  target === stringType && isTypeAssignableTo(source, numberType) ||
59282
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59283
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59283
59284
  }
59284
59285
  function getIndexInfosOfStructuredType(type) {
59285
59286
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60295,6 +60296,20 @@ var ts;
60295
60296
  constraints = ts.append(constraints, constraint);
60296
60297
  }
60297
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
+ }
60298
60313
  node = parent;
60299
60314
  }
60300
60315
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61262,7 +61277,7 @@ var ts;
61262
61277
  while (i > 0) {
61263
61278
  i--;
61264
61279
  var t = types[i];
61265
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61280
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61266
61281
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61267
61282
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61268
61283
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61421,7 +61436,7 @@ var ts;
61421
61436
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61422
61437
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61423
61438
  }
61424
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61439
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61425
61440
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61426
61441
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61427
61442
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63305,7 +63320,7 @@ var ts;
63305
63320
  if (!type.declaration.nameType) {
63306
63321
  var constraint = void 0;
63307
63322
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63308
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63323
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63309
63324
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63310
63325
  }
63311
63326
  if (isGenericTupleType(t)) {
@@ -64743,7 +64758,7 @@ var ts;
64743
64758
  }
64744
64759
  return false;
64745
64760
  }
64746
- return isTupleType(target) || isArrayType(target);
64761
+ return isArrayOrTupleType(target);
64747
64762
  }
64748
64763
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64749
64764
  if (reportErrors) {
@@ -64873,7 +64888,7 @@ var ts;
64873
64888
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64874
64889
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64875
64890
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64876
- 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 */); }))) {
64877
64892
  inPropertyCheck = true;
64878
64893
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64879
64894
  inPropertyCheck = false;
@@ -65861,7 +65876,7 @@ var ts;
65861
65876
  return varianceResult;
65862
65877
  }
65863
65878
  }
65864
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65879
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65865
65880
  if (relation !== identityRelation) {
65866
65881
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65867
65882
  }
@@ -66237,7 +66252,7 @@ var ts;
66237
66252
  }
66238
66253
  var result = -1 /* True */;
66239
66254
  if (isTupleType(target)) {
66240
- if (isArrayType(source) || isTupleType(source)) {
66255
+ if (isArrayOrTupleType(source)) {
66241
66256
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66242
66257
  return 0 /* False */;
66243
66258
  }
@@ -67198,6 +67213,9 @@ var ts;
67198
67213
  function isReadonlyArrayType(type) {
67199
67214
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67200
67215
  }
67216
+ function isArrayOrTupleType(type) {
67217
+ return isArrayType(type) || isTupleType(type);
67218
+ }
67201
67219
  function isMutableArrayOrTuple(type) {
67202
67220
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67203
67221
  }
@@ -67649,7 +67667,7 @@ var ts;
67649
67667
  else if (type.flags & 2097152 /* Intersection */) {
67650
67668
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67651
67669
  }
67652
- else if (isArrayType(type) || isTupleType(type)) {
67670
+ else if (isArrayOrTupleType(type)) {
67653
67671
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67654
67672
  }
67655
67673
  if (result && context === undefined) {
@@ -67686,7 +67704,7 @@ var ts;
67686
67704
  }
67687
67705
  }
67688
67706
  }
67689
- if (isArrayType(type) || isTupleType(type)) {
67707
+ if (isArrayOrTupleType(type)) {
67690
67708
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67691
67709
  var t = _c[_b];
67692
67710
  if (reportWideningErrorsInType(t)) {
@@ -68747,7 +68765,7 @@ var ts;
68747
68765
  }
68748
68766
  // Infer from the members of source and target only if the two types are possibly related
68749
68767
  if (!typesDefinitelyUnrelated(source, target)) {
68750
- if (isArrayType(source) || isTupleType(source)) {
68768
+ if (isArrayOrTupleType(source)) {
68751
68769
  if (isTupleType(target)) {
68752
68770
  var sourceArity = getTypeReferenceArity(source);
68753
68771
  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-dev.20220425";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -48530,6 +48530,7 @@ var ts;
48530
48530
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48531
48531
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48532
48532
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48533
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48533
48534
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48534
48535
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48535
48536
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -58914,7 +58915,7 @@ var ts;
58914
58915
  var typeVariable = getHomomorphicTypeVariable(type);
58915
58916
  if (typeVariable && !type.declaration.nameType) {
58916
58917
  var constraint = getConstraintOfTypeParameter(typeVariable);
58917
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58918
+ if (constraint && isArrayOrTupleType(constraint)) {
58918
58919
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58919
58920
  }
58920
58921
  }
@@ -59276,10 +59277,10 @@ var ts;
59276
59277
  }
59277
59278
  function isApplicableIndexType(source, target) {
59278
59279
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59279
- // 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.
59280
59281
  return isTypeAssignableTo(source, target) ||
59281
59282
  target === stringType && isTypeAssignableTo(source, numberType) ||
59282
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59283
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59283
59284
  }
59284
59285
  function getIndexInfosOfStructuredType(type) {
59285
59286
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60295,6 +60296,20 @@ var ts;
60295
60296
  constraints = ts.append(constraints, constraint);
60296
60297
  }
60297
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
+ }
60298
60313
  node = parent;
60299
60314
  }
60300
60315
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61262,7 +61277,7 @@ var ts;
61262
61277
  while (i > 0) {
61263
61278
  i--;
61264
61279
  var t = types[i];
61265
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61280
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61266
61281
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61267
61282
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61268
61283
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61421,7 +61436,7 @@ var ts;
61421
61436
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61422
61437
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61423
61438
  }
61424
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61439
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61425
61440
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61426
61441
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61427
61442
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63305,7 +63320,7 @@ var ts;
63305
63320
  if (!type.declaration.nameType) {
63306
63321
  var constraint = void 0;
63307
63322
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63308
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63323
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63309
63324
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63310
63325
  }
63311
63326
  if (isGenericTupleType(t)) {
@@ -64743,7 +64758,7 @@ var ts;
64743
64758
  }
64744
64759
  return false;
64745
64760
  }
64746
- return isTupleType(target) || isArrayType(target);
64761
+ return isArrayOrTupleType(target);
64747
64762
  }
64748
64763
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64749
64764
  if (reportErrors) {
@@ -64873,7 +64888,7 @@ var ts;
64873
64888
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64874
64889
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64875
64890
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64876
- 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 */); }))) {
64877
64892
  inPropertyCheck = true;
64878
64893
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64879
64894
  inPropertyCheck = false;
@@ -65861,7 +65876,7 @@ var ts;
65861
65876
  return varianceResult;
65862
65877
  }
65863
65878
  }
65864
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65879
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65865
65880
  if (relation !== identityRelation) {
65866
65881
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65867
65882
  }
@@ -66237,7 +66252,7 @@ var ts;
66237
66252
  }
66238
66253
  var result = -1 /* True */;
66239
66254
  if (isTupleType(target)) {
66240
- if (isArrayType(source) || isTupleType(source)) {
66255
+ if (isArrayOrTupleType(source)) {
66241
66256
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66242
66257
  return 0 /* False */;
66243
66258
  }
@@ -67198,6 +67213,9 @@ var ts;
67198
67213
  function isReadonlyArrayType(type) {
67199
67214
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67200
67215
  }
67216
+ function isArrayOrTupleType(type) {
67217
+ return isArrayType(type) || isTupleType(type);
67218
+ }
67201
67219
  function isMutableArrayOrTuple(type) {
67202
67220
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67203
67221
  }
@@ -67649,7 +67667,7 @@ var ts;
67649
67667
  else if (type.flags & 2097152 /* Intersection */) {
67650
67668
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67651
67669
  }
67652
- else if (isArrayType(type) || isTupleType(type)) {
67670
+ else if (isArrayOrTupleType(type)) {
67653
67671
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67654
67672
  }
67655
67673
  if (result && context === undefined) {
@@ -67686,7 +67704,7 @@ var ts;
67686
67704
  }
67687
67705
  }
67688
67706
  }
67689
- if (isArrayType(type) || isTupleType(type)) {
67707
+ if (isArrayOrTupleType(type)) {
67690
67708
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67691
67709
  var t = _c[_b];
67692
67710
  if (reportWideningErrorsInType(t)) {
@@ -68747,7 +68765,7 @@ var ts;
68747
68765
  }
68748
68766
  // Infer from the members of source and target only if the two types are possibly related
68749
68767
  if (!typesDefinitelyUnrelated(source, target)) {
68750
- if (isArrayType(source) || isTupleType(source)) {
68768
+ if (isArrayOrTupleType(source)) {
68751
68769
  if (isTupleType(target)) {
68752
68770
  var sourceArity = getTypeReferenceArity(source);
68753
68771
  var targetArity = getTypeReferenceArity(target);
@@ -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-dev.20220425";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -48530,6 +48530,7 @@ var ts;
48530
48530
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48531
48531
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48532
48532
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48533
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48533
48534
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48534
48535
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48535
48536
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -58914,7 +58915,7 @@ var ts;
58914
58915
  var typeVariable = getHomomorphicTypeVariable(type);
58915
58916
  if (typeVariable && !type.declaration.nameType) {
58916
58917
  var constraint = getConstraintOfTypeParameter(typeVariable);
58917
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58918
+ if (constraint && isArrayOrTupleType(constraint)) {
58918
58919
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58919
58920
  }
58920
58921
  }
@@ -59276,10 +59277,10 @@ var ts;
59276
59277
  }
59277
59278
  function isApplicableIndexType(source, target) {
59278
59279
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59279
- // 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.
59280
59281
  return isTypeAssignableTo(source, target) ||
59281
59282
  target === stringType && isTypeAssignableTo(source, numberType) ||
59282
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59283
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59283
59284
  }
59284
59285
  function getIndexInfosOfStructuredType(type) {
59285
59286
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60295,6 +60296,20 @@ var ts;
60295
60296
  constraints = ts.append(constraints, constraint);
60296
60297
  }
60297
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
+ }
60298
60313
  node = parent;
60299
60314
  }
60300
60315
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61262,7 +61277,7 @@ var ts;
61262
61277
  while (i > 0) {
61263
61278
  i--;
61264
61279
  var t = types[i];
61265
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61280
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61266
61281
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61267
61282
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61268
61283
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61421,7 +61436,7 @@ var ts;
61421
61436
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61422
61437
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61423
61438
  }
61424
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61439
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61425
61440
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61426
61441
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61427
61442
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63305,7 +63320,7 @@ var ts;
63305
63320
  if (!type.declaration.nameType) {
63306
63321
  var constraint = void 0;
63307
63322
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63308
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63323
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63309
63324
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63310
63325
  }
63311
63326
  if (isGenericTupleType(t)) {
@@ -64743,7 +64758,7 @@ var ts;
64743
64758
  }
64744
64759
  return false;
64745
64760
  }
64746
- return isTupleType(target) || isArrayType(target);
64761
+ return isArrayOrTupleType(target);
64747
64762
  }
64748
64763
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64749
64764
  if (reportErrors) {
@@ -64873,7 +64888,7 @@ var ts;
64873
64888
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64874
64889
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64875
64890
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64876
- 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 */); }))) {
64877
64892
  inPropertyCheck = true;
64878
64893
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64879
64894
  inPropertyCheck = false;
@@ -65861,7 +65876,7 @@ var ts;
65861
65876
  return varianceResult;
65862
65877
  }
65863
65878
  }
65864
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65879
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65865
65880
  if (relation !== identityRelation) {
65866
65881
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65867
65882
  }
@@ -66237,7 +66252,7 @@ var ts;
66237
66252
  }
66238
66253
  var result = -1 /* True */;
66239
66254
  if (isTupleType(target)) {
66240
- if (isArrayType(source) || isTupleType(source)) {
66255
+ if (isArrayOrTupleType(source)) {
66241
66256
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66242
66257
  return 0 /* False */;
66243
66258
  }
@@ -67198,6 +67213,9 @@ var ts;
67198
67213
  function isReadonlyArrayType(type) {
67199
67214
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
67200
67215
  }
67216
+ function isArrayOrTupleType(type) {
67217
+ return isArrayType(type) || isTupleType(type);
67218
+ }
67201
67219
  function isMutableArrayOrTuple(type) {
67202
67220
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
67203
67221
  }
@@ -67649,7 +67667,7 @@ var ts;
67649
67667
  else if (type.flags & 2097152 /* Intersection */) {
67650
67668
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67651
67669
  }
67652
- else if (isArrayType(type) || isTupleType(type)) {
67670
+ else if (isArrayOrTupleType(type)) {
67653
67671
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67654
67672
  }
67655
67673
  if (result && context === undefined) {
@@ -67686,7 +67704,7 @@ var ts;
67686
67704
  }
67687
67705
  }
67688
67706
  }
67689
- if (isArrayType(type) || isTupleType(type)) {
67707
+ if (isArrayOrTupleType(type)) {
67690
67708
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67691
67709
  var t = _c[_b];
67692
67710
  if (reportWideningErrorsInType(t)) {
@@ -68747,7 +68765,7 @@ var ts;
68747
68765
  }
68748
68766
  // Infer from the members of source and target only if the two types are possibly related
68749
68767
  if (!typesDefinitelyUnrelated(source, target)) {
68750
- if (isArrayType(source) || isTupleType(source)) {
68768
+ if (isArrayOrTupleType(source)) {
68751
68769
  if (isTupleType(target)) {
68752
68770
  var sourceArity = getTypeReferenceArity(source);
68753
68771
  var targetArity = getTypeReferenceArity(target);
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220425";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220426";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -48325,6 +48325,7 @@ var ts;
48325
48325
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48326
48326
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48327
48327
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48328
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48328
48329
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48329
48330
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48330
48331
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -58709,7 +58710,7 @@ var ts;
58709
58710
  var typeVariable = getHomomorphicTypeVariable(type);
58710
58711
  if (typeVariable && !type.declaration.nameType) {
58711
58712
  var constraint = getConstraintOfTypeParameter(typeVariable);
58712
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58713
+ if (constraint && isArrayOrTupleType(constraint)) {
58713
58714
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58714
58715
  }
58715
58716
  }
@@ -59071,10 +59072,10 @@ var ts;
59071
59072
  }
59072
59073
  function isApplicableIndexType(source, target) {
59073
59074
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59074
- // signature applies to types assignable to 'number' and numeric string literal types.
59075
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59075
59076
  return isTypeAssignableTo(source, target) ||
59076
59077
  target === stringType && isTypeAssignableTo(source, numberType) ||
59077
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59078
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59078
59079
  }
59079
59080
  function getIndexInfosOfStructuredType(type) {
59080
59081
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60090,6 +60091,20 @@ var ts;
60090
60091
  constraints = ts.append(constraints, constraint);
60091
60092
  }
60092
60093
  }
60094
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60095
+ // template type XXX, K has an added constraint of number | `${number}`.
60096
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60097
+ var mappedType = getTypeFromTypeNode(parent);
60098
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60099
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60100
+ if (typeParameter) {
60101
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60102
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60103
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60104
+ }
60105
+ }
60106
+ }
60107
+ }
60093
60108
  node = parent;
60094
60109
  }
60095
60110
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61057,7 +61072,7 @@ var ts;
61057
61072
  while (i > 0) {
61058
61073
  i--;
61059
61074
  var t = types[i];
61060
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61075
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61061
61076
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61062
61077
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61063
61078
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61216,7 +61231,7 @@ var ts;
61216
61231
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61217
61232
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61218
61233
  }
61219
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61234
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61220
61235
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61221
61236
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61222
61237
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63100,7 +63115,7 @@ var ts;
63100
63115
  if (!type.declaration.nameType) {
63101
63116
  var constraint = void 0;
63102
63117
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63103
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63118
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63104
63119
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63105
63120
  }
63106
63121
  if (isGenericTupleType(t)) {
@@ -64538,7 +64553,7 @@ var ts;
64538
64553
  }
64539
64554
  return false;
64540
64555
  }
64541
- return isTupleType(target) || isArrayType(target);
64556
+ return isArrayOrTupleType(target);
64542
64557
  }
64543
64558
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64544
64559
  if (reportErrors) {
@@ -64668,7 +64683,7 @@ var ts;
64668
64683
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64669
64684
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64670
64685
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64671
- 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 */); }))) {
64686
+ 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 */); }))) {
64672
64687
  inPropertyCheck = true;
64673
64688
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64674
64689
  inPropertyCheck = false;
@@ -65656,7 +65671,7 @@ var ts;
65656
65671
  return varianceResult;
65657
65672
  }
65658
65673
  }
65659
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65674
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65660
65675
  if (relation !== identityRelation) {
65661
65676
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65662
65677
  }
@@ -66032,7 +66047,7 @@ var ts;
66032
66047
  }
66033
66048
  var result = -1 /* True */;
66034
66049
  if (isTupleType(target)) {
66035
- if (isArrayType(source) || isTupleType(source)) {
66050
+ if (isArrayOrTupleType(source)) {
66036
66051
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66037
66052
  return 0 /* False */;
66038
66053
  }
@@ -66993,6 +67008,9 @@ var ts;
66993
67008
  function isReadonlyArrayType(type) {
66994
67009
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
66995
67010
  }
67011
+ function isArrayOrTupleType(type) {
67012
+ return isArrayType(type) || isTupleType(type);
67013
+ }
66996
67014
  function isMutableArrayOrTuple(type) {
66997
67015
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
66998
67016
  }
@@ -67444,7 +67462,7 @@ var ts;
67444
67462
  else if (type.flags & 2097152 /* Intersection */) {
67445
67463
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67446
67464
  }
67447
- else if (isArrayType(type) || isTupleType(type)) {
67465
+ else if (isArrayOrTupleType(type)) {
67448
67466
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67449
67467
  }
67450
67468
  if (result && context === undefined) {
@@ -67481,7 +67499,7 @@ var ts;
67481
67499
  }
67482
67500
  }
67483
67501
  }
67484
- if (isArrayType(type) || isTupleType(type)) {
67502
+ if (isArrayOrTupleType(type)) {
67485
67503
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67486
67504
  var t = _c[_b];
67487
67505
  if (reportWideningErrorsInType(t)) {
@@ -68542,7 +68560,7 @@ var ts;
68542
68560
  }
68543
68561
  // Infer from the members of source and target only if the two types are possibly related
68544
68562
  if (!typesDefinitelyUnrelated(source, target)) {
68545
- if (isArrayType(source) || isTupleType(source)) {
68563
+ if (isArrayOrTupleType(source)) {
68546
68564
  if (isTupleType(target)) {
68547
68565
  var sourceArity = getTypeReferenceArity(source);
68548
68566
  var targetArity = getTypeReferenceArity(target);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.7.0-dev.20220425",
5
+ "version": "4.7.0-dev.20220426",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [