typescript 5.1.0-dev.20230319 → 5.1.0-dev.20230320

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
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.1";
26
- var version = `${versionMajorMinor}.0-dev.20230319`;
26
+ var version = `${versionMajorMinor}.0-dev.20230320`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -3711,7 +3711,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3711
3711
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
3712
3712
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
3713
3713
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
3714
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
3714
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
3715
3715
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
3716
3716
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
3717
3717
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -15716,7 +15716,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
15716
15716
  return (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
15717
15717
  }
15718
15718
  function getObjectFlags(type) {
15719
- return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
15719
+ return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
15720
15720
  }
15721
15721
  function isUMDExportSymbol(symbol) {
15722
15722
  return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
@@ -56488,31 +56488,21 @@ function createTypeChecker(host) {
56488
56488
  }
56489
56489
  return type;
56490
56490
  function addSpans(texts2, types2) {
56491
- const isTextsArray = isArray(texts2);
56492
56491
  for (let i = 0; i < types2.length; i++) {
56493
56492
  const t = types2[i];
56494
- const addText = isTextsArray ? texts2[i + 1] : texts2;
56495
56493
  if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
56496
56494
  text += getTemplateStringForType(t) || "";
56497
- text += addText;
56498
- if (!isTextsArray)
56499
- return true;
56495
+ text += texts2[i + 1];
56500
56496
  } else if (t.flags & 134217728 /* TemplateLiteral */) {
56501
56497
  text += t.texts[0];
56502
56498
  if (!addSpans(t.texts, t.types))
56503
56499
  return false;
56504
- text += addText;
56505
- if (!isTextsArray)
56506
- return true;
56500
+ text += texts2[i + 1];
56507
56501
  } else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
56508
56502
  newTypes.push(t);
56509
56503
  newTexts.push(text);
56510
- text = addText;
56511
- } else if (t.flags & 2097152 /* Intersection */) {
56512
- const added = addSpans(texts2[i + 1], t.types);
56513
- if (!added)
56514
- return false;
56515
- } else if (isTextsArray) {
56504
+ text = texts2[i + 1];
56505
+ } else {
56516
56506
  return false;
56517
56507
  }
56518
56508
  }
@@ -56524,12 +56514,17 @@ function createTypeChecker(host) {
56524
56514
  }
56525
56515
  function createTemplateLiteralType(texts, types) {
56526
56516
  const type = createType(134217728 /* TemplateLiteral */);
56517
+ type.objectFlags = getPropagatingFlagsOfTypes(
56518
+ types,
56519
+ /*excludeKinds*/
56520
+ 98304 /* Nullable */
56521
+ );
56527
56522
  type.texts = texts;
56528
56523
  type.types = types;
56529
56524
  return type;
56530
56525
  }
56531
56526
  function getStringMappingType(symbol, type) {
56532
- return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
56527
+ return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 2097152 /* Intersection */ ? getIntersectionType(map(type.types, (t) => getStringMappingType(symbol, t))) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
56533
56528
  // Mapping<Mapping<T>> === Mapping<T>
56534
56529
  type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
56535
56530
  // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
@@ -56823,6 +56818,9 @@ function createTypeChecker(host) {
56823
56818
  return accessNode.kind === 210 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.kind === 197 /* IndexedAccessType */ ? accessNode.indexType : accessNode.kind === 165 /* ComputedPropertyName */ ? accessNode.expression : accessNode;
56824
56819
  }
56825
56820
  function isPatternLiteralPlaceholderType(type) {
56821
+ if (type.flags & 2097152 /* Intersection */) {
56822
+ return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t));
56823
+ }
56826
56824
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
56827
56825
  }
56828
56826
  function isPatternLiteralType(type) {
@@ -56838,7 +56836,7 @@ function createTypeChecker(host) {
56838
56836
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
56839
56837
  }
56840
56838
  function getGenericObjectFlags(type) {
56841
- if (type.flags & 3145728 /* UnionOrIntersection */) {
56839
+ if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
56842
56840
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
56843
56841
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
56844
56842
  }
@@ -56850,7 +56848,7 @@ function createTypeChecker(host) {
56850
56848
  }
56851
56849
  return type.objectFlags & 12582912 /* IsGenericType */;
56852
56850
  }
56853
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
56851
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
56854
56852
  }
