@typescript-deploys/pr-build 5.6.0-pr-59154-17 → 5.6.0-pr-59217-14

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-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."),
@@ -6685,6 +6686,9 @@ var Diagnostics = {
6685
6686
  Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled: diag(2866, 1 /* Error */, "Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_w_2866", "Import '{0}' conflicts with global value used in this file, so must be declared with a type-only import when 'isolatedModules' is enabled."),
6686
6687
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun: diag(2867, 1 /* Error */, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2867", "Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`."),
6687
6688
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig: diag(2868, 1 /* Error */, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2868", "Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig."),
6689
+ This_expression_is_always_truthy_Did_you_mean_to_test_something_else: diag(2869, 1 /* Error */, "This_expression_is_always_truthy_Did_you_mean_to_test_something_else_2869", "This expression is always truthy. Did you mean to test something else?"),
6690
+ This_expression_is_always_falsy_Did_you_mean_to_test_something_else: diag(2870, 1 /* Error */, "This_expression_is_always_falsy_Did_you_mean_to_test_something_else_2870", "This expression is always falsy. Did you mean to test something else?"),
6691
+ Using_on_this_expression_appears_unintentional_because_it_always_evaluates_to_the_same_nullishness: diag(2871, 1 /* Error */, "Using_on_this_expression_appears_unintentional_because_it_always_evaluates_to_the_same_nullishness_2871", "Using ?? on this expression appears unintentional because it always evaluates to the same nullishness."),
6688
6692
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6689
6693
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6690
6694
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -6761,7 +6765,7 @@ var Diagnostics = {
6761
6765
  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
6766
  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
6767
  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."),
6768
+ 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
6769
  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
6770
  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
6771
  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 +7003,6 @@ var Diagnostics = {
6999
7003
  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
7004
  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
7005
  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
7006
  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
7007
  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
7008
  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 +8553,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8550
8553
  hasExtendedUnicodeEscape: () => (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0,
8551
8554
  hasPrecedingLineBreak: () => (tokenFlags & 1 /* PrecedingLineBreak */) !== 0,
8552
8555
  hasPrecedingJSDocComment: () => (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0,
8556
+ hasPrecedingJSDocLeadingAsterisks: () => (tokenFlags & 32768 /* PrecedingJSDocLeadingAsterisks */) !== 0,
8553
8557
  isIdentifier: () => token === 80 /* Identifier */ || token > 118 /* LastReservedWord */,
8554
8558
  isReservedWord: () => token >= 83 /* FirstReservedWord */ && token <= 118 /* LastReservedWord */,
8555
8559
  isUnterminated: () => (tokenFlags & 4 /* Unterminated */) !== 0,
@@ -9190,7 +9194,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9190
9194
  function scan() {
9191
9195
  fullStartPos = pos;
9192
9196
  tokenFlags = 0 /* None */;
9193
- let asteriskSeen = false;
9194
9197
  while (true) {
9195
9198
  tokenStart = pos;
9196
9199
  if (pos >= end) {
@@ -9306,8 +9309,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9306
9309
  return pos += 2, token = 43 /* AsteriskAsteriskToken */;
9307
9310
  }
9308
9311
  pos++;
9309
- if (skipJsDocLeadingAsterisks && !asteriskSeen && tokenFlags & 1 /* PrecedingLineBreak */) {
9310
- asteriskSeen = true;
9312
+ if (skipJsDocLeadingAsterisks && (tokenFlags & 32768 /* PrecedingJSDocLeadingAsterisks */) === 0 && tokenFlags & 1 /* PrecedingLineBreak */) {
9313
+ tokenFlags |= 32768 /* PrecedingJSDocLeadingAsterisks */;
9311
9314
  continue;
9312
9315
  }
9313
9316
  return token = 42 /* AsteriskToken */;
@@ -28948,7 +28951,7 @@ var Parser;
28948
28951
  function createIdentifier(isIdentifier3, diagnosticMessage, privateIdentifierDiagnosticMessage) {
28949
28952
  if (isIdentifier3) {
28950
28953
  identifierCount++;
28951
- const pos = getNodePos();
28954
+ const pos = scanner.hasPrecedingJSDocLeadingAsterisks() ? scanner.getTokenStart() : getNodePos();
28952
28955
  const originalKeywordKind = token();
28953
28956
  const text = internIdentifier(scanner.getTokenValue());
28954
28957
  const hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
@@ -36078,6 +36081,7 @@ var commandOptionsWithoutBuild = [
36078
36081
  type: "boolean",
36079
36082
  affectsEmit: true,
36080
36083
  affectsBuildInfo: true,
36084
+ affectsSourceFile: true,
36081
36085
  category: Diagnostics.Emit,
36082
36086
  description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
36083
36087
  defaultValueDescription: false
@@ -36542,6 +36546,7 @@ var commandOptionsWithoutBuild = [
36542
36546
  affectsEmit: true,
36543
36547
  affectsBuildInfo: true,
36544
36548
  affectsModuleResolution: true,
36549
+ affectsSourceFile: true,
36545
36550
  category: Diagnostics.Language_and_Environment,
36546
36551
  description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
36547
36552
  defaultValueDescription: "react"
@@ -45517,13 +45522,6 @@ function createTypeChecker(host) {
45517
45522
  /*withAugmentations*/
45518
45523
  true
45519
45524
  ),
45520
- tryFindAmbientModuleWithoutAugmentations: (moduleName) => {
45521
- return tryFindAmbientModule(
45522
- moduleName,
45523
- /*withAugmentations*/
45524
- false
45525
- );
45526
- },
45527
45525
  getApparentType,
45528
45526
  getUnionType,
45529
45527
  isTypeAssignableTo,
@@ -46066,6 +46064,7 @@ function createTypeChecker(host) {
46066
46064
  };
46067
46065
  var amalgamatedDuplicates;
46068
46066
  var reverseMappedCache = /* @__PURE__ */ new Map();
46067
+ var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
46069
46068
  var ambientModulesCache;
46070
46069
  var patternAmbientModules;
46071
46070
  var patternAmbientModuleAugmentations;
@@ -46136,6 +46135,7 @@ function createTypeChecker(host) {
46136
46135
  var contextualTypes = [];
46137
46136
  var contextualIsCache = [];
46138
46137
  var contextualTypeCount = 0;
46138
+ var contextualBindingPatterns = [];
46139
46139
  var inferenceContextNodes = [];
46140
46140
  var inferenceContexts = [];
46141
46141
  var inferenceContextCount = 0;
@@ -49430,11 +49430,11 @@ function createTypeChecker(host) {
49430
49430
  function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
49431
49431
  const originalType = type;
49432
49432
  if (addUndefined) {
49433
- type = getOptionalType(type);
49433
+ type = getOptionalType(type, !isParameter(host2));
49434
49434
  }
49435
49435
  const clone = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
49436
49436
  if (clone) {
49437
- if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49437
+ if (addUndefined && containsNonMissingUndefinedType(type) && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49438
49438
  return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
49439
49439
  }
49440
49440
  return clone;
@@ -50294,7 +50294,21 @@ function createTypeChecker(host) {
50294
50294
  }
50295
50295
  function shouldUsePlaceholderForProperty(propertySymbol, context) {
50296
50296
  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 */));
50297
+ const depth = 3;
50298
+ 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());
50299
+ function isDeeplyNestedReverseMappedTypeProperty() {
50300
+ var _a2;
50301
+ if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
50302
+ return false;
50303
+ }
50304
+ for (let i = 0; i < depth; i++) {
50305
+ const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
50306
+ if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
50307
+ return false;
50308
+ }
50309
+ }
50310
+ return true;
50311
+ }
50298
50312
  }
50299
50313
  function addPropertyToElementList(propertySymbol, context, typeElements) {
50300
50314
  var _a;
@@ -51381,8 +51395,8 @@ function createTypeChecker(host) {
51381
51395
  return enclosingDeclaration;
51382
51396
  }
51383
51397
  function serializeTypeForDeclaration(context, declaration, type, symbol) {
51384
- var _a;
51385
- const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
51398
+ var _a, _b;
51399
+ const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
51386
51400
  const enclosingDeclaration = context.enclosingDeclaration;
51387
51401
  const oldFlags = context.flags;
51388
51402
  if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
@@ -51393,6 +51407,7 @@ function createTypeChecker(host) {
51393
51407
  const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
51394
51408
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
51395
51409
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
51410
+ const addUndefined = addUndefinedForParameter || !!(symbol.flags & 4 /* Property */ && symbol.flags & 16777216 /* Optional */ && isOptionalDeclaration(declWithExistingAnnotation) && ((_a = symbol.links) == null ? void 0 : _a.mappedType) && containsNonMissingUndefinedType(type));
51396
51411
  const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
51397
51412
  if (result2) {
51398
51413
  context.flags = oldFlags;
@@ -51403,9 +51418,9 @@ function createTypeChecker(host) {
51403
51418
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
51404
51419
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
51405
51420
  }
51406
- const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
51421
+ const decl = declaration ?? symbol.valueDeclaration ?? ((_b = symbol.declarations) == null ? void 0 : _b[0]);
51407
51422
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
51408
- const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
51423
+ const result = expressionOrTypeToTypeNode(context, expr, type, addUndefinedForParameter);
51409
51424
  context.flags = oldFlags;
51410
51425
  return result;
51411
51426
  }
@@ -51440,9 +51455,9 @@ function createTypeChecker(host) {
51440
51455
  const typePredicate = getTypePredicateOfSignature(signature);
51441
51456
  const type = getReturnTypeOfSignature(signature);
51442
51457
  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);
51458
+ const annotation = getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
51459
+ if (annotation) {
51460
+ const result = tryReuseExistingTypeNode(context, annotation, type, context.enclosingDeclaration);
51446
51461
  if (result) {
51447
51462
  return result;
51448
51463
  }
@@ -51936,7 +51951,10 @@ function createTypeChecker(host) {
51936
51951
  );
51937
51952
  }
51938
51953
  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 */)) {
51954
+ if (!hasDynamicName(node)) {
51955
+ return visitEachChild2(node, visitExistingNodeTreeSymbols);
51956
+ }
51957
+ if (!(context.flags & 1 /* AllowUnresolvedNames */ && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
51940
51958
  return void 0;
51941
51959
  }
51942
51960
  }
@@ -54142,6 +54160,7 @@ function createTypeChecker(host) {
54142
54160
  } else if (strictNullChecks && pattern.parent.initializer && !hasTypeFacts(getTypeOfInitializer(pattern.parent.initializer), 65536 /* EQUndefined */)) {
54143
54161
  parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
54144
54162
  }
54163
+ const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* AllowMissing */ : 0);
54145
54164
  let type;
54146
54165
  if (pattern.kind === 206 /* ObjectBindingPattern */) {
54147
54166
  if (declaration.dotDotDotToken) {
@@ -54160,7 +54179,7 @@ function createTypeChecker(host) {
54160
54179
  } else {
54161
54180
  const name = declaration.propertyName || declaration.name;
54162
54181
  const indexType = getLiteralTypeFromPropertyName(name);
54163
- const declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
54182
+ const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
54164
54183
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54165
54184
  }
54166
54185
  } else {
@@ -54171,7 +54190,6 @@ function createTypeChecker(host) {
54171
54190
  type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
54172
54191
  } else if (isArrayLikeType(parentType)) {
54173
54192
  const indexType = getNumberLiteralType(index);
54174
- const accessFlags = 32 /* ExpressionPosition */ | (noTupleBoundsCheck || hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
54175
54193
  const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
54176
54194
  type = getFlowTypeOfDestructuring(declaration, declaredType);
54177
54195
  } else {
@@ -54657,7 +54675,7 @@ function createTypeChecker(host) {
54657
54675
  /*reportErrors*/
54658
54676
  false
54659
54677
  ) : unknownType;
54660
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
54678
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
54661
54679
  }
54662
54680
  if (isBindingPattern(element.name)) {
54663
54681
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
@@ -54728,7 +54746,10 @@ function createTypeChecker(host) {
54728
54746
  return result;
54729
54747
  }
54730
54748
  function getTypeFromBindingPattern(pattern, includePatternInType = false, reportErrors2 = false) {
54731
- return pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54749
+ if (includePatternInType) contextualBindingPatterns.push(pattern);
54750
+ const result = pattern.kind === 206 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors2) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors2);
54751
+ if (includePatternInType) contextualBindingPatterns.pop();
54752
+ return result;
54732
54753
  }
54733
54754
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors2) {
54734
54755
  return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(
@@ -54809,18 +54830,18 @@ function createTypeChecker(host) {
54809
54830
  }
54810
54831
  return false;
54811
54832
  }
54812
- function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
54833
+ function getTypeOfVariableOrParameterOrProperty(symbol) {
54813
54834
  const links = getSymbolLinks(symbol);
54814
54835
  if (!links.type) {
54815
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
54816
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
54836
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
54837
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
54817
54838
  links.type = type;
54818
54839
  }
54819
54840
  return type;
54820
54841
  }
54821
54842
  return links.type;
54822
54843
  }
54823
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
54844
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
54824
54845
  if (symbol.flags & 4194304 /* Prototype */) {
54825
54846
  return getTypeOfPrototypeProperty(symbol);
54826
54847
  }
@@ -54855,9 +54876,6 @@ function createTypeChecker(host) {
54855
54876
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54856
54877
  return getTypeOfFuncClassEnumModule(symbol);
54857
54878
  }
54858
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54859
- return errorType;
54860
- }
54861
54879
  return reportCircularityError(symbol);
54862
54880
  }
54863
54881
  let type;
@@ -54895,9 +54913,6 @@ function createTypeChecker(host) {
54895
54913
  if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
54896
54914
  return getTypeOfFuncClassEnumModule(symbol);
54897
54915
  }
54898
- if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
54899
- return type;
54900
- }
54901
54916
  return reportCircularityError(symbol);
54902
54917
  }
54903
54918
  return type;
@@ -55126,7 +55141,7 @@ function createTypeChecker(host) {
55126
55141
  }
55127
55142
  return getTypeOfSymbol(symbol);
55128
55143
  }
55129
- function getTypeOfSymbol(symbol, checkMode) {
55144
+ function getTypeOfSymbol(symbol) {
55130
55145
  const checkFlags = getCheckFlags(symbol);
55131
55146
  if (checkFlags & 65536 /* DeferredType */) {
55132
55147
  return getTypeOfSymbolWithDeferredType(symbol);
@@ -55141,7 +55156,7 @@ function createTypeChecker(host) {
55141
55156
  return getTypeOfReverseMappedSymbol(symbol);
55142
55157
  }
55143
55158
  if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
55144
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
55159
+ return getTypeOfVariableOrParameterOrProperty(symbol);
55145
55160
  }
55146
55161
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
55147
55162
  return getTypeOfFuncClassEnumModule(symbol);
@@ -58027,7 +58042,7 @@ function createTypeChecker(host) {
58027
58042
  );
58028
58043
  }
58029
58044
  function createSignatureTypeMapper(signature, typeArguments) {
58030
- return createTypeMapper(signature.typeParameters, typeArguments);
58045
+ return createTypeMapper(sameMap(signature.typeParameters, (tp) => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
58031
58046
  }
58032
58047
  function getErasedSignature(signature) {
58033
58048
  return signature.typeParameters ? signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : signature;
@@ -60291,7 +60306,7 @@ function createTypeChecker(host) {
60291
60306
  }
60292
60307
  if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
60293
60308
  const index = +propName;
60294
- if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
60309
+ if (accessNode && everyType(objectType, (t) => !(t.target.combinedFlags & 12 /* Variable */)) && !(accessFlags & 16 /* AllowMissing */)) {
60295
60310
  const indexNode = getIndexNodeForAccessExpression(accessNode);
60296
60311
  if (isTupleType(objectType)) {
60297
60312
  if (index < 0) {
@@ -60430,6 +60445,9 @@ function createTypeChecker(host) {
60430
60445
  return void 0;
60431
60446
  }
60432
60447
  }
60448
+ if (accessFlags & 16 /* AllowMissing */ && isObjectLiteralType(objectType)) {
60449
+ return undefinedType;
60450
+ }
60433
60451
  if (isJSLiteralType(objectType)) {
60434
60452
  return anyType;
60435
60453
  }
@@ -62683,6 +62701,10 @@ function createTypeChecker(host) {
62683
62701
  function containsUndefinedType(type) {
62684
62702
  return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
62685
62703
  }
62704
+ function containsNonMissingUndefinedType(type) {
62705
+ const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
62706
+ return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
62707
+ }
62686
62708
  function isStringIndexSignatureOnlyType(type) {
62687
62709
  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
62710
  }
@@ -62697,7 +62719,7 @@ function createTypeChecker(host) {
62697
62719
  }
62698
62720
  const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
62699
62721
  const entry = enumRelation.get(id);
62700
- if (entry !== void 0 && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
62722
+ if (entry !== void 0 && !(entry & 2 /* Failed */ && errorReporter)) {
62701
62723
  return !!(entry & 1 /* Succeeded */);
62702
62724
  }
62703
62725
  const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -62712,10 +62734,8 @@ function createTypeChecker(host) {
62712
62734
  void 0,
62713
62735
  64 /* UseFullyQualifiedType */
62714
62736
  ));
62715
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
62716
- } else {
62717
- enumRelation.set(id, 2 /* Failed */);
62718
62737
  }
62738
+ enumRelation.set(id, 2 /* Failed */);
62719
62739
  return false;
62720
62740
  }
62721
62741
  const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, 306 /* EnumMember */)).value;
@@ -62724,26 +62744,22 @@ function createTypeChecker(host) {
62724
62744
  const sourceIsString = typeof sourceValue === "string";
62725
62745
  const targetIsString = typeof targetValue === "string";
62726
62746
  if (sourceValue !== void 0 && targetValue !== void 0) {
62727
- if (!errorReporter) {
62728
- enumRelation.set(id, 2 /* Failed */);
62729
- } else {
62747
+ if (errorReporter) {
62730
62748
  const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
62731
62749
  const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
62732
62750
  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
62751
  }
62752
+ enumRelation.set(id, 2 /* Failed */);
62735
62753
  return false;
62736
62754
  }
62737
62755
  if (sourceIsString || targetIsString) {
62738
- if (!errorReporter) {
62739
- enumRelation.set(id, 2 /* Failed */);
62740
- } else {
62756
+ if (errorReporter) {
62741
62757
  const knownStringValue = sourceValue ?? targetValue;
62742
62758
  Debug.assert(typeof knownStringValue === "string");
62743
62759
  const escapedValue = `"${escapeString(knownStringValue)}"`;
62744
62760
  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
62761
  }
62762
+ enumRelation.set(id, 2 /* Failed */);
62747
62763
  return false;
62748
62764
  }
62749
62765
  }
@@ -62901,7 +62917,7 @@ function createTypeChecker(host) {
62901
62917
  /*ignoreConstraints*/
62902
62918
  false
62903
62919
  );
62904
- relation.set(id, 4 /* Reported */ | 2 /* Failed */);
62920
+ relation.set(id, 2 /* Failed */ | (relationCount <= 0 ? 32 /* ComplexityOverflow */ : 64 /* StackDepthOverflow */));
62905
62921
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
62906
62922
  const message = relationCount <= 0 ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
62907
62923
  const diag2 = error(errorNode || currentNode, message, typeToString(source), typeToString(target));
@@ -63754,7 +63770,7 @@ function createTypeChecker(host) {
63754
63770
  );
63755
63771
  const entry = relation.get(id);
63756
63772
  if (entry !== void 0) {
63757
- if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
63773
+ if (reportErrors2 && entry & 2 /* Failed */ && !(entry & 96 /* Overflow */)) {
63758
63774
  } else {
63759
63775
  if (outofbandVarianceMarkerHandler) {
63760
63776
  const saved = entry & 24 /* ReportsMask */;
@@ -63765,6 +63781,11 @@ function createTypeChecker(host) {
63765
63781
  instantiateType(source2, reportUnreliableMapper);
63766
63782
  }
63767
63783
  }
63784
+ if (reportErrors2 && entry & 96 /* Overflow */) {
63785
+ const message = entry & 32 /* ComplexityOverflow */ ? Diagnostics.Excessive_complexity_comparing_types_0_and_1 : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
63786
+ reportError(message, typeToString(source2), typeToString(target2));
63787
+ overrideNextErrorInfo++;
63788
+ }
63768
63789
  return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
63769
63790
  }
63770
63791
  }
@@ -63862,7 +63883,7 @@ function createTypeChecker(host) {
63862
63883
  }
63863
63884
  }
63864
63885
  } else {
63865
- relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
63886
+ relation.set(id, 2 /* Failed */ | propagatingVarianceFlags);
63866
63887
  relationCount--;
63867
63888
  resetMaybeStack(
63868
63889
  /*markAllAsSucceeded*/
@@ -66332,11 +66353,11 @@ function createTypeChecker(host) {
66332
66353
  }
66333
66354
  function inferTypeForHomomorphicMappedType(source, target, constraint) {
66334
66355
  const cacheKey = source.id + "," + target.id + "," + constraint.id;
66335
- if (reverseMappedCache.has(cacheKey)) {
66336
- return reverseMappedCache.get(cacheKey);
66356
+ if (reverseHomomorphicMappedCache.has(cacheKey)) {
66357
+ return reverseHomomorphicMappedCache.get(cacheKey);
66337
66358
  }
66338
66359
  const type = createReverseMappedType(source, target, constraint);
66339
- reverseMappedCache.set(cacheKey, type);
66360
+ reverseHomomorphicMappedCache.set(cacheKey, type);
66340
66361
  return type;
66341
66362
  }
66342
66363
  function isPartiallyInferableType(type) {
@@ -69898,9 +69919,9 @@ function createTypeChecker(host) {
69898
69919
  );
69899
69920
  }
69900
69921
  }
69901
- function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
69922
+ function getNarrowedTypeOfSymbol(symbol, location) {
69902
69923
  var _a;
69903
- const type = getTypeOfSymbol(symbol, checkMode);
69924
+ const type = getTypeOfSymbol(symbol);
69904
69925
  const declaration = symbol.valueDeclaration;
69905
69926
  if (declaration) {
69906
69927
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
@@ -70039,7 +70060,10 @@ function createTypeChecker(host) {
70039
70060
  }
70040
70061
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
70041
70062
  let declaration = localOrExportSymbol.valueDeclaration;
70042
- let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
70063
+ if (declaration && declaration.kind === 208 /* BindingElement */ && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, (parent) => parent === declaration.parent)) {
70064
+ return nonInferrableAnyType;
70065
+ }
70066
+ let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
70043
70067
  const assignmentKind = getAssignmentTargetKind(node);
70044
70068
  if (assignmentKind) {
70045
70069
  if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
@@ -71732,7 +71756,7 @@ function createTypeChecker(host) {
71732
71756
  return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
71733
71757
  }
71734
71758
  function hasDefaultValue(node) {
71735
- return node.kind === 208 /* BindingElement */ && !!node.initializer || node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 64 /* EqualsToken */;
71759
+ 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
71760
  }
71737
71761
  function isSpreadIntoCallOrNew(node) {
71738
71762
  const parent = walkUpParenthesizedExpressions(node.parent);
@@ -71901,7 +71925,6 @@ function createTypeChecker(host) {
71901
71925
  return links.immediateTarget;
71902
71926
  }
71903
71927
  function checkObjectLiteral(node, checkMode = 0 /* Normal */) {
71904
- var _a;
71905
71928
  const inDestructuringPattern = isAssignmentTarget(node);
71906
71929
  checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
71907
71930
  const allPropertiesTable = strictNullChecks ? createSymbolTable() : void 0;
@@ -71956,11 +71979,8 @@ function createTypeChecker(host) {
71956
71979
  if (nameType) {
71957
71980
  prop.links.nameType = nameType;
71958
71981
  }
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
- }
71982
+ if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
71983
+ prop.flags |= 16777216 /* Optional */;
71964
71984
  } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
71965
71985
  const impliedProp = getPropertyOfType(contextualType, member.escapedName);
71966
71986
  if (impliedProp) {
@@ -72035,21 +72055,6 @@ function createTypeChecker(host) {
72035
72055
  propertiesArray.push(member);
72036
72056
  }
72037
72057
  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
72058
  if (isErrorType(spread)) {
72054
72059
  return errorType;
72055
72060
  }
@@ -77327,7 +77332,7 @@ function createTypeChecker(host) {
77327
77332
  );
77328
77333
  }
77329
77334
  }
77330
- const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
77335
+ const elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */ | (hasDefaultValue(property) ? 16 /* AllowMissing */ : 0), name);
77331
77336
  const type = getFlowTypeOfDestructuring(property, elementType);
77332
77337
  return checkDestructuringAssignment(property.kind === 304 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
77333
77338
  } else if (property.kind === 305 /* SpreadAssignment */) {
@@ -77376,7 +77381,7 @@ function createTypeChecker(host) {
77376
77381
  if (element.kind !== 230 /* SpreadElement */) {
77377
77382
  const indexType = getNumberLiteralType(elementIndex);
77378
77383
  if (isArrayLikeType(sourceType)) {
77379
- const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
77384
+ const accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AllowMissing */ : 0);
77380
77385
  const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
77381
77386
  const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
77382
77387
  const type = getFlowTypeOfDestructuring(element, assignedType);
@@ -77526,7 +77531,7 @@ function createTypeChecker(host) {
77526
77531
  setLastResult(state, checkExpression(node.right, checkMode));
77527
77532
  return state;
77528
77533
  }
77529
- checkGrammarNullishCoalesceWithLogicalExpression(node);
77534
+ checkNullishCoalesceOperands(node);
77530
77535
  const operator = node.operatorToken.kind;
77531
77536
  if (operator === 64 /* EqualsToken */ && (node.left.kind === 210 /* ObjectLiteralExpression */ || node.left.kind === 209 /* ArrayLiteralExpression */)) {
77532
77537
  state.skip = true;
@@ -77559,7 +77564,9 @@ function createTypeChecker(host) {
77559
77564
  if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent)) {
77560
77565
  checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
77561
77566
  }
77562
- checkTruthinessOfType(leftType, node.left);
77567
+ if (isBinaryLogicalOperator(operator)) {
77568
+ checkTruthinessOfType(leftType, node.left);
77569
+ }
77563
77570
  }
77564
77571
  }
77565
77572
  }
@@ -77616,7 +77623,7 @@ function createTypeChecker(host) {
77616
77623
  state.typeStack[state.stackIndex + 1] = type;
77617
77624
  }
77618
77625
  }
77619
- function checkGrammarNullishCoalesceWithLogicalExpression(node) {
77626
+ function checkNullishCoalesceOperands(node) {
77620
77627
  const { left, operatorToken, right } = node;
77621
77628
  if (operatorToken.kind === 61 /* QuestionQuestionToken */) {
77622
77629
  if (isBinaryExpression(left) && (left.operatorToken.kind === 57 /* BarBarToken */ || left.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
@@ -77625,15 +77632,56 @@ function createTypeChecker(host) {
77625
77632
  if (isBinaryExpression(right) && (right.operatorToken.kind === 57 /* BarBarToken */ || right.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
77626
77633
  grammarErrorOnNode(right, Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, tokenToString(right.operatorToken.kind), tokenToString(operatorToken.kind));
77627
77634
  }
77635
+ const leftTarget = skipOuterExpressions(left, 15 /* All */);
77636
+ if (getSyntacticNullishnessSemantics(leftTarget) !== 3 /* Sometimes */) {
77637
+ error(leftTarget, Diagnostics.Using_on_this_expression_appears_unintentional_because_it_always_evaluates_to_the_same_nullishness);
77638
+ }
77628
77639
  }
77629
77640
  }
77641
+ function getSyntacticNullishnessSemantics(node) {
77642
+ switch (node.kind) {
77643
+ case 223 /* AwaitExpression */:
77644
+ case 213 /* CallExpression */:
77645
+ case 212 /* ElementAccessExpression */:
77646
+ case 214 /* NewExpression */:
77647
+ case 211 /* PropertyAccessExpression */:
77648
+ case 229 /* YieldExpression */:
77649
+ return 3 /* Sometimes */;
77650
+ case 226 /* BinaryExpression */:
77651
+ switch (node.operatorToken.kind) {
77652
+ case 64 /* EqualsToken */:
77653
+ case 61 /* QuestionQuestionToken */:
77654
+ case 78 /* QuestionQuestionEqualsToken */:
77655
+ case 57 /* BarBarToken */:
77656
+ case 76 /* BarBarEqualsToken */:
77657
+ case 56 /* AmpersandAmpersandToken */:
77658
+ case 77 /* AmpersandAmpersandEqualsToken */:
77659
+ return 3 /* Sometimes */;
77660
+ }
77661
+ return 2 /* Never */;
77662
+ case 106 /* NullKeyword */:
77663
+ return 1 /* Always */;
77664
+ case 216 /* TypeAssertionExpression */:
77665
+ case 234 /* AsExpression */:
77666
+ case 217 /* ParenthesizedExpression */:
77667
+ return getSyntacticNullishnessSemantics(node.expression);
77668
+ case 227 /* ConditionalExpression */:
77669
+ return getSyntacticNullishnessSemantics(node.whenTrue) | getSyntacticNullishnessSemantics(node.whenFalse);
77670
+ case 80 /* Identifier */:
77671
+ if (node.escapedText === "undefined") {
77672
+ return 1 /* Always */;
77673
+ }
77674
+ return 3 /* Sometimes */;
77675
+ }
77676
+ return 2 /* Never */;
77677
+ }
77630
77678
  function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
77631
77679
  const operator = operatorToken.kind;
77632
77680
  if (operator === 64 /* EqualsToken */ && (left.kind === 210 /* ObjectLiteralExpression */ || left.kind === 209 /* ArrayLiteralExpression */)) {
77633
77681
  return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 110 /* ThisKeyword */);
77634
77682
  }
77635
77683
  let leftType;
77636
- if (isLogicalOrCoalescingBinaryOperator(operator)) {
77684
+ if (isBinaryLogicalOperator(operator)) {
77637
77685
  leftType = checkTruthinessExpression(left, checkMode);
77638
77686
  } else {
77639
77687
  leftType = checkExpression(left, checkMode);
@@ -78215,9 +78263,56 @@ function createTypeChecker(host) {
78215
78263
  void 0,
78216
78264
  checkMode || 0 /* Normal */
78217
78265
  ) : 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;
78266
+ if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) {
78267
+ if (declaration.name.kind === 206 /* ObjectBindingPattern */ && isObjectLiteralType(type)) {
78268
+ return padObjectLiteralType(type, declaration.name);
78269
+ }
78270
+ if (declaration.name.kind === 207 /* ArrayBindingPattern */ && isTupleType(type)) {
78271
+ return padTupleType(type, declaration.name);
78272
+ }
78273
+ }
78274
+ return type;
78275
+ }
78276
+ function padObjectLiteralType(type, pattern) {
78277
+ let missingElements;
78278
+ for (const e of pattern.elements) {
78279
+ if (e.initializer) {
78280
+ const name = getPropertyNameFromBindingElement(e);
78281
+ if (name && !getPropertyOfType(type, name)) {
78282
+ missingElements = append(missingElements, e);
78283
+ }
78284
+ }
78285
+ }
78286
+ if (!missingElements) {
78287
+ return type;
78288
+ }
78289
+ const members = createSymbolTable();
78290
+ for (const prop of getPropertiesOfObjectType(type)) {
78291
+ members.set(prop.escapedName, prop);
78292
+ }
78293
+ for (const e of missingElements) {
78294
+ const symbol = createSymbol(4 /* Property */ | 16777216 /* Optional */, getPropertyNameFromBindingElement(e));
78295
+ symbol.links.type = getTypeFromBindingElement(
78296
+ e,
78297
+ /*includePatternInType*/
78298
+ false,
78299
+ /*reportErrors*/
78300
+ false
78301
+ );
78302
+ members.set(symbol.escapedName, symbol);
78303
+ }
78304
+ const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type));
78305
+ result.objectFlags = type.objectFlags;
78306
+ return result;
78307
+ }
78308
+ function getPropertyNameFromBindingElement(e) {
78309
+ const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name);
78310
+ return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : void 0;
78219
78311
  }
78220
78312
  function padTupleType(type, pattern) {
78313
+ if (type.target.combinedFlags & 12 /* Variable */ || getTypeReferenceArity(type) >= pattern.elements.length) {
78314
+ return type;
78315
+ }
78221
78316
  const patternElements = pattern.elements;
78222
78317
  const elementTypes = getElementTypes(type).slice();
78223
78318
  const elementFlags = type.target.elementFlags.slice();
@@ -81189,9 +81284,53 @@ function createTypeChecker(host) {
81189
81284
  function checkTruthinessOfType(type, node) {
81190
81285
  if (type.flags & 16384 /* Void */) {
81191
81286
  error(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
81287
+ } else {
81288
+ const semantics = getSyntacticTruthySemantics(node);
81289
+ if (semantics !== 3 /* Sometimes */) {
81290
+ error(
81291
+ node,
81292
+ semantics === 1 /* Always */ ? Diagnostics.This_expression_is_always_truthy_Did_you_mean_to_test_something_else : Diagnostics.This_expression_is_always_falsy_Did_you_mean_to_test_something_else
81293
+ );
81294
+ }
81192
81295
  }
81193
81296
  return type;
81194
81297
  }
81298
+ function getSyntacticTruthySemantics(node) {
81299
+ switch (node.kind) {
81300
+ case 9 /* NumericLiteral */:
81301
+ if (node.text === "0" || node.text === "1") {
81302
+ return 3 /* Sometimes */;
81303
+ }
81304
+ return 1 /* Always */;
81305
+ case 209 /* ArrayLiteralExpression */:
81306
+ case 219 /* ArrowFunction */:
81307
+ case 10 /* BigIntLiteral */:
81308
+ case 231 /* ClassExpression */:
81309
+ case 218 /* FunctionExpression */:
81310
+ case 284 /* JsxElement */:
81311
+ case 285 /* JsxSelfClosingElement */:
81312
+ case 210 /* ObjectLiteralExpression */:
81313
+ case 14 /* RegularExpressionLiteral */:
81314
+ return 1 /* Always */;
81315
+ case 222 /* VoidExpression */:
81316
+ return 2 /* Never */;
81317
+ case 15 /* NoSubstitutionTemplateLiteral */:
81318
+ case 11 /* StringLiteral */:
81319
+ return !!node.text ? 1 /* Always */ : 2 /* Never */;
81320
+ case 216 /* TypeAssertionExpression */:
81321
+ case 234 /* AsExpression */:
81322
+ case 217 /* ParenthesizedExpression */:
81323
+ return getSyntacticTruthySemantics(node.expression);
81324
+ case 227 /* ConditionalExpression */:
81325
+ return getSyntacticTruthySemantics(node.whenTrue) | getSyntacticTruthySemantics(node.whenFalse);
81326
+ case 80 /* Identifier */:
81327
+ if (node.escapedText === "undefined") {
81328
+ return 2 /* Never */;
81329
+ }
81330
+ return 3 /* Sometimes */;
81331
+ }
81332
+ return 3 /* Sometimes */;
81333
+ }
81195
81334
  function checkTruthinessExpression(node, checkMode) {
81196
81335
  return checkTruthinessOfType(checkExpression(node, checkMode), node);
81197
81336
  }
@@ -110992,6 +111131,7 @@ function transformDeclarations(context) {
110992
111131
  }
110993
111132
  function reportInferenceFallback(node) {
110994
111133
  if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
111134
+ if (getSourceFileOfNode(node) !== currentSourceFile) return;
110995
111135
  if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
110996
111136
  reportExpandoFunctionErrors(node);
110997
111137
  } else {
@@ -111036,7 +111176,10 @@ function transformDeclarations(context) {
111036
111176
  function reportPrivateInBaseOfClassExpression(propertyName) {
111037
111177
  if (errorNameNode || errorFallbackNode) {
111038
111178
  context.addDiagnostic(
111039
- createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)
111179
+ addRelatedInfo(
111180
+ createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected, propertyName),
111181
+ ...isVariableDeclaration((errorNameNode || errorFallbackNode).parent) ? [createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.Add_a_type_annotation_to_the_variable_0, errorDeclarationNameWithFallback())] : []
111182
+ )
111040
111183
  );
111041
111184
  }
111042
111185
  }
@@ -119244,7 +119387,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119244
119387
  let commonSourceDirectory;
119245
119388
  let typeChecker;
119246
119389
  let classifiableNames;
119247
- const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
119248
119390
  let fileReasons = createMultiMap();
119249
119391
  let filesWithReferencesProcessed;
119250
119392
  let fileReasonsToChain;
@@ -119493,7 +119635,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119493
119635
  const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
119494
119636
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
119495
119637
  oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
119496
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
119638
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path), newFile);
119497
119639
  }
119498
119640
  }
119499
119641
  if (!host.getParsedCommandLine) {
@@ -119503,7 +119645,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119503
119645
  resolvedProjectReference.sourceFile,
119504
119646
  oldProgram.getCompilerOptions(),
119505
119647
  /*hasSourceFileByPath*/
119506
- false
119648
+ false,
119649
+ /*newSourceFileByResolvedPath*/
119650
+ void 0
119507
119651
  );
119508
119652
  }
119509
119653
  });
@@ -119832,35 +119976,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119832
119976
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
119833
119977
  getResolved: getResolvedModuleFromResolution,
119834
119978
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
119835
- isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
119979
+ resolveToOwnAmbientModule: true
119836
119980
  });
119837
119981
  }
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
119982
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
119865
119983
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119866
119984
  return resolveNamesReusingOldState({
@@ -119888,10 +120006,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119888
120006
  getResolutionFromOldProgram,
119889
120007
  getResolved,
119890
120008
  canReuseResolutionsInFile,
119891
- isEntryResolvingToAmbientModule
120009
+ resolveToOwnAmbientModule
119892
120010
  }) {
119893
120011
  if (!entries.length) return emptyArray;
119894
- if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
120012
+ if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119895
120013
  return resolutionWorker(
119896
120014
  entries,
119897
120015
  containingFile,
@@ -119927,12 +120045,23 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119927
120045
  continue;
119928
120046
  }
119929
120047
  }
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);
120048
+ if (resolveToOwnAmbientModule) {
120049
+ const name = nameAndModeGetter.getName(entry);
120050
+ if (contains(containingSourceFile.ambientModuleNames, name)) {
120051
+ if (isTraceEnabled(options, host)) {
120052
+ trace(
120053
+ host,
120054
+ Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1,
120055
+ name,
120056
+ getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory)
120057
+ );
120058
+ }
120059
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
120060
+ continue;
120061
+ }
119935
120062
  }
120063
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
120064
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119936
120065
  }
119937
120066
  if (!unknownEntries) return result;
119938
120067
  const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
@@ -120066,10 +120195,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120066
120195
  } else if (hasInvalidatedResolutions(oldSourceFile.path)) {
120067
120196
  structureIsReused = 1 /* SafeModules */;
120068
120197
  modifiedSourceFiles.push(newSourceFile);
120069
- } else {
120070
- for (const moduleName of oldSourceFile.ambientModuleNames) {
120071
- ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
120072
- }
120073
120198
  }
120074
120199
  newSourceFiles.push(newSourceFile);
120075
120200
  }
@@ -124597,7 +124722,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124597
124722
  let filesWithChangedSetOfUnresolvedImports;
124598
124723
  let filesWithInvalidatedResolutions;
124599
124724
  let filesWithInvalidatedNonRelativeUnresolvedImports;
124600
- const nonRelativeExternalModuleResolutions = createMultiMap();
124725
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
124601
124726
  const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
124602
124727
  const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
124603
124728
  const resolvedFileToResolution = /* @__PURE__ */ new Map();
@@ -124748,8 +124873,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124748
124873
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
124749
124874
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
124750
124875
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
124751
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124752
- nonRelativeExternalModuleResolutions.clear();
124876
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124753
124877
  isSymlinkCache.clear();
124754
124878
  }
124755
124879
  function cleanupLibResolutionWatching(newProgram) {
@@ -124768,8 +124892,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124768
124892
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
124769
124893
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
124770
124894
  allModuleAndTypeResolutionsAreInvalidated = false;
124771
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124772
- nonRelativeExternalModuleResolutions.clear();
124895
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124773
124896
  if (newProgram !== oldProgram) {
124774
124897
  cleanupLibResolutionWatching(newProgram);
124775
124898
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
@@ -125032,7 +125155,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125032
125155
  if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
125033
125156
  watchFailedLookupLocationOfResolution(resolution);
125034
125157
  } else {
125035
- nonRelativeExternalModuleResolutions.add(name, resolution);
125158
+ nonRelativeExternalModuleResolutions.add(resolution);
125036
125159
  }
125037
125160
  const resolved = getResolutionWithResolvedFileName(resolution);
125038
125161
  if (resolved && resolved.resolvedFileName) {
@@ -125168,17 +125291,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125168
125291
  (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
125169
125292
  packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
125170
125293
  }
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
- }
125294
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
125295
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
125296
+ nonRelativeExternalModuleResolutions.clear();
125182
125297
  }
125183
125298
  function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
125184
125299
  Debug.assert(!nonRecursive);
@@ -125198,11 +125313,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125198
125313
  );
125199
125314
  } else if (packageDirWatcher.isSymlink !== isSymlink) {
125200
125315
  packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
125201
- removeDirectoryWatcher(
125202
- packageDirWatcher.isSymlink ? packageDirPath : dirPath,
125203
- /*syncDirWatcherRemove*/
125204
- false
125205
- );
125316
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125206
125317
  watcher.watcher = createDirPathToWatcher();
125207
125318
  });
125208
125319
  packageDirWatcher.isSymlink = isSymlink;
@@ -125242,7 +125353,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125242
125353
  }
125243
125354
  return dirWatcher;
125244
125355
  }
125245
- function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove) {
125356
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
125246
125357
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
125247
125358
  const toWatch = getDirectoryToWatchFailedLookupLocation(
125248
125359
  failedLookupLocation,
@@ -125262,7 +125373,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125262
125373
  const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
125263
125374
  forDirPath.refCount--;
125264
125375
  if (forDirPath.refCount === 0) {
125265
- removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath, syncDirWatcherRemove);
125376
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125266
125377
  packageDirWatcher.dirPathToWatcher.delete(dirPath);
125267
125378
  if (packageDirWatcher.isSymlink) {
125268
125379
  const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
@@ -125272,15 +125383,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125272
125383
  dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
125273
125384
  }
125274
125385
  }
125275
- if (syncDirWatcherRemove) closePackageDirWatcher(packageDirWatcher, packageDirPath);
125276
125386
  }
125277
125387
  } else {
125278
- removeDirectoryWatcher(dirPath, syncDirWatcherRemove);
125388
+ removeDirectoryWatcher(dirPath);
125279
125389
  }
125280
125390
  }
125281
125391
  return removeAtRoot;
125282
125392
  }
125283
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125393
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
125284
125394
  Debug.checkDefined(resolution.files).delete(filePath);
125285
125395
  if (resolution.files.size) return;
125286
125396
  resolution.files = void 0;
@@ -125295,11 +125405,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125295
125405
  let removeAtRoot = false;
125296
125406
  if (failedLookupLocations) {
125297
125407
  for (const failedLookupLocation of failedLookupLocations) {
125298
- removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove);
125408
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
125299
125409
  }
125300
125410
  }
125301
- if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot, syncDirWatcherRemove);
125302
- if (removeAtRoot) removeDirectoryWatcher(rootPath, syncDirWatcherRemove);
125411
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
125412
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
125303
125413
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
125304
125414
  resolutionsWithOnlyAffectingLocations.delete(resolution);
125305
125415
  }
@@ -125307,14 +125417,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125307
125417
  for (const affectingLocation of affectingLocations) {
125308
125418
  const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
125309
125419
  watcher.resolutions--;
125310
- if (syncDirWatcherRemove) closeFileWatcherOfAffectingLocation(watcher, affectingLocation);
125311
125420
  }
125312
125421
  }
125313
125422
  }
125314
- function removeDirectoryWatcher(dirPath, syncDirWatcherRemove) {
125423
+ function removeDirectoryWatcher(dirPath) {
125315
125424
  const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
125316
125425
  dirWatcher.refCount--;
125317
- if (syncDirWatcherRemove) closeDirectoryWatchesOfFailedLookup(dirWatcher, dirPath);
125318
125426
  }
125319
125427
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
125320
125428
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
@@ -125325,15 +125433,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125325
125433
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
125326
125434
  }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
125327
125435
  }
125328
- function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125436
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
125329
125437
  const resolutions = cache.get(filePath);
125330
125438
  if (resolutions) {
125331
125439
  resolutions.forEach(
125332
125440
  (resolution) => stopWatchFailedLookupLocationOfResolution(
125333
125441
  resolution,
125334
125442
  filePath,
125335
- getResolutionWithResolvedFileName,
125336
- syncDirWatcherRemove
125443
+ getResolutionWithResolvedFileName
125337
125444
  )
125338
125445
  );
125339
125446
  cache.delete(filePath);
@@ -125347,9 +125454,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125347
125454
  if (!resolvedProjectReference) return;
125348
125455
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
125349
125456
  }
125350
- function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
125351
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
125352
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
125457
+ function removeResolutionsOfFile(filePath) {
125458
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
125459
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
125353
125460
  }
125354
125461
  function invalidateResolutions(resolutions, canInvalidate) {
125355
125462
  if (!resolutions) return false;