@typescript-deploys/pr-build 4.8.0-pr-50098-2 → 4.9.0-pr-50248-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.
package/lib/tsserver.js CHANGED
@@ -105,11 +105,11 @@ var ts;
105
105
  (function (ts) {
106
106
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
107
107
  // If changing the text in this section, be sure to test `configurePrerelease` too.
108
- ts.versionMajorMinor = "4.8";
108
+ ts.versionMajorMinor = "4.9";
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-insiders.20220730";
112
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220810";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -873,15 +873,18 @@ var ts;
873
873
  function insertSorted(array, insert, compare, allowDuplicates) {
874
874
  if (array.length === 0) {
875
875
  array.push(insert);
876
- return;
876
+ return true;
877
877
  }
878
878
  var insertIndex = binarySearch(array, insert, identity, compare);
879
879
  if (insertIndex < 0) {
880
880
  array.splice(~insertIndex, 0, insert);
881
+ return true;
881
882
  }
882
- else if (allowDuplicates) {
883
+ if (allowDuplicates) {
883
884
  array.splice(insertIndex, 0, insert);
885
+ return true;
884
886
  }
887
+ return false;
885
888
  }
886
889
  ts.insertSorted = insertSorted;
887
890
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -8576,7 +8579,7 @@ var ts;
8576
8579
  File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""),
8577
8580
  File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"),
8578
8581
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
8579
- Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
8582
+ Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."),
8580
8583
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8581
8584
  An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
8582
8585
  An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
@@ -8584,6 +8587,11 @@ var ts;
8584
8587
  auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
8585
8588
  An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
8586
8589
  Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
8590
+ The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."),
8591
+ To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."),
8592
+ To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."),
8593
+ To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."),
8594
+ To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."),
8587
8595
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
8588
8596
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
8589
8597
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -21878,7 +21886,7 @@ var ts;
21878
21886
  * Wraps an expression in parentheses if it is needed in order to use the expression for
21879
21887
  * property or element access.
21880
21888
  */
21881
- function parenthesizeLeftSideOfAccess(expression) {
21889
+ function parenthesizeLeftSideOfAccess(expression, optionalChain) {
21882
21890
  // isLeftHandSideExpression is almost the correct criterion for when it is not necessary
21883
21891
  // to parenthesize the expression before a dot. The known exception is:
21884
21892
  //
@@ -21887,7 +21895,8 @@ var ts;
21887
21895
  //
21888
21896
  var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
21889
21897
  if (ts.isLeftHandSideExpression(emittedExpression)
21890
- && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) {
21898
+ && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
21899
+ && (optionalChain || !ts.isOptionalChain(emittedExpression))) {
21891
21900
  // TODO(rbuckton): Verify whether this assertion holds.
21892
21901
  return expression;
21893
21902
  }
@@ -23294,7 +23303,7 @@ var ts;
23294
23303
  // @api
23295
23304
  function createDecorator(expression) {
23296
23305
  var node = createBaseNode(165 /* Decorator */);
23297
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
23306
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
23298
23307
  node.transformFlags |=
23299
23308
  propagateChildFlags(node.expression) |
23300
23309
  1 /* ContainsTypeScript */ |
@@ -24095,7 +24104,7 @@ var ts;
24095
24104
  // @api
24096
24105
  function createPropertyAccessExpression(expression, name) {
24097
24106
  var node = createBaseExpression(206 /* PropertyAccessExpression */);
24098
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24107
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24099
24108
  node.name = asName(name);
24100
24109
  node.transformFlags =
24101
24110
  propagateChildFlags(node.expression) |
@@ -24125,7 +24134,7 @@ var ts;
24125
24134
  function createPropertyAccessChain(expression, questionDotToken, name) {
24126
24135
  var node = createBaseExpression(206 /* PropertyAccessExpression */);
24127
24136
  node.flags |= 32 /* OptionalChain */;
24128
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24137
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24129
24138
  node.questionDotToken = questionDotToken;
24130
24139
  node.name = asName(name);
24131
24140
  node.transformFlags |=
@@ -24151,7 +24160,7 @@ var ts;
24151
24160
  // @api
24152
24161
  function createElementAccessExpression(expression, index) {
24153
24162
  var node = createBaseExpression(207 /* ElementAccessExpression */);
24154
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24163
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24155
24164
  node.argumentExpression = asExpression(index);
24156
24165
  node.transformFlags |=
24157
24166
  propagateChildFlags(node.expression) |
@@ -24179,7 +24188,7 @@ var ts;
24179
24188
  function createElementAccessChain(expression, questionDotToken, index) {
24180
24189
  var node = createBaseExpression(207 /* ElementAccessExpression */);
24181
24190
  node.flags |= 32 /* OptionalChain */;
24182
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24191
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24183
24192
  node.questionDotToken = questionDotToken;
24184
24193
  node.argumentExpression = asExpression(index);
24185
24194
  node.transformFlags |=
@@ -24203,7 +24212,7 @@ var ts;
24203
24212
  // @api
24204
24213
  function createCallExpression(expression, typeArguments, argumentsArray) {
24205
24214
  var node = createBaseExpression(208 /* CallExpression */);
24206
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24215
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24207
24216
  node.typeArguments = asNodeArray(typeArguments);
24208
24217
  node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
24209
24218
  node.transformFlags |=
@@ -24236,7 +24245,7 @@ var ts;
24236
24245
  function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
24237
24246
  var node = createBaseExpression(208 /* CallExpression */);
24238
24247
  node.flags |= 32 /* OptionalChain */;
24239
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24248
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24240
24249
  node.questionDotToken = questionDotToken;
24241
24250
  node.typeArguments = asNodeArray(typeArguments);
24242
24251
  node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
@@ -24291,7 +24300,7 @@ var ts;
24291
24300
  // @api
24292
24301
  function createTaggedTemplateExpression(tag, typeArguments, template) {
24293
24302
  var node = createBaseExpression(210 /* TaggedTemplateExpression */);
24294
- node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
24303
+ node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
24295
24304
  node.typeArguments = asNodeArray(typeArguments);
24296
24305
  node.template = template;
24297
24306
  node.transformFlags |=
@@ -24729,7 +24738,7 @@ var ts;
24729
24738
  // @api
24730
24739
  function createExpressionWithTypeArguments(expression, typeArguments) {
24731
24740
  var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
24732
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24741
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24733
24742
  node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
24734
24743
  node.transformFlags |=
24735
24744
  propagateChildFlags(node.expression) |
@@ -24765,7 +24774,7 @@ var ts;
24765
24774
  // @api
24766
24775
  function createNonNullExpression(expression) {
24767
24776
  var node = createBaseExpression(230 /* NonNullExpression */);
24768
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24777
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24769
24778
  node.transformFlags |=
24770
24779
  propagateChildFlags(node.expression) |
24771
24780
  1 /* ContainsTypeScript */;
@@ -24784,7 +24793,7 @@ var ts;
24784
24793
  function createNonNullChain(expression) {
24785
24794
  var node = createBaseExpression(230 /* NonNullExpression */);
24786
24795
  node.flags |= 32 /* OptionalChain */;
24787
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24796
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24788
24797
  node.transformFlags |=
24789
24798
  propagateChildFlags(node.expression) |
24790
24799
  1 /* ContainsTypeScript */;
@@ -26988,7 +26997,7 @@ var ts;
26988
26997
  }
26989
26998
  else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
26990
26999
  thisArg = createVoidZero();
26991
- target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
27000
+ target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
26992
27001
  }
26993
27002
  else if (ts.isPropertyAccessExpression(callee)) {
26994
27003
  if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
@@ -27017,7 +27026,7 @@ var ts;
27017
27026
  else {
27018
27027
  // for `a()` target is `a` and thisArg is `void 0`
27019
27028
  thisArg = createVoidZero();
27020
- target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
27029
+ target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
27021
27030
  }
27022
27031
  return { target: target, thisArg: thisArg };
27023
27032
  }
@@ -43459,15 +43468,15 @@ var ts;
43459
43468
  }
43460
43469
  ts.createModuleResolutionCache = createModuleResolutionCache;
43461
43470
  function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43462
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43471
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43463
43472
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43464
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43473
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43465
43474
  function clear() {
43466
43475
  clearAllExceptPackageJsonInfoCache();
43467
43476
  packageJsonInfoCache.clear();
43468
43477
  }
43469
43478
  function clearAllExceptPackageJsonInfoCache() {
43470
- preDirectoryResolutionCache.clear();
43479
+ perDirectoryResolutionCache.clear();
43471
43480
  }
43472
43481
  }
43473
43482
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
@@ -45812,6 +45821,9 @@ var ts;
45812
45821
  case 203 /* BindingElement */:
45813
45822
  bindBindingElementFlow(node);
45814
45823
  break;
45824
+ case 164 /* Parameter */:
45825
+ bindParameterFlow(node);
45826
+ break;
45815
45827
  case 205 /* ObjectLiteralExpression */:
45816
45828
  case 204 /* ArrayLiteralExpression */:
45817
45829
  case 296 /* PropertyAssignment */:
@@ -46552,20 +46564,38 @@ var ts;
46552
46564
  }
46553
46565
  }
46554
46566
  function bindBindingElementFlow(node) {
46555
- if (ts.isBindingPattern(node.name)) {
46556
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46557
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46558
- // - `BindingElement: BindingPattern Initializer?`
46559
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46560
- // - `BindingElement: BindingPattern Initializer?`
46561
- bind(node.dotDotDotToken);
46562
- bind(node.propertyName);
46563
- bind(node.initializer);
46564
- bind(node.name);
46567
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46568
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46569
+ // - `BindingElement: BindingPattern Initializer?`
46570
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46571
+ // - `BindingElement: BindingPattern Initializer?`
46572
+ bind(node.dotDotDotToken);
46573
+ bind(node.propertyName);
46574
+ bindInitializer(node.initializer);
46575
+ bind(node.name);
46576
+ }
46577
+ function bindParameterFlow(node) {
46578
+ bindEach(node.modifiers);
46579
+ bind(node.dotDotDotToken);
46580
+ bind(node.questionToken);
46581
+ bind(node.type);
46582
+ bindInitializer(node.initializer);
46583
+ bind(node.name);
46584
+ }
46585
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46586
+ function bindInitializer(node) {
46587
+ if (!node) {
46588
+ return;
46565
46589
  }
46566
- else {
46567
- bindEachChild(node);
46590
+ var entryFlow = currentFlow;
46591
+ bind(node);
46592
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46593
+ return;
46568
46594
  }
46595
+ var exitFlow = createBranchLabel();
46596
+ addAntecedent(exitFlow, entryFlow);
46597
+ addAntecedent(exitFlow, currentFlow);
46598
+ currentFlow = finishFlowLabel(exitFlow);
46569
46599
  }
46570
46600
  function bindJSDocTypeAlias(node) {
46571
46601
  bind(node.tagName);
@@ -49736,7 +49766,7 @@ var ts;
49736
49766
  if (unidirectional === void 0) { unidirectional = false; }
49737
49767
  source.forEach(function (sourceSymbol, id) {
49738
49768
  var targetSymbol = target.get(id);
49739
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49769
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49740
49770
  });
49741
49771
  }
49742
49772
  function mergeModuleAugmentation(moduleName) {
@@ -51256,10 +51286,6 @@ var ts;
51256
51286
  checkExpressionCached(expression);
51257
51287
  return getNodeLinks(expression).resolvedSymbol;
51258
51288
  }
51259
- function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
51260
- var expression = node.initializer;
51261
- return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
51262
- }
51263
51289
  function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
51264
51290
  if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
51265
51291
  return undefined;
@@ -51291,7 +51317,7 @@ var ts;
51291
51317
  case 297 /* ShorthandPropertyAssignment */:
51292
51318
  return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
51293
51319
  case 296 /* PropertyAssignment */:
51294
- return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
51320
+ return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
51295
51321
  case 207 /* ElementAccessExpression */:
51296
51322
  case 206 /* PropertyAccessExpression */:
51297
51323
  return getTargetOfAccessExpression(node, dontRecursivelyResolve);
@@ -51696,7 +51722,40 @@ var ts;
51696
51722
  // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
51697
51723
  // normal mode restrictions
51698
51724
  if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) {
51699
- error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
51725
+ if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) {
51726
+ // ImportEquals in a ESM file resolving to another ESM file
51727
+ error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
51728
+ }
51729
+ else {
51730
+ // CJS file resolving to an ESM file
51731
+ var diagnosticDetails = void 0;
51732
+ var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
51733
+ if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
51734
+ var scope = currentSourceFile.packageJsonScope;
51735
+ var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
51736
+ if (scope && !scope.packageJsonContent.type) {
51737
+ if (targetExt) {
51738
+ diagnosticDetails = ts.chainDiagnosticMessages(
51739
+ /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json"));
51740
+ }
51741
+ else {
51742
+ diagnosticDetails = ts.chainDiagnosticMessages(
51743
+ /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json"));
51744
+ }
51745
+ }
51746
+ else {
51747
+ if (targetExt) {
51748
+ diagnosticDetails = ts.chainDiagnosticMessages(
51749
+ /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt);
51750
+ }
51751
+ else {
51752
+ diagnosticDetails = ts.chainDiagnosticMessages(
51753
+ /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module);
51754
+ }
51755
+ }
51756
+ }
51757
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference)));
51758
+ }
51700
51759
  }
51701
51760
  }
51702
51761
  // merged symbol is module declaration symbol combined with all augmentations
@@ -56498,11 +56557,9 @@ var ts;
56498
56557
  return getReturnTypeOfSignature(getterSignature);
56499
56558
  }
56500
56559
  }
56501
- if (ts.isInJSFile(declaration)) {
56502
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56503
- if (type_1)
56504
- return type_1;
56505
- }
56560
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56561
+ if (parameterTypeOfTypeTag)
56562
+ return parameterTypeOfTypeTag;
56506
56563
  // Use contextual parameter type if one is available
56507
56564
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56508
56565
  if (type) {
@@ -56816,7 +56873,7 @@ var ts;
56816
56873
  (resolvedSymbol || symbol).exports.forEach(function (s, name) {
56817
56874
  var _a;
56818
56875
  var exportedMember = members_4.get(name);
56819
- if (exportedMember && exportedMember !== s) {
56876
+ if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
56820
56877
  if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
56821
56878
  // If the member has an additional value-like declaration, union the types from the two declarations,
56822
56879
  // but issue an error if they occurred in two different files. The purpose is to support a JS file with
@@ -57078,9 +57135,9 @@ var ts;
57078
57135
  if (typeNode === undefined) {
57079
57136
  return useUnknownInCatchVariables ? unknownType : anyType;
57080
57137
  }
57081
- var type_2 = getTypeOfNode(typeNode);
57138
+ var type_1 = getTypeOfNode(typeNode);
57082
57139
  // an errorType will make `checkTryStatement` issue an error
57083
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57140
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57084
57141
  }
57085
57142
  // Handle export default expressions
57086
57143
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57290,11 +57347,11 @@ var ts;
57290
57347
  return errorType;
57291
57348
  }
57292
57349
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57293
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57350
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57294
57351
  if (!popTypeResolution()) {
57295
57352
  return reportCircularityError(symbol);
57296
57353
  }
57297
- return type_3;
57354
+ return type_2;
57298
57355
  }
57299
57356
  }
57300
57357
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59517,10 +59574,10 @@ var ts;
59517
59574
  var baseTypes = [];
59518
59575
  var different = false;
59519
59576
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59520
- var type_4 = types_7[_i];
59521
- var baseType = getBaseConstraint(type_4);
59577
+ var type_3 = types_7[_i];
59578
+ var baseType = getBaseConstraint(type_3);
59522
59579
  if (baseType) {
59523
- if (baseType !== type_4) {
59580
+ if (baseType !== type_3) {
59524
59581
  different = true;
59525
59582
  }
59526
59583
  baseTypes.push(baseType);
@@ -60311,7 +60368,12 @@ var ts;
60311
60368
  continue;
60312
60369
  }
60313
60370
  }
60314
- result.push(getSignatureFromDeclaration(decl));
60371
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60372
+ // Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would supress checks that the two are compatible.
60373
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60374
+ !ts.isObjectLiteralMethod(decl) &&
60375
+ getSignatureOfTypeTag(decl)) ||
60376
+ getSignatureFromDeclaration(decl));
60315
60377
  }