56855
56853
  function getSimplifiedType(type, writing) {
56856
56854
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -57864,6 +57862,9 @@ function createTypeChecker(host) {
57864
57862
  if (!result) {
57865
57863
  const newMapper = createTypeMapper(typeParameters, typeArguments);
57866
57864
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
57865
+ if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
57866
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
57867
+ }
57867
57868
  target.instantiations.set(id, result);
57868
57869
  }
57869
57870
  return result;
@@ -57992,7 +57993,7 @@ function createTypeChecker(host) {
57992
57993
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
57993
57994
  }
57994
57995
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
57995
- const result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol);
57996
+ const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
57996
57997
  if (type.objectFlags & 32 /* Mapped */) {
57997
57998
  result.declaration = type.declaration;
57998
57999
  const origTypeParameter = getTypeParameterFromMappedType(type);
@@ -62500,8 +62501,8 @@ function createTypeChecker(host) {
62500
62501
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
62501
62502
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
62502
62503
  }
62503
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
62504
- if (type.flags & 3899393 /* ObjectFlagsType */) {
62504
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
62505
+ if (type.flags & 138117121 /* ObjectFlagsType */) {
62505
62506
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
62506
62507
  }
62507
62508
  return result;
@@ -66684,30 +66685,52 @@ function createTypeChecker(host) {
66684
66685
  }
66685
66686
  return void 0;
66686
66687
  }
66687
- function getContextualTypeForElementExpression(arrayContextualType, index) {
66688
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
66689
- arrayContextualType,
66690
- (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
66691
- t,
66692
- 0,
66693
- /*endSkipCount*/
66694
- 0,
66695
- /*writing*/
66696
- false,
66697
- /*noReductions*/
66698
- true
66699
- ) : getIteratedTypeOrElementType(
66700
- 1 /* Element */,
66701
- t,
66702
- undefinedType,
66703
- /*errorNode*/
66704
- void 0,
66705
- /*checkAssignability*/
66706
- false
66707
- ),
66688
+ function getSpreadIndices(elements) {
66689
+ let first2, last2;
66690
+ for (let i = 0; i < elements.length; i++) {
66691
+ if (isSpreadElement(elements[i])) {
66692
+ first2 != null ? first2 : first2 = i;
66693
+ last2 = i;
66694
+ }
66695
+ }
66696
+ return { first: first2, last: last2 };
66697
+ }
66698
+ function getContextualTypeForElementExpression(type, index, length2, firstSpreadIndex, lastSpreadIndex) {
66699
+ return type && mapType(
66700
+ type,
66701
+ (t) => {
66702
+ if (isTupleType(t)) {
66703
+ if ((firstSpreadIndex === void 0 || index < firstSpreadIndex) && index < t.target.fixedLength) {
66704
+ return getTypeArguments(t)[index];
66705
+ }
66706
+ const offset = length2 !== void 0 && (lastSpreadIndex === void 0 || index > lastSpreadIndex) ? length2 - index : 0;
66707
+ const fixedEndLength = offset > 0 && t.target.hasRestElement ? getEndElementCount(t.target, 3 /* Fixed */) : 0;
66708
+ if (offset > 0 && offset <= fixedEndLength) {
66709
+ return getTypeArguments(t)[getTypeReferenceArity(t) - offset];
66710
+ }
66711
+ return getElementTypeOfSliceOfTupleType(
66712
+ t,
66713
+ firstSpreadIndex === void 0 ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex),
66714
+ length2 === void 0 || lastSpreadIndex === void 0 ? fixedEndLength : Math.min(fixedEndLength, length2 - lastSpreadIndex),
66715
+ /*writing*/
66716
+ false,
66717
+ /*noReductions*/
66718
+ true
66719
+ );
66720
+ }
66721
+ return (!firstSpreadIndex || index < firstSpreadIndex) && getTypeOfPropertyOfContextualType(t, "" + index) || getIteratedTypeOrElementType(
66722
+ 1 /* Element */,
66723
+ t,
66724
+ undefinedType,
66725
+ /*errorNode*/
66726
+ void 0,
66727
+ /*checkAssignability*/
66728
+ false
66729
+ );
66730
+ },
66708
66731
  /*noReductions*/
66709
66732
  true
66710
- ));
66733
+ );
66711
66734
  }
