@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/typescript.js CHANGED
@@ -290,11 +290,11 @@ var ts;
290
290
  (function (ts) {
291
291
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
292
292
  // If changing the text in this section, be sure to test `configurePrerelease` too.
293
- ts.versionMajorMinor = "4.8";
293
+ ts.versionMajorMinor = "4.9";
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220730";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220810";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -1058,15 +1058,18 @@ var ts;
1058
1058
  function insertSorted(array, insert, compare, allowDuplicates) {
1059
1059
  if (array.length === 0) {
1060
1060
  array.push(insert);
1061
- return;
1061
+ return true;
1062
1062
  }
1063
1063
  var insertIndex = binarySearch(array, insert, identity, compare);
1064
1064
  if (insertIndex < 0) {
1065
1065
  array.splice(~insertIndex, 0, insert);
1066
+ return true;
1066
1067
  }
1067
- else if (allowDuplicates) {
1068
+ if (allowDuplicates) {
1068
1069
  array.splice(insertIndex, 0, insert);
1070
+ return true;
1069
1071
  }
1072
+ return false;
1070
1073
  }
1071
1074
  ts.insertSorted = insertSorted;
1072
1075
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -8761,7 +8764,7 @@ var ts;
8761
8764
  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\""),
8762
8765
  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"),
8763
8766
  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."),
8764
- 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."),
8767
+ 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."),
8765
8768
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8766
8769
  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."),
8767
8770
  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."),
@@ -8769,6 +8772,11 @@ var ts;
8769
8772
  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."),
8770
8773
  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."),
8771
8774
  Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
8775
+ 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."),
8776
+ 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\" }`."),
8777
+ 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}'."),
8778
+ 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}'."),
8779
+ 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\" }`."),
8772
8780
  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."),
8773
8781
  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."),
8774
8782
  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),
@@ -22063,7 +22071,7 @@ var ts;
22063
22071
  * Wraps an expression in parentheses if it is needed in order to use the expression for
22064
22072
  * property or element access.
22065
22073
  */