60316
60378
  return result;
60317
60379
  }
@@ -60342,7 +60404,7 @@ var ts;
60342
60404
  else {
60343
60405
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60344
60406
  var jsdocPredicate = void 0;
60345
- if (!type && ts.isInJSFile(signature.declaration)) {
60407
+ if (!type) {
60346
60408
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60347
60409
  if (jsdocSignature && signature !== jsdocSignature) {
60348
60410
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -63308,6 +63370,7 @@ var ts;
63308
63370
  }
63309
63371
  }
63310
63372
  function getTypeFromImportTypeNode(node) {
63373
+ var _a;
63311
63374
  var links = getNodeLinks(node);
63312
63375
  if (!links.resolvedType) {
63313
63376
  if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
@@ -63327,6 +63390,7 @@ var ts;
63327
63390
  links.resolvedSymbol = unknownSymbol;
63328
63391
  return links.resolvedType = errorType;
63329
63392
  }
63393
+ var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
63330
63394
  var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
63331
63395
  if (!ts.nodeIsMissing(node.qualifier)) {
63332
63396
  var nameStack = getIdentifierChain(node.qualifier);
@@ -63338,9 +63402,11 @@ var ts;
63338
63402
  // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
63339
63403
  // the `exports` lookup process that only looks up namespace members which is used for most type references
63340
63404
  var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
63341
- var next = node.isTypeOf
63405
+ var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
63342
63406
  ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
63343
- : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
63407
+ : undefined;
63408
+ var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
63409
+ var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
63344
63410
  if (!next) {
63345
63411
  error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
63346
63412
  return links.resolvedType = errorType;
@@ -64364,15 +64430,14 @@ var ts;
64364
64430
  return false;
64365
64431
  }
64366
64432
  function isContextSensitiveFunctionLikeDeclaration(node) {
64367
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64368
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64433
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64369
64434
  }
64370
64435
  function hasContextSensitiveReturnExpression(node) {
64371
64436
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64372
64437
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64373
64438
  }
64374
64439
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64375
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64440
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64376
64441
  isContextSensitiveFunctionLikeDeclaration(func);
64377
64442
  }
64378
64443
  function getTypeWithoutSignatures(type) {
@@ -66198,6 +66263,26 @@ var ts;
66198
66263
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66199
66264
  var saveErrorInfo = captureErrorCalculationState();
66200
66265
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66266
+ if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
66267
+ // The combined constraint of an intersection type is the intersection of the constraints of
66268
+ // the constituents. When an intersection type contains instantiable types with union type
66269
+ // constraints, there are situations where we need to examine the combined constraint. One is
66270
+ // when the target is a union type. Another is when the intersection contains types belonging
66271
+ // to one of the disjoint domains. For example, given type variables T and U, each with the
66272
+ // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
66273
+ // we need to check this constraint against a union on the target side. Also, given a type
66274
+ // variable V constrained to 'string | number', 'V & number' has a combined constraint of
66275
+ // 'string & number | number & number' which reduces to just 'number'.
66276
+ // This also handles type parameters, as a type parameter with a union constraint compared against a union
66277
+ // needs to have its constraint hoisted into an intersection with said type parameter, this way
66278
+ // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66279
+ // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66280
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
66281
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66282
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66283
+ result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
66284
+ }
66285
+ }
66201
66286
  if (result) {
66202
66287
  resetErrorInfo(saveErrorInfo);
66203
66288
  }
@@ -66255,28 +66340,6 @@ var ts;
66255
66340
  if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
66256
66341
  return result;
66257
66342
  }
66258
- if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
66259
- // The combined constraint of an intersection type is the intersection of the constraints of
66260
- // the constituents. When an intersection type contains instantiable types with union type
66261
- // constraints, there are situations where we need to examine the combined constraint. One is
66262
- // when the target is a union type. Another is when the intersection contains types belonging
66263
- // to one of the disjoint domains. For example, given type variables T and U, each with the
66264
- // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
66265
- // we need to check this constraint against a union on the target side. Also, given a type
66266
- // variable V constrained to 'string | number', 'V & number' has a combined constraint of
66267
- // 'string & number | number & number' which reduces to just 'number'.
66268
- // This also handles type parameters, as a type parameter with a union constraint compared against a union
66269
- // needs to have its constraint hoisted into an intersection with said type parameter, this way
66270
- // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66271
- // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66272
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
66273
- if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66274
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66275
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66276
- return result;
66277
- }
66278
- }
66279
- }
66280
66343
  // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