66712
66735
  function getContextualTypeForConditionalOperand(node, contextFlags) {
66713
66736
  const conditional = node.parent;
@@ -66894,9 +66917,9 @@ function createTypeChecker(host) {
66894
66917
  case 207 /* ArrayLiteralExpression */: {
66895
66918
  const arrayLiteral = parent;
66896
66919
  const type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
66897
- const spreadIndex = (_b = (_a2 = getNodeLinks(arrayLiteral)).firstSpreadIndex) != null ? _b : _a2.firstSpreadIndex = findIndex(arrayLiteral.elements, isSpreadElement);
66898
66920
  const elementIndex = indexOfNode(arrayLiteral.elements, node);
66899
- return getContextualTypeForElementExpression(type, spreadIndex < 0 || elementIndex < spreadIndex ? elementIndex : -1);
66921
+ const spreadIndices = (_b = (_a2 = getNodeLinks(arrayLiteral)).spreadIndices) != null ? _b : _a2.spreadIndices = getSpreadIndices(arrayLiteral.elements);
66922
+ return getContextualTypeForElementExpression(type, elementIndex, arrayLiteral.elements.length, spreadIndices.first, spreadIndices.last);
66900
66923
  }
66901
66924
  case 225 /* ConditionalExpression */:
66902
66925
  return getContextualTypeForConditionalOperand(node, contextFlags);
@@ -69308,7 +69331,7 @@ function createTypeChecker(host) {
69308
69331
  flags.push(4 /* Rest */);
69309
69332
  }
69310
69333
  } else {
69311
- const contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
69334
+ const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
69312
69335
  const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
69313
69336
  const hasPrimitiveContextualType = inConstContext || maybeTypeOfKind(contextualType, 402784252 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
69314
69337
  types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
package/lib/tsserver.js CHANGED
@@ -2285,7 +2285,7 @@ module.exports = __toCommonJS(server_exports);
2285
2285
 
2286
2286
  // src/compiler/corePublic.ts
2287
2287
  var versionMajorMinor = "5.1";
2288
- var version = `${versionMajorMinor}.0-dev.20230319`;
2288
+ var version = `${versionMajorMinor}.0-dev.20230320`;
2289
2289
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2290
2290
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2291
2291
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6632,7 +6632,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6632
6632
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
6633
6633
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
6634
6634
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
6635
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
6635
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
6636
6636
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
6637
6637
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
6638
6638
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -19713,7 +19713,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
19713
19713
  return (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
19714
19714
  }
19715
19715
  function getObjectFlags(type) {
19716
- return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
19716
+ return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
19717
19717
  }
19718
19718
  function forSomeAncestorDirectory(directory, callback) {
19719
19719
  return !!forEachAncestorDirectory(directory, (d) => callback(d) ? true : void 0);
@@ -61085,31 +61085,21 @@ function createTypeChecker(host) {
61085
61085
  }
61086
61086
  return type;
61087
61087
  function addSpans(texts2, types2) {
61088
- const isTextsArray = isArray(texts2);
61089
61088
  for (let i = 0; i < types2.length; i++) {
61090
61089
  const t = types2[i];
61091
- const addText = isTextsArray ? texts2[i + 1] : texts2;
61092
61090
  if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
61093
61091
  text += getTemplateStringForType(t) || "";
61094
- text += addText;
61095
- if (!isTextsArray)
61096
- return true;
61092
+ text += texts2[i + 1];
61097
61093
  } else if (t.flags & 134217728 /* TemplateLiteral */) {
61098
61094
  text += t.texts[0];
61099
61095
  if (!addSpans(t.texts, t.types))
61100
61096
  return false;
61101
- text += addText;
61102
- if (!isTextsArray)
61103
- return true;
61097
+ text += texts2[i + 1];
61104
61098
  } else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
61105
61099
  newTypes.push(t);
61106
61100
  newTexts.push(text);
61107
- text = addText;
61108
- } else if (t.flags & 2097152 /* Intersection */) {
61109
- const added = addSpans(texts2[i + 1], t.types);
61110
- if (!added)
61111
- return false;
61112
- } else if (isTextsArray) {
61101
+ text = texts2[i + 1];
61102
+ } else {
61113
61103
  return false;
61114
61104
  }
61115
61105
  }
@@ -61121,12 +61111,17 @@ function createTypeChecker(host) {
61121
61111
  }
61122
61112
  function createTemplateLiteralType(texts, types) {
61123
61113
  const type = createType(134217728 /* TemplateLiteral */);
61114
+ type.objectFlags = getPropagatingFlagsOfTypes(
61115
+ types,
61116
+ /*excludeKinds*/
61117
+ 98304 /* Nullable */
61118
+ );
61124
61119
  type.texts = texts;
61125
61120
  type.types = types;
61126
61121
  return type;
61127
61122
  }
61128
61123
  function getStringMappingType(symbol, type) {
61129
- return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
61124
+ return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 2097152 /* Intersection */ ? getIntersectionType(map(type.types, (t) => getStringMappingType(symbol, t))) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
61130
61125
  // Mapping<Mapping<T>> === Mapping<T>
61131
61126
  type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
61132
61127
  // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
@@ -61420,6 +61415,9 @@ function createTypeChecker(host) {
61420
61415
  return accessNode.kind === 210 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.kind === 197 /* IndexedAccessType */ ? accessNode.indexType : accessNode.kind === 165 /* ComputedPropertyName */ ? accessNode.expression : accessNode;
61421
61416
  }
61422
61417
  function isPatternLiteralPlaceholderType(type) {
61418
+ if (type.flags & 2097152 /* Intersection */) {
61419
+ return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t));
61420
+ }
61423
61421
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
61424
61422
  }
61425
61423
  function isPatternLiteralType(type) {
@@ -61435,7 +61433,7 @@ function createTypeChecker(host) {
61435
61433
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
61436
61434
  }
61437
61435
  function getGenericObjectFlags(type) {
61438
- if (type.flags & 3145728 /* UnionOrIntersection */) {
61436
+ if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
61439
61437
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
61440
61438
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
61441
61439
  }
@@ -61447,7 +61445,7 @@ function createTypeChecker(host) {
61447
61445
  }
61448
61446
  return type.objectFlags & 12582912 /* IsGenericType */;
61449
61447
  }
61450
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
61448
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
61451
61449
  }
61452
61450
  function getSimplifiedType(type, writing) {
61453
61451
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -62461,6 +62459,9 @@ function createTypeChecker(host) {
62461
62459
  if (!result) {
62462
62460
  const newMapper = createTypeMapper(typeParameters, typeArguments);
62463
62461
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62462
+ if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
62463
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
62464
+ }
62464
62465
  target.instantiations.set(id, result);
62465
62466
  }
62466
62467
  return result;
@@ -62589,7 +62590,7 @@ function createTypeChecker(host) {
62589
62590
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
62590
62591
  }
62591
62592
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
62592
- const result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol);
62593
+ const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
62593
62594
  if (type.objectFlags & 32 /* Mapped */) {
62594
62595
  result.declaration = type.declaration;
62595
62596
  const origTypeParameter = getTypeParameterFromMappedType(type);
@@ -67097,8 +67098,8 @@ function createTypeChecker(host) {
67097
67098
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
67098
67099
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
67099
67100
  }
67100
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
67101
- if (type.flags & 3899393 /* ObjectFlagsType */) {
67101
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
67102
+ if (type.flags & 138117121 /* ObjectFlagsType */) {
67102
67103
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
67103
67104
  }
67104
67105
  return result;
@@ -71281,30 +71282,52 @@ function createTypeChecker(host) {
71281
71282
  }
71282
71283
  return void 0;
71283
71284
  }
71284
- function getContextualTypeForElementExpression(arrayContextualType, index) {
71285
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
71286
- arrayContextualType,
71287
- (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
71288
- t,
71289
- 0,
71290
- /*endSkipCount*/
71291
- 0,
71292
- /*writing*/
71293
- false,
71294
- /*noReductions*/
71295
- true
71296
- ) : getIteratedTypeOrElementType(
71297
- 1 /* Element */,
71298
- t,
71299
- undefinedType,
71300
- /*errorNode*/
71301
- void 0,
71302
- /*checkAssignability*/
71303
- false
71304
- ),
71285
+ function getSpreadIndices(elements) {
71286
+ let first2, last2;
71287
+ for (let i = 0; i < elements.length; i++) {
71288
+ if (isSpreadElement(elements[i])) {
71289
+ first2 != null ? first2 : first2 = i;
71290
+ last2 = i;
71291
+ }
71292
+ }
71293
+ return { first: first2, last: last2 };
71294
+ }
71295
+ function getContextualTypeForElementExpression(type, index, length2, firstSpreadIndex, lastSpreadIndex) {
71296
+ return type && mapType(
71297
+ type,
71298
+ (t) => {
71299
+ if (isTupleType(t)) {
71300
+ if ((firstSpreadIndex === void 0 || index < firstSpreadIndex) && index < t.target.fixedLength) {
71301
+ return getTypeArguments(t)[index];
71302
+ }
71303
+ const offset = length2 !== void 0 && (lastSpreadIndex === void 0 || index > lastSpreadIndex) ? length2 - index : 0;
71304
+ const fixedEndLength = offset > 0 && t.target.hasRestElement ? getEndElementCount(t.target, 3 /* Fixed */) : 0;
71305
+ if (offset > 0 && offset <= fixedEndLength) {
71306
+ return getTypeArguments(t)[getTypeReferenceArity(t) - offset];
71307
+ }
71308
+ return getElementTypeOfSliceOfTupleType(
71309
+ t,
71310
+ firstSpreadIndex === void 0 ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex),
71311
+ length2 === void 0 || lastSpreadIndex === void 0 ? fixedEndLength : Math.min(fixedEndLength, length2 - lastSpreadIndex),
71312
+ /*writing*/
71313
+ false,
71314
+ /*noReductions*/
71315
+ true
71316
+ );
71317
+ }
71318
+ return (!firstSpreadIndex || index < firstSpreadIndex) && getTypeOfPropertyOfContextualType(t, "" + index) || getIteratedTypeOrElementType(
71319
+ 1 /* Element */,
71320
+ t,
71321
+ undefinedType,
71322
+ /*errorNode*/
71323
+ void 0,
71324
+ /*checkAssignability*/
71325
+ false
71326
+ );
71327
+ },
71305
71328
  /*noReductions*/
71306
71329
  true
71307
- ));
71330
+ );
71308
71331
  }
71309
71332
  function getContextualTypeForConditionalOperand(node, contextFlags) {
71310
71333
  const conditional = node.parent;
@@ -71491,9 +71514,9 @@ function createTypeChecker(host) {
71491
71514
  case 207 /* ArrayLiteralExpression */: {
71492
71515
  const arrayLiteral = parent2;
71493
71516
  const type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
71494
- const spreadIndex = (_b = (_a2 = getNodeLinks(arrayLiteral)).firstSpreadIndex) != null ? _b : _a2.firstSpreadIndex = findIndex(arrayLiteral.elements, isSpreadElement);
71495
71517
  const elementIndex = indexOfNode(arrayLiteral.elements, node);
71496
- return getContextualTypeForElementExpression(type, spreadIndex < 0 || elementIndex < spreadIndex ? elementIndex : -1);
71518
+ const spreadIndices = (_b = (_a2 = getNodeLinks(arrayLiteral)).spreadIndices) != null ? _b : _a2.spreadIndices = getSpreadIndices(arrayLiteral.elements);
71519
+ return getContextualTypeForElementExpression(type, elementIndex, arrayLiteral.elements.length, spreadIndices.first, spreadIndices.last);
71497
71520
  }
71498
71521
  case 225 /* ConditionalExpression */:
71499
71522
  return getContextualTypeForConditionalOperand(node, contextFlags);
@@ -73905,7 +73928,7 @@ function createTypeChecker(host) {
73905
73928
  flags.push(4 /* Rest */);
73906
73929
  }
73907
73930
  } else {
73908
- const contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
73931
+ const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
73909
73932
  const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
73910
73933
  const hasPrimitiveContextualType = inConstContext || maybeTypeOfKind(contextualType, 402784252 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
73911
73934
  types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230319`;
38
+ version = `${versionMajorMinor}.0-dev.20230320`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4439,7 +4439,7 @@ ${lanes.join("\n")}
4439
4439
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
4440
4440
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
4441
4441
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
4442
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
4442
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
4443
4443
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
4444
4444
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
4445
4445
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -17454,7 +17454,7 @@ ${lanes.join("\n")}
17454
17454
  return (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
17455
17455
  }
17456
17456
  function getObjectFlags(type) {
17457
- return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
17457
+ return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
17458
17458
  }
17459
17459
  function forSomeAncestorDirectory(directory, callback) {
17460
17460
  return !!forEachAncestorDirectory(directory, (d) => callback(d) ? true : void 0);
@@ -58895,31 +58895,21 @@ ${lanes.join("\n")}
58895
58895
  }
58896
58896
  return type;
58897
58897
  function addSpans(texts2, types2) {
58898
- const isTextsArray = isArray(texts2);
58899
58898
  for (let i = 0; i < types2.length; i++) {
58900
58899
  const t = types2[i];
58901
- const addText = isTextsArray ? texts2[i + 1] : texts2;
58902
58900
  if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
58903
58901
  text += getTemplateStringForType(t) || "";
58904
- text += addText;
58905
- if (!isTextsArray)
58906
- return true;
58902
+ text += texts2[i + 1];
58907
58903
  } else if (t.flags & 134217728 /* TemplateLiteral */) {
58908
58904
  text += t.texts[0];
58909
58905
  if (!addSpans(t.texts, t.types))
58910
58906
  return false;
58911
- text += addText;
58912
- if (!isTextsArray)
58913
- return true;
58907
+ text += texts2[i + 1];
58914
58908
  } else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
58915
58909
  newTypes.push(t);
58916
58910
  newTexts.push(text);
58917
- text = addText;
58918
- } else if (t.flags & 2097152 /* Intersection */) {
58919
- const added = addSpans(texts2[i + 1], t.types);
58920
- if (!added)
58921
- return false;
58922
- } else if (isTextsArray) {
58911
+ text = texts2[i + 1];
58912
+ } else {
58923
58913
  return false;
58924
58914
  }
58925
58915
  }
@@ -58931,12 +58921,17 @@ ${lanes.join("\n")}
58931
58921
  }
58932
58922
  function createTemplateLiteralType(texts, types) {
58933
58923
  const type = createType(134217728 /* TemplateLiteral */);
58924
+ type.objectFlags = getPropagatingFlagsOfTypes(
58925
+ types,
58926
+ /*excludeKinds*/
58927
+ 98304 /* Nullable */
58928
+ );
58934
58929
  type.texts = texts;
58935
58930
  type.types = types;
58936
58931
  return type;
58937
58932
  }
58938
58933
  function getStringMappingType(symbol, type) {
58939
- return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
58934
+ return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 2097152 /* Intersection */ ? getIntersectionType(map(type.types, (t) => getStringMappingType(symbol, t))) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
58940
58935
  // Mapping<Mapping<T>> === Mapping<T>
58941
58936
  type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
58942
58937
  // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
@@ -59230,6 +59225,9 @@ ${lanes.join("\n")}
59230
59225
  return accessNode.kind === 210 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.kind === 197 /* IndexedAccessType */ ? accessNode.indexType : accessNode.kind === 165 /* ComputedPropertyName */ ? accessNode.expression : accessNode;
59231
59226
  }
59232
59227
  function isPatternLiteralPlaceholderType(type) {
59228
+ if (type.flags & 2097152 /* Intersection */) {
59229
+ return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t));
59230
+ }
59233
59231
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
59234
59232
  }
59235
59233
  function isPatternLiteralType(type) {
@@ -59245,7 +59243,7 @@ ${lanes.join("\n")}
59245
59243
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
59246
59244
  }
59247
59245
  function getGenericObjectFlags(type) {
59248
- if (type.flags & 3145728 /* UnionOrIntersection */) {
59246
+ if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
59249
59247
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
59250
59248
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
59251
59249
  }
@@ -59257,7 +59255,7 @@ ${lanes.join("\n")}
59257
59255
  }
59258
59256
  return type.objectFlags & 12582912 /* IsGenericType */;
59259
59257
  }
59260
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
59258
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
59261
59259
  }
59262
59260
  function getSimplifiedType(type, writing) {
59263
59261
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -60271,6 +60269,9 @@ ${lanes.join("\n")}
60271
60269
  if (!result) {
60272
60270
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60273
60271
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60272
+ if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60273
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60274
+ }
60274
60275
  target.instantiations.set(id, result);
60275
60276
  }
60276
60277
  return result;
@@ -60399,7 +60400,7 @@ ${lanes.join("\n")}
60399
60400
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
60400
60401
  }
60401
60402
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
60402
- const result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol);
60403
+ const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
60403
60404
  if (type.objectFlags & 32 /* Mapped */) {
60404
60405
  result.declaration = type.declaration;
60405
60406
  const origTypeParameter = getTypeParameterFromMappedType(type);
@@ -64907,8 +64908,8 @@ ${lanes.join("\n")}
64907
64908
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
64908
64909
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
64909
64910
  }
64910
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64911
- if (type.flags & 3899393 /* ObjectFlagsType */) {
64911
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64912
+ if (type.flags & 138117121 /* ObjectFlagsType */) {
64912
64913
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
64913
64914
  }
64914
64915
  return result;
@@ -69091,30 +69092,52 @@ ${lanes.join("\n")}
69091
69092
  }
69092
69093
  return void 0;
69093
69094
  }
69094
- function getContextualTypeForElementExpression(arrayContextualType, index) {
69095
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
69096
- arrayContextualType,
69097
- (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
69098
- t,
69099
- 0,
69100
- /*endSkipCount*/
69101
- 0,
69102
- /*writing*/
69103
- false,
69104
- /*noReductions*/
69105
- true
69106
- ) : getIteratedTypeOrElementType(
69107
- 1 /* Element */,
69108
- t,
69109
- undefinedType,
69110
- /*errorNode*/
69111
- void 0,
69112
- /*checkAssignability*/
69113
- false
69114
- ),
69095
+ function getSpreadIndices(elements) {
69096
+ let first2, last2;
69097
+ for (let i = 0; i < elements.length; i++) {
69098
+ if (isSpreadElement(elements[i])) {
69099
+ first2 != null ? first2 : first2 = i;
69100
+ last2 = i;
69101
+ }
69102
+ }
69103
+ return { first: first2, last: last2 };
69104
+ }
69105
+ function getContextualTypeForElementExpression(type, index, length2, firstSpreadIndex, lastSpreadIndex) {
69106
+ return type && mapType(
69107
+ type,
69108
+ (t) => {
69109
+ if (isTupleType(t)) {
69110
+ if ((firstSpreadIndex === void 0 || index < firstSpreadIndex) && index < t.target.fixedLength) {
69111
+ return getTypeArguments(t)[index];
69112
+ }
69113
+ const offset = length2 !== void 0 && (lastSpreadIndex === void 0 || index > lastSpreadIndex) ? length2 - index : 0;
69114
+ const fixedEndLength = offset > 0 && t.target.hasRestElement ? getEndElementCount(t.target, 3 /* Fixed */) : 0;
69115
+ if (offset > 0 && offset <= fixedEndLength) {
69116
+ return getTypeArguments(t)[getTypeReferenceArity(t) - offset];
69117
+ }
69118
+ return getElementTypeOfSliceOfTupleType(
69119
+ t,
69120
+ firstSpreadIndex === void 0 ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex),
69121
+ length2 === void 0 || lastSpreadIndex === void 0 ? fixedEndLength : Math.min(fixedEndLength, length2 - lastSpreadIndex),
69122
+ /*writing*/
69123
+ false,
69124
+ /*noReductions*/
69125
+ true
69126
+ );
69127
+ }
69128
+ return (!firstSpreadIndex || index < firstSpreadIndex) && getTypeOfPropertyOfContextualType(t, "" + index) || getIteratedTypeOrElementType(
69129
+ 1 /* Element */,
69130
+ t,
69131
+ undefinedType,
69132
+ /*errorNode*/
69133
+ void 0,
69134
+ /*checkAssignability*/
69135
+ false
69136
+ );
69137
+ },
69115
69138
  /*noReductions*/
69116
69139
  true
69117
- ));
69140
+ );
69118
69141
  }
69119
69142
  function getContextualTypeForConditionalOperand(node, contextFlags) {
69120
69143
  const conditional = node.parent;
@@ -69301,9 +69324,9 @@ ${lanes.join("\n")}
69301
69324
  case 207 /* ArrayLiteralExpression */: {
69302
69325
  const arrayLiteral = parent2;
69303
69326
  const type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
69304
- const spreadIndex = (_b = (_a2 = getNodeLinks(arrayLiteral)).firstSpreadIndex) != null ? _b : _a2.firstSpreadIndex = findIndex(arrayLiteral.elements, isSpreadElement);
69305
69327
  const elementIndex = indexOfNode(arrayLiteral.elements, node);
69306
- return getContextualTypeForElementExpression(type, spreadIndex < 0 || elementIndex < spreadIndex ? elementIndex : -1);
69328
+ const spreadIndices = (_b = (_a2 = getNodeLinks(arrayLiteral)).spreadIndices) != null ? _b : _a2.spreadIndices = getSpreadIndices(arrayLiteral.elements);
69329
+ return getContextualTypeForElementExpression(type, elementIndex, arrayLiteral.elements.length, spreadIndices.first, spreadIndices.last);
69307
69330
  }
69308
69331
  case 225 /* ConditionalExpression */:
69309
69332
  return getContextualTypeForConditionalOperand(node, contextFlags);
@@ -71715,7 +71738,7 @@ ${lanes.join("\n")}
71715
71738
  flags.push(4 /* Rest */);
71716
71739
  }
71717
71740
  } else {
71718
- const contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
71741
+ const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
71719
71742
  const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
71720
71743
  const hasPrimitiveContextualType = inConstContext || maybeTypeOfKind(contextualType, 402784252 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
71721
71744
  types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230319`;
38
+ version = `${versionMajorMinor}.0-dev.20230320`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4439,7 +4439,7 @@ ${lanes.join("\n")}
4439
4439
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
4440
4440
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
4441
4441
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
4442
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
4442
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
4443
4443
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
4444
4444
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
4445
4445
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
@@ -17454,7 +17454,7 @@ ${lanes.join("\n")}
17454
17454
  return (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
17455
17455
  }
17456
17456
  function getObjectFlags(type) {
17457
- return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
17457
+ return type.flags & 138117121 /* ObjectFlagsType */ ? type.objectFlags : 0;
17458
17458
  }
17459
17459
  function forSomeAncestorDirectory(directory, callback) {
17460
17460
  return !!forEachAncestorDirectory(directory, (d) => callback(d) ? true : void 0);
@@ -58895,31 +58895,21 @@ ${lanes.join("\n")}
58895
58895
  }
58896
58896
  return type;
58897
58897
  function addSpans(texts2, types2) {
58898
- const isTextsArray = isArray(texts2);
58899
58898
  for (let i = 0; i < types2.length; i++) {
58900
58899
  const t = types2[i];
58901
- const addText = isTextsArray ? texts2[i + 1] : texts2;
58902
58900
  if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
58903
58901
  text += getTemplateStringForType(t) || "";
58904
- text += addText;
58905
- if (!isTextsArray)
58906
- return true;
58902
+ text += texts2[i + 1];
58907
58903
  } else if (t.flags & 134217728 /* TemplateLiteral */) {
58908
58904
  text += t.texts[0];
58909
58905
  if (!addSpans(t.texts, t.types))
58910
58906
  return false;
58911
- text += addText;
58912
- if (!isTextsArray)
58913
- return true;
58907
+ text += texts2[i + 1];
58914
58908
  } else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
58915
58909
  newTypes.push(t);
58916
58910
  newTexts.push(text);
58917
- text = addText;
58918
- } else if (t.flags & 2097152 /* Intersection */) {
58919
- const added = addSpans(texts2[i + 1], t.types);
58920
- if (!added)
58921
- return false;
58922
- } else if (isTextsArray) {
58911
+ text = texts2[i + 1];
58912
+ } else {
58923
58913
  return false;
58924
58914
  }
58925
58915
  }
@@ -58931,12 +58921,17 @@ ${lanes.join("\n")}
58931
58921
  }
58932
58922
  function createTemplateLiteralType(texts, types) {
58933
58923
  const type = createType(134217728 /* TemplateLiteral */);
58924
+ type.objectFlags = getPropagatingFlagsOfTypes(
58925
+ types,
58926
+ /*excludeKinds*/
58927
+ 98304 /* Nullable */
58928
+ );
58934
58929
  type.texts = texts;
58935
58930
  type.types = types;
58936
58931
  return type;
58937
58932
  }
58938
58933
  function getStringMappingType(symbol, type) {
58939
- return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
58934
+ return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 2097152 /* Intersection */ ? getIntersectionType(map(type.types, (t) => getStringMappingType(symbol, t))) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
58940
58935
  // Mapping<Mapping<T>> === Mapping<T>
58941
58936
  type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
58942
58937
  // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
@@ -59230,6 +59225,9 @@ ${lanes.join("\n")}
59230
59225
  return accessNode.kind === 210 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.kind === 197 /* IndexedAccessType */ ? accessNode.indexType : accessNode.kind === 165 /* ComputedPropertyName */ ? accessNode.expression : accessNode;
59231
59226
  }
59232
59227
  function isPatternLiteralPlaceholderType(type) {
59228
+ if (type.flags & 2097152 /* Intersection */) {
59229
+ return some(type.types, (t) => !!(t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) || isPatternLiteralPlaceholderType(t));
59230
+ }
59233
59231
  return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
59234
59232
  }
59235
59233
  function isPatternLiteralType(type) {
@@ -59245,7 +59243,7 @@ ${lanes.join("\n")}
59245
59243
  return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
59246
59244
  }
59247
59245
  function getGenericObjectFlags(type) {
59248
- if (type.flags & 3145728 /* UnionOrIntersection */) {
59246
+ if (type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */)) {
59249
59247
  if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
59250
59248
  type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
59251
59249
  }
@@ -59257,7 +59255,7 @@ ${lanes.join("\n")}
59257
59255
  }
59258
59256
  return type.objectFlags & 12582912 /* IsGenericType */;
59259
59257
  }
59260
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
59258
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
59261
59259
  }
