@typescript-deploys/pr-build 5.6.0-pr-59154-17 → 5.6.0-pr-59287-2

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.
Files changed (3) hide show
  1. package/lib/tsc.js +192 -175
  2. package/lib/typescript.js +217 -206
  3. package/package.json +2 -2
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-insiders.20240708`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240715`;
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."),
@@ -6761,7 +6762,7 @@ var Diagnostics = {
6761
6762
  Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
6762
6763
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
6763
6764
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
6764
- Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
6765
+ Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected_4094", "Property '{0}' of exported anonymous class type may not be private or protected."),
6765
6766
  Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4095, 1 /* Error */, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095", "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
6766
6767
  Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4096, 1 /* Error */, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096", "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
6767
6768
  Public_static_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4097, 1 /* Error */, "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097", "Public static method '{0}' of exported class has or is using private name '{1}'."),
@@ -6999,7 +7000,6 @@ var Diagnostics = {
6999
7000
  Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, 3 /* Message */, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", 'Parse in strict mode and emit "use strict" for each source file.'),
7000
7001
  Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, 1 /* Error */, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."),
7001
7002
  Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, 3 /* Message */, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."),
7002
- Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, 3 /* Message */, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."),
7003
7003
  Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, 3 /* Message */, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."),
7004
7004
  Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, 3 /* Message */, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."),
7005
7005
  Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, 3 /* Message */, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."),
@@ -8550,6 +8550,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8550
8550
  hasExtendedUnicodeEscape: () => (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0,
8551
8551
  hasPrecedingLineBreak: () => (tokenFlags & 1 /* PrecedingLineBreak */) !== 0,
8552
8552
  hasPrecedingJSDocComment: () => (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0,
8553
+ hasPrecedingJSDocLeadingAsterisks: () => (tokenFlags & 32768 /* PrecedingJSDocLeadingAsterisks */) !== 0,
8553
8554
  isIdentifier: () => token === 80 /* Identifier */ || token > 118 /* LastReservedWord */,
8554
8555
  isReservedWord: () => token >= 83 /* FirstReservedWord */ && token <= 118 /* LastReservedWord */,
8555
8556
  isUnterminated: () => (tokenFlags & 4 /* Unterminated */) !== 0,
@@ -9190,7 +9191,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9190
9191
  function scan() {
9191
9192
  fullStartPos = pos;
9192
9193
  tokenFlags = 0 /* None */;
9193
- let asteriskSeen = false;
9194
9194
  while (true) {
9195
9195
  tokenStart = pos;
9196
9196
  if (pos >= end) {
@@ -9306,8 +9306,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9306
9306
  return pos += 2, token = 43 /* AsteriskAsteriskToken */;
9307
9307
  }
9308
9308
  pos++;
9309
- if (skipJsDocLeadingAsterisks && !asteriskSeen && tokenFlags & 1 /* PrecedingLineBreak */) {
9310
- asteriskSeen = true;
9309
+ if (skipJsDocLeadingAsterisks && (tokenFlags & 32768 /* PrecedingJSDocLeadingAsterisks */) === 0 && tokenFlags & 1 /* PrecedingLineBreak */) {
9310
+ tokenFlags |= 32768 /* PrecedingJSDocLeadingAsterisks */;
9311
9311
  continue;
9312
9312
  }
9313
9313
  return token = 42 /* AsteriskToken */;
@@ -28948,7 +28948,7 @@ var Parser;
28948
28948
  function createIdentifier(isIdentifier3, diagnosticMessage, privateIdentifierDiagnosticMessage) {
28949
28949
  if (isIdentifier3) {
28950
28950
  identifierCount++;
28951
- const pos = getNodePos();
28951
+ const pos = scanner.hasPrecedingJSDocLeadingAsterisks() ? scanner.getTokenStart() : getNodePos();
28952
28952
  const originalKeywordKind = token();
28953
28953
  const text = internIdentifier(scanner.getTokenValue());
28954
28954
  const hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
@@ -36078,6 +36078,7 @@ var commandOptionsWithoutBuild = [
36078
36078
  type: "boolean",
36079
36079
  affectsEmit: true,
36080
36080
  affectsBuildInfo: true,
36081
+ affectsSourceFile: true,
36081
36082
  category: Diagnostics.Emit,
36082
36083
  description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
36083
36084
  defaultValueDescription: false
@@ -36542,6 +36543,7 @@ var commandOptionsWithoutBuild = [
36542
36543
  affectsEmit: true,
36543
36544
  affectsBuildInfo: true,
36544
36545
  affectsModuleResolution: true,
36546
+ affectsSourceFile: true,
36545
36547
  category: Diagnostics.Language_and_Environment,
36546
36548
  description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
36547
36549
  defaultValueDescription: "react"
@@ -45517,13 +45519,6 @@ function createTypeChecker(host) {
45517
45519
  /*withAugmentations*/
45518
45520
  true
45519
45521
  ),
45520
- tryFindAmbientModuleWithoutAugmentations: (moduleName) => {
45521
- return tryFindAmbientModule(
45522
- moduleName,
45523
- /*withAugmentations*/
45524
- false
45525
- );
45526
- },
45527
45522
  getApparentType,
45528
45523
  getUnionType,
45529
45524
  isTypeAssignableTo,
@@ -46066,6 +46061,7 @@ function createTypeChecker(host) {
46066
46061
  };
46067
46062
  var amalgamatedDuplicates;
46068
46063
  var reverseMappedCache = /* @__PURE__ */ new Map();
46064
+ var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
46069
46065
  var ambientModulesCache;
46070
46066
  var patternAmbientModules;
46071
46067
  var patternAmbientModuleAugmentations;
@@ -46136,6 +46132,7 @@ function createTypeChecker(host) {
46136
46132
  var contextualTypes = [];
46137
46133
  var contextualIsCache = [];
46138
46134
  var contextualTypeCount = 0;
46135
+ var contextualBindingPatterns = [];
46139
46136
  var inferenceContextNodes = [];
46140
46137
  var inferenceContexts = [];
46141
46138
  var inferenceContextCount = 0;
@@ -49430,11 +49427,11 @@ function createTypeChecker(host) {
49430
49427
  function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
49431
49428
  const originalType = type;
49432
49429
  if (addUndefined) {
49433
- type = getOptionalType(type);
49430
+ type = getOptionalType(type, !isParameter(host2));
49434
49431
  }
49435
49432
  const clone = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
49436
49433
  if (clone) {
49437
- if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49434
+ if (addUndefined && containsNonMissingUndefinedType(type) && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49438
49435
  return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
49439
49436
  }
49440
49437
  return clone;
@@ -50294,7 +50291,21 @@ function createTypeChecker(host) {
50294
50291
  }
50295
50292
  function shouldUsePlaceholderForProperty(propertySymbol, context) {
50296
50293
  var _a;
50297
- return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
50294
+ const depth = 3;
50295
+ return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */) || isDeeplyNestedReverseMappedTypeProperty());
50296
+ function isDeeplyNestedReverseMappedTypeProperty() {
50297
+ var _a2;
50298
+ if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
50299
+ return false;
50300
+ }
50301
+ for (let i = 0; i < depth; i++) {
50302
+ const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
50303
+ if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
50304
+ return false;
50305
+ }
50306
+ }
50307
+ return true;
50308
+ }
50298
50309
  }
50299
50310
  function addPropertyToElementList(propertySymbol, context, typeElements) {
50300
50311
  var _a;
@@ -51381,8 +51392,8 @@ function createTypeChecker(host) {
51381
51392
  return enclosingDeclaration;
51382
51393
  }
51383
51394
  function serializeTypeForDeclaration(context, declaration, type, symbol) {
51384
- var _a;
51385
- const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
51395
+ var _a, _b;
51396
+ const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
51386
51397
  const enclosingDeclaration = context.enclosingDeclaration;
51387
51398
  const oldFlags = context.flags;
51388
51399
  if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
@@ -51393,6 +51404,7 @@ function createTypeChecker(host) {
51393
51404
  const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
51394
51405
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
51395
51406
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
51407
+ const addUndefined = addUndefinedForParameter || !!(symbol.flags & 4 /* Property */ && symbol.flags & 16777216 /* Optional */ && isOptionalDeclaration(declWithExistingAnnotation) && ((_a = symbol.links) == null ? void 0 : _a.mappedType) && containsNonMissingUndefinedType(type));
51396
51408
  const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
51397
51409
  if (result2) {
51398
51410
  context.flags = oldFlags;
@@ -51403,9 +51415,9 @@ function createTypeChecker(host) {
51403
51415
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
51404
51416
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
51405
51417
  }
51406
- const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
51418
+ const decl = declaration ?? symbol.valueDeclaration ?? ((_b = symbol.declarations) == null ? void 0 : _b[0]);
51407
51419
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
51408
- const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
51420
+ const result = expressionOrTypeToTypeNode(context, expr, type, addUndefinedForParameter);
51409
51421
  context.flags = oldFlags;
51410
51422
  return result;
51411
51423
  }
@@ -51440,9 +51452,9 @@ function createTypeChecker(host) {
51440
51452
  const typePredicate = getTypePredicateOfSignature(signature);
51441
51453
  const type = getReturnTypeOfSignature(signature);
51442
51454
  if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
51443
- const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
51444
- if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
51445
- const result = tryReuseExistingTypeNodeHelper(context, annotation);
51455
+ const annotation = getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
51456
+ if (annotation) {
51457
+ const result = tryReuseExistingTypeNode(context, annotation, type, context.enclosingDeclaration);
51446
51458
  if (result) {
51447
51459
  return result;
51448
51460
  }
@@ -51936,7 +51948,10 @@ function createTypeChecker(host) {
51936
51948
  );
51937
51949
  }
51938
51950
  if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
51939
- if (!(context.flags & 1 /* AllowUnresolvedNames */ && hasDynamicName(node) && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
51951
+ if (!hasDynamicName(node)) {
51952
+ return visitEachChild2(node, visitExistingNodeTreeSymbols);
51953
+ }
51954
+ if (!(context.flags & 1 /* AllowUnresolvedNames */ && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
51940
51955
  return void 0;
51941
51956
  }
51942
51957
  }
@@ -54142,6 +54157,7 @@ function createTypeChecker(host) {
54142
54157
  } else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
54143
54158
  parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
54144
54159
  }
54160
+ const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* AllowMissing */ : 0);
54145
54161
  let type;
54146
54162
  if (pattern.kind === 206 /* ObjectBindingPattern */) {
54147
54163
  if (declaration.dotDotDotToken) {
@@ -54160,7 +54176,7 @@ function createTypeChecker(host) {
54160
54176
  } else {
54161
54177
  const name = declaration.propertyName || declaration.name;
54162
54178
  const indexType = getLiteralTypeFromPropertyName(name);
54163
- const declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
54179
+ const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
54164
54180
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54165
54181
  }
54166
54182
  } else {
@@ -54171,7 +54187,6 @@ function createTypeChecker(host) {
54171
54187
  type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
54172
54188
  } else if (isArrayLikeType(parentType)) {
54173
54189
  const indexType = getNumberLiteralType(index);
54174
- const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
54175
54190
  const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
54176
54191
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54177
54192
  } else {
@@ -54657,7 +54672,7 @@ function createTypeChecker(host) {
54657
54672
  /*reportErrors*/
54658
54673
  false
54659
54674
  ) : unknownType;
54660
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
54675
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
54661
54676
  }
54662
54677
  if (isBindingPattern(element.name)) {
54663
54678
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
@@ -54728,7 +54743,10 @@ function createTypeChecker(host) {
54728
54743
  return result;
54729
54744
  }
54730
54745
  function getTypeFromBindingPattern(pattern, includePatternInType = false, reportErrors2 = false) {
54731
- 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;
54732
54750
  }
54733
54751
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors2) {
54734
54752
  return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(
@@ -54809,18 +54827,18 @@ function createTypeChecker(host) {
54809
54827
  }
54810
54828
  return false;
54811
54829
  }
54812
- function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
54830
+ function getTypeOfVariableOrParameterOrProperty(symbol) {
54813
54831
  const links = getSymbolLinks(symbol);
54814
54832
  if (!links.type) {
54815
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
54816
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
54833
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
54834
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
54817
54835
  links.type = type;
54818
54836
  }
54819
54837
  return type;
54820
54838
  }
54821
54839
  return links.type;
54822
54840
  }
54823
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
54841
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
54824
54842
  if (symbol.flags & 4194304 /* Prototype */) {
54825
54843
  return getTypeOfPrototypeProperty(symbol);
54826
54844
  }
@@ -54855,9 +54873,6 @@ function createTypeChecker(host) {
54855
54873
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54856
54874
  return getTypeOfFuncClassEnumModule(symbol);
54857
54875
  }
54858
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54859
- return errorType;
54860
- }
54861
54876
  return reportCircularityError(symbol);
54862
54877
  }
54863
54878
  let type;
@@ -54895,9 +54910,6 @@ function createTypeChecker(host) {
54895
54910
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54896
54911
  return getTypeOfFuncClassEnumModule(symbol);
54897
54912
  }
54898
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54899
- return type;
54900
- }
54901
54913
  return reportCircularityError(symbol);
54902
54914
  }
54903
54915
  return type;
@@ -55126,7 +55138,7 @@ function createTypeChecker(host) {
55126
55138
  }
55127
55139
  return getTypeOfSymbol(symbol);
55128
55140
  }
55129
- function getTypeOfSymbol(symbol, checkMode) {
55141
+ function getTypeOfSymbol(symbol) {
55130
55142
  const checkFlags = getCheckFlags(symbol);
55131
55143
  if (checkFlags & 65536 /* DeferredType */) {
55132
55144
  return getTypeOfSymbolWithDeferredType(symbol);
@@ -55141,7 +55153,7 @@ function createTypeChecker(host) {
55141
55153
  return getTypeOfReverseMappedSymbol(symbol);
55142
55154
  }
55143
55155
  if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
55144
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
55156
+ return getTypeOfVariableOrParameterOrProperty(symbol);
55145
55157
  }
55146
55158
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
55147
55159
  return getTypeOfFuncClassEnumModule(symbol);
@@ -58027,7 +58039,7 @@ function createTypeChecker(host) {
58027
58039
  );
58028
58040
  }
58029
58041
  function createSignatureTypeMapper(signature, typeArguments) {
58030
- return createTypeMapper(signature.typeParameters, typeArguments);
58042
+ return createTypeMapper(sameMap(signature.typeParameters, (tp) => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
58031
58043
  }
58032
58044
  function getErasedSignature(signature) {
58033
58045
  return signature.typeParameters ? signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : signature;
@@ -60291,7 +60303,7 @@ function createTypeChecker(host) {
60291
60303
  }
60292
60304
  if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
60293
60305
  const index = +propName;
60294
- 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 */)) {
60295
60307
  const indexNode = getIndexNodeForAccessExpression(accessNode);
60296
60308
  if (isTupleType(objectType)) {
60297
60309
  if (index < 0) {
@@ -60430,6 +60442,9 @@ function createTypeChecker(host) {
60430
60442
  return void 0;
60431
60443
  }
60432
60444
  }
60445
+ if (accessFlags & 16 /* AllowMissing */ && isObjectLiteralType(objectType)) {
60446
+ return undefinedType;
60447
+ }
60433
60448
  if (isJSLiteralType(objectType)) {
60434
60449
  return anyType;
60435
60450
  }
@@ -62683,6 +62698,10 @@ function createTypeChecker(host) {
62683
62698
  function containsUndefinedType(type) {
62684
62699
  return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
62685
62700
  }
62701
+ function containsNonMissingUndefinedType(type) {
62702
+ const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
62703
+ return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
62704
+ }
62686
62705
  function isStringIndexSignatureOnlyType(type) {
62687
62706
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
62688
62707
  }
@@ -62697,7 +62716,7 @@ function createTypeChecker(host) {
62697
62716
  }
62698
62717
  const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
62699
62718
  const entry = enumRelation.get(id);
62700
- if (entry !== void 0 && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
62719
+ if (entry !== void 0 && !(entry & 2 /* Failed */ && errorReporter)) {
62701
62720
  return !!(entry & 1 /* Succeeded */);
62702
62721
  }
62703
62722
  const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -62712,10 +62731,8 @@ function createTypeChecker(host) {
62712
62731
  void 0,
62713
62732
  64 /* UseFullyQualifiedType */
62714
62733
  ));
62715
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62716
- } else {
62717
- enumRelation.set(id, 2 /* Failed */);
62718
62734
  }
62735
+ enumRelation.set(id, 2 /* Failed */);
62719
62736
  return false;
62720
62737
  }
62721
62738
  const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
@@ -62724,26 +62741,22 @@ function createTypeChecker(host) {
62724
62741
  const sourceIsString = typeof sourceValue === "string";
62725
62742
  const targetIsString = typeof targetValue === "string";
62726
62743
  if (sourceValue !== void 0 && targetValue !== void 0) {
62727
- if (!errorReporter) {
62728
- enumRelation.set(id, 2 /* Failed */);
62729
- } else {
62744
+ if (errorReporter) {
62730
62745
  const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
62731
62746
  const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
62732
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);
62733
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62734
62748
  }
62749
+ enumRelation.set(id, 2 /* Failed */);
62735
62750
  return false;
62736
62751
  }
62737
62752
  if (sourceIsString || targetIsString) {
62738
- if (!errorReporter) {
62739
- enumRelation.set(id, 2 /* Failed */);
62740
- } else {
62753
+ if (errorReporter) {
62741
62754
  const knownStringValue = sourceValue ?? targetValue;
62742
62755
  Debug.assert(typeof knownStringValue === "string");
62743
62756
  const escapedValue = `"${escapeString(knownStringValue)}"`;
62744
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);
62745
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62746
62758
  }
62759
+ enumRelation.set(id, 2 /* Failed */);
62747
62760
  return false;
62748
62761
  }
62749
62762
  }
@@ -62901,7 +62914,7 @@ function createTypeChecker(host) {
62901
62914
  /*ignoreConstraints*/
62902
62915
  false
62903
62916
  );
62904
- relation.set(id, 4 /* Reported */ | 2 /* Failed */);
62917
+ relation.set(id, 2 /* Failed */ | (relationCount <= 0 ? 32 /* ComplexityOverflow */ : 64 /* StackDepthOverflow */));
62905
62918
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
62906
62919
  const message = relationCount <= 0 ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
62907
62920
  const diag2 = error(errorNode || currentNode, message, typeToString(source), typeToString(target));
@@ -63754,7 +63767,7 @@ function createTypeChecker(host) {
63754
63767
  );
63755
63768
  const entry = relation.get(id);
63756
63769
  if (entry !== void 0) {
63757
- if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
63770
+ if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 96 /* Overflow */)) {
63758
63771
  } else {
63759
63772
  if (outofbandVarianceMarkerHandler) {
63760
63773
  const saved = entry & 24 /* ReportsMask */;
@@ -63765,6 +63778,11 @@ function createTypeChecker(host) {
63765
63778
  instantiateType(source2, reportUnreliableMapper);
63766
63779
  }
63767
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
+ }
63768
63786
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
63769
63787
  }
63770
63788
  }
@@ -63862,7 +63880,7 @@ function createTypeChecker(host) {
63862
63880
  }
63863
63881
  }
63864
63882
  } else {
63865
- relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
63883
+ relation.set(id, 2 /* Failed */ | propagatingVarianceFlags);
63866
63884
  relationCount--;
63867
63885
  resetMaybeStack(
63868
63886
  /*markAllAsSucceeded*/
@@ -65957,12 +65975,12 @@ function createTypeChecker(host) {
65957
65975
  const widened = getWidenedTypeWithContext(original, propContext);
65958
65976
  return widened === original ? prop : createSymbolWithType(prop, widened);
65959
65977
  }
65960
- function getUndefinedProperty(prop) {
65978
+ function getOptionalNeverProperty(prop) {
65961
65979
  const cached = undefinedProperties.get(prop.escapedName);
65962
65980
  if (cached) {
65963
65981
  return cached;
65964
65982
  }
65965
- const result = createSymbolWithType(prop, undefinedOrMissingType);
65983
+ const result = createSymbolWithType(prop, neverType);
65966
65984
  result.flags |= 16777216 /* Optional */;
65967
65985
  undefinedProperties.set(prop.escapedName, result);
65968
65986
  return result;
@@ -65975,7 +65993,7 @@ function createTypeChecker(host) {
65975
65993
  if (context) {
65976
65994
  for (const prop of getPropertiesOfContext(context)) {
65977
65995
  if (!members.has(prop.escapedName)) {
65978
- members.set(prop.escapedName, getUndefinedProperty(prop));
65996
+ members.set(prop.escapedName, getOptionalNeverProperty(prop));
65979
65997
  }
65980
65998
  }
65981
65999
  }
@@ -66332,11 +66350,11 @@ function createTypeChecker(host) {
66332
66350
  }
66333
66351
  function inferTypeForHomomorphicMappedType(source, target, constraint) {
66334
66352
  const cacheKey = source.id + "," + target.id + "," + constraint.id;
66335
- if (reverseMappedCache.has(cacheKey)) {
66336
- return reverseMappedCache.get(cacheKey);
66353
+ if (reverseHomomorphicMappedCache.has(cacheKey)) {
66354
+ return reverseHomomorphicMappedCache.get(cacheKey);
66337
66355
  }
66338
66356
  const type = createReverseMappedType(source, target, constraint);
66339
- reverseMappedCache.set(cacheKey, type);
66357
+ reverseHomomorphicMappedCache.set(cacheKey, type);
66340
66358
  return type;
66341
66359
  }
66342
66360
  function isPartiallyInferableType(type) {
@@ -69898,9 +69916,9 @@ function createTypeChecker(host) {
69898
69916
  );
69899
69917
  }
69900
69918
  }
69901
- function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
69919
+ function getNarrowedTypeOfSymbol(symbol, location) {
69902
69920
  var _a;
69903
- const type = getTypeOfSymbol(symbol, checkMode);
69921
+ const type = getTypeOfSymbol(symbol);
69904
69922
  const declaration = symbol.valueDeclaration;
69905
69923
  if (declaration) {
69906
69924
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
@@ -70039,7 +70057,10 @@ function createTypeChecker(host) {
70039
70057
  }
70040
70058
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
70041
70059
  let declaration = localOrExportSymbol.valueDeclaration;
70042
- 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);
70043
70064
  const assignmentKind = getAssignmentTargetKind(node);
70044
70065
  if (assignmentKind) {
70045
70066
  if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
@@ -71732,7 +71753,7 @@ function createTypeChecker(host) {
71732
71753
  return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
71733
71754
  }
71734
71755
  function hasDefaultValue(node) {
71735
- 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 */;
71736
71757
  }
71737
71758
  function isSpreadIntoCallOrNew(node) {
71738
71759
  const parent = walkUpParenthesizedExpressions(node.parent);
@@ -71901,7 +71922,6 @@ function createTypeChecker(host) {
71901
71922
  return links.immediateTarget;
71902
71923
  }
71903
71924
  function checkObjectLiteral(node, checkMode = 0 /* Normal */) {
71904
- var _a;
71905
71925
  const inDestructuringPattern = isAssignmentTarget(node);
71906
71926
  checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
71907
71927
  const allPropertiesTable = strictNullChecks ? createSymbolTable() : void 0;
@@ -71956,11 +71976,8 @@ function createTypeChecker(host) {
71956
71976
  if (nameType) {
71957
71977
  prop.links.nameType = nameType;
71958
71978
  }
71959
- if (inDestructuringPattern) {
71960
- const isOptional = memberDecl.kind === 303 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer) || memberDecl.kind === 304 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer;
71961
- if (isOptional) {
71962
- prop.flags |= 16777216 /* Optional */;
71963
- }
71979
+ if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
71980
+ prop.flags |= 16777216 /* Optional */;
71964
71981
  } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
71965
71982
  const impliedProp = getPropertyOfType(contextualType, member.escapedName);
71966
71983
  if (impliedProp) {
@@ -72035,21 +72052,6 @@ function createTypeChecker(host) {
72035
72052
  propertiesArray.push(member);
72036
72053
  }
72037
72054
  popContextualType();
72038
- if (contextualTypeHasPattern) {
72039
- const rootPatternParent = findAncestor(contextualType.pattern.parent, (n) => n.kind === 260 /* VariableDeclaration */ || n.kind === 226 /* BinaryExpression */ || n.kind === 169 /* Parameter */);
72040
- const spreadOrOutsideRootObject = findAncestor(node, (n) => n === rootPatternParent || n.kind === 305 /* SpreadAssignment */);
72041
- if (spreadOrOutsideRootObject.kind !== 305 /* SpreadAssignment */) {
72042
- for (const prop of getPropertiesOfType(contextualType)) {
72043
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
72044
- if (!(prop.flags & 16777216 /* Optional */)) {
72045
- 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);
72046
- }
72047
- propertiesTable.set(prop.escapedName, prop);
72048
- propertiesArray.push(prop);
72049
- }
72050
- }
72051
- }
72052
- }
72053
72055
  if (isErrorType(spread)) {
72054
72056
  return errorType;
72055
72057
  }
@@ -77327,7 +77329,7 @@ function createTypeChecker(host) {
77327
77329
  );
77328
77330
  }
77329
77331
  }
77330
- const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
77332
+ const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */ | (hasDefaultValue(property) ? 16 /* AllowMissing */ : 0), name);
77331
77333
  const type = getFlowTypeOfDestructuring(property, elementType);
77332
77334
  return checkDestructuringAssignment(property.kind === 304 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
77333
77335
  } else if (property.kind === 305 /* SpreadAssignment */) {
@@ -77376,7 +77378,7 @@ function createTypeChecker(host) {
77376
77378
  if (element.kind !== 230 /* SpreadElement */) {
77377
77379
  const indexType = getNumberLiteralType(elementIndex);
77378
77380
  if (isArrayLikeType(sourceType)) {
77379
- const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
77381
+ const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AllowMissing */ : 0);
77380
77382
  const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
77381
77383
  const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
77382
77384
  const type = getFlowTypeOfDestructuring(element, assignedType);
@@ -78215,9 +78217,56 @@ function createTypeChecker(host) {
78215
78217
  void 0,
78216
78218
  checkMode || 0 /* Normal */
78217
78219
  ) : checkExpressionCached(initializer, checkMode));
78218
- 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;
78219
78265
  }
78220
78266
  function padTupleType(type, pattern) {
78267
+ if (type.target.combinedFlags & 12 /* Variable */ || getTypeReferenceArity(type) >= pattern.elements.length) {
78268
+ return type;
78269
+ }
78221
78270
  const patternElements = pattern.elements;
78222
78271
  const elementTypes = getElementTypes(type).slice();
78223
78272
  const elementFlags = type.target.elementFlags.slice();
@@ -110992,6 +111041,7 @@ function transformDeclarations(context) {
110992
111041
  }
110993
111042
  function reportInferenceFallback(node) {
110994
111043
  if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
111044
+ if (getSourceFileOfNode(node) !== currentSourceFile) return;
110995
111045
  if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
110996
111046
  reportExpandoFunctionErrors(node);
110997
111047
  } else {
@@ -111036,7 +111086,10 @@ function transformDeclarations(context) {
111036
111086
  function reportPrivateInBaseOfClassExpression(propertyName) {
111037
111087
  if (errorNameNode || errorFallbackNode) {
111038
111088
  context.addDiagnostic(
111039
- createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)
111089
+ addRelatedInfo(
111090
+ createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected, propertyName),
111091
+ ...isVariableDeclaration((errorNameNode || errorFallbackNode).parent) ? [createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Add_a_type_annotation_to_the_variable_0, errorDeclarationNameWithFallback())] : []
111092
+ )
111040
111093
  );
111041
111094
  }
111042
111095
  }
@@ -119244,7 +119297,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119244
119297
  let commonSourceDirectory;
119245
119298
  let typeChecker;
119246
119299
  let classifiableNames;
119247
- const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
119248
119300
  let fileReasons = createMultiMap();
119249
119301
  let filesWithReferencesProcessed;
119250
119302
  let fileReasonsToChain;
@@ -119493,7 +119545,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119493
119545
  const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
119494
119546
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
119495
119547
  oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
119496
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
119548
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path), newFile);
119497
119549
  }
119498
119550
  }
119499
119551
  if (!host.getParsedCommandLine) {
@@ -119503,7 +119555,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119503
119555
  resolvedProjectReference.sourceFile,
119504
119556
  oldProgram.getCompilerOptions(),
119505
119557
  /*hasSourceFileByPath*/
119506
- false
119558
+ false,
119559
+ /*newSourceFileByResolvedPath*/
119560
+ void 0
119507
119561
  );
119508
119562
  }
119509
119563
  });
@@ -119832,35 +119886,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119832
119886
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
119833
119887
  getResolved: getResolvedModuleFromResolution,
119834
119888
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
119835
- isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
119889
+ resolveToOwnAmbientModule: true
119836
119890
  });
119837
119891
  }
119838
- function moduleNameResolvesToAmbientModule(moduleName, file) {
119839
- if (contains(file.ambientModuleNames, moduleName.text)) {
119840
- if (isTraceEnabled(options, host)) {
119841
- trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
119842
- }
119843
- return true;
119844
- } else {
119845
- return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
119846
- }
119847
- }
119848
- function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file) {
119849
- var _a2;
119850
- const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
119851
- const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
119852
- if (resolutionToFile && resolvedFile) {
119853
- return false;
119854
- }
119855
- const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
119856
- if (!unmodifiedFile) {
119857
- return false;
119858
- }
119859
- if (isTraceEnabled(options, host)) {
119860
- trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
119861
- }
119862
- return true;
119863
- }
119864
119892
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
119865
119893
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119866
119894
  return resolveNamesReusingOldState({
@@ -119888,10 +119916,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119888
119916
  getResolutionFromOldProgram,
119889
119917
  getResolved,
119890
119918
  canReuseResolutionsInFile,
119891
- isEntryResolvingToAmbientModule
119919
+ resolveToOwnAmbientModule
119892
119920
  }) {
119893
119921
  if (!entries.length) return emptyArray;
119894
- if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119922
+ if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119895
119923
  return resolutionWorker(
119896
119924
  entries,
119897
119925
  containingFile,
@@ -119927,12 +119955,23 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119927
119955
  continue;
119928
119956
  }
119929
119957
  }
119930
- if (isEntryResolvingToAmbientModule == null ? void 0 : isEntryResolvingToAmbientModule(entry, containingFile)) {
119931
- (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119932
- } else {
119933
- (unknownEntries ?? (unknownEntries = [])).push(entry);
119934
- (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119958
+ if (resolveToOwnAmbientModule) {
119959
+ const name = nameAndModeGetter.getName(entry);
119960
+ if (contains(containingSourceFile.ambientModuleNames, name)) {
119961
+ if (isTraceEnabled(options, host)) {
119962
+ trace(
119963
+ host,
119964
+ Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1,
119965
+ name,
119966
+ getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory)
119967
+ );
119968
+ }
119969
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119970
+ continue;
119971
+ }
119935
119972
  }
119973
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
119974
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119936
119975
  }
119937
119976
  if (!unknownEntries) return result;
119938
119977
  const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
@@ -120066,10 +120105,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120066
120105
  } else if (hasInvalidatedResolutions(oldSourceFile.path)) {
120067
120106
  structureIsReused = 1 /* SafeModules */;
120068
120107
  modifiedSourceFiles.push(newSourceFile);
120069
- } else {
120070
- for (const moduleName of oldSourceFile.ambientModuleNames) {
120071
- ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
120072
- }
120073
120108
  }
120074
120109
  newSourceFiles.push(newSourceFile);
120075
120110
  }
@@ -124597,7 +124632,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124597
124632
  let filesWithChangedSetOfUnresolvedImports;
124598
124633
  let filesWithInvalidatedResolutions;
124599
124634
  let filesWithInvalidatedNonRelativeUnresolvedImports;
124600
- const nonRelativeExternalModuleResolutions = createMultiMap();
124635
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
124601
124636
  const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
124602
124637
  const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
124603
124638
  const resolvedFileToResolution = /* @__PURE__ */ new Map();
@@ -124748,8 +124783,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124748
124783
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
124749
124784
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
124750
124785
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
124751
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124752
- nonRelativeExternalModuleResolutions.clear();
124786
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124753
124787
  isSymlinkCache.clear();
124754
124788
  }
124755
124789
  function cleanupLibResolutionWatching(newProgram) {
@@ -124768,8 +124802,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124768
124802
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
124769
124803
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
124770
124804
  allModuleAndTypeResolutionsAreInvalidated = false;
124771
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124772
- nonRelativeExternalModuleResolutions.clear();
124805
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124773
124806
  if (newProgram !== oldProgram) {
124774
124807
  cleanupLibResolutionWatching(newProgram);
124775
124808
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
@@ -125032,7 +125065,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125032
125065
  if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
125033
125066
  watchFailedLookupLocationOfResolution(resolution);
125034
125067
  } else {
125035
- nonRelativeExternalModuleResolutions.add(name, resolution);
125068
+ nonRelativeExternalModuleResolutions.add(resolution);
125036
125069
  }
125037
125070
  const resolved = getResolutionWithResolvedFileName(resolution);
125038
125071
  if (resolved && resolved.resolvedFileName) {
@@ -125168,17 +125201,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125168
125201
  (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
125169
125202
  packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
125170
125203
  }
125171
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
125172
- const program = resolutionHost.getCurrentProgram();
125173
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
125174
- resolutions.forEach(watchFailedLookupLocationOfResolution);
125175
- } else {
125176
- resolutions.forEach((resolution) => watchAffectingLocationsOfResolution(
125177
- resolution,
125178
- /*addToResolutionsWithOnlyAffectingLocations*/
125179
- true
125180
- ));
125181
- }
125204
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
125205
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
125206
+ nonRelativeExternalModuleResolutions.clear();
125182
125207
  }
125183
125208
  function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
125184
125209
  Debug.assert(!nonRecursive);
@@ -125198,11 +125223,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125198
125223
  );
125199
125224
  } else if (packageDirWatcher.isSymlink !== isSymlink) {
125200
125225
  packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
125201
- removeDirectoryWatcher(
125202
- packageDirWatcher.isSymlink ? packageDirPath : dirPath,
125203
- /*syncDirWatcherRemove*/
125204
- false
125205
- );
125226
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125206
125227
  watcher.watcher = createDirPathToWatcher();
125207
125228
  });