66281
66344
  // Source is instantiable (e.g. source has union or intersection constraint).
66282
66345
  // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
@@ -73202,12 +73265,15 @@ var ts;
73202
73265
  if (contextualReturnType) {
73203
73266
  var functionFlags = ts.getFunctionFlags(func);
73204
73267
  if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
73205
- var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
73206
- var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined);
73207
- if (!iterationTypes) {
73268
+ var isAsyncGenerator_1 = (functionFlags & 2 /* Async */) !== 0;
73269
+ if (contextualReturnType.flags & 1048576 /* Union */) {
73270
+ contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_1); });
73271
+ }
73272
+ var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
73273
+ if (!iterationReturnType) {
73208
73274
  return undefined;
73209
73275
  }
73210
- contextualReturnType = iterationTypes.returnType;
73276
+ contextualReturnType = iterationReturnType;
73211
73277
  // falls through to unwrap Promise for AsyncGenerators
73212
73278
  }
73213
73279
  if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function
@@ -73234,9 +73300,13 @@ var ts;
73234
73300
  var functionFlags = ts.getFunctionFlags(func);
73235
73301
  var contextualReturnType = getContextualReturnType(func, contextFlags);
73236
73302
  if (contextualReturnType) {
73303
+ var isAsyncGenerator_2 = (functionFlags & 2 /* Async */) !== 0;
73304
+ if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* Union */) {
73305
+ contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_2); });
73306
+ }
73237
73307
  return node.asteriskToken
73238
73308
  ? contextualReturnType
73239
- : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
73309
+ : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator_2);
73240
73310
  }
73241
73311
  }
73242
73312
  return undefined;
@@ -74412,16 +74482,30 @@ var ts;
74412
74482
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74413
74483
  // type with those properties for which the binding pattern specifies a default value.
74414
74484
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74415
- // literal handle it instead.
74416
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74417
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74418
- var prop = _e[_d];
74419
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74420
- if (!(prop.flags & 16777216 /* Optional */)) {
74421
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74485
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74486
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74487
+ // It's not possible to check if the immediate parent node is a spread assignment
74488
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74489
+ if (contextualTypeHasPattern) {
74490
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74491
+ return n.kind === 254 /* VariableDeclaration */ ||
74492
+ n.kind === 221 /* BinaryExpression */ ||
74493
+ n.kind === 164 /* Parameter */;
74494
+ });
74495
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74496
+ return n === rootPatternParent_1 ||
74497
+ n.kind === 298 /* SpreadAssignment */;
74498
+ });
74499
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74500
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74501
+ var prop = _e[_d];
74502
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74503
+ if (!(prop.flags & 16777216 /* Optional */)) {
74504
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74505
+ }
74506
+ propertiesTable.set(prop.escapedName, prop);
74507
+ propertiesArray.push(prop);
74422
74508
  }