59262
59260
  function getSimplifiedType(type, writing) {
59263
59261
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -60271,6 +60269,9 @@ ${lanes.join("\n")}
60271
60269
  if (!result) {
60272
60270
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60273
60271
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60272
+ if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60273
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60274
+ }
60274
60275
  target.instantiations.set(id, result);
60275
60276
  }
60276
60277
  return result;
@@ -60399,7 +60400,7 @@ ${lanes.join("\n")}
60399
60400
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
60400
60401
  }
60401
60402
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
60402
- const result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol);
60403
+ const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
60403
60404
  if (type.objectFlags & 32 /* Mapped */) {
60404
60405
  result.declaration = type.declaration;
60405
60406
  const origTypeParameter = getTypeParameterFromMappedType(type);
@@ -64907,8 +64908,8 @@ ${lanes.join("\n")}
64907
64908
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
64908
64909
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
64909
64910
  }
64910
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64911
- if (type.flags & 3899393 /* ObjectFlagsType */) {
64911
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64912
+ if (type.flags & 138117121 /* ObjectFlagsType */) {
64912
64913
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
64913
64914
  }
64914
64915
  return result;
@@ -69091,30 +69092,52 @@ ${lanes.join("\n")}
69091
69092
  }
69092
69093
  return void 0;