125208
125229
  packageDirWatcher.isSymlink = isSymlink;
@@ -125242,7 +125263,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125242
125263
  }
125243
125264
  return dirWatcher;
125244
125265
  }
125245
- function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove) {
125266
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
125246
125267
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
125247
125268
  const toWatch = getDirectoryToWatchFailedLookupLocation(
125248
125269
  failedLookupLocation,
@@ -125262,7 +125283,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125262
125283
  const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
125263
125284
  forDirPath.refCount--;
125264
125285
  if (forDirPath.refCount === 0) {
125265
- removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath, syncDirWatcherRemove);
125286
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125266
125287
  packageDirWatcher.dirPathToWatcher.delete(dirPath);
125267
125288
  if (packageDirWatcher.isSymlink) {
125268
125289
  const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
@@ -125272,15 +125293,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125272
125293
  dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
125273
125294
  }
125274
125295
  }
125275
- if (syncDirWatcherRemove) closePackageDirWatcher(packageDirWatcher, packageDirPath);
125276
125296
  }
125277
125297
  } else {
125278
- removeDirectoryWatcher(dirPath, syncDirWatcherRemove);
125298
+ removeDirectoryWatcher(dirPath);
125279
125299
  }
125280
125300
  }
125281
125301
  return removeAtRoot;