74423
- propertiesTable.set(prop.escapedName, prop);
74424
- propertiesArray.push(prop);
74425
74509
  }
74426
74510
  }
74427
74511
  }
@@ -77973,8 +78057,8 @@ var ts;
77973
78057
  if (hasDefaultOnly && type && !isErrorType(type)) {
77974
78058
  var synthType = type;
77975
78059
  if (!synthType.defaultOnlyType) {
77976
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
77977
- synthType.defaultOnlyType = type_5;
78060
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78061
+ synthType.defaultOnlyType = type_4;
77978
78062
  }
77979
78063
  return synthType.defaultOnlyType;
77980
78064
  }
@@ -82130,9 +82214,11 @@ var ts;
82130
82214
  // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82131
82215
  if (isGenericObjectType(type)) {
82132
82216
  var baseConstraint = getBaseConstraintOfType(type);
82133
- // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82217
+ // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82134
82218
  // or is promise-like.
82135
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82219
+ if (baseConstraint ?
82220
+ baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
82221
+ maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
82136
82222
  return true;
82137
82223
  }
82138
82224
  }
@@ -84009,17 +84095,28 @@ var ts;
84009
84095
  * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
84010
84096
  */
84011
84097
  function getIterationTypesOfIterable(type, use, errorNode) {
84098
+ var _a, _b;
84012
84099
  if (isTypeAny(type)) {
84013
84100
  return anyIterationTypes;
84014
84101
  }
84015
84102
  if (!(type.flags & 1048576 /* Union */)) {
84016
- var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
84103
+ var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
84104
+ var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
84017
84105
  if (iterationTypes_1 === noIterationTypes) {
84018
84106
  if (errorNode) {
84019
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84107
+ var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84108
+ if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
84109
+ ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
84110
+ }
84020
84111
  }
84021
84112
  return undefined;
84022
84113
  }
84114
+ else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
84115
+ for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
84116
+ var diag = _c[_i];
84117
+ diagnostics.add(diag);
84118
+ }
84119
+ }
84023
84120
  return iterationTypes_1;
84024
84121
  }
84025
84122
  var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
@@ -84027,19 +84124,27 @@ var ts;
84027
84124
  if (cachedTypes)
84028
84125
  return cachedTypes === noIterationTypes ? undefined : cachedTypes;
84029
84126
  var allIterationTypes;
84030
- for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
84031
- var constituent = _a[_i];
84032
- var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
84127
+ for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
84128
+ var constituent = _e[_d];
84129
+ var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
84130
+ var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
84033
84131
  if (iterationTypes_2 === noIterationTypes) {
84034
84132
  if (errorNode) {
84035
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84133
+ var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84134
+ if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
84135
+ ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
84136
+ }
84036
84137
  }
84037
84138
  setCachedIterationTypes(type, cacheKey, noIterationTypes);
84038
84139
  return undefined;
84039
84140
  }
84040
- else {
84041
- allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
84141
+ else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
84142
+ for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
84143
+ var diag = _g[_f];
84144
+ diagnostics.add(diag);
84145
+ }
84042
84146
  }
84147
+ allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
84043
84148
  }
84044
84149
  var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
84045
84150
  setCachedIterationTypes(type, cacheKey, iterationTypes);
@@ -84067,47 +84172,62 @@ var ts;
84067
84172
  * NOTE: You probably don't want to call this directly and should be calling
84068
84173
  * `getIterationTypesOfIterable` instead.
84069
84174
  */
84070
- function getIterationTypesOfIterableWorker(type, use, errorNode) {
84175
+ function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
84071
84176
  if (isTypeAny(type)) {
84072
84177
  return anyIterationTypes;
84073
84178
  }
84179
+ // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
84180
+ // In addition, we should not cache any new results for this call.
84181
+ var noCache = false;
84074
84182
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84075
84183
  var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
84076
84184
  getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
84077
84185
  if (iterationTypes) {
84078
- return use & 8 /* ForOfFlag */ ?
84079
- getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
84080
- iterationTypes;
84186
+ if (iterationTypes === noIterationTypes && errorNode) {
84187
+ // ignore the cached value
84188
+ noCache = true;
84189
+ }
84190
+ else {
84191
+ return use & 8 /* ForOfFlag */ ?
84192
+ getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
84193
+ iterationTypes;
84194
+ }
84081
84195
  }
84082
84196
  }
84083
84197
  if (use & 1 /* AllowsSyncIterablesFlag */) {
84084
84198
  var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
84085
84199
  getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
84086
84200
  if (iterationTypes) {
84087
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
84088
- // for a sync iterable in an async context, only use the cached types if they are valid.
84089
- if (iterationTypes !== noIterationTypes) {
84090
- return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
84091
- }
84201
+ if (iterationTypes === noIterationTypes && errorNode) {
84202
+ // ignore the cached value
84203
+ noCache = true;
84092
84204
  }
84093
84205
  else {
84094
- return iterationTypes;
84206
+ if (use & 2 /* AllowsAsyncIterablesFlag */) {
84207
+ // for a sync iterable in an async context, only use the cached types if they are valid.
84208
+ if (iterationTypes !== noIterationTypes) {
84209
+ iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
84210
+ return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
84211
+ }
84212
+ }
84213
+ else {
84214
+ return iterationTypes;
84215
+ }
84095
84216
  }
84096
84217
  }
84097
84218
  }
84098
84219
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84099
- var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
84220
+ var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
84100
84221
  if (iterationTypes !== noIterationTypes) {
84101
84222
  return iterationTypes;
84102
84223
  }
84103
84224
  }
84104
84225
  if (use & 1 /* AllowsSyncIterablesFlag */) {
84105
- var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
84226
+ var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
84106
84227
  if (iterationTypes !== noIterationTypes) {
84107
84228
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84108
- return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
84109
- ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
84110
- : noIterationTypes);
84229
+ iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
84230
+ return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
84111
84231
  }
84112
84232
  else {
84113
84233
  return iterationTypes;
@@ -84128,7 +84248,7 @@ var ts;
84128
84248
  }
84129
84249
  function getIterationTypesOfGlobalIterableType(globalType, resolver) {
84130
84250
  var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
84131
- getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
84251
+ getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
84132
84252
  return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
84133
84253
  }
84134
84254
  /**
@@ -84182,40 +84302,56 @@ var ts;
84182
84302
  * NOTE: You probably don't want to call this directly and should be calling
84183
84303
  * `getIterationTypesOfIterable` instead.
84184
84304
  */
84185
- function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
84305
+ function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
84186
84306
  var _a;
84187
84307
  var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
84188
84308
  var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
84189
84309
  if (isTypeAny(methodType)) {
84190
- return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
84310
+ return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
84191
84311
  }
84192
84312
  var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
84193
84313
  if (!ts.some(signatures)) {
84194
- return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
84314
+ return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
84195
84315
  }
84196
84316
  var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
84197
- var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
84198
- return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
84317
+ var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
84318
+ return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
84199
84319
  }
84200
84320
  function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
84201
84321
  var message = allowAsyncIterables
84202
84322
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84203
84323
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84204
- errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
84324
+ return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
84325
+ }
84326
+ /**
84327
+ * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
84328
+ *
84329
+ * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84330
+ * record is returned. Otherwise, `undefined` is returned.
84331
+ */
84332
+ function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
84333
+ return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
84205
84334
  }
84206
84335
  /**
84207
84336
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
84208
84337
  *
84209
84338
  * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84210
84339
  * record is returned. Otherwise, `undefined` is returned.
84340
+ *
84341
+ * NOTE: You probably don't want to call this directly and should be calling
84342
+ * `getIterationTypesOfIterator` instead.
84211
84343
  */