22066
- function parenthesizeLeftSideOfAccess(expression) {
22074
+ function parenthesizeLeftSideOfAccess(expression, optionalChain) {
22067
22075
  // isLeftHandSideExpression is almost the correct criterion for when it is not necessary
22068
22076
  // to parenthesize the expression before a dot. The known exception is:
22069
22077
  //
@@ -22072,7 +22080,8 @@ var ts;
22072
22080
  //
22073
22081
  var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
22074
22082
  if (ts.isLeftHandSideExpression(emittedExpression)
22075
- && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) {
22083
+ && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
22084
+ && (optionalChain || !ts.isOptionalChain(emittedExpression))) {
22076
22085
  // TODO(rbuckton): Verify whether this assertion holds.
22077
22086
  return expression;
22078
22087
  }
@@ -23479,7 +23488,7 @@ var ts;
23479
23488
  // @api
23480
23489
  function createDecorator(expression) {
23481
23490
  var node = createBaseNode(165 /* Decorator */);
23482
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
23491
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
23483
23492
  node.transformFlags |=
23484
23493
  propagateChildFlags(node.expression) |
23485
23494
  1 /* ContainsTypeScript */ |
@@ -24280,7 +24289,7 @@ var ts;
24280
24289
  // @api
24281
24290
  function createPropertyAccessExpression(expression, name) {
24282
24291
  var node = createBaseExpression(206 /* PropertyAccessExpression */);
24283
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24292
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24284
24293
  node.name = asName(name);
24285
24294
  node.transformFlags =
24286
24295
  propagateChildFlags(node.expression) |
@@ -24310,7 +24319,7 @@ var ts;
24310
24319
  function createPropertyAccessChain(expression, questionDotToken, name) {
24311
24320
  var node = createBaseExpression(206 /* PropertyAccessExpression */);
24312
24321
  node.flags |= 32 /* OptionalChain */;
24313
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24322
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24314
24323
  node.questionDotToken = questionDotToken;
24315
24324
  node.name = asName(name);
24316
24325
  node.transformFlags |=
@@ -24336,7 +24345,7 @@ var ts;
24336
24345
  // @api
24337
24346
  function createElementAccessExpression(expression, index) {
24338
24347
  var node = createBaseExpression(207 /* ElementAccessExpression */);
24339
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24348
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24340
24349
  node.argumentExpression = asExpression(index);
24341
24350
  node.transformFlags |=
24342
24351
  propagateChildFlags(node.expression) |
@@ -24364,7 +24373,7 @@ var ts;
24364
24373
  function createElementAccessChain(expression, questionDotToken, index) {
24365
24374
  var node = createBaseExpression(207 /* ElementAccessExpression */);
24366
24375
  node.flags |= 32 /* OptionalChain */;
24367
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24376
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24368
24377
  node.questionDotToken = questionDotToken;
24369
24378
  node.argumentExpression = asExpression(index);
24370
24379
  node.transformFlags |=
@@ -24388,7 +24397,7 @@ var ts;
24388
24397
  // @api
24389
24398
  function createCallExpression(expression, typeArguments, argumentsArray) {
24390
24399
  var node = createBaseExpression(208 /* CallExpression */);
24391
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24400
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24392
24401
  node.typeArguments = asNodeArray(typeArguments);
24393
24402
  node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
24394
24403
  node.transformFlags |=
@@ -24421,7 +24430,7 @@ var ts;
24421
24430
  function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
24422
24431
  var node = createBaseExpression(208 /* CallExpression */);
24423
24432
  node.flags |= 32 /* OptionalChain */;
24424
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24433
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24425
24434
  node.questionDotToken = questionDotToken;
24426
24435
  node.typeArguments = asNodeArray(typeArguments);
24427
24436
  node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
@@ -24476,7 +24485,7 @@ var ts;
24476
24485
  // @api
24477
24486
  function createTaggedTemplateExpression(tag, typeArguments, template) {
24478
24487
  var node = createBaseExpression(210 /* TaggedTemplateExpression */);
24479
- node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
24488
+ node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
24480
24489
  node.typeArguments = asNodeArray(typeArguments);
24481
24490
  node.template = template;
24482
24491
  node.transformFlags |=
@@ -24914,7 +24923,7 @@ var ts;
24914
24923
  // @api
24915
24924
  function createExpressionWithTypeArguments(expression, typeArguments) {
24916
24925
  var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
24917
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24926
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24918
24927
  node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
24919
24928
  node.transformFlags |=
24920
24929
  propagateChildFlags(node.expression) |
@@ -24950,7 +24959,7 @@ var ts;
24950
24959
  // @api
24951
24960
  function createNonNullExpression(expression) {
24952
24961
  var node = createBaseExpression(230 /* NonNullExpression */);
24953
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24962
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
24954
24963
  node.transformFlags |=
24955
24964
  propagateChildFlags(node.expression) |
24956
24965
  1 /* ContainsTypeScript */;
@@ -24969,7 +24978,7 @@ var ts;
24969
24978
  function createNonNullChain(expression) {
24970
24979
  var node = createBaseExpression(230 /* NonNullExpression */);
24971
24980
  node.flags |= 32 /* OptionalChain */;
24972
- node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
24981
+ node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
24973
24982
  node.transformFlags |=
24974
24983
  propagateChildFlags(node.expression) |
24975
24984
  1 /* ContainsTypeScript */;
@@ -27173,7 +27182,7 @@ var ts;
27173
27182
  }
27174
27183
  else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
27175
27184
  thisArg = createVoidZero();
27176
- target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
27185
+ target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
27177
27186
  }
27178
27187
  else if (ts.isPropertyAccessExpression(callee)) {
27179
27188
  if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
@@ -27202,7 +27211,7 @@ var ts;
27202
27211
  else {
27203
27212
  // for `a()` target is `a` and thisArg is `void 0`
27204
27213
  thisArg = createVoidZero();
27205
- target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
27214
+ target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
27206
27215
  }
27207
27216
  return { target: target, thisArg: thisArg };
27208
27217
  }
@@ -43644,15 +43653,15 @@ var ts;
43644
43653
  }
43645
43654
  ts.createModuleResolutionCache = createModuleResolutionCache;
43646
43655
  function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43647
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43656
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43648
43657
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43649
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43658
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43650
43659
  function clear() {
43651
43660
  clearAllExceptPackageJsonInfoCache();
43652
43661
  packageJsonInfoCache.clear();
43653
43662
  }
43654
43663
  function clearAllExceptPackageJsonInfoCache() {
43655
- preDirectoryResolutionCache.clear();
43664
+ perDirectoryResolutionCache.clear();
43656
43665
  }
43657
43666
  }
43658
43667
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
@@ -45997,6 +46006,9 @@ var ts;
45997
46006
  case 203 /* BindingElement */:
45998
46007
  bindBindingElementFlow(node);
45999
46008
  break;
46009
+ case 164 /* Parameter */:
46010
+ bindParameterFlow(node);
46011
+ break;
46000
46012
  case 205 /* ObjectLiteralExpression */:
46001
46013
  case 204 /* ArrayLiteralExpression */:
46002
46014
  case 296 /* PropertyAssignment */:
@@ -46737,20 +46749,38 @@ var ts;
46737
46749
  }
46738
46750
  }
46739
46751
  function bindBindingElementFlow(node) {
46740
- if (ts.isBindingPattern(node.name)) {
46741
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46742
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46743
- // - `BindingElement: BindingPattern Initializer?`
46744
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46745
- // - `BindingElement: BindingPattern Initializer?`
46746
- bind(node.dotDotDotToken);
46747
- bind(node.propertyName);
46748
- bind(node.initializer);
46749
- bind(node.name);
46752
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46753
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46754
+ // - `BindingElement: BindingPattern Initializer?`
46755
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46756
+ // - `BindingElement: BindingPattern Initializer?`
46757
+ bind(node.dotDotDotToken);
46758
+ bind(node.propertyName);
46759
+ bindInitializer(node.initializer);
46760
+ bind(node.name);
46761
+ }
46762
+ function bindParameterFlow(node) {
46763
+ bindEach(node.modifiers);
46764
+ bind(node.dotDotDotToken);
46765
+ bind(node.questionToken);
46766
+ bind(node.type);
46767
+ bindInitializer(node.initializer);
46768
+ bind(node.name);
46769
+ }
46770
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46771
+ function bindInitializer(node) {
46772
+ if (!node) {
46773
+ return;
46750
46774
  }
46751
- else {
46752
- bindEachChild(node);
46775
+ var entryFlow = currentFlow;
46776
+ bind(node);
46777
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46778
+ return;
46753
46779
  }
46780
+ var exitFlow = createBranchLabel();
46781
+ addAntecedent(exitFlow, entryFlow);
46782
+ addAntecedent(exitFlow, currentFlow);
46783
+ currentFlow = finishFlowLabel(exitFlow);
46754
46784
  }
46755
46785
  function bindJSDocTypeAlias(node) {
46756
46786
  bind(node.tagName);
@@ -49921,7 +49951,7 @@ var ts;
49921
49951
  if (unidirectional === void 0) { unidirectional = false; }
49922
49952
  source.forEach(function (sourceSymbol, id) {
49923
49953
  var targetSymbol = target.get(id);
49924
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49954
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49925
49955
  });
49926
49956
  }
49927
49957
  function mergeModuleAugmentation(moduleName) {
@@ -51441,10 +51471,6 @@ var ts;
51441
51471
  checkExpressionCached(expression);
51442
51472
  return getNodeLinks(expression).resolvedSymbol;
51443
51473
  }
51444
- function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
51445
- var expression = node.initializer;
51446
- return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
51447
- }
51448
51474
  function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
51449
51475
  if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
51450
51476
  return undefined;
@@ -51476,7 +51502,7 @@ var ts;
51476
51502
  case 297 /* ShorthandPropertyAssignment */:
51477
51503
  return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
51478
51504
  case 296 /* PropertyAssignment */:
51479
- return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
51505
+ return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
51480
51506
  case 207 /* ElementAccessExpression */:
51481
51507
  case 206 /* PropertyAccessExpression */:
51482
51508
  return getTargetOfAccessExpression(node, dontRecursivelyResolve);
@@ -51881,7 +51907,40 @@ var ts;
51881
51907
  // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
51882
51908
  // normal mode restrictions
51883
51909
  if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) {
51884
- 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);
51910
+ if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) {
51911
+ // ImportEquals in a ESM file resolving to another ESM file
51912
+ 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);
51913
+ }
51914
+ else {
51915
+ // CJS file resolving to an ESM file
51916
+ var diagnosticDetails = void 0;
51917
+ var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
51918
+ if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
51919
+ var scope = currentSourceFile.packageJsonScope;
51920
+ var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
51921
+ if (scope && !scope.packageJsonContent.type) {
51922
+ if (targetExt) {
51923
+ diagnosticDetails = ts.chainDiagnosticMessages(
51924
+ /*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"));
51925
+ }
51926
+ else {
51927
+ diagnosticDetails = ts.chainDiagnosticMessages(
51928
+ /*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"));
51929
+ }
51930
+ }
51931
+ else {
51932
+ if (targetExt) {
51933
+ diagnosticDetails = ts.chainDiagnosticMessages(
51934
+ /*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);
51935
+ }
51936
+ else {
51937
+ diagnosticDetails = ts.chainDiagnosticMessages(
51938
+ /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module);
51939
+ }
51940
+ }
51941
+ }
51942
+ 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)));
51943
+ }
51885
51944
  }
51886
51945
  }
51887
51946
  // merged symbol is module declaration symbol combined with all augmentations
@@ -56683,11 +56742,9 @@ var ts;
56683
56742
  return getReturnTypeOfSignature(getterSignature);
56684
56743
  }
56685
56744
  }
56686
- if (ts.isInJSFile(declaration)) {
56687
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56688
- if (type_1)
56689
- return type_1;
56690
- }
56745
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56746
+ if (parameterTypeOfTypeTag)
56747
+ return parameterTypeOfTypeTag;
56691
56748
  // Use contextual parameter type if one is available
56692
56749
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56693
56750
  if (type) {
@@ -57001,7 +57058,7 @@ var ts;
57001
57058
  (resolvedSymbol || symbol).exports.forEach(function (s, name) {
57002
57059
  var _a;
57003
57060
  var exportedMember = members_4.get(name);
57004
- if (exportedMember && exportedMember !== s) {
57061
+ if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
57005
57062
  if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
57006
57063
  // If the member has an additional value-like declaration, union the types from the two declarations,
57007
57064
  // but issue an error if they occurred in two different files. The purpose is to support a JS file with
@@ -57263,9 +57320,9 @@ var ts;
57263
57320
  if (typeNode === undefined) {
57264
57321
  return useUnknownInCatchVariables ? unknownType : anyType;
57265
57322
  }
57266
- var type_2 = getTypeOfNode(typeNode);
57323
+ var type_1 = getTypeOfNode(typeNode);
57267
57324
  // an errorType will make `checkTryStatement` issue an error
57268
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57325
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57269
57326
  }
57270
57327
  // Handle export default expressions
57271
57328
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57475,11 +57532,11 @@ var ts;
57475
57532
  return errorType;
57476
57533
  }
57477
57534
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57478
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57535
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57479
57536
  if (!popTypeResolution()) {
57480
57537
  return reportCircularityError(symbol);
57481
57538
  }
57482
- return type_3;
57539
+ return type_2;
57483
57540
  }
57484
57541
  }
57485
57542
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59702,10 +59759,10 @@ var ts;
59702
59759
  var baseTypes = [];
59703
59760
  var different = false;
59704
59761
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59705
- var type_4 = types_7[_i];
59706
- var baseType = getBaseConstraint(type_4);
59762
+ var type_3 = types_7[_i];
59763
+ var baseType = getBaseConstraint(type_3);
59707
59764
  if (baseType) {
59708
- if (baseType !== type_4) {
59765
+ if (baseType !== type_3) {
59709
59766
  different = true;
59710
59767
  }
59711
59768
  baseTypes.push(baseType);
@@ -60496,7 +60553,12 @@ var ts;
60496
60553
  continue;
60497
60554
  }
60498
60555
  }
60499
- result.push(getSignatureFromDeclaration(decl));
60556
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60557
+ // 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.
60558
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60559
+ !ts.isObjectLiteralMethod(decl) &&
60560
+ getSignatureOfTypeTag(decl)) ||
60561
+ getSignatureFromDeclaration(decl));
60500
60562
  }
60501
60563
  return result;
60502
60564
  }
@@ -60527,7 +60589,7 @@ var ts;
60527
60589
  else {
60528
60590
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60529
60591
  var jsdocPredicate = void 0;
60530
- if (!type && ts.isInJSFile(signature.declaration)) {
60592
+ if (!type) {
60531
60593
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60532
60594
  if (jsdocSignature && signature !== jsdocSignature) {
60533
60595
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -63493,6 +63555,7 @@ var ts;
63493
63555
  }
63494
63556
  }
63495
63557
  function getTypeFromImportTypeNode(node) {
63558
+ var _a;
63496
63559
  var links = getNodeLinks(node);
63497
63560
  if (!links.resolvedType) {
63498
63561
  if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
@@ -63512,6 +63575,7 @@ var ts;
63512
63575
  links.resolvedSymbol = unknownSymbol;
63513
63576
  return links.resolvedType = errorType;
63514
63577
  }
63578
+ var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
63515
63579
  var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
63516
63580
  if (!ts.nodeIsMissing(node.qualifier)) {
63517
63581
  var nameStack = getIdentifierChain(node.qualifier);
@@ -63523,9 +63587,11 @@ var ts;
63523
63587
  // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
63524
63588
  // the `exports` lookup process that only looks up namespace members which is used for most type references
63525
63589
  var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
63526
- var next = node.isTypeOf
63590
+ var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
63527
63591
  ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
63528
- : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
63592
+ : undefined;
63593
+ var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
63594
+ var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
63529
63595
  if (!next) {
63530
63596
  error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
63531
63597
  return links.resolvedType = errorType;
@@ -64549,15 +64615,14 @@ var ts;
64549
64615
  return false;
64550
64616
  }
64551
64617
  function isContextSensitiveFunctionLikeDeclaration(node) {
64552
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64553
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64618
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64554
64619
  }
64555
64620
  function hasContextSensitiveReturnExpression(node) {
64556
64621
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64557
64622
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64558
64623
  }
64559
64624
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64560
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64625
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64561
64626
  isContextSensitiveFunctionLikeDeclaration(func);
64562
64627
  }
64563
64628
  function getTypeWithoutSignatures(type) {
@@ -66383,6 +66448,26 @@ var ts;
66383
66448
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66384
66449
  var saveErrorInfo = captureErrorCalculationState();
66385
66450
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66451
+ if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
66452
+ // The combined constraint of an intersection type is the intersection of the constraints of
66453
+ // the constituents. When an intersection type contains instantiable types with union type
66454
+ // constraints, there are situations where we need to examine the combined constraint. One is
66455
+ // when the target is a union type. Another is when the intersection contains types belonging
66456
+ // to one of the disjoint domains. For example, given type variables T and U, each with the
66457
+ // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
66458
+ // we need to check this constraint against a union on the target side. Also, given a type
66459
+ // variable V constrained to 'string | number', 'V & number' has a combined constraint of
66460
+ // 'string & number | number & number' which reduces to just 'number'.
66461
+ // This also handles type parameters, as a type parameter with a union constraint compared against a union
66462
+ // needs to have its constraint hoisted into an intersection with said type parameter, this way
66463
+ // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66464
+ // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66465
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
66466
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66467
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66468
+ result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
66469
+ }
66470
+ }
66386
66471
  if (result) {
66387
66472
  resetErrorInfo(saveErrorInfo);
66388
66473
  }
@@ -66440,28 +66525,6 @@ var ts;
66440
66525
  if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
66441
66526
  return result;
66442
66527
  }
66443
- if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
66444
- // The combined constraint of an intersection type is the intersection of the constraints of
66445
- // the constituents. When an intersection type contains instantiable types with union type
66446
- // constraints, there are situations where we need to examine the combined constraint. One is
66447
- // when the target is a union type. Another is when the intersection contains types belonging
66448
- // to one of the disjoint domains. For example, given type variables T and U, each with the
66449
- // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
66450
- // we need to check this constraint against a union on the target side. Also, given a type
66451
- // variable V constrained to 'string | number', 'V & number' has a combined constraint of
66452
- // 'string & number | number & number' which reduces to just 'number'.
66453
- // This also handles type parameters, as a type parameter with a union constraint compared against a union
66454
- // needs to have its constraint hoisted into an intersection with said type parameter, this way
66455
- // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66456
- // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66457
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
66458
- if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66459
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66460
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66461
- return result;
66462
- }
66463
- }
66464
- }
66465
66528
  // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
66466
66529
  // Source is instantiable (e.g. source has union or intersection constraint).
66467
66530
  // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
@@ -73387,12 +73450,15 @@ var ts;
73387
73450
  if (contextualReturnType) {
73388
73451
  var functionFlags = ts.getFunctionFlags(func);
73389
73452
  if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
73390
- var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
73391
- var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined);
73392
- if (!iterationTypes) {
73453
+ var isAsyncGenerator_1 = (functionFlags & 2 /* Async */) !== 0;
73454
+ if (contextualReturnType.flags & 1048576 /* Union */) {
73455
+ contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_1); });
73456
+ }
73457
+ var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
73458
+ if (!iterationReturnType) {
73393
73459
  return undefined;
73394
73460
  }
73395
- contextualReturnType = iterationTypes.returnType;
73461
+ contextualReturnType = iterationReturnType;
73396
73462
  // falls through to unwrap Promise for AsyncGenerators
73397
73463
  }
73398
73464
  if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function
@@ -73419,9 +73485,13 @@ var ts;
73419
73485
  var functionFlags = ts.getFunctionFlags(func);
73420
73486
  var contextualReturnType = getContextualReturnType(func, contextFlags);
73421
73487
  if (contextualReturnType) {
73488
+ var isAsyncGenerator_2 = (functionFlags & 2 /* Async */) !== 0;
73489
+ if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* Union */) {
73490
+ contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_2); });
73491
+ }
73422
73492
  return node.asteriskToken