125282
125302
  }
125283
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125303
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
125284
125304
  Debug.checkDefined(resolution.files).delete(filePath);
125285
125305
  if (resolution.files.size) return;
125286
125306
  resolution.files = void 0;
@@ -125295,11 +125315,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125295
125315
  let removeAtRoot = false;
125296
125316
  if (failedLookupLocations) {
125297
125317
  for (const failedLookupLocation of failedLookupLocations) {
125298
- removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove);
125318
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
125299
125319
  }
125300
125320
  }
125301
- if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot, syncDirWatcherRemove);
125302
- if (removeAtRoot) removeDirectoryWatcher(rootPath, syncDirWatcherRemove);
125321
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
125322
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
125303
125323
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
125304
125324
  resolutionsWithOnlyAffectingLocations.delete(resolution);
125305
125325
  }
@@ -125307,14 +125327,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125307
125327
  for (const affectingLocation of affectingLocations) {
125308
125328
  const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
125309
125329
  watcher.resolutions--;
125310
- if (syncDirWatcherRemove) closeFileWatcherOfAffectingLocation(watcher, affectingLocation);
125311
125330
  }
125312
125331
  }
125313
125332
  }
125314
- function removeDirectoryWatcher(dirPath, syncDirWatcherRemove) {
125333
+ function removeDirectoryWatcher(dirPath) {
125315
125334
  const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
125316
125335
  dirWatcher.refCount--;
125317
- if (syncDirWatcherRemove) closeDirectoryWatchesOfFailedLookup(dirWatcher, dirPath);
125318
125336
  }
125319
125337
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
125320
125338
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
@@ -125325,15 +125343,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125325
125343
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
125326
125344
  }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
125327
125345
  }
125328
- function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125346
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
125329
125347
  const resolutions = cache.get(filePath);
125330
125348
  if (resolutions) {
125331
125349
  resolutions.forEach(
125332
125350
  (resolution) => stopWatchFailedLookupLocationOfResolution(
125333
125351
  resolution,
125334
125352
  filePath,
125335
- getResolutionWithResolvedFileName,
125336
- syncDirWatcherRemove
125353
+ getResolutionWithResolvedFileName
125337
125354
  )
125338
125355
  );
125339
125356
  cache.delete(filePath);
@@ -125347,9 +125364,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125347
125364
  if (!resolvedProjectReference) return;
125348
125365
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
125349
125366
  }
125350
- function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
125351
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
125352
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
125367
+ function removeResolutionsOfFile(filePath) {
125368
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
125369
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
125353
125370
  }
125354
125371
  function invalidateResolutions(resolutions, canInvalidate) {
125355
125372
  if (!resolutions) return false;