84212
- function getIterationTypesOfIterator(type, resolver, errorNode) {
84344
+ function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
84213
84345
  if (isTypeAny(type)) {
84214
84346
  return anyIterationTypes;
84215
84347
  }
84216
84348
  var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
84217
- getIterationTypesOfIteratorFast(type, resolver) ||
84218
- getIterationTypesOfIteratorSlow(type, resolver, errorNode);
84349
+ getIterationTypesOfIteratorFast(type, resolver);
84350
+ if (iterationTypes === noIterationTypes && errorNode) {
84351
+ iterationTypes = undefined;
84352
+ noCache = true;
84353
+ }
84354
+ iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
84219
84355
  return iterationTypes === noIterationTypes ? undefined : iterationTypes;
84220
84356
  }
84221
84357
  /**
@@ -84253,7 +84389,7 @@ var ts;
84253
84389
  // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
84254
84390
  // and `undefined` in our libs by default, a custom lib *could* use different definitions.
84255
84391
  var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
84256
- getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
84392
+ getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
84257
84393
  var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
84258
84394
  return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
84259
84395
  }
@@ -84323,8 +84459,8 @@ var ts;
84323
84459
  * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84324
84460
  * record is returned. Otherwise, we return `undefined`.
84325
84461
  */
84326
- function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
84327
- var _a, _b, _c, _d;
84462
+ function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
84463
+ var _a, _b, _c, _d, _e, _f;
84328
84464
  var method = getPropertyOfType(type, methodName);
84329
84465
  // Ignore 'return' or 'throw' if they are missing.
84330
84466
  if (!method && methodName !== "next") {
@@ -84344,9 +84480,15 @@ var ts;
84344
84480
  var diagnostic = methodName === "next"
84345
84481
  ? resolver.mustHaveANextMethodDiagnostic
84346
84482
  : resolver.mustBeAMethodDiagnostic;
84347
- error(errorNode, diagnostic, methodName);
84483
+ if (errorOutputContainer) {
84484
+ (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
84485
+ errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
84486
+ }
84487
+ else {
84488
+ error(errorNode, diagnostic, methodName);
84489
+ }
84348
84490
  }
84349
- return methodName === "next" ? anyIterationTypes : undefined;
84491
+ return methodName === "next" ? noIterationTypes : undefined;
84350
84492
  }
84351
84493
  // If the method signature comes exclusively from the global iterator or generator type,
84352
84494
  // create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
@@ -84358,8 +84500,8 @@ var ts;
84358
84500
  if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
84359
84501
  var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
84360
84502
  var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
84361
- var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol;
84362
- var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol;
84503
+ var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol;
84504
+ var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol;
84363
84505
  if (isGeneratorMethod || isIteratorMethod) {
84364
84506
  var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
84365
84507
  var mapper = methodType.mapper;
@@ -84399,7 +84541,13 @@ var ts;
84399
84541
  var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
84400
84542
  if (iterationTypes === noIterationTypes) {
84401
84543
  if (errorNode) {
84402
- error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
84544
+ if (errorOutputContainer) {
84545
+ (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
84546
+ errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
84547
+ }
84548
+ else {
84549
+ error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
84550
+ }
84403
84551
  }
84404
84552
  yieldType = anyType;
84405
84553
  returnTypes = ts.append(returnTypes, anyType);
@@ -84420,13 +84568,13 @@ var ts;
84420
84568
  * NOTE: You probably don't want to call this directly and should be calling
84421
84569
  * `getIterationTypesOfIterator` instead.
84422
84570
  */
84423
- function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
84571
+ function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
84424
84572
  var iterationTypes = combineIterationTypes([
84425
- getIterationTypesOfMethod(type, resolver, "next", errorNode),
84426
- getIterationTypesOfMethod(type, resolver, "return", errorNode),
84427
- getIterationTypesOfMethod(type, resolver, "throw", errorNode),
84573
+ getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
84574
+ getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
84575
+ getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
84428
84576
  ]);
84429
- return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
84577
+ return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
84430
84578
  }
84431
84579
  /**
84432
84580
  * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
@@ -84447,7 +84595,7 @@ var ts;
84447
84595
  var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
84448
84596
  var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
84449
84597
  return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
84450
- getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
84598
+ getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
84451
84599
  }
84452
84600
  function checkBreakOrContinueStatement(node) {
84453
84601
  // Grammar checking
@@ -87247,6 +87395,12 @@ var ts;
87247
87395
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87248
87396
  }
87249
87397
  }
87398
+ if (result && isJSDoc_1) {
87399
+ var container = ts.getJSDocHost(name);
87400
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87401
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87402
+ }
87403
+ }
87250
87404
  return result;
87251
87405
  }
87252
87406
  else if (ts.isPrivateIdentifier(name)) {
@@ -94904,10 +95058,11 @@ var ts;
94904
95058
  }
94905
95059
  function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
94906
95060
  if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
94907
- if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
95061
+ var operand = ts.skipParentheses(node.operand);
95062
+ if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
94908
95063
  var info = void 0;
94909
- if (info = accessPrivateIdentifier(node.operand.name)) {
94910
- var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
95064
+ if (info = accessPrivateIdentifier(operand.name)) {
95065
+ var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
94911
95066
  var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
94912
95067
  var expression = createPrivateIdentifierAccess(info, readExpression);
94913
95068
  var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
@@ -94923,7 +95078,7 @@ var ts;
94923
95078
  }
94924
95079
  }
94925
95080
  else if (shouldTransformSuperInStaticInitializers &&
94926
- ts.isSuperProperty(node.operand) &&
95081
+ ts.isSuperProperty(operand) &&
94927
95082
  currentStaticPropertyDeclarationOrStaticBlock &&
94928
95083
  currentClassLexicalEnvironment) {
94929
95084
  // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
@@ -94936,31 +95091,31 @@ var ts;
94936
95091
  // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
94937
95092
  var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
94938
95093
  if (facts & 1 /* ClassWasDecorated */) {
94939
- var operand = visitInvalidSuperProperty(node.operand);
95094
+ var expression = visitInvalidSuperProperty(operand);
94940
95095
  return ts.isPrefixUnaryExpression(node) ?
94941
- factory.updatePrefixUnaryExpression(node, operand) :
94942
- factory.updatePostfixUnaryExpression(node, operand);
95096
+ factory.updatePrefixUnaryExpression(node, expression) :
95097
+ factory.updatePostfixUnaryExpression(node, expression);
94943
95098
  }
94944
95099
  if (classConstructor && superClassReference) {
94945
95100
  var setterName = void 0;
94946
95101
  var getterName = void 0;
94947
- if (ts.isPropertyAccessExpression(node.operand)) {
94948
- if (ts.isIdentifier(node.operand.name)) {
94949
- getterName = setterName = factory.createStringLiteralFromNode(node.operand.name);
95102
+ if (ts.isPropertyAccessExpression(operand)) {
95103
+ if (ts.isIdentifier(operand.name)) {
95104
+ getterName = setterName = factory.createStringLiteralFromNode(operand.name);
94950
95105
  }
94951
95106
  }
94952
95107
  else {
94953
- if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) {
94954
- getterName = setterName = node.operand.argumentExpression;
95108
+ if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
95109
+ getterName = setterName = operand.argumentExpression;
94955
95110
  }
94956
95111
  else {
94957
95112
  getterName = factory.createTempVariable(hoistVariableDeclaration);
94958
- setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression));
95113
+ setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
94959
95114
  }
94960
95115
  }
94961
95116
  if (setterName && getterName) {
94962
95117
  var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
94963
- ts.setTextRange(expression, node.operand);
95118
+ ts.setTextRange(expression, operand);
94964
95119
  var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
94965
95120
  expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
94966
95121
  expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
@@ -107407,6 +107562,13 @@ var ts;
107407
107562
  ts.Debug.assert(importVariableName !== undefined);
107408
107563
  // save import into the local
107409
107564
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107565
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107566
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107567
+ /*typeArguments*/ undefined, [
107568
+ factory.createStringLiteral(ts.idText(importVariableName)),
107569
+ parameterName,
107570
+ ])));
107571
+ }
107410
107572
  break;
