typescript 5.6.0-dev.20240715 → 5.6.0-dev.20240717

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.20240715`;
21
+ var version = `${versionMajorMinor}.0-dev.20240717`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -2515,10 +2515,12 @@ function tryGetPerformance() {
2515
2515
  if (isNodeLikeSystem()) {
2516
2516
  try {
2517
2517
  const { performance: performance2 } = require("perf_hooks");
2518
- return {
2519
- shouldWriteNativeEvents: false,
2520
- performance: performance2
2521
- };
2518
+ if (performance2) {
2519
+ return {
2520
+ shouldWriteNativeEvents: false,
2521
+ performance: performance2
2522
+ };
2523
+ }
2522
2524
  } catch {
2523
2525
  }
2524
2526
  }
@@ -3416,10 +3418,12 @@ var RelationComparisonResult = /* @__PURE__ */ ((RelationComparisonResult3) => {
3416
3418
  RelationComparisonResult3[RelationComparisonResult3["None"] = 0] = "None";
3417
3419
  RelationComparisonResult3[RelationComparisonResult3["Succeeded"] = 1] = "Succeeded";
3418
3420
  RelationComparisonResult3[RelationComparisonResult3["Failed"] = 2] = "Failed";
3419
- RelationComparisonResult3[RelationComparisonResult3["Reported"] = 4] = "Reported";
3420
3421
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable";
3421
3422
  RelationComparisonResult3[RelationComparisonResult3["ReportsUnreliable"] = 16] = "ReportsUnreliable";
3422
3423
  RelationComparisonResult3[RelationComparisonResult3["ReportsMask"] = 24] = "ReportsMask";
3424
+ RelationComparisonResult3[RelationComparisonResult3["ComplexityOverflow"] = 32] = "ComplexityOverflow";
3425
+ RelationComparisonResult3[RelationComparisonResult3["StackDepthOverflow"] = 64] = "StackDepthOverflow";
3426
+ RelationComparisonResult3[RelationComparisonResult3["Overflow"] = 96] = "Overflow";
3423
3427
  return RelationComparisonResult3;
3424
3428
  })(RelationComparisonResult || {});
3425
3429
  var GeneratedIdentifierFlags = /* @__PURE__ */ ((GeneratedIdentifierFlags2) => {
@@ -6372,7 +6376,6 @@ var Diagnostics = {
6372
6376
  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
6377
  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
6378
  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
6379
  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
6380
  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
6381
  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."),
@@ -12584,6 +12587,34 @@ function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, pack
12584
12587
  if (result) result.repopulateInfo = () => ({ moduleReference, mode, packageName: packageName === moduleReference ? void 0 : packageName });
12585
12588
  return result;
12586
12589
  }
12590
+ function createModeMismatchDetails(currentSourceFile) {
12591
+ const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
12592
+ const scope = currentSourceFile.packageJsonScope;
12593
+ const targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : void 0;
12594
+ const result = scope && !scope.contents.packageJsonContent.type ? targetExt ? chainDiagnosticMessages(
12595
+ /*details*/
12596
+ void 0,
12597
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
12598
+ targetExt,
12599
+ combinePaths(scope.packageDirectory, "package.json")
12600
+ ) : chainDiagnosticMessages(
12601
+ /*details*/
12602
+ void 0,
12603
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
12604
+ combinePaths(scope.packageDirectory, "package.json")
12605
+ ) : targetExt ? chainDiagnosticMessages(
12606
+ /*details*/
12607
+ void 0,
12608
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
12609
+ targetExt
12610
+ ) : chainDiagnosticMessages(
12611
+ /*details*/
12612
+ void 0,
12613
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module
12614
+ );
12615
+ result.repopulateInfo = () => true;
12616
+ return result;
12617
+ }
12587
12618
  function packageIdIsEqual(a, b) {
12588
12619
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version && a.peerDependencies === b.peerDependencies;
12589
12620
  }
@@ -40132,22 +40163,16 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
40132
40163
  resolvedPackageDirectory: false
40133
40164
  };
40134
40165
  }
40135
- function getPackageScopeForPath(fileName, state) {
40136
- const parts = getPathComponents(fileName);
40137
- parts.pop();
40138
- while (parts.length > 0) {
40139
- const pkg = getPackageJsonInfo(
40140
- getPathFromPathComponents(parts),
40166
+ function getPackageScopeForPath(directory, state) {
40167
+ return forEachAncestorDirectory(
40168
+ directory,
40169
+ (dir) => getPackageJsonInfo(
40170
+ dir,
40141
40171
  /*onlyRecordFailures*/
40142
40172
  false,
40143
40173
  state
40144
- );
40145
- if (pkg) {
40146
- return pkg;
40147
- }
40148
- parts.pop();
40149
- }
40150
- return void 0;
40174
+ )
40175
+ );
40151
40176
  }
40152
40177
  function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
40153
40178
  if (packageJsonInfo.contents.versionPaths === void 0) {
@@ -40310,7 +40335,7 @@ function noKeyStartsWithDot(obj) {
40310
40335
  }
40311
40336
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
40312
40337
  var _a, _b;
40313
- const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
40338
+ const directoryPath = getNormalizedAbsolutePath(directory, (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
40314
40339
  const scope = getPackageScopeForPath(directoryPath, state);
40315
40340
  if (!scope || !scope.contents.packageJsonContent.exports) {
40316
40341
  return void 0;
@@ -40406,7 +40431,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
40406
40431
  void 0
40407
40432
  );
40408
40433
  }
40409
- const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
40434
+ const directoryPath = getNormalizedAbsolutePath(directory, (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
40410
40435
  const scope = getPackageScopeForPath(directoryPath, state);
40411
40436
  if (!scope) {
40412
40437
  if (state.traceEnabled) {
@@ -44517,7 +44542,7 @@ function getAllModulePathsWorker(info, importedFileName, host, compilerOptions,
44517
44542
  if (cache && links && host.readFile && !pathContainsNodeModules(info.importingSourceFileName)) {
44518
44543
  Debug.type(host);
44519
44544
  const state = getTemporaryModuleResolutionState(cache.getPackageJsonInfoCache(), host, {});
44520
- const packageJson = getPackageScopeForPath(info.importingSourceFileName, state);
44545
+ const packageJson = getPackageScopeForPath(getDirectoryPath(info.importingSourceFileName), state);
44521
44546
  if (packageJson) {
44522
44547
  const toResolve = getAllRuntimeDependencies(packageJson.contents.packageJsonContent);
44523
44548
  for (const depName of toResolve || emptyArray) {
@@ -46131,6 +46156,7 @@ function createTypeChecker(host) {
46131
46156
  var contextualTypes = [];
46132
46157
  var contextualIsCache = [];
46133
46158
  var contextualTypeCount = 0;
46159
+ var contextualBindingPatterns = [];
46134
46160
  var inferenceContextNodes = [];
46135
46161
  var inferenceContexts = [];
46136
46162
  var inferenceContextCount = 0;
@@ -48185,41 +48211,7 @@ function createTypeChecker(host) {
48185
48211
  let diagnosticDetails;
48186
48212
  const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
48187
48213
  if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
48188
- const scope = currentSourceFile.packageJsonScope;
48189
- const targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : void 0;
48190
- if (scope && !scope.contents.packageJsonContent.type) {
48191
- if (targetExt) {
48192
- diagnosticDetails = chainDiagnosticMessages(
48193
- /*details*/
48194
- void 0,
48195
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
48196
- targetExt,
48197
- combinePaths(scope.packageDirectory, "package.json")
48198
- );
48199
- } else {
48200
- diagnosticDetails = chainDiagnosticMessages(
48201
- /*details*/
48202
- void 0,
48203
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
48204
- combinePaths(scope.packageDirectory, "package.json")
48205
- );
48206
- }
48207
- } else {
48208
- if (targetExt) {
48209
- diagnosticDetails = chainDiagnosticMessages(
48210
- /*details*/
48211
- void 0,
48212
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
48213
- targetExt
48214
- );
48215
- } else {
48216
- diagnosticDetails = chainDiagnosticMessages(
48217
- /*details*/
48218
- void 0,
48219
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module
48220
- );
48221
- }
48222
- }
48214
+ diagnosticDetails = createModeMismatchDetails(currentSourceFile);
48223
48215
  }
48224
48216
  diagnostics.add(createDiagnosticForNodeFromMessageChain(
48225
48217
  getSourceFileOfNode(errorNode),
@@ -52079,7 +52071,7 @@ function createTypeChecker(host) {
52079
52071
  if (result) {
52080
52072
  if (result.pos !== -1 || result.end !== -1) {
52081
52073
  if (result === nodes) {
52082
- result = factory.createNodeArray(nodes, nodes.hasTrailingComma);
52074
+ result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma);
52083
52075
  }
52084
52076
  setTextRangePosEnd(result, -1, -1);
52085
52077
  }
@@ -54155,6 +54147,7 @@ function createTypeChecker(host) {
54155
54147
  } else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
54156
54148
  parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
54157
54149
  }
54150
+ const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* AllowMissing */ : 0);
54158
54151
  let type;
54159
54152
  if (pattern.kind === 206 /* ObjectBindingPattern */) {
54160
54153
  if (declaration.dotDotDotToken) {
@@ -54173,7 +54166,7 @@ function createTypeChecker(host) {
54173
54166
  } else {
54174
54167
  const name = declaration.propertyName || declaration.name;
54175
54168
  const indexType = getLiteralTypeFromPropertyName(name);
54176
- const declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
54169
+ const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
54177
54170
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54178
54171
  }
54179
54172
  } else {
@@ -54184,7 +54177,6 @@ function createTypeChecker(host) {
54184
54177
  type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
54185
54178
  } else if (isArrayLikeType(parentType)) {
54186
54179
  const indexType = getNumberLiteralType(index);
54187
- const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
54188
54180
  const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
54189
54181
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54190
54182
  } else {
@@ -54670,7 +54662,7 @@ function createTypeChecker(host) {
54670
54662
  /*reportErrors*/
54671
54663
  false
54672
54664
  ) : unknownType;
54673
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
54665
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
54674
54666
  }
54675
54667
  if (isBindingPattern(element.name)) {
54676
54668
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
@@ -54741,7 +54733,10 @@ function createTypeChecker(host) {
54741
54733
  return result;
54742
54734
  }
54743
54735
  function getTypeFromBindingPattern(pattern, includePatternInType = false, reportErrors2 = false) {
54744
- return pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54736
+ if (includePatternInType) contextualBindingPatterns.push(pattern);
54737
+ const result = pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54738
+ if (includePatternInType) contextualBindingPatterns.pop();
54739
+ return result;
54745
54740
  }
54746
54741
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors2) {
54747
54742
  return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(
@@ -54822,18 +54817,18 @@ function createTypeChecker(host) {
54822
54817
  }
54823
54818
  return false;
54824
54819
  }
54825
- function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
54820
+ function getTypeOfVariableOrParameterOrProperty(symbol) {
54826
54821
  const links = getSymbolLinks(symbol);
54827
54822
  if (!links.type) {
54828
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
54829
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
54823
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
54824
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
54830
54825
  links.type = type;
54831
54826
  }
54832
54827
  return type;
54833
54828
  }
54834
54829
  return links.type;
54835
54830
  }
54836
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
54831
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
54837
54832
  if (symbol.flags & 4194304 /* Prototype */) {
54838
54833
  return getTypeOfPrototypeProperty(symbol);
54839
54834
  }
@@ -54868,9 +54863,6 @@ function createTypeChecker(host) {
54868
54863
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54869
54864
  return getTypeOfFuncClassEnumModule(symbol);
54870
54865
  }
54871
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54872
- return errorType;
54873
- }
54874
54866
  return reportCircularityError(symbol);
54875
54867
  }
54876
54868
  let type;
@@ -54908,9 +54900,6 @@ function createTypeChecker(host) {
54908
54900
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54909
54901
  return getTypeOfFuncClassEnumModule(symbol);
54910
54902
  }
54911
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54912
- return type;
54913
- }
54914
54903
  return reportCircularityError(symbol);
54915
54904
  }
54916
54905
  return type;
@@ -55139,7 +55128,7 @@ function createTypeChecker(host) {
55139
55128
  }
55140
55129
  return getTypeOfSymbol(symbol);
55141
55130
  }
55142
- function getTypeOfSymbol(symbol, checkMode) {
55131
+ function getTypeOfSymbol(symbol) {
55143
55132
  const checkFlags = getCheckFlags(symbol);
55144
55133
  if (checkFlags & 65536 /* DeferredType */) {
55145
55134
  return getTypeOfSymbolWithDeferredType(symbol);
@@ -55154,7 +55143,7 @@ function createTypeChecker(host) {
55154
55143
  return getTypeOfReverseMappedSymbol(symbol);
55155
55144
  }
55156
55145
  if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
55157
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
55146
+ return getTypeOfVariableOrParameterOrProperty(symbol);
55158
55147
  }
55159
55148
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
55160
55149
  return getTypeOfFuncClassEnumModule(symbol);
@@ -58301,14 +58290,14 @@ function createTypeChecker(host) {
58301
58290
  var _a, _b;
58302
58291
  if (!type.resolvedTypeArguments) {
58303
58292
  if (!pushTypeResolution(type, 5 /* ResolvedTypeArguments */)) {
58304
- return ((_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
58293
+ return concatenate(type.target.outerTypeParameters, (_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
58305
58294
  }
58306
58295
  const node = type.node;
58307
58296
  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
58297
  if (popTypeResolution()) {
58309
58298
  type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
58310
58299
  } else {
58311
- type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
58300
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = concatenate(type.target.outerTypeParameters, ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray));
58312
58301
  error(
58313
58302
  type.node || currentNode,
58314
58303
  type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
@@ -60304,7 +60293,7 @@ function createTypeChecker(host) {
60304
60293
  }
60305
60294
  if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
60306
60295
  const index = +propName;
60307
- if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
60296
+ if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* AllowMissing */)) {
60308
60297
  const indexNode = getIndexNodeForAccessExpression(accessNode);
60309
60298
  if (isTupleType(objectType)) {
60310
60299
  if (index < 0) {
@@ -60443,6 +60432,9 @@ function createTypeChecker(host) {
60443
60432
  return void 0;
60444
60433
  }
60445
60434
  }
60435
+ if (accessFlags & 16 /* AllowMissing */ && isObjectLiteralType(objectType)) {
60436
+ return undefinedType;
60437
+ }
60446
60438
  if (isJSLiteralType(objectType)) {
60447
60439
  return anyType;
60448
60440
  }
@@ -62714,7 +62706,7 @@ function createTypeChecker(host) {
62714
62706
  }
62715
62707
  const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
62716
62708
  const entry = enumRelation.get(id);
62717
- if (entry !== void 0 && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
62709
+ if (entry !== void 0 && !(entry & 2 /* Failed */ && errorReporter)) {
62718
62710
  return !!(entry & 1 /* Succeeded */);
62719
62711
  }
62720
62712
  const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -62729,10 +62721,8 @@ function createTypeChecker(host) {
62729
62721
  void 0,
62730
62722
  64 /* UseFullyQualifiedType */
62731
62723
  ));
62732
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62733
- } else {
62734
- enumRelation.set(id, 2 /* Failed */);
62735
62724
  }
62725
+ enumRelation.set(id, 2 /* Failed */);
62736
62726
  return false;
62737
62727
  }
62738
62728
  const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
@@ -62741,26 +62731,22 @@ function createTypeChecker(host) {
62741
62731
  const sourceIsString = typeof sourceValue === "string";
62742
62732
  const targetIsString = typeof targetValue === "string";
62743
62733
  if (sourceValue !== void 0 && targetValue !== void 0) {
62744
- if (!errorReporter) {
62745
- enumRelation.set(id, 2 /* Failed */);
62746
- } else {
62734
+ if (errorReporter) {
62747
62735
  const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
62748
62736
  const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
62749
62737
  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
62738
  }
62739
+ enumRelation.set(id, 2 /* Failed */);
62752
62740
  return false;
62753
62741
  }
62754
62742
  if (sourceIsString || targetIsString) {
62755
- if (!errorReporter) {
62756
- enumRelation.set(id, 2 /* Failed */);
62757
- } else {
62743
+ if (errorReporter) {
62758
62744
  const knownStringValue = sourceValue ?? targetValue;
62759
62745
  Debug.assert(typeof knownStringValue === "string");
62760
62746
  const escapedValue = `"${escapeString(knownStringValue)}"`;
62761
62747
  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
62748
  }
62749
+ enumRelation.set(id, 2 /* Failed */);
62764
62750
  return false;
62765
62751
  }
62766
62752
  }
@@ -62918,7 +62904,7 @@ function createTypeChecker(host) {
62918
62904
  /*ignoreConstraints*/
62919
62905
  false
62920
62906
  );
62921
- relation.set(id, 4 /* Reported */ | 2 /* Failed */);
62907
+ relation.set(id, 2 /* Failed */ | (relationCount <= 0 ? 32 /* ComplexityOverflow */ : 64 /* StackDepthOverflow */));
62922
62908
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
62923
62909
  const message = relationCount <= 0 ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
62924
62910
  const diag2 = error(errorNode || currentNode, message, typeToString(source), typeToString(target));
@@ -63771,7 +63757,7 @@ function createTypeChecker(host) {
63771
63757
  );
63772
63758
  const entry = relation.get(id);
63773
63759
  if (entry !== void 0) {
63774
- if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
63760
+ if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 96 /* Overflow */)) {
63775
63761
  } else {
63776
63762
  if (outofbandVarianceMarkerHandler) {
63777
63763
  const saved = entry & 24 /* ReportsMask */;
@@ -63782,6 +63768,11 @@ function createTypeChecker(host) {
63782
63768
  instantiateType(source2, reportUnreliableMapper);
63783
63769
  }
63784
63770
  }
63771
+ if (reportErrors2 && entry & 96 /* Overflow */) {
63772
+ const message = entry & 32 /* ComplexityOverflow */ ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
63773
+ reportError(message, typeToString(source2), typeToString(target2));
63774
+ overrideNextErrorInfo++;
63775
+ }
63785
63776
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
63786
63777
  }
63787
63778
  }
@@ -63879,7 +63870,7 @@ function createTypeChecker(host) {
63879
63870
  }
63880
63871
  }
63881
63872
  } else {
63882
- relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
63873
+ relation.set(id, 2 /* Failed */ | propagatingVarianceFlags);
63883
63874
  relationCount--;
63884
63875
  resetMaybeStack(
63885
63876
  /*markAllAsSucceeded*/
@@ -69915,9 +69906,9 @@ function createTypeChecker(host) {
69915
69906
  );
69916
69907
  }
69917
69908
  }
69918
- function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
69909
+ function getNarrowedTypeOfSymbol(symbol, location) {
69919
69910
  var _a;
69920
- const type = getTypeOfSymbol(symbol, checkMode);
69911
+ const type = getTypeOfSymbol(symbol);
69921
69912
  const declaration = symbol.valueDeclaration;
69922
69913
  if (declaration) {
69923
69914
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
@@ -70056,7 +70047,10 @@ function createTypeChecker(host) {
70056
70047
  }
70057
70048
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
70058
70049
  let declaration = localOrExportSymbol.valueDeclaration;
70059
- let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
70050
+ if (declaration && declaration.kind === 208 /* BindingElement */ && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, (parent) => parent === declaration.parent)) {
70051
+ return nonInferrableAnyType;
70052
+ }
70053
+ let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
70060
70054
  const assignmentKind = getAssignmentTargetKind(node);
70061
70055
  if (assignmentKind) {
70062
70056
  if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
@@ -71749,7 +71743,7 @@ function createTypeChecker(host) {
71749
71743
  return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
71750
71744
  }
71751
71745
  function hasDefaultValue(node) {
71752
- return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
71746
+ 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
71747
  }
71754
71748
  function isSpreadIntoCallOrNew(node) {
71755
71749
  const parent = walkUpParenthesizedExpressions(node.parent);
@@ -71918,7 +71912,6 @@ function createTypeChecker(host) {
71918
71912
  return links.immediateTarget;
71919
71913
  }
71920
71914
  function checkObjectLiteral(node, checkMode = 0 /* Normal */) {
71921
- var _a;
71922
71915
  const inDestructuringPattern = isAssignmentTarget(node);
71923
71916
  checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
71924
71917
  const allPropertiesTable = strictNullChecks ? createSymbolTable() : void 0;
@@ -71973,11 +71966,8 @@ function createTypeChecker(host) {
71973
71966
  if (nameType) {
71974
71967
  prop.links.nameType = nameType;
71975
71968
  }
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
- }
71969
+ if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
71970
+ prop.flags |= 16777216 /* Optional */;
71981
71971
  } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
71982
71972
  const impliedProp = getPropertyOfType(contextualType, member.escapedName);
71983
71973
  if (impliedProp) {
@@ -72052,21 +72042,6 @@ function createTypeChecker(host) {
72052
72042
  propertiesArray.push(member);
72053
72043
  }
72054
72044
  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
72045
  if (isErrorType(spread)) {
72071
72046
  return errorType;
72072
72047
  }
@@ -72589,7 +72564,7 @@ function createTypeChecker(host) {
72589
72564
  checkGrammarJsxElement(node);
72590
72565
  }
72591
72566
  checkJsxPreconditions(node);
72592
- markLinkedReferences(node, 4 /* Jsx */);
72567
+ markJsxAliasReferenced(node);
72593
72568
  if (isNodeOpeningLikeElement) {
72594
72569
  const jsxOpeningLikeNode = node;
72595
72570
  const sig = getResolvedSignature(jsxOpeningLikeNode);
@@ -77344,7 +77319,7 @@ function createTypeChecker(host) {
77344
77319
  );
77345
77320
  }
77346
77321
  }
77347
- const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
77322
+ const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */ | (hasDefaultValue(property) ? 16 /* AllowMissing */ : 0), name);
77348
77323
  const type = getFlowTypeOfDestructuring(property, elementType);
77349
77324
  return checkDestructuringAssignment(property.kind === 304 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
77350
77325
  } else if (property.kind === 305 /* SpreadAssignment */) {
@@ -77393,7 +77368,7 @@ function createTypeChecker(host) {
77393
77368
  if (element.kind !== 230 /* SpreadElement */) {
77394
77369
  const indexType = getNumberLiteralType(elementIndex);
77395
77370
  if (isArrayLikeType(sourceType)) {
77396
- const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
77371
+ const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AllowMissing */ : 0);
77397
77372
  const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
77398
77373
  const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
77399
77374
  const type = getFlowTypeOfDestructuring(element, assignedType);
@@ -78232,9 +78207,56 @@ function createTypeChecker(host) {
78232
78207
  void 0,
78233
78208
  checkMode || 0 /* Normal */
78234
78209
  ) : 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;
78210
+ if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) {
78211
+ if (declaration.name.kind === 206 /* ObjectBindingPattern */ && isObjectLiteralType(type)) {
78212
+ return padObjectLiteralType(type, declaration.name);
78213
+ }
78214
+ if (declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type)) {
78215
+ return padTupleType(type, declaration.name);
78216
+ }
78217
+ }
78218
+ return type;
78219
+ }
78220
+ function padObjectLiteralType(type, pattern) {
78221
+ let missingElements;
78222
+ for (const e of pattern.elements) {
78223
+ if (e.initializer) {
78224
+ const name = getPropertyNameFromBindingElement(e);
78225
+ if (name && !getPropertyOfType(type, name)) {
78226
+ missingElements = append(missingElements, e);
78227
+ }
78228
+ }
78229
+ }
78230
+ if (!missingElements) {
78231
+ return type;
78232
+ }
78233
+ const members = createSymbolTable();
78234
+ for (const prop of getPropertiesOfObjectType(type)) {
78235
+ members.set(prop.escapedName, prop);
78236
+ }
78237
+ for (const e of missingElements) {
78238
+ const symbol = createSymbol(4 /* Property */ | 16777216 /* Optional */, getPropertyNameFromBindingElement(e));
78239
+ symbol.links.type = getTypeFromBindingElement(
78240
+ e,
78241
+ /*includePatternInType*/
78242
+ false,
78243
+ /*reportErrors*/
78244
+ false
78245
+ );
78246
+ members.set(symbol.escapedName, symbol);
78247
+ }
78248
+ const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type));
78249
+ result.objectFlags = type.objectFlags;
78250
+ return result;
78251
+ }
78252
+ function getPropertyNameFromBindingElement(e) {
78253
+ const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name);
78254
+ return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : void 0;
78236
78255
  }
78237
78256
  function padTupleType(type, pattern) {
78257
+ if (type.target.combinedFlags & 12 /* Variable */ || getTypeReferenceArity(type) >= pattern.elements.length) {
78258
+ return type;
78259
+ }
78238
78260
  const patternElements = pattern.elements;
78239
78261
  const elementTypes = getElementTypes(type).slice();
78240
78262
  const elementFlags = type.target.elementFlags.slice();
@@ -85391,15 +85413,14 @@ function createTypeChecker(host) {
85391
85413
  function checkChildIdentifiers(node2) {
85392
85414
  forEachNodeRecursively(node2, checkIdentifiers);
85393
85415
  }
85416
+ function isExpressionNodeOrShorthandPropertyAssignmentName(node2) {
85417
+ return isExpressionNode(node2) || isShorthandPropertyAssignment(node2.parent) && (node2.parent.objectAssignmentInitializer ?? node2.parent.name) === node2;
85418
+ }
85394
85419
  function checkSingleIdentifier(node2) {
85395
85420
  const nodeLinks2 = getNodeLinks(node2);
85396
85421
  nodeLinks2.calculatedFlags |= 536870912 /* ConstructorReference */ | 16384 /* CapturedBlockScopedBinding */ | 32768 /* BlockScopedBindingInLoop */;
85397
- if (isIdentifier(node2) && isExpressionNode(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
85398
- const s = getSymbolAtLocation(
85399
- node2,
85400
- /*ignoreErrors*/
85401
- true
85402
- );
85422
+ if (isIdentifier(node2) && isExpressionNodeOrShorthandPropertyAssignmentName(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
85423
+ const s = getResolvedSymbol(node2);
85403
85424
  if (s && s !== unknownSymbol) {
85404
85425
  checkIdentifierCalculateNodeCheckFlags(node2, s);
85405
85426
  }
@@ -119129,7 +119150,7 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
119129
119150
  const packageJsonLocations = [];
119130
119151
  state.failedLookupLocations = packageJsonLocations;
119131
119152
  state.affectingLocations = packageJsonLocations;
119132
- const packageJsonScope = getPackageScopeForPath(fileName, state);
119153
+ const packageJsonScope = getPackageScopeForPath(getDirectoryPath(fileName), state);
119133
119154
  const impliedNodeFormat = (packageJsonScope == null ? void 0 : packageJsonScope.contents.packageJsonContent.type) === "module" ? 99 /* ESNext */ : 1 /* CommonJS */;
119134
119155
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
119135
119156
  }
@@ -123044,7 +123065,12 @@ function repopulateDiagnostics(diagnostics, newProgram) {
123044
123065
  }
123045
123066
  function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo) {
123046
123067
  const info = repopulateInfo(chain);
123047
- if (info) {
123068
+ if (info === true) {
123069
+ return {
123070
+ ...createModeMismatchDetails(sourceFile),
123071
+ next: convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo)
123072
+ };
123073
+ } else if (info) {
123048
123074
  return {
123049
123075
  ...createModuleNotFoundChain(sourceFile, newProgram, info.moduleReference, info.mode, info.packageName || info.moduleReference),
123050
123076
  next: convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo)
@@ -124775,7 +124801,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124775
124801
  cleanupLibResolutionWatching(newProgram);
124776
124802
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
124777
124803
  var _a;
124778
- const expected = isExternalOrCommonJsModule(newFile) ? ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0 : 0;
124804
+ const expected = ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0;
124779
124805
  const existing = impliedFormatPackageJsons.get(newFile.resolvedPath) ?? emptyArray;
124780
124806
  for (let i = existing.length; i < expected; i++) {
124781
124807
  createFileWatcherOfAffectingLocation(