73423
73493
  ? contextualReturnType
73424
- : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
73494
+ : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator_2);
73425
73495
  }
73426
73496
  }
73427
73497
  return undefined;
@@ -74597,16 +74667,30 @@ var ts;
74597
74667
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74598
74668
  // type with those properties for which the binding pattern specifies a default value.
74599
74669
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74600
- // literal handle it instead.
74601
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74602
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74603
- var prop = _e[_d];
74604
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74605
- if (!(prop.flags & 16777216 /* Optional */)) {
74606
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74670
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74671
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74672
+ // It's not possible to check if the immediate parent node is a spread assignment
74673
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74674
+ if (contextualTypeHasPattern) {
74675
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74676
+ return n.kind === 254 /* VariableDeclaration */ ||
74677
+ n.kind === 221 /* BinaryExpression */ ||
74678
+ n.kind === 164 /* Parameter */;
74679
+ });
74680
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74681
+ return n === rootPatternParent_1 ||
74682
+ n.kind === 298 /* SpreadAssignment */;
74683
+ });
74684
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74685
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74686
+ var prop = _e[_d];
74687
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74688
+ if (!(prop.flags & 16777216 /* Optional */)) {
74689
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74690
+ }
74691
+ propertiesTable.set(prop.escapedName, prop);
74692
+ propertiesArray.push(prop);
74607
74693
  }