107411
107573
  case 272 /* ExportDeclaration */:
107412
107574
  ts.Debug.assert(importVariableName !== undefined);
@@ -110249,8 +110411,12 @@ var ts;
110249
110411
  }
110250
110412
  var previousNeedsDeclare = needsDeclare;
110251
110413
  switch (input.kind) {
110252
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110253
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110414
+ case 259 /* TypeAliasDeclaration */: {
110415
+ needsDeclare = false;
110416
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110417
+ needsDeclare = previousNeedsDeclare;
110418
+ return clean;
110419
+ }
110254
110420
  case 258 /* InterfaceDeclaration */: {
110255
110421
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110256
110422
  }
@@ -116501,7 +116667,16 @@ var ts;
116501
116667
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116502
116668
  }
116503
116669
  function getCachedFileSystemEntriesForBaseDir(path) {
116504
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116670
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116671
+ if (!entries) {
116672
+ return entries;
116673
+ }
116674
+ // If we're looking for the base directory, we're definitely going to search the entries
116675
+ if (!entries.sortedAndCanonicalizedFiles) {
116676
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116677
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116678
+ }
116679
+ return entries;
116505
116680
  }
116506
116681
  function getBaseNameOfFileName(fileName) {
116507
116682
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116544,21 +116719,10 @@ var ts;
116544
116719
  return undefined;
116545
116720
  }
116546
116721
  }
116547
- function fileNameEqual(name1, name2) {
116548
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116549
- }
116550
116722
  function hasEntry(entries, name) {
116551
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116552
- }
116553
- function updateFileSystemEntry(entries, baseName, isValid) {
116554
- if (hasEntry(entries, baseName)) {
116555
- if (!isValid) {
116556
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116557
- }
116558
- }
116559
- else if (isValid) {
116560
- return entries.push(baseName);
116561
- }
116723
+ // Case-sensitive comparison since already canonicalized
116724
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116725
+ return index >= 0;
116562
116726
  }
116563
116727
  function writeFile(fileName, data, writeByteOrderMark) {
116564
116728
  var path = toPath(fileName);
@@ -116571,7 +116735,7 @@ var ts;
116571
116735
  function fileExists(fileName) {
116572
116736
  var path = toPath(fileName);
116573
116737
  var result = getCachedFileSystemEntriesForBaseDir(path);
116574
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116738
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116575
116739
  host.fileExists(fileName);
116576
116740
  }
116577
116741
  function directoryExists(dirPath) {
@@ -116581,9 +116745,14 @@ var ts;
116581
116745
  function createDirectory(dirPath) {
116582
116746
  var path = toPath(dirPath);
116583
116747
  var result = getCachedFileSystemEntriesForBaseDir(path);
116584
- var baseFileName = getBaseNameOfFileName(dirPath);
116585
116748
  if (result) {
116586
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116749
+ var baseName = getBaseNameOfFileName(dirPath);
116750
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116751
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116752
+ // Case-sensitive comparison since already canonicalized
116753
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116754
+ result.directories.push(baseName);
116755
+ }
116587
116756
  }
116588
116757
  host.createDirectory(dirPath);
116589
116758
  }
@@ -116652,7 +116821,7 @@ var ts;
116652
116821
  fileExists: host.fileExists(fileOrDirectoryPath),
116653
116822
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116654
116823
  };
116655
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116824
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116656
116825
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116657
116826
  clearCache();
116658
116827
  }
@@ -116672,7 +116841,23 @@ var ts;
116672
116841
  }
116673
116842
  }
116674
116843
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116675
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
116844
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
116845
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116846
+ if (fileExists) {
116847
+ // Case-sensitive comparison since already canonicalized
116848
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116849
+ parentResult.files.push(baseName);
116850
+ }
116851
+ }
116852
+ else {
116853
+ // Case-sensitive comparison since already canonicalized
116854
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
116855
+ if (sortedIndex >= 0) {
116856
+ canonicalizedFiles.splice(sortedIndex, 1);
116857
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
116858
+ parentResult.files.splice(unsortedIndex, 1);
116859
+ }
116860
+ }
116676
116861
  }
116677
116862
  function clearCache() {
116678
116863
  cachedReadDirectoryResult.clear();
@@ -119430,14 +119615,16 @@ var ts;
119430
119615
  addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
119431
119616
  }
119432
119617
  }
119433
- function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
119618
+ function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
119619
+ var _a;
119434
119620
  var redirect = Object.create(redirectTarget);
119435
119621
  redirect.fileName = fileName;
119436
119622
  redirect.path = path;
119437
119623
  redirect.resolvedPath = resolvedPath;
119438
119624
  redirect.originalFileName = originalFileName;
119439
119625
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
119440
- // TODO:" shkamat"
119626
+ redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
119627
+ redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
119441
119628
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
119442
119629
  Object.defineProperties(redirect, {
119443
119630
  id: {
@@ -119568,7 +119755,7 @@ var ts;
119568
119755
  if (fileFromPackageId) {
119569
119756
  // Some other SourceFile already exists with this package name and version.
119570
119757
  // Instead of creating a duplicate, just redirect to the existing one.
119571
- var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217
119758
+ var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
119572
119759
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
119573
119760
  addFileToFilesByName(dupFile, path, redirectedPath);
119574
119761
  addFileIncludeReason(dupFile, reason);
@@ -119591,7 +119778,6 @@ var ts;
119591
119778
  file.originalFileName = originalFileName;
119592
119779
  file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
119593
119780
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
119594
- // TODO: handle watch when same file has changes in failed and affecting locations
119595
119781
  addFileIncludeReason(file, reason);
119596
119782
  if (host.useCaseSensitiveFileNames()) {
119597
119783
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -122653,7 +122839,6 @@ var ts;
122653
122839
  resolvedModuleNames.clear();
122654
122840
  resolvedTypeReferenceDirectives.clear();
122655
122841
  resolvedFileToResolution.clear();
122656
- nonRelativeExternalModuleResolutions.clear();
122657
122842
  resolutionsWithFailedLookups.length = 0;
122658
122843
  resolutionsWithOnlyAffectingLocations.length = 0;
122659
122844
  failedLookupChecks = undefined;
@@ -122661,8 +122846,6 @@ var ts;
122661
122846
  isInDirectoryChecks = undefined;
122662
122847
  affectingPathChecks = undefined;
122663
122848
  affectingPathChecksForFile = undefined;
122664
- // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122665
- // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122666
122849
  moduleResolutionCache.clear();
122667
122850
  typeReferenceDirectiveResolutionCache.clear();
122668
122851
  impliedFormatPackageJsons.clear();
@@ -122700,6 +122883,10 @@ var ts;
122700
122883
  function startCachingPerDirectoryResolution() {
122701
122884
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
122702
122885
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
122886
+ // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122887
+ // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122888
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122889
+ nonRelativeExternalModuleResolutions.clear();
122703
122890
  }
122704
122891
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122705
122892
  filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
@@ -122741,8 +122928,6 @@ var ts;
122741
122928
  if (watcher.files === 0 && watcher.resolutions === 0) {
122742
122929
  fileWatchesOfAffectingLocations.delete(path);
122743
122930
  watcher.watcher.close();
122744
- // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122745
- watcher.watcher = ts.noopFileWatcher;
122746
122931
  }
122747
122932
  });
122748
122933
  hasChangedAutomaticTypeDirectiveNames = false;
@@ -123088,20 +123273,27 @@ var ts;
123088
123273
  }
123089
123274
  var paths = new ts.Set();
123090
123275
  paths.add(locationToWatch);
123276
+ var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123277
+ resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123278
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123279
+ var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
123280
+ paths.forEach(function (path) {
123281
+ if (watcher.resolutions)
123282
+ (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123283
+ if (watcher.files)
123284
+ (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123285
+ packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
123286
+ });
123287
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123288
+ }) : ts.noopFileWatcher;
123091
123289
  var watcher = {
123092
- watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123093
- resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123094
- cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123095
- paths.forEach(function (path) {
123096
- var _a;
123097
- if (watcher.resolutions)
123098
- (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123099
- if (watcher.files)
123100
- (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123101
- (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
123102
- });
123103
- resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123104
- }) : ts.noopFileWatcher,
123290
+ watcher: actualWatcher !== ts.noopFileWatcher ? {
123291
+ close: function () {
123292
+ actualWatcher.close();
123293
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
123294
+ actualWatcher = ts.noopFileWatcher;
123295
+ }
123296
+ } : actualWatcher,
123105
123297
  resolutions: forResolution ? 1 : 0,
123106
123298
  files: forResolution ? 0 : 1,
123107
123299
  paths: paths,
@@ -123515,7 +123707,7 @@ var ts;
123515
123707
  var info = getInfo(importingSourceFileName, host);
123516
123708
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
123517
123709
  return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
123518
- getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
123710
+ getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
123519
123711
  }
123520
123712
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
123521
123713
  if (options === void 0) { options = {}; }
@@ -123598,7 +123790,7 @@ var ts;
123598
123790
  return nodeModulesSpecifiers;
123599
123791
  }
123600
123792
  if (!specifier && !modulePath.isRedirect) {
123601
- var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
123793
+ var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
123602
123794
  if (ts.pathIsBareSpecifier(local)) {
123603
123795
  pathsSpecifiers = ts.append(pathsSpecifiers, local);
123604
123796
  }
@@ -123626,7 +123818,7 @@ var ts;
123626
123818
  var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
123627
123819
  return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
123628
123820
  }
123629
- function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
123821
+ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
123630
123822
  var ending = _a.ending, relativePreference = _a.relativePreference;
123631
123823
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
123632
123824
  var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
@@ -123640,9 +123832,8 @@ var ts;
123640
123832
  if (!relativeToBaseUrl) {
123641
123833
  return relativePath;
123642
123834
  }
123643
- var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
123644
- var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
123645
- var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
123835
+ var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
123836
+ var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
123646
123837
  if (!nonRelative) {
123647
123838
  return relativePath;
123648
123839
  }
@@ -123877,28 +124068,102 @@ var ts;
123877
124068
  return ambientModuleDeclare.name.text;
123878
124069
  }
123879
124070
  }
