typescript 5.6.0-dev.20240714 → 5.6.0-dev.20240716

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-dev.20240714`;
21
+ var version = `${versionMajorMinor}.0-dev.20240716`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3416,10 +3416,12 @@ var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => {
3416
3416
  RelationComparisonResult3[RelationComparisonResult3["None"] = 0] = "None";
3417
3417
  RelationComparisonResult3[RelationComparisonResult3["Succeeded"] = 1] = "Succeeded";
3418
3418
  RelationComparisonResult3[RelationComparisonResult3["Failed"] = 2] = "Failed";
3419
- RelationComparisonResult3[RelationComparisonResult3["Reported"] = 4] = "Reported";
3420
3419
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable";
3421
3420
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnreliable"] = 16] = "ReportsUnreliable";
3422
3421
  RelationComparisonResult3[RelationComparisonResult3["ReportsMask"] = 24] = "ReportsMask";
3422
+ RelationComparisonResult3[RelationComparisonResult3["ComplexityOverflow"] = 32] = "ComplexityOverflow";
3423
+ RelationComparisonResult3[RelationComparisonResult3["StackDepthOverflow"] = 64] = "StackDepthOverflow";
3424
+ RelationComparisonResult3[RelationComparisonResult3["Overflow"] = 96] = "Overflow";
3423
3425
  return RelationComparisonResult3;
3424
3426
  })(RelationComparisonResult || {});
3425
3427
  var GeneratedIdentifierFlags = /* @__PURE__ */ ((GeneratedIdentifierFlags2) => {
@@ -6372,7 +6374,6 @@ var Diagnostics = {
6372
6374
  The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_standard_function_or_method: diag(2522, 1 /* Error */, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_sta_2522", "The 'arguments' object cannot be referenced in an async function or method in ES5. Consider using a standard function or method."),
6373
6375
  yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, 1 /* Error */, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."),
6374
6376
  await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, 1 /* Error */, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."),
6375
- Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: diag(2525, 1 /* Error */, "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", "Initializer provides no value for this binding element and the binding element has no default value."),
6376
6377
  A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: diag(2526, 1 /* Error */, "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", "A 'this' type is available only in a non-static member of a class or interface."),
6377
6378
  The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: diag(2527, 1 /* Error */, "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527", "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary."),
6378
6379
  A_module_cannot_have_multiple_default_exports: diag(2528, 1 /* Error */, "A_module_cannot_have_multiple_default_exports_2528", "A module cannot have multiple default exports."),
@@ -46131,6 +46132,7 @@ function createTypeChecker(host) {
46131
46132
  var contextualTypes = [];
46132
46133
  var contextualIsCache = [];
46133
46134
  var contextualTypeCount = 0;
46135
+ var contextualBindingPatterns = [];
46134
46136
  var inferenceContextNodes = [];
46135
46137
  var inferenceContexts = [];
46136
46138
  var inferenceContextCount = 0;
@@ -54155,6 +54157,7 @@ function createTypeChecker(host) {
54155
54157
  } else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
54156
54158
  parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
54157
54159
  }
54160
+ const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* AllowMissing */ : 0);
54158
54161
  let type;
54159
54162
  if (pattern.kind === 206 /* ObjectBindingPattern */) {
54160
54163
  if (declaration.dotDotDotToken) {
@@ -54173,7 +54176,7 @@ function createTypeChecker(host) {
54173
54176
  } else {
54174
54177
  const name = declaration.propertyName || declaration.name;
54175
54178
  const indexType = getLiteralTypeFromPropertyName(name);
54176
- const declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
54179
+ const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
54177
54180
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54178
54181
  }
54179
54182
  } else {
@@ -54184,7 +54187,6 @@ function createTypeChecker(host) {
54184
54187
  type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
54185
54188
  } else if (isArrayLikeType(parentType)) {
54186
54189
  const indexType = getNumberLiteralType(index);
54187
- const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
54188
54190
  const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
54189
54191
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54190
54192
  } else {
@@ -54670,7 +54672,7 @@ function createTypeChecker(host) {
54670
54672
  /*reportErrors*/
54671
54673
  false
54672
54674
  ) : unknownType;
54673
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
54675
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
54674
54676
  }
54675
54677
  if (isBindingPattern(element.name)) {
54676
54678
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
@@ -54741,7 +54743,10 @@ function createTypeChecker(host) {
54741
54743
  return result;
54742
54744
  }
54743
54745
  function getTypeFromBindingPattern(pattern, includePatternInType = false, reportErrors2 = false) {
54744
- return pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54746
+ if (includePatternInType) contextualBindingPatterns.push(pattern);
54747
+ const result = pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54748
+ if (includePatternInType) contextualBindingPatterns.pop();
54749
+ return result;
54745
54750
  }
54746
54751
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors2) {
54747
54752
  return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(
@@ -54822,18 +54827,18 @@ function createTypeChecker(host) {
54822
54827
  }
54823
54828
  return false;
54824
54829
  }
54825
- function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
54830
+ function getTypeOfVariableOrParameterOrProperty(symbol) {
54826
54831
  const links = getSymbolLinks(symbol);
54827
54832
  if (!links.type) {
54828
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
54829
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
54833
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
54834
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
54830
54835
  links.type = type;
54831
54836
  }
54832
54837
  return type;
54833
54838
  }
54834
54839
  return links.type;
54835
54840
  }
54836
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
54841
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
54837
54842
  if (symbol.flags & 4194304 /* Prototype */) {
54838
54843
  return getTypeOfPrototypeProperty(symbol);
54839
54844
  }
@@ -54868,9 +54873,6 @@ function createTypeChecker(host) {
54868
54873
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54869
54874
  return getTypeOfFuncClassEnumModule(symbol);
54870
54875
  }
54871
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54872
- return errorType;
54873
- }
54874
54876
  return reportCircularityError(symbol);
54875
54877
  }
54876
54878
  let type;
@@ -54908,9 +54910,6 @@ function createTypeChecker(host) {
54908
54910
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54909
54911
  return getTypeOfFuncClassEnumModule(symbol);
54910
54912
  }
54911
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54912
- return type;
54913
- }
54914
54913
  return reportCircularityError(symbol);
54915
54914
  }
54916
54915
  return type;
@@ -55139,7 +55138,7 @@ function createTypeChecker(host) {
55139
55138
  }
55140
55139
  return getTypeOfSymbol(symbol);
55141
55140
  }
55142
- function getTypeOfSymbol(symbol, checkMode) {
55141
+ function getTypeOfSymbol(symbol) {
55143
55142
  const checkFlags = getCheckFlags(symbol);
55144
55143
  if (checkFlags & 65536 /* DeferredType */) {
55145
55144
  return getTypeOfSymbolWithDeferredType(symbol);
@@ -55154,7 +55153,7 @@ function createTypeChecker(host) {
55154
55153
  return getTypeOfReverseMappedSymbol(symbol);
55155
55154
  }
55156
55155
  if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
55157
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
55156
+ return getTypeOfVariableOrParameterOrProperty(symbol);
55158
55157
  }
55159
55158
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
55160
55159
  return getTypeOfFuncClassEnumModule(symbol);
@@ -58301,14 +58300,14 @@ function createTypeChecker(host) {
58301
58300
  var _a, _b;
58302
58301
  if (!type.resolvedTypeArguments) {
58303
58302
  if (!pushTypeResolution(type, 5 /* ResolvedTypeArguments */)) {
58304
- return ((_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
58303
+ return concatenate(type.target.outerTypeParameters, (_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
58305
58304
  }
58306
58305
  const node = type.node;
58307
58306
  const typeArguments = !node ? emptyArray : node.kind === 183 /* TypeReference */ ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : node.kind === 188 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
58308
58307
  if (popTypeResolution()) {
58309
58308
  type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
58310
58309
  } else {
58311
- type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
58310
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = concatenate(type.target.outerTypeParameters, ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray));
58312
58311
  error(
58313
58312
  type.node || currentNode,
58314
58313
  type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
@@ -60304,7 +60303,7 @@ function createTypeChecker(host) {
60304
60303
  }
60305
60304
  if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
60306
60305
  const index = +propName;
60307
- if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
60306
+ if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* AllowMissing */)) {
60308
60307
  const indexNode = getIndexNodeForAccessExpression(accessNode);
60309
60308
  if (isTupleType(objectType)) {
60310
60309
  if (index < 0) {
@@ -60443,6 +60442,9 @@ function createTypeChecker(host) {
60443
60442
  return void 0;
60444
60443
  }
60445
60444
  }
60445
+ if (accessFlags & 16 /* AllowMissing */ && isObjectLiteralType(objectType)) {
60446
+ return undefinedType;
60447
+ }
60446
60448
  if (isJSLiteralType(objectType)) {
60447
60449
  return anyType;
60448
60450
  }
@@ -62714,7 +62716,7 @@ function createTypeChecker(host) {
62714
62716
  }
62715
62717
  const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
62716
62718
  const entry = enumRelation.get(id);
62717
- if (entry !== void 0 && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
62719
+ if (entry !== void 0 && !(entry & 2 /* Failed */ && errorReporter)) {
62718
62720
  return !!(entry & 1 /* Succeeded */);
62719
62721
  }
62720
62722
  const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -62729,10 +62731,8 @@ function createTypeChecker(host) {
62729
62731
  void 0,
62730
62732
  64 /* UseFullyQualifiedType */
62731
62733
  ));
62732
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62733
- } else {
62734
- enumRelation.set(id, 2 /* Failed */);
62735
62734
  }
62735
+ enumRelation.set(id, 2 /* Failed */);
62736
62736
  return false;
62737
62737
  }
62738
62738
  const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
@@ -62741,26 +62741,22 @@ function createTypeChecker(host) {
62741
62741
  const sourceIsString = typeof sourceValue === "string";
62742
62742
  const targetIsString = typeof targetValue === "string";
62743
62743
  if (sourceValue !== void 0 && targetValue !== void 0) {
62744
- if (!errorReporter) {
62745
- enumRelation.set(id, 2 /* Failed */);
62746
- } else {
62744
+ if (errorReporter) {
62747
62745
  const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
62748
62746
  const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
62749
62747
  errorReporter(Diagnostics.Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given, symbolName(targetSymbol), symbolName(targetProperty), escapedTarget, escapedSource);
62750
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62751
62748
  }
62749
+ enumRelation.set(id, 2 /* Failed */);
62752
62750
  return false;
62753
62751
  }
62754
62752
  if (sourceIsString || targetIsString) {
62755
- if (!errorReporter) {
62756
- enumRelation.set(id, 2 /* Failed */);
62757
- } else {
62753
+ if (errorReporter) {
62758
62754
  const knownStringValue = sourceValue ?? targetValue;
62759
62755
  Debug.assert(typeof knownStringValue === "string");
62760
62756
  const escapedValue = `"${escapeString(knownStringValue)}"`;
62761
62757
  errorReporter(Diagnostics.One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value, symbolName(targetSymbol), symbolName(targetProperty), escapedValue);
62762
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62763
62758
  }
62759
+ enumRelation.set(id, 2 /* Failed */);
62764
62760
  return false;
62765
62761
  }
62766
62762
  }
@@ -62918,7 +62914,7 @@ function createTypeChecker(host) {
62918
62914
  /*ignoreConstraints*/
62919
62915
  false
62920
62916
  );
62921
- relation.set(id, 4 /* Reported */ | 2 /* Failed */);
62917
+ relation.set(id, 2 /* Failed */ | (relationCount <= 0 ? 32 /* ComplexityOverflow */ : 64 /* StackDepthOverflow */));
62922
62918
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
62923
62919
  const message = relationCount <= 0 ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
62924
62920
  const diag2 = error(errorNode || currentNode, message, typeToString(source), typeToString(target));
@@ -63771,7 +63767,7 @@ function createTypeChecker(host) {
63771
63767
  );
63772
63768
  const entry = relation.get(id);
63773
63769
  if (entry !== void 0) {
63774
- if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
63770
+ if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 96 /* Overflow */)) {
63775
63771
  } else {
63776
63772
  if (outofbandVarianceMarkerHandler) {
63777
63773
  const saved = entry & 24 /* ReportsMask */;
@@ -63782,6 +63778,11 @@ function createTypeChecker(host) {
63782
63778
  instantiateType(source2, reportUnreliableMapper);
63783
63779
  }
63784
63780
  }
63781
+ if (reportErrors2 && entry & 96 /* Overflow */) {
63782
+ const message = entry & 32 /* ComplexityOverflow */ ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
63783
+ reportError(message, typeToString(source2), typeToString(target2));
63784
+ overrideNextErrorInfo++;
63785
+ }
63785
63786
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
63786
63787
  }
63787
63788
  }
@@ -63879,7 +63880,7 @@ function createTypeChecker(host) {
63879
63880
  }
63880
63881
  }
63881
63882
  } else {
63882
- relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
63883
+ relation.set(id, 2 /* Failed */ | propagatingVarianceFlags);
63883
63884
  relationCount--;
63884
63885
  resetMaybeStack(
63885
63886
  /*markAllAsSucceeded*/
@@ -69915,9 +69916,9 @@ function createTypeChecker(host) {
69915
69916
  );
69916
69917
  }
69917
69918
  }
69918
- function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
69919
+ function getNarrowedTypeOfSymbol(symbol, location) {
69919
69920
  var _a;
69920
- const type = getTypeOfSymbol(symbol, checkMode);
69921
+ const type = getTypeOfSymbol(symbol);
69921
69922
  const declaration = symbol.valueDeclaration;
69922
69923
  if (declaration) {
69923
69924
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
@@ -70056,7 +70057,10 @@ function createTypeChecker(host) {
70056
70057
  }
70057
70058
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
70058
70059
  let declaration = localOrExportSymbol.valueDeclaration;
70059
- let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
70060
+ if (declaration && declaration.kind === 208 /* BindingElement */ && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, (parent) => parent === declaration.parent)) {
70061
+ return nonInferrableAnyType;
70062
+ }
70063
+ let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
70060
70064
  const assignmentKind = getAssignmentTargetKind(node);
70061
70065
  if (assignmentKind) {
70062
70066
  if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
@@ -71749,7 +71753,7 @@ function createTypeChecker(host) {
71749
71753
  return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
71750
71754
  }
71751
71755
  function hasDefaultValue(node) {
71752
- return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
71756
+ return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 303 /* PropertyAssignment */ && hasDefaultValue(node.initializer) || node.kind === 304 /* ShorthandPropertyAssignment */ && !!node.objectAssignmentInitializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
71753
71757
  }
71754
71758
  function isSpreadIntoCallOrNew(node) {
71755
71759
  const parent = walkUpParenthesizedExpressions(node.parent);
@@ -71918,7 +71922,6 @@ function createTypeChecker(host) {
71918
71922
  return links.immediateTarget;
71919
71923
  }
71920
71924
  function checkObjectLiteral(node, checkMode = 0 /* Normal */) {
71921
- var _a;
71922
71925
  const inDestructuringPattern = isAssignmentTarget(node);
71923
71926
  checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
71924
71927
  const allPropertiesTable = strictNullChecks ? createSymbolTable() : void 0;
@@ -71973,11 +71976,8 @@ function createTypeChecker(host) {
71973
71976
  if (nameType) {
71974
71977
  prop.links.nameType = nameType;
71975
71978
  }
71976
- if (inDestructuringPattern) {
71977
- const isOptional = memberDecl.kind === 303 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer) || memberDecl.kind === 304 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer;
71978
- if (isOptional) {
71979
- prop.flags |= 16777216 /* Optional */;
71980
- }
71979
+ if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
71980
+ prop.flags |= 16777216 /* Optional */;
71981
71981
  } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
71982
71982
  const impliedProp = getPropertyOfType(contextualType, member.escapedName);
71983
71983
  if (impliedProp) {
@@ -72052,21 +72052,6 @@ function createTypeChecker(host) {
72052
72052
  propertiesArray.push(member);
72053
72053
  }
72054
72054
  popContextualType();
72055
- if (contextualTypeHasPattern) {
72056
- const rootPatternParent = findAncestor(contextualType.pattern.parent, (n) => n.kind === 260 /* VariableDeclaration */ || n.kind === 226 /* BinaryExpression */ || n.kind === 169 /* Parameter */);
72057
- const spreadOrOutsideRootObject = findAncestor(node, (n) => n === rootPatternParent || n.kind === 305 /* SpreadAssignment */);
72058
- if (spreadOrOutsideRootObject.kind !== 305 /* SpreadAssignment */) {
72059
- for (const prop of getPropertiesOfType(contextualType)) {
72060
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
72061
- if (!(prop.flags & 16777216 /* Optional */)) {
72062
- error(prop.valueDeclaration || ((_a = tryCast(prop, isTransientSymbol)) == null ? void 0 : _a.links.bindingElement), Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
72063
- }
72064
- propertiesTable.set(prop.escapedName, prop);
72065
- propertiesArray.push(prop);
72066
- }
72067
- }
72068
- }
72069
- }
72070
72055
  if (isErrorType(spread)) {
72071
72056
  return errorType;
72072
72057
  }
@@ -77344,7 +77329,7 @@ function createTypeChecker(host) {
77344
77329
  );
77345
77330
  }
77346
77331
  }
77347
- const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
77332
+ const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */ | (hasDefaultValue(property) ? 16 /* AllowMissing */ : 0), name);
77348
77333
  const type = getFlowTypeOfDestructuring(property, elementType);
77349
77334
  return checkDestructuringAssignment(property.kind === 304 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
77350
77335
  } else if (property.kind === 305 /* SpreadAssignment */) {
@@ -77393,7 +77378,7 @@ function createTypeChecker(host) {
77393
77378
  if (element.kind !== 230 /* SpreadElement */) {
77394
77379
  const indexType = getNumberLiteralType(elementIndex);
77395
77380
  if (isArrayLikeType(sourceType)) {
77396
- const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
77381
+ const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AllowMissing */ : 0);
77397
77382
  const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
77398
77383
  const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
77399
77384
  const type = getFlowTypeOfDestructuring(element, assignedType);
@@ -78232,9 +78217,56 @@ function createTypeChecker(host) {
78232
78217
  void 0,
78233
78218
  checkMode || 0 /* Normal */
78234
78219
  ) : checkExpressionCached(initializer, checkMode));
78235
- return isParameter(declaration) && declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type) && !(type.target.combinedFlags & 12 /* Variable */) && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type;
78220
+ if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) {
78221
+ if (declaration.name.kind === 206 /* ObjectBindingPattern */ && isObjectLiteralType(type)) {
78222
+ return padObjectLiteralType(type, declaration.name);
78223
+ }
78224
+ if (declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type)) {
78225
+ return padTupleType(type, declaration.name);
78226
+ }
78227
+ }
78228
+ return type;
78229
+ }
78230
+ function padObjectLiteralType(type, pattern) {
78231
+ let missingElements;
78232
+ for (const e of pattern.elements) {
78233
+ if (e.initializer) {
78234
+ const name = getPropertyNameFromBindingElement(e);
78235
+ if (name && !getPropertyOfType(type, name)) {
78236
+ missingElements = append(missingElements, e);
78237
+ }
78238
+ }
78239
+ }
78240
+ if (!missingElements) {
78241
+ return type;
78242
+ }
78243
+ const members = createSymbolTable();
78244
+ for (const prop of getPropertiesOfObjectType(type)) {
78245
+ members.set(prop.escapedName, prop);
78246
+ }
78247
+ for (const e of missingElements) {
78248
+ const symbol = createSymbol(4 /* Property */ | 16777216 /* Optional */, getPropertyNameFromBindingElement(e));
78249
+ symbol.links.type = getTypeFromBindingElement(
78250
+ e,
78251
+ /*includePatternInType*/
78252
+ false,
78253
+ /*reportErrors*/
78254
+ false
78255
+ );
78256
+ members.set(symbol.escapedName, symbol);
78257
+ }
78258
+ const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type));
78259
+ result.objectFlags = type.objectFlags;
78260
+ return result;
78261
+ }
78262
+ function getPropertyNameFromBindingElement(e) {
78263
+ const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name);
78264
+ return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : void 0;
78236
78265
  }
78237
78266
  function padTupleType(type, pattern) {
78267
+ if (type.target.combinedFlags & 12 /* Variable */ || getTypeReferenceArity(type) >= pattern.elements.length) {
78268
+ return type;
78269
+ }
78238
78270
  const patternElements = pattern.elements;
78239
78271
  const elementTypes = getElementTypes(type).slice();
78240
78272
  const elementFlags = type.target.elementFlags.slice();
package/lib/typescript.js CHANGED
@@ -2251,7 +2251,7 @@ module.exports = __toCommonJS(typescript_exports);
2251
2251
 
2252
2252
  // src/compiler/corePublic.ts
2253
2253
  var versionMajorMinor = "5.6";
2254
- var version = `${versionMajorMinor}.0-dev.20240714`;
2254
+ var version = `${versionMajorMinor}.0-dev.20240716`;
2255
2255
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2256
2256
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2257
2257
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5978,10 +5978,12 @@ var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => {
5978
5978
  RelationComparisonResult3[RelationComparisonResult3["None"] = 0] = "None";
5979
5979
  RelationComparisonResult3[RelationComparisonResult3["Succeeded"] = 1] = "Succeeded";
5980
5980
  RelationComparisonResult3[RelationComparisonResult3["Failed"] = 2] = "Failed";
5981
- RelationComparisonResult3[RelationComparisonResult3["Reported"] = 4] = "Reported";
5982
5981
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable";
5983
5982
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnreliable"] = 16] = "ReportsUnreliable";
5984
5983
  RelationComparisonResult3[RelationComparisonResult3["ReportsMask"] = 24] = "ReportsMask";
5984
+ RelationComparisonResult3[RelationComparisonResult3["ComplexityOverflow"] = 32] = "ComplexityOverflow";
5985
+ RelationComparisonResult3[RelationComparisonResult3["StackDepthOverflow"] = 64] = "StackDepthOverflow";
5986
+ RelationComparisonResult3[RelationComparisonResult3["Overflow"] = 96] = "Overflow";
5985
5987
  return RelationComparisonResult3;
5986
5988
  })(RelationComparisonResult || {});
5987
5989
  var GeneratedIdentifierFlags = /* @__PURE__ */ ((GeneratedIdentifierFlags2) => {
@@ -6526,7 +6528,7 @@ var AccessFlags = /* @__PURE__ */ ((AccessFlags2) => {
6526
6528
  AccessFlags2[AccessFlags2["NoIndexSignatures"] = 2] = "NoIndexSignatures";
6527
6529
  AccessFlags2[AccessFlags2["Writing"] = 4] = "Writing";
6528
6530
  AccessFlags2[AccessFlags2["CacheSymbol"] = 8] = "CacheSymbol";
6529
- AccessFlags2[AccessFlags2["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck";
6531
+ AccessFlags2[AccessFlags2["AllowMissing"] = 16] = "AllowMissing";
6530
6532
  AccessFlags2[AccessFlags2["ExpressionPosition"] = 32] = "ExpressionPosition";
6531
6533
  AccessFlags2[AccessFlags2["ReportDeprecated"] = 64] = "ReportDeprecated";
6532
6534
  AccessFlags2[AccessFlags2["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError";
@@ -9752,7 +9754,6 @@ var Diagnostics = {
9752
9754
  The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_standard_function_or_method: diag(2522, 1 /* Error */, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_sta_2522", "The 'arguments' object cannot be referenced in an async function or method in ES5. Consider using a standard function or method."),
9753
9755
  yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, 1 /* Error */, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."),
9754
9756
  await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, 1 /* Error */, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."),
9755
- Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: diag(2525, 1 /* Error */, "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", "Initializer provides no value for this binding element and the binding element has no default value."),
9756
9757
  A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: diag(2526, 1 /* Error */, "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", "A 'this' type is available only in a non-static member of a class or interface."),
9757
9758
  The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: diag(2527, 1 /* Error */, "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527", "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary."),
9758
9759
  A_module_cannot_have_multiple_default_exports: diag(2528, 1 /* Error */, "A_module_cannot_have_multiple_default_exports_2528", "A module cannot have multiple default exports."),
@@ -50733,6 +50734,7 @@ function createTypeChecker(host) {
50733
50734
  var contextualTypes = [];
50734
50735
  var contextualIsCache = [];
50735
50736
  var contextualTypeCount = 0;
50737
+ var contextualBindingPatterns = [];
50736
50738
  var inferenceContextNodes = [];
50737
50739
  var inferenceContexts = [];
50738
50740
  var inferenceContextCount = 0;
@@ -58757,6 +58759,7 @@ function createTypeChecker(host) {
58757
58759
  } else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
58758
58760
  parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
58759
58761
  }
58762
+ const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* AllowMissing */ : 0);
58760
58763
  let type;
58761
58764
  if (pattern.kind === 206 /* ObjectBindingPattern */) {
58762
58765
  if (declaration.dotDotDotToken) {
@@ -58775,7 +58778,7 @@ function createTypeChecker(host) {
58775
58778
  } else {
58776
58779
  const name = declaration.propertyName || declaration.name;
58777
58780
  const indexType = getLiteralTypeFromPropertyName(name);
58778
- const declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
58781
+ const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
58779
58782
  type = getFlowTypeOfDestructuring(declaration, declaredType);
58780
58783
  }
58781
58784
  } else {
@@ -58786,7 +58789,6 @@ function createTypeChecker(host) {
58786
58789
  type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
58787
58790
  } else if (isArrayLikeType(parentType)) {
58788
58791
  const indexType = getNumberLiteralType(index);
58789
- const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
58790
58792
  const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
58791
58793
  type = getFlowTypeOfDestructuring(declaration, declaredType);
58792
58794
  } else {
@@ -59272,7 +59274,7 @@ function createTypeChecker(host) {
59272
59274
  /*reportErrors*/
59273
59275
  false
59274
59276
  ) : unknownType;
59275
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
59277
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
59276
59278
  }
59277
59279
  if (isBindingPattern(element.name)) {
59278
59280
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
@@ -59343,7 +59345,10 @@ function createTypeChecker(host) {
59343
59345
  return result;
59344
59346
  }
59345
59347
  function getTypeFromBindingPattern(pattern, includePatternInType = false, reportErrors2 = false) {
59346
- return pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
59348
+ if (includePatternInType) contextualBindingPatterns.push(pattern);
59349
+ const result = pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
59350
+ if (includePatternInType) contextualBindingPatterns.pop();
59351
+ return result;
59347
59352
  }
59348
59353
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors2) {
59349
59354
  return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(
@@ -59424,18 +59429,18 @@ function createTypeChecker(host) {
59424
59429
  }
59425
59430
  return false;
59426
59431
  }
59427
- function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
59432
+ function getTypeOfVariableOrParameterOrProperty(symbol) {
59428
59433
  const links = getSymbolLinks(symbol);
59429
59434
  if (!links.type) {
59430
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
59431
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
59435
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
59436
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
59432
59437
  links.type = type;
59433
59438
  }
59434
59439
  return type;
59435
59440
  }
59436
59441
  return links.type;
59437
59442
  }
59438
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
59443
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
59439
59444
  if (symbol.flags & 4194304 /* Prototype */) {
59440
59445
  return getTypeOfPrototypeProperty(symbol);
59441
59446
  }
@@ -59470,9 +59475,6 @@ function createTypeChecker(host) {
59470
59475
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
59471
59476
  return getTypeOfFuncClassEnumModule(symbol);
59472
59477
  }
59473
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
59474
- return errorType;
59475
- }
59476
59478
  return reportCircularityError(symbol);
59477
59479
  }
59478
59480
  let type;
@@ -59510,9 +59512,6 @@ function createTypeChecker(host) {
59510
59512
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
59511
59513
  return getTypeOfFuncClassEnumModule(symbol);
59512
59514
  }
59513
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
59514
- return type;
59515
- }
59516
59515
  return reportCircularityError(symbol);
59517
59516
  }
59518
59517
  return type;
@@ -59741,7 +59740,7 @@ function createTypeChecker(host) {
59741
59740
  }
59742
59741
  return getTypeOfSymbol(symbol);
59743
59742
  }
59744
- function getTypeOfSymbol(symbol, checkMode) {
59743
+ function getTypeOfSymbol(symbol) {
59745
59744
  const checkFlags = getCheckFlags(symbol);
59746
59745
  if (checkFlags & 65536 /* DeferredType */) {
59747
59746
  return getTypeOfSymbolWithDeferredType(symbol);
@@ -59756,7 +59755,7 @@ function createTypeChecker(host) {
59756
59755
  return getTypeOfReverseMappedSymbol(symbol);
59757
59756
  }
59758
59757
  if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
59759
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
59758
+ return getTypeOfVariableOrParameterOrProperty(symbol);
59760
59759
  }
59761
59760
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
59762
59761
  return getTypeOfFuncClassEnumModule(symbol);
@@ -62903,14 +62902,14 @@ function createTypeChecker(host) {
62903
62902
  var _a, _b;
62904
62903
  if (!type.resolvedTypeArguments) {
62905
62904
  if (!pushTypeResolution(type, 5 /* ResolvedTypeArguments */)) {
62906
- return ((_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
62905
+ return concatenate(type.target.outerTypeParameters, (_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
62907
62906
  }
62908
62907
  const node = type.node;
62909
62908
  const typeArguments = !node ? emptyArray : node.kind === 183 /* TypeReference */ ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments2(node, type.target.localTypeParameters)) : node.kind === 188 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
62910
62909
  if (popTypeResolution()) {
62911
62910
  type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
62912
62911
  } else {
62913
- type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
62912
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = concatenate(type.target.outerTypeParameters, ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray));
62914
62913
  error2(
62915
62914
  type.node || currentNode,
62916
62915
  type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
@@ -64906,7 +64905,7 @@ function createTypeChecker(host) {
64906
64905
  }
64907
64906
  if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
64908
64907
  const index = +propName;
64909
- if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
64908
+ if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* AllowMissing */)) {
64910
64909
  const indexNode = getIndexNodeForAccessExpression(accessNode);
64911
64910
  if (isTupleType(objectType)) {
64912
64911
  if (index < 0) {
@@ -65045,6 +65044,9 @@ function createTypeChecker(host) {
65045
65044
  return void 0;
65046
65045
  }
65047
65046
  }
65047
+ if (accessFlags & 16 /* AllowMissing */ && isObjectLiteralType2(objectType)) {
65048
+ return undefinedType;
65049
+ }
65048
65050
  if (isJSLiteralType(objectType)) {
65049
65051
  return anyType;
65050
65052
  }
@@ -67316,7 +67318,7 @@ function createTypeChecker(host) {
67316
67318
  }
67317
67319
  const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
67318
67320
  const entry = enumRelation.get(id);
67319
- if (entry !== void 0 && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
67321
+ if (entry !== void 0 && !(entry & 2 /* Failed */ && errorReporter)) {
67320
67322
  return !!(entry & 1 /* Succeeded */);
67321
67323
  }
67322
67324
  const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -67331,10 +67333,8 @@ function createTypeChecker(host) {
67331
67333
  void 0,
67332
67334
  64 /* UseFullyQualifiedType */
67333
67335
  ));
67334
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
67335
- } else {
67336
- enumRelation.set(id, 2 /* Failed */);
67337
67336
  }
67337
+ enumRelation.set(id, 2 /* Failed */);
67338
67338
  return false;
67339
67339
  }
67340
67340
  const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
@@ -67343,26 +67343,22 @@ function createTypeChecker(host) {
67343
67343
  const sourceIsString = typeof sourceValue === "string";
67344
67344
  const targetIsString = typeof targetValue === "string";
67345
67345
  if (sourceValue !== void 0 && targetValue !== void 0) {
67346
- if (!errorReporter) {
67347
- enumRelation.set(id, 2 /* Failed */);
67348
- } else {
67346
+ if (errorReporter) {
67349
67347
  const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
67350
67348
  const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
67351
67349
  errorReporter(Diagnostics.Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given, symbolName(targetSymbol), symbolName(targetProperty), escapedTarget, escapedSource);
67352
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
67353
67350
  }
67351
+ enumRelation.set(id, 2 /* Failed */);
67354
67352
  return false;
67355
67353
  }
67356
67354
  if (sourceIsString || targetIsString) {
67357
- if (!errorReporter) {
67358
- enumRelation.set(id, 2 /* Failed */);
67359
- } else {
67355
+ if (errorReporter) {
67360
67356
  const knownStringValue = sourceValue ?? targetValue;
67361
67357
  Debug.assert(typeof knownStringValue === "string");
67362
67358
  const escapedValue = `"${escapeString(knownStringValue)}"`;
67363
67359
  errorReporter(Diagnostics.One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value, symbolName(targetSymbol), symbolName(targetProperty), escapedValue);
67364
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
67365
67360
  }
67361
+ enumRelation.set(id, 2 /* Failed */);
67366
67362
  return false;
67367
67363
  }
67368
67364
  }
@@ -67520,7 +67516,7 @@ function createTypeChecker(host) {
67520
67516
  /*ignoreConstraints*/
67521
67517
  false
67522
67518
  );
67523
- relation.set(id, 4 /* Reported */ | 2 /* Failed */);
67519
+ relation.set(id, 2 /* Failed */ | (relationCount <= 0 ? 32 /* ComplexityOverflow */ : 64 /* StackDepthOverflow */));
67524
67520
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
67525
67521
  const message = relationCount <= 0 ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
67526
67522
  const diag2 = error2(errorNode || currentNode, message, typeToString(source), typeToString(target));
@@ -68373,7 +68369,7 @@ function createTypeChecker(host) {
68373
68369
  );
68374
68370
  const entry = relation.get(id);
68375
68371
  if (entry !== void 0) {
68376
- if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
68372
+ if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 96 /* Overflow */)) {
68377
68373
  } else {
68378
68374
  if (outofbandVarianceMarkerHandler) {
68379
68375
  const saved = entry & 24 /* ReportsMask */;
@@ -68384,6 +68380,11 @@ function createTypeChecker(host) {
68384
68380
  instantiateType(source2, reportUnreliableMapper);
68385
68381
  }
68386
68382
  }
68383
+ if (reportErrors2 && entry & 96 /* Overflow */) {
68384
+ const message = entry & 32 /* ComplexityOverflow */ ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
68385
+ reportError(message, typeToString(source2), typeToString(target2));
68386
+ overrideNextErrorInfo++;
68387
+ }
68387
68388
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
68388
68389
  }
68389
68390
  }
@@ -68481,7 +68482,7 @@ function createTypeChecker(host) {
68481
68482
  }
68482
68483
  }
68483
68484
  } else {
68484
- relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
68485
+ relation.set(id, 2 /* Failed */ | propagatingVarianceFlags);
68485
68486
  relationCount--;
68486
68487
  resetMaybeStack(
68487
68488
  /*markAllAsSucceeded*/
@@ -74517,9 +74518,9 @@ function createTypeChecker(host) {
74517
74518
  );
74518
74519
  }
74519
74520
  }
74520
- function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
74521
+ function getNarrowedTypeOfSymbol(symbol, location) {
74521
74522
  var _a;
74522
- const type = getTypeOfSymbol(symbol, checkMode);
74523
+ const type = getTypeOfSymbol(symbol);
74523
74524
  const declaration = symbol.valueDeclaration;
74524
74525
  if (declaration) {
74525
74526
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
@@ -74658,7 +74659,10 @@ function createTypeChecker(host) {
74658
74659
  }
74659
74660
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
74660
74661
  let declaration = localOrExportSymbol.valueDeclaration;
74661
- let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
74662
+ if (declaration && declaration.kind === 208 /* BindingElement */ && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, (parent2) => parent2 === declaration.parent)) {
74663
+ return nonInferrableAnyType;
74664
+ }
74665
+ let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
74662
74666
  const assignmentKind = getAssignmentTargetKind(node);
74663
74667
  if (assignmentKind) {
74664
74668
  if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
@@ -76351,7 +76355,7 @@ function createTypeChecker(host) {
76351
76355
  return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
76352
76356
  }
76353
76357
  function hasDefaultValue(node) {
76354
- return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
76358
+ return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 303 /* PropertyAssignment */ && hasDefaultValue(node.initializer) || node.kind === 304 /* ShorthandPropertyAssignment */ && !!node.objectAssignmentInitializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
76355
76359
  }
76356
76360
  function isSpreadIntoCallOrNew(node) {
76357
76361
  const parent2 = walkUpParenthesizedExpressions(node.parent);
@@ -76520,7 +76524,6 @@ function createTypeChecker(host) {
76520
76524
  return links.immediateTarget;
76521
76525
  }
76522
76526
  function checkObjectLiteral(node, checkMode = 0 /* Normal */) {
76523
- var _a;
76524
76527
  const inDestructuringPattern = isAssignmentTarget(node);
76525
76528
  checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
76526
76529
  const allPropertiesTable = strictNullChecks ? createSymbolTable() : void 0;
@@ -76575,11 +76578,8 @@ function createTypeChecker(host) {
76575
76578
  if (nameType) {
76576
76579
  prop.links.nameType = nameType;
76577
76580
  }
76578
- if (inDestructuringPattern) {
76579
- const isOptional = memberDecl.kind === 303 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer) || memberDecl.kind === 304 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer;
76580
- if (isOptional) {
76581
- prop.flags |= 16777216 /* Optional */;
76582
- }
76581
+ if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
76582
+ prop.flags |= 16777216 /* Optional */;
76583
76583
  } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
76584
76584
  const impliedProp = getPropertyOfType(contextualType, member.escapedName);
76585
76585
  if (impliedProp) {
@@ -76654,21 +76654,6 @@ function createTypeChecker(host) {
76654
76654
  propertiesArray.push(member);
76655
76655
  }
76656
76656
  popContextualType();
76657
- if (contextualTypeHasPattern) {
76658
- const rootPatternParent = findAncestor(contextualType.pattern.parent, (n) => n.kind === 260 /* VariableDeclaration */ || n.kind === 226 /* BinaryExpression */ || n.kind === 169 /* Parameter */);
76659
- const spreadOrOutsideRootObject = findAncestor(node, (n) => n === rootPatternParent || n.kind === 305 /* SpreadAssignment */);
76660
- if (spreadOrOutsideRootObject.kind !== 305 /* SpreadAssignment */) {
76661
- for (const prop of getPropertiesOfType(contextualType)) {
76662
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
76663
- if (!(prop.flags & 16777216 /* Optional */)) {
76664
- error2(prop.valueDeclaration || ((_a = tryCast(prop, isTransientSymbol)) == null ? void 0 : _a.links.bindingElement), Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
76665
- }
76666
- propertiesTable.set(prop.escapedName, prop);
76667
- propertiesArray.push(prop);
76668
- }
76669
- }
76670
- }
76671
- }
76672
76657
  if (isErrorType(spread)) {
76673
76658
  return errorType;
76674
76659
  }
@@ -81946,7 +81931,7 @@ function createTypeChecker(host) {
81946
81931
  );
81947
81932
  }
81948
81933
  }
81949
- const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
81934
+ const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */ | (hasDefaultValue(property) ? 16 /* AllowMissing */ : 0), name);
81950
81935
  const type = getFlowTypeOfDestructuring(property, elementType);
81951
81936
  return checkDestructuringAssignment(property.kind === 304 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
81952
81937
  } else if (property.kind === 305 /* SpreadAssignment */) {
@@ -81995,7 +81980,7 @@ function createTypeChecker(host) {
81995
81980
  if (element.kind !== 230 /* SpreadElement */) {
81996
81981
  const indexType = getNumberLiteralType(elementIndex);
81997
81982
  if (isArrayLikeType(sourceType)) {
81998
- const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
81983
+ const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AllowMissing */ : 0);
81999
81984
  const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
82000
81985
  const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
82001
81986
  const type = getFlowTypeOfDestructuring(element, assignedType);
@@ -82834,9 +82819,56 @@ function createTypeChecker(host) {
82834
82819
  void 0,
82835
82820
  checkMode || 0 /* Normal */
82836
82821
  ) : checkExpressionCached(initializer, checkMode));
82837
- return isParameter(declaration) && declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type) && !(type.target.combinedFlags & 12 /* Variable */) && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type;
82822
+ if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) {
82823
+ if (declaration.name.kind === 206 /* ObjectBindingPattern */ && isObjectLiteralType2(type)) {
82824
+ return padObjectLiteralType(type, declaration.name);
82825
+ }
82826
+ if (declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type)) {
82827
+ return padTupleType(type, declaration.name);
82828
+ }
82829
+ }
82830
+ return type;
82831
+ }
82832
+ function padObjectLiteralType(type, pattern) {
82833
+ let missingElements;
82834
+ for (const e of pattern.elements) {
82835
+ if (e.initializer) {
82836
+ const name = getPropertyNameFromBindingElement(e);
82837
+ if (name && !getPropertyOfType(type, name)) {
82838
+ missingElements = append(missingElements, e);
82839
+ }
82840
+ }
82841
+ }
82842
+ if (!missingElements) {
82843
+ return type;
82844
+ }
82845
+ const members = createSymbolTable();
82846
+ for (const prop of getPropertiesOfObjectType(type)) {
82847
+ members.set(prop.escapedName, prop);
82848
+ }
82849
+ for (const e of missingElements) {
82850
+ const symbol = createSymbol(4 /* Property */ | 16777216 /* Optional */, getPropertyNameFromBindingElement(e));
82851
+ symbol.links.type = getTypeFromBindingElement(
82852
+ e,
82853
+ /*includePatternInType*/
82854
+ false,
82855
+ /*reportErrors*/
82856
+ false
82857
+ );
82858
+ members.set(symbol.escapedName, symbol);
82859
+ }
82860
+ const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type));
82861
+ result.objectFlags = type.objectFlags;
82862
+ return result;
82863
+ }
82864
+ function getPropertyNameFromBindingElement(e) {
82865
+ const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name);
82866
+ return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : void 0;
82838
82867
  }
82839
82868
  function padTupleType(type, pattern) {
82869
+ if (type.target.combinedFlags & 12 /* Variable */ || getTypeReferenceArity(type) >= pattern.elements.length) {
82870
+ return type;
82871
+ }
82840
82872
  const patternElements = pattern.elements;
82841
82873
  const elementTypes = getElementTypes(type).slice();
82842
82874
  const elementFlags = type.target.elementFlags.slice();
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.6.0-dev.20240714",
5
+ "version": "5.6.0-dev.20240716",
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": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "6d3be985c82bead3b41348de76efec8110c677c5"
116
+ "gitHead": "ec446b6f19b44ed3db2d787b59d9c99a5b710283"
117
117
  }