74608
- propertiesTable.set(prop.escapedName, prop);
74609
- propertiesArray.push(prop);
74610
74694
  }
74611
74695
  }
74612
74696
  }
@@ -78158,8 +78242,8 @@ var ts;
78158
78242
  if (hasDefaultOnly && type && !isErrorType(type)) {
78159
78243
  var synthType = type;
78160
78244
  if (!synthType.defaultOnlyType) {
78161
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78162
- synthType.defaultOnlyType = type_5;
78245
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78246
+ synthType.defaultOnlyType = type_4;
78163
78247
  }
78164
78248
  return synthType.defaultOnlyType;
78165
78249
  }
@@ -82315,9 +82399,11 @@ var ts;
82315
82399
  // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82316
82400
  if (isGenericObjectType(type)) {
82317
82401
  var baseConstraint = getBaseConstraintOfType(type);
82318
- // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82402
+ // 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`,
82319
82403
  // or is promise-like.
82320
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82404
+ if (baseConstraint ?
82405
+ baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
82406
+ maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
82321
82407
  return true;
82322
82408
  }
82323
82409
  }
@@ -84194,17 +84280,28 @@ var ts;
84194
84280
  * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
84195
84281
  */
84196
84282
  function getIterationTypesOfIterable(type, use, errorNode) {
84283
+ var _a, _b;
84197
84284
  if (isTypeAny(type)) {
84198
84285
  return anyIterationTypes;
84199
84286
  }
84200
84287
  if (!(type.flags & 1048576 /* Union */)) {
84201
- var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
84288
+ var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
84289
+ var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
84202
84290
  if (iterationTypes_1 === noIterationTypes) {
84203
84291
  if (errorNode) {
84204
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84292
+ var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84293
+ if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
84294
+ ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
84295
+ }
84205
84296
  }
84206
84297
  return undefined;
84207
84298
  }
84299
+ else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
84300
+ for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
84301
+ var diag = _c[_i];
84302
+ diagnostics.add(diag);
84303
+ }
84304
+ }
84208
84305
  return iterationTypes_1;
84209
84306
  }
84210
84307
  var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
@@ -84212,19 +84309,27 @@ var ts;
84212
84309
  if (cachedTypes)
84213
84310
  return cachedTypes === noIterationTypes ? undefined : cachedTypes;
84214
84311
  var allIterationTypes;
84215
- for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
84216
- var constituent = _a[_i];
84217
- var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
84312
+ for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
84313
+ var constituent = _e[_d];
84314
+ var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
84315
+ var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
84218
84316
  if (iterationTypes_2 === noIterationTypes) {
84219
84317
  if (errorNode) {
84220
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84318
+ var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
84319
+ if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
84320
+ ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
84321
+ }
84221
84322
  }
84222
84323
  setCachedIterationTypes(type, cacheKey, noIterationTypes);
84223
84324
  return undefined;
84224
84325
  }
84225
- else {
84226
- allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
84326
+ else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
84327
+ for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
84328
+ var diag = _g[_f];
84329
+ diagnostics.add(diag);
84330
+ }
84227
84331
  }
84332
+ allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
84228
84333
  }
84229
84334
  var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
84230
84335
  setCachedIterationTypes(type, cacheKey, iterationTypes);
@@ -84252,47 +84357,62 @@ var ts;
84252
84357
  * NOTE: You probably don't want to call this directly and should be calling
84253
84358
  * `getIterationTypesOfIterable` instead.
84254
84359
  */
84255
- function getIterationTypesOfIterableWorker(type, use, errorNode) {
84360
+ function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
84256
84361
  if (isTypeAny(type)) {
84257
84362
  return anyIterationTypes;
84258
84363
  }
84364
+ // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
84365
+ // In addition, we should not cache any new results for this call.
84366
+ var noCache = false;
84259
84367
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84260
84368
  var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
84261
84369
  getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
84262
84370
  if (iterationTypes) {
84263
- return use & 8 /* ForOfFlag */ ?
84264
- getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
84265
- iterationTypes;
84371
+ if (iterationTypes === noIterationTypes && errorNode) {
84372
+ // ignore the cached value
84373
+ noCache = true;
84374
+ }
84375
+ else {
84376
+ return use & 8 /* ForOfFlag */ ?
84377
+ getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
84378
+ iterationTypes;
84379
+ }
84266
84380
  }
84267
84381
  }
84268
84382
  if (use & 1 /* AllowsSyncIterablesFlag */) {
84269
84383
  var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
84270
84384
  getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
84271
84385
  if (iterationTypes) {
84272
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
84273
- // for a sync iterable in an async context, only use the cached types if they are valid.
84274
- if (iterationTypes !== noIterationTypes) {
84275
- return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
84276
- }
84386
+ if (iterationTypes === noIterationTypes && errorNode) {
84387
+ // ignore the cached value
84388
+ noCache = true;
84277
84389
  }
84278
84390
  else {
84279
- return iterationTypes;
84391
+ if (use & 2 /* AllowsAsyncIterablesFlag */) {
84392
+ // for a sync iterable in an async context, only use the cached types if they are valid.
84393
+ if (iterationTypes !== noIterationTypes) {
84394
+ iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
84395
+ return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
84396
+ }
84397
+ }
84398
+ else {
84399
+ return iterationTypes;
84400
+ }
84280
84401
  }
84281
84402
  }
84282
84403
  }
84283
84404
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84284
- var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
84405
+ var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
84285
84406
  if (iterationTypes !== noIterationTypes) {
84286
84407
  return iterationTypes;
84287
84408
  }
84288
84409
  }
84289
84410
  if (use & 1 /* AllowsSyncIterablesFlag */) {
84290
- var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
84411
+ var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
84291
84412
  if (iterationTypes !== noIterationTypes) {
84292
84413
  if (use & 2 /* AllowsAsyncIterablesFlag */) {
84293
- return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
84294
- ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
84295
- : noIterationTypes);
84414
+ iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
84415
+ return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
84296
84416
  }
84297
84417
  else {
84298
84418
  return iterationTypes;
@@ -84313,7 +84433,7 @@ var ts;
84313
84433
  }
84314
84434
  function getIterationTypesOfGlobalIterableType(globalType, resolver) {
84315
84435
  var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
84316
- getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
84436
+ getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
84317
84437
  return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
84318
84438
  }
84319
84439
  /**
@@ -84367,40 +84487,56 @@ var ts;
84367
84487
  * NOTE: You probably don't want to call this directly and should be calling
84368
84488
  * `getIterationTypesOfIterable` instead.
84369
84489
  */
84370
- function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
84490
+ function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
84371
84491
  var _a;
84372
84492
  var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
84373
84493
  var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
84374
84494
  if (isTypeAny(methodType)) {
84375
- return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
84495
+ return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
84376
84496
  }
84377
84497
  var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
84378
84498
  if (!ts.some(signatures)) {
84379
- return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
84499
+ return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
84380
84500
  }
84381
84501
  var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
84382
- var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
84383
- return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
84502
+ var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
84503
+ return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
84384
84504
  }
84385
84505
  function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
84386
84506
  var message = allowAsyncIterables
84387
84507
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84388
84508
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84389
- errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
84509
+ return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
84510
+ }
84511
+ /**
84512
+ * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
84513
+ *
84514
+ * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84515
+ * record is returned. Otherwise, `undefined` is returned.
84516
+ */
84517
+ function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
84518
+ return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
84390
84519
  }
84391
84520
  /**
84392
84521
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
84393
84522
  *
84394
84523
  * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84395
84524
  * record is returned. Otherwise, `undefined` is returned.
84525
+ *
84526
+ * NOTE: You probably don't want to call this directly and should be calling
84527
+ * `getIterationTypesOfIterator` instead.
84396
84528
  */