123880
- function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
124071
+ function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
124072
+ if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
124073
+ return [2 /* JsExtension */];
124074
+ }
124075
+ switch (preferredEnding) {
124076
+ case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
124077
+ case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
124078
+ case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
124079
+ default: ts.Debug.assertNever(preferredEnding);
124080
+ }
124081
+ }
124082
+ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
123881
124083
  for (var key in paths) {
123882
- for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
123883
- var patternText_1 = _a[_i];
123884
- var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
124084
+ var _loop_36 = function (patternText_1) {
124085
+ var pattern = ts.normalizePath(patternText_1);
123885
124086
  var indexOfStar = pattern.indexOf("*");
124087
+ // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
124088
+ // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
124089
+ // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
124090
+ // and matches the '*'. For example:
124091
+ //
124092
+ // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
124093
+ // ---------------------->------------------------------->--------------------->---------------------------------------------------------------
124094
+ // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
124095
+ // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
124096
+ //
124097
+ // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
124098
+ //
124099
+ // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
124100
+ // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
124101
+ // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
124102
+ // extension for a module specifier.)
124103
+ //
124104
+ // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
124105
+ // .ts extension) or the possible relative module specifiers representing that file:
124106
+ //
124107
+ // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
124108
+ // --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
124109
+ // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
124110
+ // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
124111
+ // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
124112
+ // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js
124113
+ // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
124114
+ //
124115
+ // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
124116
+ // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
124117
+ // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
124118
+ // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
124119
+ // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
124120
+ // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
124121
+ // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
124122
+ // sorted among the others for a particular value of `importModuleSpecifierEnding`.
124123
+ var candidates = allowedEndings.map(function (ending) { return ({
124124
+ ending: ending,
124125
+ value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
124126
+ }); });
124127
+ if (ts.tryGetExtensionFromPath(pattern)) {
124128
+ candidates.push({ ending: undefined, value: relativeToBaseUrl });
124129
+ }
123886
124130
  if (indexOfStar !== -1) {
123887
- var prefix = pattern.substr(0, indexOfStar);
123888
- var suffix = pattern.substr(indexOfStar + 1);
123889
- if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
123890
- ts.startsWith(relativeToBaseUrl, prefix) &&
123891
- ts.endsWith(relativeToBaseUrl, suffix) ||
123892
- !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
123893
- var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length);
123894
- return key.replace("*", matchedStar);
124131
+ var prefix = pattern.substring(0, indexOfStar);
124132
+ var suffix = pattern.substring(indexOfStar + 1);
124133
+ for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
124134
+ var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
124135
+ if (value.length >= prefix.length + suffix.length &&
124136
+ ts.startsWith(value, prefix) &&
124137
+ ts.endsWith(value, suffix) &&
124138
+ validateEnding({ ending: ending, value: value })) {
124139
+ var matchedStar = value.substring(prefix.length, value.length - suffix.length);
124140
+ return { value: key.replace("*", matchedStar) };
124141
+ }
123895
124142
  }
123896
124143
  }
123897
- else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
123898
- return key;
124144
+ else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
124145
+ ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
124146
+ return { value: key };
123899
124147
  }
124148
+ };
124149
+ for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
124150
+ var patternText_1 = _a[_i];
124151
+ var state_12 = _loop_36(patternText_1);
124152
+ if (typeof state_12 === "object")
124153
+ return state_12.value;
123900
124154
  }
123901
124155
  }
124156
+ function validateEnding(_a) {
124157
+ var ending = _a.ending, value = _a.value;
124158
+ // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
124159
+ // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
124160
+ // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
124161
+ // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
124162
+ // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
124163
+ // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
124164
+ // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
124165
+ return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
124166
+ }
123902
124167
  }
123903
124168
  var MatchingMode;