69093
69094
  }
69094
- function getContextualTypeForElementExpression(arrayContextualType, index) {
69095
- return arrayContextualType && (index >= 0 && getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) || mapType(
69096
- arrayContextualType,
69097
- (t) => isTupleType(t) ? getElementTypeOfSliceOfTupleType(
69098
- t,
69099
- 0,
69100
- /*endSkipCount*/
69101
- 0,
69102
- /*writing*/
69103
- false,
69104
- /*noReductions*/
69105
- true
69106
- ) : getIteratedTypeOrElementType(
69107
- 1 /* Element */,
69108
- t,
69109
- undefinedType,
69110
- /*errorNode*/
69111
- void 0,
69112
- /*checkAssignability*/
69113
- false
69114
- ),
69095
+ function getSpreadIndices(elements) {
69096
+ let first2, last2;
69097
+ for (let i = 0; i < elements.length; i++) {
69098
+ if (isSpreadElement(elements[i])) {
69099
+ first2 != null ? first2 : first2 = i;
69100
+ last2 = i;
69101
+ }
69102
+ }
69103
+ return { first: first2, last: last2 };
69104
+ }
69105
+ function getContextualTypeForElementExpression(type, index, length2, firstSpreadIndex, lastSpreadIndex) {
69106
+ return type && mapType(
69107
+ type,
69108
+ (t) => {
69109
+ if (isTupleType(t)) {
69110
+ if ((firstSpreadIndex === void 0 || index < firstSpreadIndex) && index < t.target.fixedLength) {
69111
+ return getTypeArguments(t)[index];
69112
+ }
69113
+ const offset = length2 !== void 0 && (lastSpreadIndex === void 0 || index > lastSpreadIndex) ? length2 - index : 0;
69114
+ const fixedEndLength = offset > 0 && t.target.hasRestElement ? getEndElementCount(t.target, 3 /* Fixed */) : 0;
69115
+ if (offset > 0 && offset <= fixedEndLength) {
69116
+ return getTypeArguments(t)[getTypeReferenceArity(t) - offset];
69117
+ }
69118
+ return getElementTypeOfSliceOfTupleType(
69119
+ t,
69120
+ firstSpreadIndex === void 0 ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex),
69121
+ length2 === void 0 || lastSpreadIndex === void 0 ? fixedEndLength : Math.min(fixedEndLength, length2 - lastSpreadIndex),
69122
+ /*writing*/
69123
+ false,
69124
+ /*noReductions*/
69125
+ true
69126
+ );
69127
+ }
69128
+ return (!firstSpreadIndex || index < firstSpreadIndex) && getTypeOfPropertyOfContextualType(t, "" + index) || getIteratedTypeOrElementType(
69129
+ 1 /* Element */,
69130
+ t,
69131
+ undefinedType,
69132
+ /*errorNode*/
69133
+ void 0,
69134
+ /*checkAssignability*/
69135
+ false
69136
+ );
69137
+ },
69115
69138
  /*noReductions*/
69116
69139
  true
69117
- ));
69140
+ );
69118
69141
  }