84397
- function getIterationTypesOfIterator(type, resolver, errorNode) {
84529
+ function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
84398
84530
  if (isTypeAny(type)) {
84399
84531
  return anyIterationTypes;
84400
84532
  }
84401
84533
  var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
84402
- getIterationTypesOfIteratorFast(type, resolver) ||
84403
- getIterationTypesOfIteratorSlow(type, resolver, errorNode);
84534
+ getIterationTypesOfIteratorFast(type, resolver);
84535
+ if (iterationTypes === noIterationTypes && errorNode) {
84536
+ iterationTypes = undefined;
84537
+ noCache = true;
84538
+ }
84539
+ iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
84404
84540
  return iterationTypes === noIterationTypes ? undefined : iterationTypes;
84405
84541
  }
84406
84542
  /**
@@ -84438,7 +84574,7 @@ var ts;
84438
84574
  // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
84439
84575
  // and `undefined` in our libs by default, a custom lib *could* use different definitions.
84440
84576
  var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
84441
- getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
84577
+ getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
84442
84578
  var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
84443
84579
  return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
84444
84580
  }
@@ -84508,8 +84644,8 @@ var ts;
84508
84644
  * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
84509
84645
  * record is returned. Otherwise, we return `undefined`.
84510
84646
  */
84511
- function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
84512
- var _a, _b, _c, _d;
84647
+ function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
84648
+ var _a, _b, _c, _d, _e, _f;
84513
84649
  var method = getPropertyOfType(type, methodName);
84514
84650
  // Ignore 'return' or 'throw' if they are missing.
84515
84651
  if (!method && methodName !== "next") {
@@ -84529,9 +84665,15 @@ var ts;
84529
84665
  var diagnostic = methodName === "next"
84530
84666
  ? resolver.mustHaveANextMethodDiagnostic
84531
84667
  : resolver.mustBeAMethodDiagnostic;
84532
- error(errorNode, diagnostic, methodName);
84668
+ if (errorOutputContainer) {
84669
+ (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
84670
+ errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
84671
+ }
84672
+ else {
84673
+ error(errorNode, diagnostic, methodName);
84674
+ }
84533
84675
  }
84534
- return methodName === "next" ? anyIterationTypes : undefined;
84676
+ return methodName === "next" ? noIterationTypes : undefined;
84535
84677
  }
84536
84678
  // If the method signature comes exclusively from the global iterator or generator type,
84537
84679
  // create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
@@ -84543,8 +84685,8 @@ var ts;
84543
84685
  if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
84544
84686
  var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
84545
84687
  var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
84546
- 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;
84547
- 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;
84688
+ 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;
84689
+ 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;
84548
84690
  if (isGeneratorMethod || isIteratorMethod) {
84549
84691
  var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
84550
84692
  var mapper = methodType.mapper;
@@ -84584,7 +84726,13 @@ var ts;
84584
84726
  var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
84585
84727
  if (iterationTypes === noIterationTypes) {
84586
84728
  if (errorNode) {
84587
- error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
84729
+ if (errorOutputContainer) {
84730
+ (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
84731
+ errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
84732
+ }
84733
+ else {
84734
+ error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
84735
+ }
84588
84736
  }
84589
84737
  yieldType = anyType;
84590
84738
  returnTypes = ts.append(returnTypes, anyType);
@@ -84605,13 +84753,13 @@ var ts;
84605
84753
  * NOTE: You probably don't want to call this directly and should be calling
84606
84754
  * `getIterationTypesOfIterator` instead.
84607
84755
  */
84608
- function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
84756
+ function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
84609
84757
  var iterationTypes = combineIterationTypes([
84610
- getIterationTypesOfMethod(type, resolver, "next", errorNode),
84611
- getIterationTypesOfMethod(type, resolver, "return", errorNode),
84612
- getIterationTypesOfMethod(type, resolver, "throw", errorNode),
84758
+ getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
84759
+ getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
84760
+ getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
84613
84761
  ]);
84614
- return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
84762
+ return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
84615
84763
  }
84616
84764
  /**
84617
84765
  * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
@@ -84632,7 +84780,7 @@ var ts;
84632
84780
  var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
84633
84781
  var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
84634
84782
  return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
84635
- getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
84783
+ getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
84636
84784
  }
84637
84785
  function checkBreakOrContinueStatement(node) {
84638
84786
  // Grammar checking
@@ -87432,6 +87580,12 @@ var ts;
87432
87580
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87433
87581
  }
87434
87582
  }
87583
+ if (result && isJSDoc_1) {
87584
+ var container = ts.getJSDocHost(name);
87585
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87586
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87587
+ }
87588
+ }
87435
87589
  return result;
87436
87590
  }
87437
87591
  else if (ts.isPrivateIdentifier(name)) {
@@ -95089,10 +95243,11 @@ var ts;
95089
95243
  }
95090
95244
  function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
95091
95245
  if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
95092
- if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
95246
+ var operand = ts.skipParentheses(node.operand);
95247
+ if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
95093
95248
  var info = void 0;
95094
- if (info = accessPrivateIdentifier(node.operand.name)) {
95095
- var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
95249
+ if (info = accessPrivateIdentifier(operand.name)) {
95250
+ var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
95096
95251
  var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
95097
95252
  var expression = createPrivateIdentifierAccess(info, readExpression);
95098
95253
  var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
@@ -95108,7 +95263,7 @@ var ts;
95108
95263
  }
95109
95264
  }
95110
95265
  else if (shouldTransformSuperInStaticInitializers &&
95111
- ts.isSuperProperty(node.operand) &&
95266
+ ts.isSuperProperty(operand) &&
95112
95267
  currentStaticPropertyDeclarationOrStaticBlock &&
95113
95268
  currentClassLexicalEnvironment) {
95114
95269
  // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
@@ -95121,31 +95276,31 @@ var ts;
95121
95276
  // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
95122
95277
  var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
95123
95278
  if (facts & 1 /* ClassWasDecorated */) {
95124
- var operand = visitInvalidSuperProperty(node.operand);
95279
+ var expression = visitInvalidSuperProperty(operand);
95125
95280
  return ts.isPrefixUnaryExpression(node) ?
95126
- factory.updatePrefixUnaryExpression(node, operand) :
95127
- factory.updatePostfixUnaryExpression(node, operand);
95281
+ factory.updatePrefixUnaryExpression(node, expression) :
95282
+ factory.updatePostfixUnaryExpression(node, expression);
95128
95283
  }
95129
95284
  if (classConstructor && superClassReference) {
95130
95285
  var setterName = void 0;
95131
95286
  var getterName = void 0;
95132
- if (ts.isPropertyAccessExpression(node.operand)) {
95133
- if (ts.isIdentifier(node.operand.name)) {
95134
- getterName = setterName = factory.createStringLiteralFromNode(node.operand.name);
95287
+ if (ts.isPropertyAccessExpression(operand)) {
95288
+ if (ts.isIdentifier(operand.name)) {
95289
+ getterName = setterName = factory.createStringLiteralFromNode(operand.name);
95135
95290
  }
95136
95291
  }
95137
95292
  else {
95138
- if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) {
95139
- getterName = setterName = node.operand.argumentExpression;
95293
+ if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
95294
+ getterName = setterName = operand.argumentExpression;
95140
95295
  }
95141
95296
  else {
95142
95297
  getterName = factory.createTempVariable(hoistVariableDeclaration);
95143
- setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression));
95298
+ setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
95144
95299
  }
95145
95300
  }
95146
95301
  if (setterName && getterName) {
95147
95302
  var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
95148
- ts.setTextRange(expression, node.operand);
95303
+ ts.setTextRange(expression, operand);
95149
95304
  var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
95150
95305
  expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
95151
95306
  expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
@@ -107592,6 +107747,13 @@ var ts;
107592
107747
  ts.Debug.assert(importVariableName !== undefined);
107593
107748
  // save import into the local
107594
107749
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107750
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107751
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107752
+ /*typeArguments*/ undefined, [
107753
+ factory.createStringLiteral(ts.idText(importVariableName)),
107754
+ parameterName,
107755
+ ])));
107756
+ }
107595
107757
  break;