123904
124169
  (function (MatchingMode) {
@@ -123994,10 +124259,10 @@ var ts;
123994
124259
  return undefined;
123995
124260
  }
123996
124261
  // Simplify the full file path to something that can be resolved by Node.
124262
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
123997
124263
  var moduleSpecifier = path;
123998
124264
  var isPackageRootPath = false;
123999
124265
  if (!packageNameOnly) {
124000
- var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
124001
124266
  var packageRootIndex = parts.packageRootIndex;
124002
124267
  var moduleFileName = void 0;
124003
124268
  while (true) {
@@ -124046,15 +124311,13 @@ var ts;
124046
124311
  var packageRootPath = path.substring(0, packageRootIndex);
124047
124312
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
124048
124313
  var moduleFileToTry = path;
124314
+ var maybeBlockedByTypesVersions = false;
124049
124315
  var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
124050
124316
  if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
124051
124317
  var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
124318
+ var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
124052
124319
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
124053
- // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
124054
- // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
124055
- // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
124056
- // with, so for now we just stick with the mode of the file.
124057
- var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
124320
+ var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
124058
124321
  var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
124059
124322
  ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
124060
124323
  : undefined;
@@ -124073,16 +124336,26 @@ var ts;
124073
124336
  : undefined;
124074
124337
  if (versionPaths) {
124075
124338
  var subModuleName = path.slice(packageRootPath.length + 1);
124076
- var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths);
124077
- if (fromPaths !== undefined) {
124339
+ var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
124340
+ if (fromPaths === undefined) {
124341
+ maybeBlockedByTypesVersions = true;
124342
+ }
124343
+ else {
124078
124344
  moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
124079
124345
  }
124080
124346
  }
124081
124347
  // If the file is the main module, it can be imported by the package name
124082
124348
  var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
124083
- if (ts.isString(mainFileRelative)) {
124349
+ if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
124350
+ // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
124351
+ // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
124352
+ // (The only way this can happen is if some file in a package that's not resolvable from outside the
124353
+ // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
124354
+ // happens very easily in fourslash tests though, since every test file listed gets included. See
124355
+ // importNameCodeFix_typesVersions.ts for an example.)
124084
124356
  var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
124085
124357
  if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
124358
+ // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
124086
124359
  return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
124087
124360
  }
124088
124361
  }
@@ -156342,6 +156615,15 @@ var ts;
156342
156615
  ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
156343
156616
  ts.Diagnostics.Cannot_find_name_0.code
156344
156617
  ];
156618
+ var InfoKind;
156619
+ (function (InfoKind) {
156620
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
156621
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
156622
+ InfoKind[InfoKind["Function"] = 2] = "Function";
156623
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
156624
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
156625
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
156626
+ })(InfoKind || (InfoKind = {}));
156345
156627
  codefix.registerCodeFix({
156346
156628
  errorCodes: errorCodes,
156347
156629
  getCodeActions: function (context) {
@@ -156350,19 +156632,19 @@ var ts;
156350
156632
  if (!info) {
156351
156633
  return undefined;
156352
156634
  }
156353
- if (info.kind === 3 /* ObjectLiteral */) {
156635
+ if (info.kind === InfoKind.ObjectLiteral) {
156354
156636
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
156355
156637
  return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
156356
156638
  }
156357
- if (info.kind === 4 /* JsxAttributes */) {
156639
+ if (info.kind === InfoKind.JsxAttributes) {
156358
156640
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
156359
156641
  return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
156360
156642
  }
156361
- if (info.kind === 2 /* Function */) {
156643
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
156362
156644
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
156363
156645
  return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
156364
156646
  }
156365
- if (info.kind === 1 /* Enum */) {
156647
+ if (info.kind === InfoKind.Enum) {
156366
156648
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
156367
156649
  return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
156368
156650
  }
@@ -156380,20 +156662,20 @@ var ts;
156380
156662
  if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
156381
156663
  return;
156382
156664
  }
156383
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
156665
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
156384
156666
  addFunctionDeclaration(changes, context, info);
156385
156667
  }
156386
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
156668
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
156387
156669
  addObjectLiteralProperties(changes, context, info);
156388
156670
  }
156389
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
156671
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
156390
156672
  addJsxAttributes(changes, context, info);
156391
156673
  }
156392
156674
  else {
156393
- if (info.kind === 1 /* Enum */) {
156675
+ if (info.kind === InfoKind.Enum) {
156394
156676
  addEnumMemberDeclaration(changes, checker, info);
156395
156677
  }
156396
- if (info.kind === 0 /* TypeLikeDeclaration */) {
156678
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
156397
156679
  var parentDeclaration = info.parentDeclaration, token_1 = info.token;
156398
156680
  var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
156399
156681
  if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -156437,14 +156719,6 @@ var ts;
156437
156719
  }));
156438
156720
  },
156439
156721
  });
156440
- var InfoKind;
156441
- (function (InfoKind) {
156442
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
156443
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
156444
- InfoKind[InfoKind["Function"] = 2] = "Function";
156445
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
156446
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
156447
- })(InfoKind || (InfoKind = {}));
156448
156722
  function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
156449
156723
  // The identifier of the missing property. eg:
156450
156724
  // this.missing = 1;
@@ -156466,7 +156740,7 @@ var ts;
156466
156740
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
156467
156741
  if (!ts.length(properties))
156468
156742
  return undefined;
156469
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
156743
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
156470
156744
  }
156471
156745
  if (!ts.isMemberName(token))
156472
156746
  return undefined;
@@ -156474,17 +156748,26 @@ var ts;
156474
156748
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
156475
156749
  if (!ts.length(properties))
156476
156750
  return undefined;
156477
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
156751
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
156478
156752
  }
156479
156753
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
156480
156754
  var target = ts.getEmitScriptTarget(program.getCompilerOptions());
156481
156755
  var attributes = getUnmatchedAttributes(checker, target, token.parent);
156482
156756
  if (!ts.length(attributes))
156483
156757
  return undefined;
156484
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
156758
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
156485
156759
  }
156486
- if (ts.isIdentifier(token) && ts.isCallExpression(parent)) {
156487
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
156760
+ if (ts.isIdentifier(token)) {
156761
+ var type = checker.getContextualType(token);
156762
+ if (type && ts.getObjectFlags(type) & 16 /* Anonymous */) {
156763
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
156764
+ if (signature === undefined)
156765
+ return undefined;
156766
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
156767
+ }
156768
+ if (ts.isCallExpression(parent) && parent.expression === token) {
156769
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: findScope(token) };
156770
+ }
156488
156771
  }
156489
156772
  if (!ts.isPropertyAccessExpression(parent))
156490
156773
  return undefined;
@@ -156496,13 +156779,13 @@ var ts;
156496
156779
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
156497
156780
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
156498
156781
  if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
156499
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
156782
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
156500
156783
  }
156501
156784
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
156502
156785
  if (sourceFile.commonJsModuleIndicator)
156503
156786
  return undefined;
156504
156787
  if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
156505
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
156788
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
156506
156789
  }
156507
156790
  }
156508
156791
  var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -156520,11 +156803,11 @@ var ts;
156520
156803
  (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
156521
156804
  var isJSFile = ts.isSourceFileJS(declSourceFile);
156522
156805
  var call = ts.tryCast(parent.parent, ts.isCallExpression);
156523
- return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
156806
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
156524
156807
  }
156525
156808
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
156526
156809
  if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
156527
- return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
156810
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
156528
156811
  }
156529
156812
  return undefined;
156530
156813
  }
@@ -156700,9 +156983,17 @@ var ts;
156700
156983
  });
156701
156984
  }
156702
156985
  function addFunctionDeclaration(changes, context, info) {
156986
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
156703
156987
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
156704
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
156705
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
156988
+ var functionDeclaration = info.kind === InfoKind.Function
156989
+ ? codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
156990
+ : codefix.createSignatureDeclarationFromSignature(256 /* FunctionDeclaration */, context, quotePreference, info.signature, codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), info.token, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
156991
+ if (functionDeclaration === undefined) {
156992
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
156993
+ }
156994
+ ts.isReturnStatement(info.parentDeclaration)
156995
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
156996
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
156706
156997
  importAdder.writeFixes(changes);
156707
156998
  }
156708
156999
  function addJsxAttributes(changes, context, info) {
@@ -156860,6 +157151,14 @@ var ts;
156860
157151
  }
156861
157152
  return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
156862
157153
  }
157154
+ function findScope(node) {
157155
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
157156
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
157157
+ if (returnStatement)
157158
+ return returnStatement;
157159
+ }
157160
+ return ts.getSourceFileOfNode(node);
157161
+ }
156863
157162
  })(codefix = ts.codefix || (ts.codefix = {}));
156864
157163
  })(ts || (ts = {}));
156865
157164
  /* @internal */
@@ -159549,6 +159848,9 @@ var ts;
159549
159848
  if (ts.isMethodDeclaration(signatureDeclaration)) {
159550
159849
  return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
159551
159850
  }
159851
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
159852
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
159853
+ }
159552
159854
  return undefined;
159553
159855
  }
159554
159856
  codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -161728,6 +162030,9 @@ var ts;
161728
162030
  if (!containingDecl) {
161729
162031
  return;
161730
162032
  }
162033
+ if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
162034
+ return;
162035
+ }
161731
162036
  var checker = program.getTypeChecker();
161732
162037
  var signatureSymbol = containingDecl.symbol;
161733
162038
  if (!signatureSymbol) {