69119
69142
  function getContextualTypeForConditionalOperand(node, contextFlags) {
69120
69143
  const conditional = node.parent;
@@ -69301,9 +69324,9 @@ ${lanes.join("\n")}
69301
69324
  case 207 /* ArrayLiteralExpression */: {
69302
69325
  const arrayLiteral = parent2;
69303
69326
  const type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
69304
- const spreadIndex = (_b = (_a2 = getNodeLinks(arrayLiteral)).firstSpreadIndex) != null ? _b : _a2.firstSpreadIndex = findIndex(arrayLiteral.elements, isSpreadElement);
69305
69327
  const elementIndex = indexOfNode(arrayLiteral.elements, node);
69306
- return getContextualTypeForElementExpression(type, spreadIndex < 0 || elementIndex < spreadIndex ? elementIndex : -1);
69328
+ const spreadIndices = (_b = (_a2 = getNodeLinks(arrayLiteral)).spreadIndices) != null ? _b : _a2.spreadIndices = getSpreadIndices(arrayLiteral.elements);
69329
+ return getContextualTypeForElementExpression(type, elementIndex, arrayLiteral.elements.length, spreadIndices.first, spreadIndices.last);
69307
69330
  }
69308
69331
  case 225 /* ConditionalExpression */:
69309
69332
  return getContextualTypeForConditionalOperand(node, contextFlags);
@@ -71715,7 +71738,7 @@ ${lanes.join("\n")}
71715
71738
  flags.push(4 /* Rest */);
71716
71739
  }
71717
71740
  } else {
71718
- const contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
71741
+ const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
71719
71742
  const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
71720
71743
  const hasPrimitiveContextualType = inConstContext || maybeTypeOfKind(contextualType, 402784252 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
71721
71744
  types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230319`;
57
+ var version = `${versionMajorMinor}.0-dev.20230320`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -3117,7 +3117,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3117
3117
  TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
3118
3118
  TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
3119
3119
  TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
3120
- TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
3120
+ TypeFlags2[TypeFlags2["ObjectFlagsType"] = 138117121] = "ObjectFlagsType";
3121
3121
  TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
3122
3122
  TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
3123
3123
  TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
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": "5.1.0-dev.20230319",
5
+ "version": "5.1.0-dev.20230320",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "905a0b4e693e8cc13a726ad650b908fee4f75408"
116
+ "gitHead": "86f811440484f6a91e3d2a5ddaeb05eed8bf95cc"
117
117
  }