107596
107758
  case 272 /* ExportDeclaration */:
107597
107759
  ts.Debug.assert(importVariableName !== undefined);
@@ -110434,8 +110596,12 @@ var ts;
110434
110596
  }
110435
110597
  var previousNeedsDeclare = needsDeclare;
110436
110598
  switch (input.kind) {
110437
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110438
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110599
+ case 259 /* TypeAliasDeclaration */: {
110600
+ needsDeclare = false;
110601
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110602
+ needsDeclare = previousNeedsDeclare;
110603
+ return clean;
110604
+ }
110439
110605
  case 258 /* InterfaceDeclaration */: {
110440
110606
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110441
110607
  }
@@ -116686,7 +116852,16 @@ var ts;
116686
116852
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116687
116853
  }
116688
116854
  function getCachedFileSystemEntriesForBaseDir(path) {
116689
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116855
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116856
+ if (!entries) {
116857
+ return entries;
116858
+ }
116859
+ // If we're looking for the base directory, we're definitely going to search the entries
116860
+ if (!entries.sortedAndCanonicalizedFiles) {
116861
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116862
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116863
+ }
116864
+ return entries;
116690
116865
  }
116691
116866
  function getBaseNameOfFileName(fileName) {
116692
116867
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116729,21 +116904,10 @@ var ts;
116729
116904
  return undefined;
116730
116905
  }
116731
116906
  }
116732
- function fileNameEqual(name1, name2) {
116733
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116734
- }
116735
116907
  function hasEntry(entries, name) {
116736
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116737
- }
116738
- function updateFileSystemEntry(entries, baseName, isValid) {
116739
- if (hasEntry(entries, baseName)) {
116740
- if (!isValid) {
116741
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116742
- }
116743
- }
116744
- else if (isValid) {
116745
- return entries.push(baseName);
116746
- }
116908
+ // Case-sensitive comparison since already canonicalized
116909
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116910
+ return index >= 0;
116747
116911
  }
116748
116912
  function writeFile(fileName, data, writeByteOrderMark) {
116749
116913
  var path = toPath(fileName);
@@ -116756,7 +116920,7 @@ var ts;
116756
116920
  function fileExists(fileName) {
116757
116921
  var path = toPath(fileName);
116758
116922
  var result = getCachedFileSystemEntriesForBaseDir(path);
116759
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116923
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116760
116924
  host.fileExists(fileName);
116761
116925
  }
116762
116926
  function directoryExists(dirPath) {
@@ -116766,9 +116930,14 @@ var ts;
116766
116930
  function createDirectory(dirPath) {
116767
116931
  var path = toPath(dirPath);
116768
116932
  var result = getCachedFileSystemEntriesForBaseDir(path);
116769
- var baseFileName = getBaseNameOfFileName(dirPath);
116770
116933
  if (result) {
116771
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116934
+ var baseName = getBaseNameOfFileName(dirPath);
116935
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116936
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116937
+ // Case-sensitive comparison since already canonicalized
116938
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116939
+ result.directories.push(baseName);
116940
+ }
116772
116941
  }
116773
116942
  host.createDirectory(dirPath);
116774
116943
  }
@@ -116837,7 +117006,7 @@ var ts;
116837
117006
  fileExists: host.fileExists(fileOrDirectoryPath),
116838
117007
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116839
117008
  };
116840
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
117009
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116841
117010
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116842
117011
  clearCache();
116843
117012
  }
@@ -116857,7 +117026,23 @@ var ts;
116857
117026
  }
116858
117027
  }
116859
117028
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116860
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
117029
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
117030
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
117031
+ if (fileExists) {
117032
+ // Case-sensitive comparison since already canonicalized
117033
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
117034
+ parentResult.files.push(baseName);
117035
+ }
117036
+ }
117037
+ else {
117038
+ // Case-sensitive comparison since already canonicalized
117039
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
117040
+ if (sortedIndex >= 0) {
117041
+ canonicalizedFiles.splice(sortedIndex, 1);
117042
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
117043
+ parentResult.files.splice(unsortedIndex, 1);
117044
+ }
117045
+ }
116861
117046
  }
116862
117047
  function clearCache() {
116863
117048
  cachedReadDirectoryResult.clear();
@@ -119615,14 +119800,16 @@ var ts;
119615
119800
  addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
119616
119801
  }
119617
119802
  }
119618
- function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
119803
+ function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
119804
+ var _a;
119619
119805
  var redirect = Object.create(redirectTarget);
119620
119806
  redirect.fileName = fileName;
119621
119807
  redirect.path = path;
119622
119808
  redirect.resolvedPath = resolvedPath;
119623
119809
  redirect.originalFileName = originalFileName;
119624
119810
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
119625
- // TODO:" shkamat"
119811
+ redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
119812
+ redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
119626
119813
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
119627
119814
  Object.defineProperties(redirect, {
119628
119815
  id: {
@@ -119753,7 +119940,7 @@ var ts;
119753
119940
  if (fileFromPackageId) {
119754
119941
  // Some other SourceFile already exists with this package name and version.
119755
119942
  // Instead of creating a duplicate, just redirect to the existing one.
119756
- var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217
119943
+ var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
119757
119944
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
119758
119945
  addFileToFilesByName(dupFile, path, redirectedPath);
119759
119946
  addFileIncludeReason(dupFile, reason);
@@ -119776,7 +119963,6 @@ var ts;
119776
119963
  file.originalFileName = originalFileName;
119777
119964
  file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
119778
119965
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
119779
- // TODO: handle watch when same file has changes in failed and affecting locations
119780
119966
  addFileIncludeReason(file, reason);
119781
119967
  if (host.useCaseSensitiveFileNames()) {
119782
119968
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -122838,7 +123024,6 @@ var ts;
122838
123024
  resolvedModuleNames.clear();
122839
123025
  resolvedTypeReferenceDirectives.clear();
122840
123026
  resolvedFileToResolution.clear();
122841
- nonRelativeExternalModuleResolutions.clear();
122842
123027
  resolutionsWithFailedLookups.length = 0;
122843
123028
  resolutionsWithOnlyAffectingLocations.length = 0;
122844
123029
  failedLookupChecks = undefined;
@@ -122846,8 +123031,6 @@ var ts;
122846
123031
  isInDirectoryChecks = undefined;
122847
123032
  affectingPathChecks = undefined;
122848
123033
  affectingPathChecksForFile = undefined;
122849
- // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122850
- // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122851
123034
  moduleResolutionCache.clear();
122852
123035
  typeReferenceDirectiveResolutionCache.clear();
122853
123036
  impliedFormatPackageJsons.clear();
@@ -122885,6 +123068,10 @@ var ts;
122885
123068
  function startCachingPerDirectoryResolution() {
122886
123069
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
122887
123070
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
123071
+ // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
123072
+ // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
123073
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
123074
+ nonRelativeExternalModuleResolutions.clear();
122888
123075
  }
122889
123076
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122890
123077
  filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
@@ -122926,8 +123113,6 @@ var ts;
122926
123113
  if (watcher.files === 0 && watcher.resolutions === 0) {
122927
123114
  fileWatchesOfAffectingLocations.delete(path);
122928
123115
  watcher.watcher.close();
122929
- // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122930
- watcher.watcher = ts.noopFileWatcher;
122931
123116
  }
122932
123117
  });
122933
123118
  hasChangedAutomaticTypeDirectiveNames = false;
@@ -123273,20 +123458,27 @@ var ts;
123273
123458
  }
123274
123459
  var paths = new ts.Set();
123275
123460
  paths.add(locationToWatch);
123461
+ var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123462
+ resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123463
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123464
+ var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
123465
+ paths.forEach(function (path) {
123466
+ if (watcher.resolutions)
123467
+ (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123468
+ if (watcher.files)
123469
+ (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123470
+ packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
123471
+ });
123472
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123473
+ }) : ts.noopFileWatcher;
123276
123474
  var watcher = {
123277
- watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123278
- resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123279
- cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123280
- paths.forEach(function (path) {
123281
- var _a;
123282
- if (watcher.resolutions)
123283
- (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123284
- if (watcher.files)
123285
- (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123286
- (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
123287
- });
123288
- resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123289
- }) : ts.noopFileWatcher,
123475
+ watcher: actualWatcher !== ts.noopFileWatcher ? {
123476
+ close: function () {
123477
+ actualWatcher.close();
123478
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
123479
+ actualWatcher = ts.noopFileWatcher;
123480
+ }
123481
+ } : actualWatcher,
123290
123482
  resolutions: forResolution ? 1 : 0,
123291
123483
  files: forResolution ? 0 : 1,
123292
123484
  paths: paths,
@@ -123700,7 +123892,7 @@ var ts;
123700
123892
  var info = getInfo(importingSourceFileName, host);
123701
123893
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
123702
123894
  return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
123703
- getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
123895
+ getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
123704
123896
  }
123705
123897
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
123706
123898
  if (options === void 0) { options = {}; }
@@ -123783,7 +123975,7 @@ var ts;
123783
123975
  return nodeModulesSpecifiers;
123784
123976
  }
123785
123977
  if (!specifier && !modulePath.isRedirect) {
123786
- var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
123978
+ var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
123787
123979
  if (ts.pathIsBareSpecifier(local)) {
123788
123980
  pathsSpecifiers = ts.append(pathsSpecifiers, local);
123789
123981
  }
@@ -123811,7 +124003,7 @@ var ts;
123811
124003
  var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
123812
124004
  return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
123813
124005
  }
123814
- function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
124006
+ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
123815
124007
  var ending = _a.ending, relativePreference = _a.relativePreference;
123816
124008
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
123817
124009
  var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
@@ -123825,9 +124017,8 @@ var ts;
123825
124017
  if (!relativeToBaseUrl) {
123826
124018
  return relativePath;
123827
124019
  }
123828
- var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
123829
- var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
123830
- var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
124020
+ var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
124021
+ var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
123831
124022
  if (!nonRelative) {
123832
124023
  return relativePath;
123833
124024
  }
@@ -124062,28 +124253,102 @@ var ts;
124062
124253
  return ambientModuleDeclare.name.text;
124063
124254
  }
124064
124255
  }
124065
- function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
124256
+ function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
124257
+ if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
124258
+ return [2 /* JsExtension */];
124259
+ }
124260
+ switch (preferredEnding) {
124261
+ case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
124262
+ case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
124263
+ case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
124264
+ default: ts.Debug.assertNever(preferredEnding);
124265
+ }
124266
+ }
124267
+ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
124066
124268
  for (var key in paths) {
124067
- for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
124068
- var patternText_1 = _a[_i];
124069
- var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
124269
+ var _loop_36 = function (patternText_1) {
124270
+ var pattern = ts.normalizePath(patternText_1);
124070
124271
  var indexOfStar = pattern.indexOf("*");
124272
+ // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
124273
+ // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
124274
+ // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
124275
+ // and matches the '*'. For example:
124276
+ //
124277
+ // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
124278
+ // ---------------------->------------------------------->--------------------->---------------------------------------------------------------
124279
+ // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
124280
+ // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
124281
+ //
124282
+ // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
124283
+ //
124284
+ // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
124285
+ // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
124286
+ // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
124287
+ // extension for a module specifier.)
124288
+ //
124289
+ // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
124290
+ // .ts extension) or the possible relative module specifiers representing that file:
124291
+ //
124292
+ // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
124293
+ // --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
124294
+ // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
124295
+ // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
124296
+ // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
124297
+ // 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
124298
+ // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
124299
+ //
124300
+ // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
124301
+ // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
124302
+ // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
124303
+ // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
124304
+ // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
124305
+ // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
124306
+ // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
124307
+ // sorted among the others for a particular value of `importModuleSpecifierEnding`.
124308
+ var candidates = allowedEndings.map(function (ending) { return ({
124309
+ ending: ending,
124310
+ value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
124311
+ }); });
124312
+ if (ts.tryGetExtensionFromPath(pattern)) {
124313
+ candidates.push({ ending: undefined, value: relativeToBaseUrl });
124314
+ }
124071
124315
  if (indexOfStar !== -1) {
124072
- var prefix = pattern.substr(0, indexOfStar);
124073
- var suffix = pattern.substr(indexOfStar + 1);
124074
- if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
124075
- ts.startsWith(relativeToBaseUrl, prefix) &&
124076
- ts.endsWith(relativeToBaseUrl, suffix) ||
124077
- !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
124078
- var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length);
124079
- return key.replace("*", matchedStar);
124316
+ var prefix = pattern.substring(0, indexOfStar);
124317
+ var suffix = pattern.substring(indexOfStar + 1);
124318
+ for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
124319
+ var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
124320
+ if (value.length >= prefix.length + suffix.length &&
124321
+ ts.startsWith(value, prefix) &&
124322
+ ts.endsWith(value, suffix) &&
124323
+ validateEnding({ ending: ending, value: value })) {
124324
+ var matchedStar = value.substring(prefix.length, value.length - suffix.length);
124325
+ return { value: key.replace("*", matchedStar) };
124326
+ }
124080
124327
  }
124081
124328
  }
124082
- else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
124083
- return key;
124329
+ else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
124330
+ ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
124331
+ return { value: key };
124084
124332
  }
124333
+ };
124334
+ for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
124335
+ var patternText_1 = _a[_i];
124336
+ var state_12 = _loop_36(patternText_1);
124337
+ if (typeof state_12 === "object")
124338
+ return state_12.value;
124085
124339
  }
124086
124340
  }
124341
+ function validateEnding(_a) {
124342
+ var ending = _a.ending, value = _a.value;
124343
+ // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
124344
+ // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
124345
+ // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
124346
+ // 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
124347
+ // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
124348
+ // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
124349
+ // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
124350
+ return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
124351
+ }
124087
124352
  }
124088
124353
  var MatchingMode;
124089
124354
  (function (MatchingMode) {
@@ -124179,10 +124444,10 @@ var ts;
124179
124444
  return undefined;
124180
124445
  }
124181
124446
  // Simplify the full file path to something that can be resolved by Node.
124447
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
124182
124448
  var moduleSpecifier = path;
124183
124449
  var isPackageRootPath = false;
124184
124450
  if (!packageNameOnly) {
124185
- var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
124186
124451
  var packageRootIndex = parts.packageRootIndex;
124187
124452
  var moduleFileName = void 0;
124188
124453
  while (true) {
@@ -124231,15 +124496,13 @@ var ts;
124231
124496
  var packageRootPath = path.substring(0, packageRootIndex);
124232
124497
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
124233
124498
  var moduleFileToTry = path;
124499
+ var maybeBlockedByTypesVersions = false;
124234
124500
  var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
124235
124501
  if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
124236
124502
  var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
124503
+ var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
124237
124504
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
124238
- // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
124239
- // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
124240
- // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
124241
- // with, so for now we just stick with the mode of the file.
124242
- var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
124505
+ var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
124243
124506
  var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
124244
124507
  ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
124245
124508
  : undefined;
@@ -124258,16 +124521,26 @@ var ts;
124258
124521
  : undefined;
124259
124522
  if (versionPaths) {
124260
124523
  var subModuleName = path.slice(packageRootPath.length + 1);
124261
- var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths);
124262
- if (fromPaths !== undefined) {
124524
+ var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
124525
+ if (fromPaths === undefined) {
124526
+ maybeBlockedByTypesVersions = true;
124527
+ }
124528
+ else {
124263
124529
  moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
124264
124530
  }
124265
124531
  }
124266
124532
  // If the file is the main module, it can be imported by the package name
124267
124533
  var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
124268
- if (ts.isString(mainFileRelative)) {
124534
+ if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
124535
+ // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
124536
+ // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
124537
+ // (The only way this can happen is if some file in a package that's not resolvable from outside the
124538
+ // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
124539
+ // happens very easily in fourslash tests though, since every test file listed gets included. See
124540
+ // importNameCodeFix_typesVersions.ts for an example.)
124269
124541
  var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
124270
124542
  if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
124543
+ // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
124271
124544
  return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
124272
124545
  }
124273
124546
  }
@@ -156946,6 +157219,15 @@ var ts;
156946
157219
  ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
156947
157220
  ts.Diagnostics.Cannot_find_name_0.code
156948
157221
  ];
157222
+ var InfoKind;
157223
+ (function (InfoKind) {
157224
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157225
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
157226
+ InfoKind[InfoKind["Function"] = 2] = "Function";
157227
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157228
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157229
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
157230
+ })(InfoKind || (InfoKind = {}));
156949
157231
  codefix.registerCodeFix({
156950
157232
  errorCodes: errorCodes,
156951
157233
  getCodeActions: function (context) {
@@ -156954,19 +157236,19 @@ var ts;
156954
157236
  if (!info) {
156955
157237
  return undefined;
156956
157238
  }
156957
- if (info.kind === 3 /* ObjectLiteral */) {
157239
+ if (info.kind === InfoKind.ObjectLiteral) {
156958
157240
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
156959
157241
  return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
156960
157242
  }
156961
- if (info.kind === 4 /* JsxAttributes */) {
157243
+ if (info.kind === InfoKind.JsxAttributes) {
156962
157244
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
156963
157245
  return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
156964
157246
  }
156965
- if (info.kind === 2 /* Function */) {
157247
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
156966
157248
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
156967
157249
  return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
156968
157250
  }
156969
- if (info.kind === 1 /* Enum */) {
157251
+ if (info.kind === InfoKind.Enum) {
156970
157252
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
156971
157253
  return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
156972
157254
  }
@@ -156984,20 +157266,20 @@ var ts;
156984
157266
  if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
156985
157267
  return;
156986
157268
  }
156987
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
157269
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
156988
157270
  addFunctionDeclaration(changes, context, info);
156989
157271
  }
156990
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157272
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
156991
157273
  addObjectLiteralProperties(changes, context, info);
156992
157274
  }
156993
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157275
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
156994
157276
  addJsxAttributes(changes, context, info);
156995
157277
  }
156996
157278
  else {
156997
- if (info.kind === 1 /* Enum */) {
157279
+ if (info.kind === InfoKind.Enum) {
156998
157280
  addEnumMemberDeclaration(changes, checker, info);
156999
157281
  }
157000
- if (info.kind === 0 /* TypeLikeDeclaration */) {
157282
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
157001
157283
  var parentDeclaration = info.parentDeclaration, token_1 = info.token;
157002
157284
  var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
157003
157285
  if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -157041,14 +157323,6 @@ var ts;
157041
157323
  }));
157042
157324
  },
157043
157325
  });
157044
- var InfoKind;
157045
- (function (InfoKind) {
157046
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157047
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
157048
- InfoKind[InfoKind["Function"] = 2] = "Function";
157049
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157050
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157051
- })(InfoKind || (InfoKind = {}));
157052
157326
  function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
157053
157327
  // The identifier of the missing property. eg:
157054
157328
  // this.missing = 1;
@@ -157070,7 +157344,7 @@ var ts;
157070
157344
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157071
157345
  if (!ts.length(properties))
157072
157346
  return undefined;
157073
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
157347
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
157074
157348
  }
157075
157349
  if (!ts.isMemberName(token))
157076
157350
  return undefined;
@@ -157078,17 +157352,26 @@ var ts;
157078
157352
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157079
157353
  if (!ts.length(properties))
157080
157354
  return undefined;
157081
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
157355
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
157082
157356
  }
157083
157357
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
157084
157358
  var target = ts.getEmitScriptTarget(program.getCompilerOptions());
157085
157359
  var attributes = getUnmatchedAttributes(checker, target, token.parent);
157086
157360
  if (!ts.length(attributes))
157087
157361
  return undefined;
157088
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
157362
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
157089
157363
  }
157090
- if (ts.isIdentifier(token) && ts.isCallExpression(parent)) {
157091
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
157364
+ if (ts.isIdentifier(token)) {
157365
+ var type = checker.getContextualType(token);
157366
+ if (type && ts.getObjectFlags(type) & 16 /* Anonymous */) {
157367
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
157368
+ if (signature === undefined)
157369
+ return undefined;
157370
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
157371
+ }
157372
+ if (ts.isCallExpression(parent) && parent.expression === token) {
157373
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: findScope(token) };
157374
+ }
157092
157375
  }
157093
157376
  if (!ts.isPropertyAccessExpression(parent))
157094
157377
  return undefined;
@@ -157100,13 +157383,13 @@ var ts;
157100
157383
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
157101
157384
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
157102
157385
  if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
157103
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157386
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157104
157387
  }
157105
157388
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
157106
157389
  if (sourceFile.commonJsModuleIndicator)
157107
157390
  return undefined;
157108
157391
  if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
157109
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157392
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157110
157393
  }
157111
157394
  }
157112
157395
  var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -157124,11 +157407,11 @@ var ts;
157124
157407
  (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
157125
157408
  var isJSFile = ts.isSourceFileJS(declSourceFile);
157126
157409
  var call = ts.tryCast(parent.parent, ts.isCallExpression);
157127
- return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157410
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157128
157411
  }
157129
157412
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
157130
157413
  if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157131
- return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
157414
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
157132
157415
  }
157133
157416
  return undefined;
157134
157417
  }
@@ -157304,9 +157587,17 @@ var ts;
157304
157587
  });
157305
157588
  }
157306
157589
  function addFunctionDeclaration(changes, context, info) {
157590
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
157307
157591
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
157308
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
157309
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157592
+ var functionDeclaration = info.kind === InfoKind.Function
157593
+ ? codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
157594
+ : 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);
157595
+ if (functionDeclaration === undefined) {
157596
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
157597
+ }
157598
+ ts.isReturnStatement(info.parentDeclaration)
157599
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
157600
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157310
157601
  importAdder.writeFixes(changes);
157311
157602
  }
157312
157603
  function addJsxAttributes(changes, context, info) {
@@ -157464,6 +157755,14 @@ var ts;
157464
157755
  }
157465
157756
  return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
157466
157757
  }
157758
+ function findScope(node) {
157759
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
157760
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
157761
+ if (returnStatement)
157762
+ return returnStatement;
157763
+ }
157764
+ return ts.getSourceFileOfNode(node);
157765
+ }
157467
157766
  })(codefix = ts.codefix || (ts.codefix = {}));
157468
157767
  })(ts || (ts = {}));
157469
157768
  /* @internal */
@@ -160153,6 +160452,9 @@ var ts;
160153
160452
  if (ts.isMethodDeclaration(signatureDeclaration)) {
160154
160453
  return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
160155
160454
  }
160455
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
160456
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
160457
+ }
160156
160458
  return undefined;
160157
160459
  }
160158
160460
  codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -162332,6 +162634,9 @@ var ts;
162332
162634
  if (!containingDecl) {
162333
162635
  return;
162334
162636
  }
162637
+ if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
162638
+ return;
162639
+ }
162335
162640
  var checker = program.getTypeChecker();
162336
162641
  var signatureSymbol = containingDecl.symbol;
162337
162642
  if (!signatureSymbol) {