@typescript-deploys/pr-build 4.6.0-pr-47717-6 → 4.6.0-pr-45974-9

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.
@@ -294,7 +294,7 @@ var ts;
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.20220204";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220211";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -1468,11 +1468,11 @@ var ts;
1468
1468
  return result;
1469
1469
  }
1470
1470
  ts.getAllKeys = getAllKeys;
1471
- function getOwnValues(sparseArray) {
1471
+ function getOwnValues(collection) {
1472
1472
  var values = [];
1473
- for (var key in sparseArray) {
1474
- if (hasOwnProperty.call(sparseArray, key)) {
1475
- values.push(sparseArray[key]);
1473
+ for (var key in collection) {
1474
+ if (hasOwnProperty.call(collection, key)) {
1475
+ values.push(collection[key]);
1476
1476
  }
1477
1477
  }
1478
1478
  return values;
@@ -7830,18 +7830,6 @@ var ts;
7830
7830
  return getCanonicalFileName(nonCanonicalizedPath);
7831
7831
  }
7832
7832
  ts.toPath = toPath;
7833
- function normalizePathAndParts(path) {
7834
- path = normalizeSlashes(path);
7835
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7836
- if (parts.length) {
7837
- var joinedParts = root + parts.join(ts.directorySeparator);
7838
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7839
- }
7840
- else {
7841
- return { path: root, parts: parts };
7842
- }
7843
- }
7844
- ts.normalizePathAndParts = normalizePathAndParts;
7845
7833
  function removeTrailingDirectorySeparator(path) {
7846
7834
  if (hasTrailingDirectorySeparator(path)) {
7847
7835
  return path.substr(0, path.length - 1);
@@ -8239,10 +8227,10 @@ var ts;
8239
8227
  A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
8240
8228
  A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
8241
8229
  An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."),
8242
- An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."),
8243
- An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."),
8230
+ An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232", "An import declaration can only be used at the top level of a namespace or module."),
8231
+ An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233", "An export declaration can only be used at the top level of a namespace or module."),
8244
8232
  An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
8245
- A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."),
8233
+ A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235", "A namespace declaration is only allowed at the top level of a namespace or module."),
8246
8234
  The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
8247
8235
  The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
8248
8236
  Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
@@ -8274,6 +8262,7 @@ var ts;
8274
8262
  An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
8275
8263
  Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
8276
8264
  An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
8265
+ Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
8277
8266
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
8278
8267
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
8279
8268
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -8410,6 +8399,8 @@ var ts;
8410
8399
  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."),
8411
8400
  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."),
8412
8401
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8402
+ 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."),
8403
+ 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."),
8413
8404
  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."),
8414
8405
  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."),
8415
8406
  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),
@@ -9829,6 +9820,10 @@ var ts;
9829
9820
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9830
9821
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9831
9822
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9823
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9824
+ Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
9825
+ Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
9826
+ Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
9832
9827
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9833
9828
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9834
9829
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -14090,6 +14085,10 @@ var ts;
14090
14085
  return undefined;
14091
14086
  }
14092
14087
  ts.getDeclarationOfKind = getDeclarationOfKind;
14088
+ function getDeclarationsOfKind(symbol, kind) {
14089
+ return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
14090
+ }
14091
+ ts.getDeclarationsOfKind = getDeclarationsOfKind;
14093
14092
  function createSymbolTable(symbols) {
14094
14093
  var result = new ts.Map();
14095
14094
  if (symbols) {
@@ -14325,6 +14324,10 @@ var ts;
14325
14324
  return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
14326
14325
  }
14327
14326
  ts.getSourceFileOfModule = getSourceFileOfModule;
14327
+ function isPlainJsFile(file, checkJs) {
14328
+ return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
14329
+ }
14330
+ ts.isPlainJsFile = isPlainJsFile;
14328
14331
  function isStatementWithLocals(node) {
14329
14332
  switch (node.kind) {
14330
14333
  case 234 /* Block */:
@@ -41900,7 +41903,7 @@ var ts;
41900
41903
  result_4 = searchResult && searchResult.value;
41901
41904
  }
41902
41905
  else {
41903
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
41906
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
41904
41907
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
41905
41908
  }
41906
41909
  return resolvedTypeScriptOnly(result_4);
@@ -42603,13 +42606,25 @@ var ts;
42603
42606
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
42604
42607
  }
42605
42608
  else {
42606
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
42609
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
42607
42610
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
42608
42611
  // Treat explicit "node_modules" import as an external library import.
42609
42612
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
42610
42613
  }
42611
42614
  }
42612
42615
  }
42616
+ // If you import from "." inside a containing directory "/foo", the result of `normalizePath`
42617
+ // would be "/foo", but this loses the information that `foo` is a directory and we intended
42618
+ // to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
42619
+ // (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
42620
+ // in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
42621
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
42622
+ var combined = ts.combinePaths(containingDirectory, moduleName);
42623
+ var parts = ts.getPathComponents(combined);
42624
+ var lastPart = ts.lastOrUndefined(parts);
42625
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
42626
+ return { path: path, parts: parts };
42627
+ }
42613
42628
  function realPath(path, host, traceEnabled) {
42614
42629
  if (!host.realpath) {
42615
42630
  return path;
@@ -44357,7 +44372,7 @@ var ts;
44357
44372
  return ts.isDottedName(expr)
44358
44373
  || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
44359
44374
  || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right)
44360
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
44375
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isIdentifier(expr.argumentExpression)) && isNarrowableReference(expr.expression)
44361
44376
  || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
44362
44377
  }
44363
44378
  function containsNarrowableReference(expr) {
@@ -47102,6 +47117,9 @@ var ts;
47102
47117
  CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
47103
47118
  CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
47104
47119
  CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
47120
+ CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
47121
+ // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
47122
+ // we need to preserve generic types instead of substituting them for constraints
47105
47123
  })(CheckMode || (CheckMode = {}));
47106
47124
  var SignatureCheckMode;
47107
47125
  (function (SignatureCheckMode) {
@@ -48154,13 +48172,13 @@ var ts;
48154
48172
  else { // error
48155
48173
  var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
48156
48174
  var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
48157
- var message = isEitherEnum
48158
- ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
48159
- : isEitherBlockScoped_1
48160
- ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
48175
+ var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
48176
+ : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
48161
48177
  : ts.Diagnostics.Duplicate_identifier_0;
48162
48178
  var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
48163
48179
  var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
48180
+ var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
48181
+ var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
48164
48182
  var symbolName_1 = symbolToString(source);
48165
48183
  // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
48166
48184
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
@@ -48172,12 +48190,16 @@ var ts;
48172
48190
  var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
48173
48191
  return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
48174
48192
  });
48175
- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
48176
- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
48193
+ if (!isSourcePlainJs)
48194
+ addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
48195
+ if (!isTargetPlainJs)
48196
+ addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
48177
48197
  }
48178
48198
  else {
48179
- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
48180
- addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
48199
+ if (!isSourcePlainJs)
48200
+ addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
48201
+ if (!isTargetPlainJs)
48202
+ addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
48181
48203
  }
48182
48204
  }
48183
48205
  return target;
@@ -48634,6 +48656,8 @@ var ts;
48634
48656
  // type parameters are visible in parameter list, return type and type parameter list
48635
48657
  ? lastLocation === location.type ||
48636
48658
  lastLocation.kind === 163 /* Parameter */ ||
48659
+ lastLocation.kind === 338 /* JSDocParameterTag */ ||
48660
+ lastLocation.kind === 339 /* JSDocReturnTag */ ||
48637
48661
  lastLocation.kind === 162 /* TypeParameter */
48638
48662
  // local types not visible outside the function body
48639
48663
  : false;
@@ -48893,9 +48917,9 @@ var ts;
48893
48917
  lastSelfReferenceLocation = location;
48894
48918
  }
48895
48919
  lastLocation = location;
48896
- location = ts.isJSDocTemplateTag(location) ?
48897
- ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
48898
- location.parent;
48920
+ location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
48921
+ ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
48922
+ location.parent;
48899
48923
  }
48900
48924
  // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
48901
48925
  // If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
@@ -50029,16 +50053,20 @@ var ts;
50029
50053
  return;
50030
50054
  }
50031
50055
  var host = ts.getJSDocHost(node);
50032
- if (host &&
50033
- ts.isExpressionStatement(host) &&
50034
- ts.isBinaryExpression(host.expression) &&
50035
- ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
50036
- // X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
50056
+ if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
50057
+ // /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
50037
50058
  var symbol = getSymbolOfNode(host.expression.left);
50038
50059
  if (symbol) {
50039
50060
  return getDeclarationOfJSPrototypeContainer(symbol);
50040
50061
  }
50041
50062
  }
50063
+ if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
50064
+ // X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
50065
+ var symbol = getSymbolOfNode(host.parent.left);
50066
+ if (symbol) {
50067
+ return getDeclarationOfJSPrototypeContainer(symbol);
50068
+ }
50069
+ }
50042
50070
  if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
50043
50071
  ts.isBinaryExpression(host.parent.parent) &&
50044
50072
  ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
@@ -54525,9 +54553,12 @@ var ts;
54525
54553
  }
54526
54554
  // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
54527
54555
  // assigned by contextual typing.
54528
- function getTypeForBindingElementParent(node) {
54556
+ function getTypeForBindingElementParent(node, checkMode) {
54557
+ if (checkMode !== 0 /* Normal */) {
54558
+ return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54559
+ }
54529
54560
  var symbol = getSymbolOfNode(node);
54530
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
54561
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54531
54562
  }
54532
54563
  function getRestType(source, properties, symbol) {
54533
54564
  source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
@@ -54645,7 +54676,8 @@ var ts;
54645
54676
  }
54646
54677
  /** Return the inferred type for a binding element */
54647
54678
  function getTypeForBindingElement(declaration) {
54648
- var parentType = getTypeForBindingElementParent(declaration.parent.parent);
54679
+ var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
54680
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
54649
54681
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
54650
54682
  }
54651
54683
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -54717,9 +54749,9 @@ var ts;
54717
54749
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
54718
54750
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
54719
54751
  // undefined from the final type.
54720
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54752
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54721
54753
  }
54722
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
54754
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
54723
54755
  }
54724
54756
  function getTypeForDeclarationFromJSDocComment(declaration) {
54725
54757
  var jsdocType = ts.getJSDocType(declaration);
@@ -54742,11 +54774,11 @@ var ts;
54742
54774
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
54743
54775
  }
54744
54776
  // Return the inferred type for a variable, parameter, or property declaration
54745
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
54777
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
54746
54778
  // A variable declared in a for..in statement is of type string, or of type keyof T when the
54747
54779
  // right hand expression is of a type parameter type.
54748
54780
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
54749
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
54781
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
54750
54782
  return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
54751
54783
  }
54752
54784
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
@@ -54801,12 +54833,9 @@ var ts;
54801
54833
  }
54802
54834
  }
54803
54835
  if (ts.isInJSFile(declaration)) {
54804
- var typeTag = ts.getJSDocType(func);
54805
- if (typeTag && ts.isFunctionTypeNode(typeTag)) {
54806
- var signature = getSignatureFromDeclaration(typeTag);
54807
- var pos = func.parameters.indexOf(declaration);
54808
- return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
54809
- }
54836
+ var type_1 = getParameterTypeOfTypeTag(func, declaration);
54837
+ if (type_1)
54838
+ return type_1;
54810
54839
  }
54811
54840
  // Use contextual parameter type if one is available
54812
54841
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
@@ -54823,7 +54852,7 @@ var ts;
54823
54852
  return containerObjectType;
54824
54853
  }
54825
54854
  }
54826
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
54855
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
54827
54856
  return addOptionality(type, isProperty, isOptional);
54828
54857
  }
54829
54858
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -55195,7 +55224,7 @@ var ts;
55195
55224
  // contextual type or, if the element itself is a binding pattern, with the type implied by that binding
55196
55225
  // pattern.
55197
55226
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
55198
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
55227
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
55199
55228
  }
55200
55229
  if (ts.isBindingPattern(element.name)) {
55201
55230
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -55284,7 +55313,7 @@ var ts;
55284
55313
  // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
55285
55314
  // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
55286
55315
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
55287
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
55316
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
55288
55317
  }
55289
55318
  function isGlobalSymbolConstructor(node) {
55290
55319
  var symbol = getSymbolOfNode(node);
@@ -55373,9 +55402,9 @@ var ts;
55373
55402
  if (typeNode === undefined) {
55374
55403
  return useUnknownInCatchVariables ? unknownType : anyType;
55375
55404
  }
55376
- var type_1 = getTypeOfNode(typeNode);
55405
+ var type_2 = getTypeOfNode(typeNode);
55377
55406
  // an errorType will make `checkTryStatement` issue an error
55378
- return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
55407
+ return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
55379
55408
  }
55380
55409
  // Handle export default expressions
55381
55410
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -55513,10 +55542,12 @@ var ts;
55513
55542
  if (writing === void 0) { writing = false; }
55514
55543
  var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
55515
55544
  var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
55516
- var setterType = getAnnotatedAccessorType(setter);
55517
55545
  // For write operations, prioritize type annotations on the setter
55518
- if (writing && setterType) {
55519
- return instantiateTypeIfNeeded(setterType, symbol);
55546
+ if (writing) {
55547
+ var setterType_1 = getAnnotatedAccessorType(setter);
55548
+ if (setterType_1) {
55549
+ return instantiateTypeIfNeeded(setterType_1, symbol);
55550
+ }
55520
55551
  }
55521
55552
  // Else defer to the getter type
55522
55553
  if (getter && ts.isInJSFile(getter)) {
@@ -55531,6 +55562,7 @@ var ts;
55531
55562
  return instantiateTypeIfNeeded(getterType, symbol);
55532
55563
  }
55533
55564
  // If the user didn't specify a return type, try to use the set-accessor's parameter type.
55565
+ var setterType = getAnnotatedAccessorType(setter);
55534
55566
  if (setterType) {
55535
55567
  return setterType;
55536
55568
  }
@@ -55601,11 +55633,11 @@ var ts;
55601
55633
  return errorType;
55602
55634
  }
55603
55635
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
55604
- var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
55636
+ var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
55605
55637
  if (!popTypeResolution()) {
55606
55638
  return reportCircularityError(symbol);
55607
55639
  }
55608
- return type_2;
55640
+ return type_3;
55609
55641
  }
55610
55642
  }
55611
55643
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -55679,6 +55711,39 @@ var ts;
55679
55711
  }
55680
55712
  return links.type;
55681
55713
  }
55714
+ function getWriteTypeOfSymbolWithDeferredType(symbol) {
55715
+ var links = getSymbolLinks(symbol);
55716
+ if (!links.writeType && links.deferralWriteConstituents) {
55717
+ ts.Debug.assertIsDefined(links.deferralParent);
55718
+ ts.Debug.assertIsDefined(links.deferralConstituents);
55719
+ links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
55720
+ }
55721
+ return links.writeType;
55722
+ }
55723
+ /**
55724
+ * Distinct write types come only from set accessors, but union and intersection
55725
+ * properties deriving from set accessors will either pre-compute or defer the
55726
+ * union or intersection of the writeTypes of their constituents. To account for
55727
+ * this, we will assume that any deferred type or transient symbol may have a
55728
+ * `writeType` (or a deferred write type ready to be computed) that should be
55729
+ * used before looking for set accessor declarations.
55730
+ */
55731
+ function getWriteTypeOfSymbol(symbol) {
55732
+ var checkFlags = ts.getCheckFlags(symbol);
55733
+ if (checkFlags & 65536 /* DeferredType */) {
55734
+ var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
55735
+ if (writeType) {
55736
+ return writeType;
55737
+ }
55738
+ }
55739
+ if (symbol.flags & 33554432 /* Transient */) {
55740
+ var writeType = symbol.writeType;
55741
+ if (writeType) {
55742
+ return writeType;
55743
+ }
55744
+ }
55745
+ return getSetAccessorTypeOfSymbol(symbol);
55746
+ }
55682
55747
  function getSetAccessorTypeOfSymbol(symbol) {
55683
55748
  if (symbol.flags & 98304 /* Accessor */) {
55684
55749
  var type = getTypeOfSetAccessor(symbol);
@@ -57804,10 +57869,10 @@ var ts;
57804
57869
  var baseTypes = [];
57805
57870
  var different = false;
57806
57871
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
57807
- var type_3 = types_7[_i];
57808
- var baseType = getBaseConstraint(type_3);
57872
+ var type_4 = types_7[_i];
57873
+ var baseType = getBaseConstraint(type_4);
57809
57874
  if (baseType) {
57810
- if (baseType !== type_3) {
57875
+ if (baseType !== type_4) {
57811
57876
  different = true;
57812
57877
  }
57813
57878
  baseTypes.push(baseType);
@@ -58049,6 +58114,7 @@ var ts;
58049
58114
  var firstType;
58050
58115
  var nameType;
58051
58116
  var propTypes = [];
58117
+ var writeTypes;
58052
58118
  var firstValueDeclaration;
58053
58119
  var hasNonUniformValueDeclaration = false;
58054
58120
  for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
@@ -58065,6 +58131,10 @@ var ts;
58065
58131
  firstType = type;
58066
58132
  nameType = getSymbolLinks(prop).nameType;
58067
58133
  }
58134
+ var writeType = getWriteTypeOfSymbol(prop);
58135
+ if (writeTypes || writeType !== type) {
58136
+ writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
58137
+ }
58068
58138
  else if (type !== firstType) {
58069
58139
  checkFlags |= 64 /* HasNonUniformType */;
58070
58140
  }
@@ -58093,9 +58163,13 @@ var ts;
58093
58163
  result.checkFlags |= 65536 /* DeferredType */;
58094
58164
  result.deferralParent = containingType;
58095
58165
  result.deferralConstituents = propTypes;
58166
+ result.deferralWriteConstituents = writeTypes;
58096
58167
  }
58097
58168
  else {
58098
58169
  result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
58170
+ if (writeTypes) {
58171
+ result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
58172
+ }
58099
58173
  }
58100
58174
  return result;
58101
58175
  }
@@ -58511,6 +58585,13 @@ var ts;
58511
58585
  var typeTag = ts.getJSDocTypeTag(node);
58512
58586
  return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
58513
58587
  }
58588
+ function getParameterTypeOfTypeTag(func, parameter) {
58589
+ var signature = getSignatureOfTypeTag(func);
58590
+ if (!signature)
58591
+ return undefined;
58592
+ var pos = func.parameters.indexOf(parameter);
58593
+ return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
58594
+ }
58514
58595
  function getReturnTypeOfTypeTag(node) {
58515
58596
  var signature = getSignatureOfTypeTag(node);
58516
58597
  return signature && getReturnTypeOfSignature(signature);
@@ -59237,7 +59318,7 @@ var ts;
59237
59318
  }
59238
59319
  function getImpliedConstraint(type, checkNode, extendsNode) {
59239
59320
  return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
59240
- getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
59321
+ getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
59241
59322
  undefined;
59242
59323
  }
59243
59324
  function getConditionalFlowTypeOfType(type, node) {
@@ -59703,7 +59784,7 @@ var ts;
59703
59784
  }
59704
59785
  }
59705
59786
  var fixedLength = properties.length;
59706
- var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
59787
+ var lengthSymbol = createSymbol(4 /* Property */, "length");
59707
59788
  if (combinedFlags & 12 /* Variable */) {
59708
59789
  lengthSymbol.type = numberType;
59709
59790
  }
@@ -67918,8 +67999,9 @@ var ts;
67918
67999
  return isMatchingReference(source.expression, target);
67919
68000
  case 205 /* PropertyAccessExpression */:
67920
68001
  case 206 /* ElementAccessExpression */:
67921
- return ts.isAccessExpression(target) &&
67922
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
68002
+ var sourcePropertyName = getAccessedPropertyName(source);
68003
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
68004
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
67923
68005
  isMatchingReference(source.expression, target.expression);
67924
68006
  case 160 /* QualifiedName */:
67925
68007
  return ts.isAccessExpression(target) &&
@@ -67931,12 +68013,49 @@ var ts;
67931
68013
  return false;
67932
68014
  }
67933
68015
  function getAccessedPropertyName(access) {
67934
- var propertyName;
67935
- return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67936
- access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67937
- access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67938
- access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67939
- undefined;
68016
+ if (ts.isPropertyAccessExpression(access)) {
68017
+ return access.name.escapedText;
68018
+ }
68019
+ if (ts.isElementAccessExpression(access)) {
68020
+ return tryGetElementAccessExpressionName(access);
68021
+ }
68022
+ if (ts.isBindingElement(access)) {
68023
+ var name = getDestructuringPropertyName(access);
68024
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
68025
+ }
68026
+ if (ts.isParameter(access)) {
68027
+ return ("" + access.parent.parameters.indexOf(access));
68028
+ }
68029
+ return undefined;
68030
+ }
68031
+ function tryGetNameFromType(type) {
68032
+ return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName :
68033
+ type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
68034
+ }
68035
+ function tryGetElementAccessExpressionName(node) {
68036
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
68037
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
68038
+ }
68039
+ if (ts.isIdentifier(node.argumentExpression)) {
68040
+ var symbol = getResolvedSymbol(node.argumentExpression);
68041
+ if (!isConstVariable(symbol))
68042
+ return undefined;
68043
+ var declaration = symbol.valueDeclaration;
68044
+ if (declaration === undefined)
68045
+ return undefined;
68046
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
68047
+ if (type) {
68048
+ var name = tryGetNameFromType(type);
68049
+ if (name !== undefined) {
68050
+ return name;
68051
+ }
68052
+ }
68053
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
68054
+ var initializer = ts.getEffectiveInitializer(declaration);
68055
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
68056
+ }
68057
+ }
68058
+ return undefined;
67940
68059
  }
67941
68060
  function containsMatchingReference(source, target) {
67942
68061
  while (ts.isAccessExpression(source)) {
@@ -70046,12 +70165,16 @@ var ts;
70046
70165
  function isGenericTypeWithoutNullableConstraint(type) {
70047
70166
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
70048
70167
  }
70049
- function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
70168
+ function hasContextualTypeWithNoGenericTypes(node, checkMode) {
70050
70169
  // Computing the contextual type for a child of a JSX element involves resolving the type of the
70051
70170
  // element's tag name, so we exclude that here to avoid circularities.
70171
+ // If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
70172
+ // as we want the type of a rest element to be generic when possible.
70052
70173
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
70053
70174
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
70054
- getContextualType(node, 8 /* SkipBindingPatterns */);
70175
+ (checkMode && checkMode & 32 /* RestBindingElement */ ?
70176
+ getContextualType(node, 8 /* SkipBindingPatterns */)
70177
+ : getContextualType(node));
70055
70178
  return contextualType && !isGenericType(contextualType);
70056
70179
  }
70057
70180
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -70064,7 +70187,7 @@ var ts;
70064
70187
  // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
70065
70188
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
70066
70189
  someType(type, isGenericTypeWithUnionConstraint) &&
70067
- (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
70190
+ (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70068
70191
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
70069
70192
  }
70070
70193
  function isExportOrExportExpression(location) {
@@ -70132,7 +70255,7 @@ var ts;
70132
70255
  var links = getNodeLinks(location);
70133
70256
  if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
70134
70257
  links.flags |= 268435456 /* InCheckIdentifier */;
70135
- var parentType = getTypeForBindingElementParent(parent);
70258
+ var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
70136
70259
  links.flags &= ~268435456 /* InCheckIdentifier */;
70137
70260
  if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
70138
70261
  var pattern = declaration.parent;
@@ -70985,7 +71108,7 @@ var ts;
70985
71108
  var parent = declaration.parent.parent;
70986
71109
  var name = declaration.propertyName || declaration.name;
70987
71110
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
70988
- parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
71111
+ parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
70989
71112
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
70990
71113
  return undefined;
70991
71114
  if (parent.name.kind === 201 /* ArrayBindingPattern */) {
@@ -73226,7 +73349,7 @@ var ts;
73226
73349
  error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
73227
73350
  return errorType;
73228
73351
  }
73229
- propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop);
73352
+ propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
73230
73353
  }
73231
73354
  return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
73232
73355
  }
@@ -75696,8 +75819,8 @@ var ts;
75696
75819
  if (hasDefaultOnly && type && !isErrorType(type)) {
75697
75820
  var synthType = type;
75698
75821
  if (!synthType.defaultOnlyType) {
75699
- var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
75700
- synthType.defaultOnlyType = type_4;
75822
+ var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
75823
+ synthType.defaultOnlyType = type_5;
75701
75824
  }
75702
75825
  return synthType.defaultOnlyType;
75703
75826
  }
@@ -76151,7 +76274,7 @@ var ts;
76151
76274
  var links = getSymbolLinks(parameter);
76152
76275
  if (!links.type) {
76153
76276
  var declaration = parameter.valueDeclaration;
76154
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
76277
+ links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
76155
76278
  if (declaration.name.kind !== 79 /* Identifier */) {
76156
76279
  // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
76157
76280
  if (links.type === unknownType) {
@@ -76424,12 +76547,12 @@ var ts;
76424
76547
  var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
76425
76548
  // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
76426
76549
  var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
76427
- var type_5 = getBaseConstraintOfType(operandType) || operandType;
76550
+ var type_6 = getBaseConstraintOfType(operandType) || operandType;
76428
76551
  // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
76429
- if (type_5.flags & 3 /* AnyOrUnknown */) {
76552
+ if (type_6.flags & 3 /* AnyOrUnknown */) {
76430
76553
  return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
76431
76554
  }
76432
- return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
76555
+ return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
76433
76556
  }
76434
76557
  var type = getTypeOfExpression(node.expression);
76435
76558
  if (!isLiteralType(type)) {
@@ -77882,11 +78005,11 @@ var ts;
77882
78005
  }
77883
78006
  }
77884
78007
  function checkExpressionCached(node, checkMode) {
78008
+ if (checkMode && checkMode !== 0 /* Normal */) {
78009
+ return checkExpression(node, checkMode);
78010
+ }
77885
78011
  var links = getNodeLinks(node);
77886
78012
  if (!links.resolvedType) {
77887
- if (checkMode && checkMode !== 0 /* Normal */) {
77888
- return checkExpression(node, checkMode);
77889
- }
77890
78013
  // When computing a type that we're going to cache, we need to ignore any ongoing control flow
77891
78014
  // analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
77892
78015
  // to the top of the stack ensures all transient types are computed from a known point.
@@ -77906,10 +78029,12 @@ var ts;
77906
78029
  node.kind === 228 /* AsExpression */ ||
77907
78030
  ts.isJSDocTypeAssertion(node);
77908
78031
  }
77909
- function checkDeclarationInitializer(declaration, contextualType) {
78032
+ function checkDeclarationInitializer(declaration, checkMode, contextualType) {
77910
78033
  var initializer = ts.getEffectiveInitializer(declaration);
77911
78034
  var type = getQuickTypeOfExpression(initializer) ||
77912
- (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer));
78035
+ (contextualType ?
78036
+ checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
78037
+ : checkExpressionCached(initializer, checkMode));
77913
78038
  return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
77914
78039
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
77915
78040
  padTupleType(type, declaration.name) : type;
@@ -78549,6 +78674,7 @@ var ts;
78549
78674
  }
78550
78675
  }
78551
78676
  checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
78677
+ checkUnmatchedJSDocParameters(node);
78552
78678
  ts.forEach(node.parameters, checkParameter);
78553
78679
  // TODO(rbuckton): Should we start checking JSDoc types?
78554
78680
  if (node.type) {
@@ -80120,31 +80246,6 @@ var ts;
80120
80246
  }
80121
80247
  function checkJSDocParameterTag(node) {
80122
80248
  checkSourceElement(node.typeExpression);
80123
- if (!ts.getParameterSymbolFromJSDoc(node)) {
80124
- var decl = ts.getHostSignatureFromJSDoc(node);
80125
- // don't issue an error for invalid hosts -- just functions --
80126
- // and give a better error message when the host function mentions `arguments`
80127
- // but the tag doesn't have an array type
80128
- if (decl) {
80129
- var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
80130
- if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
80131
- return;
80132
- }
80133
- if (!containsArgumentsReference(decl)) {
80134
- if (ts.isQualifiedName(node.name)) {
80135
- error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
80136
- }
80137
- else {
80138
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
80139
- }
80140
- }
80141
- else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
80142
- node.typeExpression && node.typeExpression.type &&
80143
- !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
80144
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 /* QualifiedName */ ? node.name.right : node.name));
80145
- }
80146
- }
80147
- }
80148
80249
  }
80149
80250
  function checkJSDocPropertyTag(node) {
80150
80251
  checkSourceElement(node.typeExpression);
@@ -80846,7 +80947,8 @@ var ts;
80846
80947
  }
80847
80948
  // check private/protected variable access
80848
80949
  var parent = node.parent.parent;
80849
- var parentType = getTypeForBindingElementParent(parent);
80950
+ var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
80951
+ var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
80850
80952
  var name = node.propertyName || node.name;
80851
80953
  if (parentType && !ts.isBindingPattern(name)) {
80852
80954
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -82085,7 +82187,7 @@ var ts;
82085
82187
  var declaration = catchClause.variableDeclaration;
82086
82188
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
82087
82189
  if (typeNode) {
82088
- var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
82190
+ var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
82089
82191
  if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
82090
82192
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
82091
82193
  }
@@ -82216,6 +82318,45 @@ var ts;
82216
82318
  error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
82217
82319
  }
82218
82320
  }
82321
+ function checkUnmatchedJSDocParameters(node) {
82322
+ var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
82323
+ if (!ts.length(jsdocParameters))
82324
+ return;
82325
+ var isJs = ts.isInJSFile(node);
82326
+ var parameters = new ts.Set();
82327
+ var excludedParameters = new ts.Set();
82328
+ ts.forEach(node.parameters, function (_a, index) {
82329
+ var name = _a.name;
82330
+ if (ts.isIdentifier(name)) {
82331
+ parameters.add(name.escapedText);
82332
+ }
82333
+ if (ts.isBindingPattern(name)) {
82334
+ excludedParameters.add(index);
82335
+ }
82336
+ });
82337
+ var containsArguments = containsArgumentsReference(node);
82338
+ if (containsArguments) {
82339
+ var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82340
+ if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82341
+ lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82342
+ errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82343
+ }
82344
+ }
82345
+ else {
82346
+ ts.forEach(jsdocParameters, function (_a, index) {
82347
+ var name = _a.name;
82348
+ if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
82349
+ return;
82350
+ }
82351
+ if (ts.isQualifiedName(name)) {
82352
+ errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82353
+ }
82354
+ else {
82355
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
82356
+ }
82357
+ });
82358
+ }
82359
+ }
82219
82360
  /**
82220
82361
  * Check each type parameter and check that type parameters have no duplicate type parameter declarations
82221
82362
  */
@@ -82832,7 +82973,7 @@ var ts;
82832
82973
  }
82833
82974
  if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
82834
82975
  var propName = member.name;
82835
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
82976
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
82836
82977
  var type = getTypeOfSymbol(getSymbolOfNode(member));
82837
82978
  if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
82838
82979
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
@@ -82867,7 +83008,9 @@ var ts;
82867
83008
  return false;
82868
83009
  }
82869
83010
  function isPropertyInitializedInConstructor(propName, propType, constructor) {
82870
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
83011
+ var reference = ts.isComputedPropertyName(propName)
83012
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
83013
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
82871
83014
  ts.setParent(reference.expression, reference);
82872
83015
  ts.setParent(reference, constructor);
82873
83016
  reference.flowNode = constructor.returnFlowNode;
@@ -83191,7 +83334,7 @@ var ts;
83191
83334
  var isAmbientExternalModule = ts.isAmbientModule(node);
83192
83335
  var contextErrorMessage = isAmbientExternalModule
83193
83336
  ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
83194
- : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
83337
+ : ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
83195
83338
  if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
83196
83339
  // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
83197
83340
  return;
@@ -83424,6 +83567,9 @@ var ts;
83424
83567
  var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83425
83568
  addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
83426
83569
  }
83570
+ if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
83571
+ error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
83572
+ }
83427
83573
  break;
83428
83574
  }
83429
83575
  case 274 /* ExportSpecifier */: {
@@ -83507,7 +83653,7 @@ var ts;
83507
83653
  }
83508
83654
  }
83509
83655
  function checkImportDeclaration(node) {
83510
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
83656
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
83511
83657
  // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
83512
83658
  return;
83513
83659
  }
@@ -83540,7 +83686,7 @@ var ts;
83540
83686
  checkAssertClause(node);
83541
83687
  }
83542
83688
  function checkImportEqualsDeclaration(node) {
83543
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
83689
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
83544
83690
  // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
83545
83691
  return;
83546
83692
  }
@@ -83577,7 +83723,7 @@ var ts;
83577
83723
  }
83578
83724
  }
83579
83725
  function checkExportDeclaration(node) {
83580
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
83726
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
83581
83727
  // If we hit an export in an illegal context, just bail out to avoid cascading errors.
83582
83728
  return;
83583
83729
  }
@@ -84811,7 +84957,7 @@ var ts;
84811
84957
  return errorType;
84812
84958
  }
84813
84959
  if (ts.isBindingPattern(node)) {
84814
- return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
84960
+ return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
84815
84961
  }
84816
84962
  if (isInRightSideOfImportOrExportAssignment(node)) {
84817
84963
  var symbol = getSymbolAtLocation(node);
@@ -114558,9 +114704,9 @@ var ts;
114558
114704
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
114559
114705
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
114560
114706
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
114561
- ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module.code,
114707
+ ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
114562
114708
  ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
114563
- ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module.code,
114709
+ ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
114564
114710
  ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
114565
114711
  ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
114566
114712
  ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
@@ -115628,7 +115774,7 @@ var ts;
115628
115774
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
115629
115775
  var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
115630
115776
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
115631
- var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
115777
+ var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
115632
115778
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
115633
115779
  // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
115634
115780
  // - plain JS: .js files with no // ts-check and checkJs: undefined
@@ -127439,6 +127585,10 @@ var ts;
127439
127585
  return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
127440
127586
  }
127441
127587
  ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
127588
+ function jsxModeNeedsExplicitImport(jsx) {
127589
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
127590
+ }
127591
+ ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
127442
127592
  // #endregion
127443
127593
  })(ts || (ts = {}));
127444
127594
  /*@internal*/
@@ -129383,9 +129533,18 @@ var ts;
129383
129533
  return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
129384
129534
  }
129385
129535
  }
129536
+ function isEmitResolutionKindUsingNodeModules(compilerOptions) {
129537
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
129538
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
129539
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
129540
+ }
129541
+ function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
129542
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
129543
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
129544
+ }
129386
129545
  function getSupportedExtensionsForModuleResolution(compilerOptions) {
129387
129546
  var extensions = ts.getSupportedExtensions(compilerOptions);
129388
- return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
129547
+ return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
129389
129548
  ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
129390
129549
  extensions;
129391
129550
  }
@@ -129548,7 +129707,7 @@ var ts;
129548
129707
  result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
129549
129708
  }
129550
129709
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
129551
- if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) {
129710
+ if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
129552
129711
  // If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
129553
129712
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
129554
129713
  var foundGlobal = false;
@@ -129565,12 +129724,68 @@ var ts;
129565
129724
  }
129566
129725
  }
129567
129726
  if (!foundGlobal) {
129568
- ts.forEachAncestorDirectory(scriptPath, function (ancestor) {
129727
+ var ancestorLookup = function (ancestor) {
129569
129728
  var nodeModules = ts.combinePaths(ancestor, "node_modules");
129570
129729
  if (ts.tryDirectoryExists(host, nodeModules)) {
129571
129730
  getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
129572
129731
  }
129573
- });
129732
+ };
129733
+ if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
129734
+ var nodeModulesDirectoryLookup_1 = ancestorLookup;
129735
+ ancestorLookup = function (ancestor) {
129736
+ var components = ts.getPathComponents(fragment);
129737
+ components.shift(); // shift off empty root
129738
+ var packagePath = components.shift();
129739
+ if (!packagePath) {
129740
+ return nodeModulesDirectoryLookup_1(ancestor);
129741
+ }
129742
+ if (ts.startsWith(packagePath, "@")) {
129743
+ var subName = components.shift();
129744
+ if (!subName) {
129745
+ return nodeModulesDirectoryLookup_1(ancestor);
129746
+ }
129747
+ packagePath = ts.combinePaths(packagePath, subName);
129748
+ }
129749
+ var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
129750
+ if (ts.tryFileExists(host, packageFile)) {
129751
+ var packageJson = ts.readJson(packageFile, host);
129752
+ var exports = packageJson.exports;
129753
+ if (exports) {
129754
+ if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
129755
+ return; // null exports or entrypoint only, no sub-modules available
129756
+ }
129757
+ var keys = ts.getOwnKeys(exports);
129758
+ var fragmentSubpath_1 = components.join("/");
129759
+ var processedKeys = ts.mapDefined(keys, function (k) {
129760
+ if (k === ".")
129761
+ return undefined;
129762
+ if (!ts.startsWith(k, "./"))
129763
+ return undefined;
129764
+ var subpath = k.substring(2);
129765
+ if (!ts.startsWith(subpath, fragmentSubpath_1))
129766
+ return undefined;
129767
+ // subpath is a valid export (barring conditions, which we don't currently check here)
129768
+ if (!ts.stringContains(subpath, "*")) {
129769
+ return subpath;
129770
+ }
129771
+ // pattern export - only return everything up to the `*`, so the user can autocomplete, then
129772
+ // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
129773
+ // but conditions will make that somewhat awkward, as each condition may have a different set of possible
129774
+ // options for the `*`.
129775
+ return subpath.slice(0, subpath.indexOf("*"));
129776
+ });
129777
+ ts.forEach(processedKeys, function (k) {
129778
+ if (k) {
129779
+ result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
129780
+ }
129781
+ });
129782
+ return;
129783
+ }
129784
+ }
129785
+ return nodeModulesDirectoryLookup_1(ancestor);
129786
+ };
129787
+ }
129788
+ ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
129574
129789
  }
129575
129790
  }
129576
129791
  return result;
@@ -130938,7 +131153,8 @@ var ts;
130938
131153
  case 103 /* NewKeyword */:
130939
131154
  return checker.getContextualType(parent);
130940
131155
  case 82 /* CaseKeyword */:
130941
- return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker);
131156
+ var caseClause = ts.tryCast(parent, ts.isCaseClause);
131157
+ return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
130942
131158
  case 18 /* OpenBraceToken */:
130943
131159
  return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
130944
131160
  default:
@@ -133583,7 +133799,24 @@ var ts;
133583
133799
  function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
133584
133800
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
133585
133801
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
133802
+ var oldBucketCount = buckets.size;
133586
133803
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
133804
+ if (ts.tracing) {
133805
+ if (buckets.size > oldBucketCount) {
133806
+ // It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
133807
+ // perhaps they are for two projects that don't have any overlap.
133808
+ // Bonus: these events can help us interpret the more interesting event below.
133809
+ ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
133810
+ }
133811
+ // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
133812
+ // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
133813
+ // Skip .d.ts files to reduce noise (should also cover most of node_modules).
133814
+ var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
133815
+ ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
133816
+ if (otherBucketKey) {
133817
+ ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
133818
+ }
133819
+ }
133587
133820
  var bucketEntry = bucket.get(path);
133588
133821
  var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
133589
133822
  if (!entry && externalCache) {
@@ -137657,7 +137890,27 @@ var ts;
137657
137890
  case 326 /* JSDocAugmentsTag */:
137658
137891
  return withNode(tag.class);
137659
137892
  case 342 /* JSDocTemplateTag */:
137660
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137893
+ var templateTag = tag;
137894
+ var displayParts_3 = [];
137895
+ if (templateTag.constraint) {
137896
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137897
+ }
137898
+ if (ts.length(templateTag.typeParameters)) {
137899
+ if (ts.length(displayParts_3)) {
137900
+ displayParts_3.push(ts.spacePart());
137901
+ }
137902
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137903
+ ts.forEach(templateTag.typeParameters, function (tp) {
137904
+ displayParts_3.push(namePart(tp.getText()));
137905
+ if (lastTypeParameter_1 !== tp) {
137906
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137907
+ }
137908
+ });
137909
+ }
137910
+ if (comment) {
137911
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137912
+ }
137913
+ return displayParts_3;
137661
137914
  case 341 /* JSDocTypeTag */:
137662
137915
  return withNode(tag.typeExpression);
137663
137916
  case 343 /* JSDocTypedefTag */:
@@ -139025,6 +139278,7 @@ var ts;
139025
139278
  return oldImports;
139026
139279
  }
139027
139280
  var typeChecker = program.getTypeChecker();
139281
+ var compilerOptions = program.getCompilerOptions();
139028
139282
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
139029
139283
  var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
139030
139284
  var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
@@ -139081,7 +139335,7 @@ var ts;
139081
139335
  return usedImports;
139082
139336
  function isDeclarationUsed(identifier) {
139083
139337
  // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
139084
- return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
139338
+ return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
139085
139339
  ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
139086
139340
  }
139087
139341
  }
@@ -145699,6 +145953,8 @@ var ts;
145699
145953
  case 179 /* ConstructorType */:
145700
145954
  case 174 /* ConstructSignature */:
145701
145955
  return getList(node.typeParameters) || getList(node.parameters);
145956
+ case 171 /* GetAccessor */:
145957
+ return getList(node.parameters);
145702
145958
  case 256 /* ClassDeclaration */:
145703
145959
  case 225 /* ClassExpression */:
145704
145960
  case 257 /* InterfaceDeclaration */:
@@ -146319,8 +146575,18 @@ var ts;
146319
146575
  var indent = sourceFile.text.slice(startPosition, fnStart);
146320
146576
  this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
146321
146577
  };
146578
+ ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
146579
+ var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
146580
+ return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
146581
+ });
146582
+ var jsDoc = ts.singleOrUndefined(node.jsDoc);
146583
+ return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
146584
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
146585
+ };
146586
+ ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
146587
+ this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
146588
+ };
146322
146589
  ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
146323
- var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
146324
146590
  var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
146325
146591
  var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
146326
146592
  var merged = tryMergeJsdocTags(tag, newTag);
@@ -146328,20 +146594,10 @@ var ts;
146328
146594
  oldTags[i] = merged;
146329
146595
  return !!merged;
146330
146596
  }); });
146331
- var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
146332
- var jsDoc = ts.singleOrUndefined(parent.jsDoc);
146333
- var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
146334
- ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
146335
- var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
146336
- var host = updateJSDocHost(parent);
146337
- this.insertJsdocCommentBefore(sourceFile, host, tag);
146597
+ this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
146338
146598
  };
146339
146599
  ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
146340
- var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
146341
- var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
146342
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray([], (ts.filter(oldTags, predicate) || ts.emptyArray), true)));
146343
- var host = updateJSDocHost(parent);
146344
- this.insertJsdocCommentBefore(sourceFile, host, tag);
146600
+ this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
146345
146601
  };
146346
146602
  ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
146347
146603
  this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
@@ -150136,9 +150392,9 @@ var ts;
150136
150392
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
150137
150393
  var checker = program.getTypeChecker();
150138
150394
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
150139
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
150395
+ var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
150140
150396
  var useRequire = shouldUseRequire(sourceFile, program);
150141
- var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
150397
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
150142
150398
  if (fix) {
150143
150399
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
150144
150400
  }
@@ -150327,7 +150583,7 @@ var ts;
150327
150583
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
150328
150584
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
150329
150585
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
150330
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
150586
+ return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
150331
150587
  }
150332
150588
  function codeFixActionToCodeAction(_a) {
150333
150589
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -150387,7 +150643,7 @@ var ts;
150387
150643
  /*position*/ undefined,
150388
150644
  /*isValidTypeOnlyUseSite*/ false,
150389
150645
  /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
150390
- var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
150646
+ var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
150391
150647
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
150392
150648
  }
150393
150649
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
@@ -150557,7 +150813,7 @@ var ts;
150557
150813
  // 5. Literally nothing to go on
150558
150814
  return true;
150559
150815
  }
150560
- function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, moduleSymbols, host, preferences, fromCacheOnly) {
150816
+ function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
150561
150817
  var isJs = ts.isSourceFileJS(sourceFile);
150562
150818
  var compilerOptions = program.getCompilerOptions();
150563
150819
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
@@ -150566,7 +150822,7 @@ var ts;
150566
150822
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
150567
150823
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
150568
150824
  var computedWithoutCacheCount = 0;
150569
- var fixes = ts.flatMap(moduleSymbols, function (exportInfo) {
150825
+ var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
150570
150826
  var checker = getChecker(exportInfo.isFromPackageJson);
150571
150827
  var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
150572
150828
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
@@ -150575,7 +150831,7 @@ var ts;
150575
150831
  return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
150576
150832
  // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
150577
150833
  return !importedSymbolHasValueMeaning && isJs && position !== undefined
150578
- ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
150834
+ ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
150579
150835
  : {
150580
150836
  kind: 3 /* AddNew */,
150581
150837
  moduleSpecifier: moduleSpecifier,
@@ -150583,6 +150839,7 @@ var ts;
150583
150839
  useRequire: useRequire,
150584
150840
  addAsTypeOnly: addAsTypeOnly,
150585
150841
  exportInfo: exportInfo,
150842
+ isReExport: i > 0,
150586
150843
  };
150587
150844
  });
150588
150845
  });
@@ -150620,12 +150877,13 @@ var ts;
150620
150877
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150621
150878
  }
150622
150879
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150623
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150880
+ return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
150624
150881
  }
150625
- function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
150626
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
150882
+ function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
150883
+ var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
150884
+ return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
150627
150885
  }
150628
- function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
150886
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
150629
150887
  if (!ts.some(fixes))
150630
150888
  return;
150631
150889
  // These will always be placed first if available, and are better than other kinds
@@ -150634,22 +150892,37 @@ var ts;
150634
150892
  }
150635
150893
  return fixes.reduce(function (best, fix) {
150636
150894
  // Takes true branch of conditional if `fix` is better than `best`
150637
- return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
150895
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
150638
150896
  });
150639
150897
  }
150640
150898
  /** @returns `Comparison.LessThan` if `a` is better than `b`. */
150641
- function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
150899
+ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
150642
150900
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
150643
150901
  return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
150644
150902
  || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
150645
- || ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
150903
+ || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
150646
150904
  || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
150647
150905
  }
150648
150906
  return 0 /* EqualTo */;
150649
150907
  }
150650
- var notDotOrSlashPattern = /[^.\/]/;
150651
- function isOnlyDotsAndSlashes(path) {
150652
- return !notDotOrSlashPattern.test(path);
150908
+ // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
150909
+ // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
150910
+ // This can produce false positives or negatives if re-exports cross into sibling directories
150911
+ // (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
150912
+ // this if we're in a resolution mode where you can't drop trailing "/index" from paths).
150913
+ function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
150914
+ var _a;
150915
+ if (fix.isReExport &&
150916
+ ((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
150917
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
150918
+ isIndexFileName(fix.exportInfo.moduleFileName)) {
150919
+ var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
150920
+ return ts.startsWith((importingFile.path), reExportDir);
150921
+ }
150922
+ return false;
150923
+ }
150924
+ function isIndexFileName(fileName) {
150925
+ return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
150653
150926
  }
150654
150927
  function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
150655
150928
  if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
@@ -150667,9 +150940,9 @@ var ts;
150667
150940
  return undefined;
150668
150941
  var symbol = checker.getAliasedSymbol(umdSymbol);
150669
150942
  var symbolName = umdSymbol.name;
150670
- var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150943
+ var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150671
150944
  var useRequire = shouldUseRequire(sourceFile, program);
150672
- var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150945
+ var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150673
150946
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
150674
150947
  }
150675
150948
  function getUmdSymbol(token, checker) {
@@ -150736,8 +151009,8 @@ var ts;
150736
151009
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
150737
151010
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
150738
151011
  var useRequire = shouldUseRequire(sourceFile, program);
150739
- var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150740
- var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
151012
+ var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
151013
+ var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
150741
151014
  var _ = _a[0], exportInfos = _a[1];
150742
151015
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150743
151016
  }));
@@ -150753,12 +151026,9 @@ var ts;
150753
151026
  return undefined;
150754
151027
  return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150755
151028
  }
150756
- function jsxModeNeedsExplicitImport(jsx) {
150757
- return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150758
- }
150759
151029
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
150760
151030
  var parent = symbolToken.parent;
150761
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
151031
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150762
151032
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150763
151033
  if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150764
151034
  return jsxNamespace;
@@ -152838,6 +153108,95 @@ var ts;
152838
153108
  })(ts || (ts = {}));
152839
153109
  /* @internal */
152840
153110
  var ts;
153111
+ (function (ts) {
153112
+ var codefix;
153113
+ (function (codefix) {
153114
+ var deleteUnmatchedParameter = "deleteUnmatchedParameter";
153115
+ var renameUnmatchedParameter = "renameUnmatchedParameter";
153116
+ var errorCodes = [
153117
+ ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
153118
+ ];
153119
+ codefix.registerCodeFix({
153120
+ fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
153121
+ errorCodes: errorCodes,
153122
+ getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
153123
+ var sourceFile = context.sourceFile, span = context.span;
153124
+ var actions = [];
153125
+ var info = getInfo(sourceFile, span.start);
153126
+ if (info) {
153127
+ ts.append(actions, getDeleteAction(context, info));
153128
+ ts.append(actions, getRenameAction(context, info));
153129
+ return actions;
153130
+ }
153131
+ return undefined;
153132
+ },
153133
+ getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
153134
+ var tagsToSignature = new ts.Map();
153135
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
153136
+ codefix.eachDiagnostic(context, errorCodes, function (_a) {
153137
+ var file = _a.file, start = _a.start;
153138
+ var info = getInfo(file, start);
153139
+ if (info) {
153140
+ tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
153141
+ }
153142
+ });
153143
+ tagsToSignature.forEach(function (tags, signature) {
153144
+ if (context.fixId === deleteUnmatchedParameter) {
153145
+ var tagsSet_1 = new ts.Set(tags);
153146
+ changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
153147
+ }
153148
+ });
153149
+ }));
153150
+ }
153151
+ });
153152
+ function getDeleteAction(context, _a) {
153153
+ var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
153154
+ var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
153155
+ return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
153156
+ });
153157
+ return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
153158
+ }
153159
+ function getRenameAction(context, _a) {
153160
+ var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
153161
+ if (!ts.length(signature.parameters))
153162
+ return undefined;
153163
+ var sourceFile = context.sourceFile;
153164
+ var tags = ts.getJSDocTags(signature);
153165
+ var names = new ts.Set();
153166
+ for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
153167
+ var tag = tags_2[_i];
153168
+ if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
153169
+ names.add(tag.name.escapedText);
153170
+ }
153171
+ }
153172
+ // @todo - match to all available names instead to the first parameter name
153173
+ // @see /codeFixRenameUnmatchedParameter3.ts
153174
+ var parameterName = ts.firstDefined(signature.parameters, function (p) {
153175
+ return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
153176
+ });
153177
+ if (parameterName === undefined)
153178
+ return undefined;
153179
+ var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
153180
+ var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
153181
+ return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
153182
+ });
153183
+ return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
153184
+ }
153185
+ function getInfo(sourceFile, pos) {
153186
+ var token = ts.getTokenAtPosition(sourceFile, pos);
153187
+ if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
153188
+ var jsDocParameterTag = token.parent;
153189
+ var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
153190
+ if (signature) {
153191
+ return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
153192
+ }
153193
+ }
153194
+ return undefined;
153195
+ }
153196
+ })(codefix = ts.codefix || (ts.codefix = {}));
153197
+ })(ts || (ts = {}));
153198
+ /* @internal */
153199
+ var ts;
152841
153200
  (function (ts) {
152842
153201
  var codefix;
152843
153202
  (function (codefix) {
@@ -153135,6 +153494,9 @@ var ts;
153135
153494
  case 172 /* SetAccessor */:
153136
153495
  // Setter must have a parameter
153137
153496
  return false;
153497
+ case 171 /* GetAccessor */:
153498
+ // Getter cannot have parameters
153499
+ return true;
153138
153500
  default:
153139
153501
  return ts.Debug.failBadSyntaxKind(parent);
153140
153502
  }
@@ -155745,10 +156107,12 @@ var ts;
155745
156107
  });
155746
156108
  function getInfo(sourceFile, pos) {
155747
156109
  var token = ts.getTokenAtPosition(sourceFile, pos);
155748
- var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration);
155749
- if (ts.isClassDeclaration(indexSignature.parent))
156110
+ var indexSignature = ts.tryCast(token.parent.parent, ts.isIndexSignatureDeclaration);
156111
+ if (!indexSignature)
156112
+ return undefined;
156113
+ var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.tryCast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
156114
+ if (!container)
155750
156115
  return undefined;
155751
- var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
155752
156116
  return { indexSignature: indexSignature, container: container };
155753
156117
  }
155754
156118
  function createTypeAliasFromInterface(declaration, type) {
@@ -156285,51 +156649,53 @@ var ts;
156285
156649
  (function (ts) {
156286
156650
  var refactor;
156287
156651
  (function (refactor) {
156652
+ var _a;
156288
156653
  var refactorName = "Convert import";
156289
- var namespaceToNamedAction = {
156290
- name: "Convert namespace import to named imports",
156291
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156292
- kind: "refactor.rewrite.import.named",
156293
- };
156294
- var namedToNamespaceAction = {
156295
- name: "Convert named imports to namespace import",
156296
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156297
- kind: "refactor.rewrite.import.namespace",
156298
- };
156654
+ var actions = (_a = {},
156655
+ _a[0 /* Named */] = {
156656
+ name: "Convert namespace import to named imports",
156657
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156658
+ kind: "refactor.rewrite.import.named",
156659
+ },
156660
+ _a[2 /* Namespace */] = {
156661
+ name: "Convert named imports to namespace import",
156662
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156663
+ kind: "refactor.rewrite.import.namespace",
156664
+ },
156665
+ _a[1 /* Default */] = {
156666
+ name: "Convert named imports to default import",
156667
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
156668
+ kind: "refactor.rewrite.import.default",
156669
+ },
156670
+ _a);
156299
156671
  refactor.registerRefactor(refactorName, {
156300
- kinds: [
156301
- namespaceToNamedAction.kind,
156302
- namedToNamespaceAction.kind
156303
- ],
156672
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
156304
156673
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
156305
- var info = getImportToConvert(context, context.triggerReason === "invoked");
156674
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
156306
156675
  if (!info)
156307
156676
  return ts.emptyArray;
156308
156677
  if (!refactor.isRefactorErrorInfo(info)) {
156309
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
156310
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
156678
+ var action = actions[info.convertTo];
156311
156679
  return [{ name: refactorName, description: action.description, actions: [action] }];
156312
156680
  }
156313
156681
  if (context.preferences.provideRefactorNotApplicableReason) {
156314
- return [
156315
- { name: refactorName, description: namespaceToNamedAction.description,
156316
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
156317
- { name: refactorName, description: namedToNamespaceAction.description,
156318
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
156319
- ];
156682
+ return ts.getOwnValues(actions).map(function (action) { return ({
156683
+ name: refactorName,
156684
+ description: action.description,
156685
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
156686
+ }); });
156320
156687
  }
156321
156688
  return ts.emptyArray;
156322
156689
  },
156323
156690
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
156324
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
156325
- var info = getImportToConvert(context);
156691
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
156692
+ var info = getImportConversionInfo(context);
156326
156693
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
156327
156694
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
156328
156695
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
156329
156696
  }
156330
156697
  });
156331
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
156332
- function getImportToConvert(context, considerPartialSpans) {
156698
+ function getImportConversionInfo(context, considerPartialSpans) {
156333
156699
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
156334
156700
  var file = context.file;
156335
156701
  var span = ts.getRefactorContextSpan(context);
@@ -156348,15 +156714,23 @@ var ts;
156348
156714
  if (!importClause.namedBindings) {
156349
156715
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
156350
156716
  }
156351
- return importClause.namedBindings;
156717
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
156718
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
156719
+ }
156720
+ var compilerOptions = context.program.getCompilerOptions();
156721
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
156722
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
156723
+ return shouldUseDefault
156724
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
156725
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
156352
156726
  }
156353
- function doChange(sourceFile, program, changes, toConvert) {
156727
+ function doChange(sourceFile, program, changes, info) {
156354
156728
  var checker = program.getTypeChecker();
156355
- if (toConvert.kind === 267 /* NamespaceImport */) {
156356
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156729
+ if (info.convertTo === 0 /* Named */) {
156730
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156357
156731
  }
156358
156732
  else {
156359
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
156733
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
156360
156734
  }
156361
156735
  }
156362
156736
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -156406,7 +156780,7 @@ var ts;
156406
156780
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
156407
156781
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
156408
156782
  }
156409
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
156783
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
156410
156784
  var importDecl = toConvert.parent.parent;
156411
156785
  var moduleSpecifier = importDecl.moduleSpecifier;
156412
156786
  var toConvertSymbols = new ts.Set();
@@ -156457,7 +156831,9 @@ var ts;
156457
156831
  var element = _a[_i];
156458
156832
  _loop_17(element);
156459
156833
  }
156460
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156834
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
156835
+ ? ts.factory.createIdentifier(namespaceImportName)
156836
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156461
156837
  if (neededNamedImports.size) {
156462
156838
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
156463
156839
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -156465,6 +156841,13 @@ var ts;
156465
156841
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
156466
156842
  }
156467
156843
  }
156844
+ function isExportEqualsModule(moduleSpecifier, checker) {
156845
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
156846
+ if (!externalModule)
156847
+ return false;
156848
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
156849
+ return externalModule !== exportEquals;
156850
+ }
156468
156851
  function updateImport(old, defaultImportName, elements) {
156469
156852
  return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
156470
156853
  }
@@ -157320,8 +157703,8 @@ var ts;
157320
157703
  // but a super *method call* simply implies a 'this' reference
157321
157704
  if (node.parent.kind === 207 /* CallExpression */) {
157322
157705
  // Super constructor call
157323
- var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217
157324
- if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
157706
+ var containingClass_1 = ts.getContainingClass(node);
157707
+ if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
157325
157708
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
157326
157709
  return true;
157327
157710
  }
@@ -171723,9 +172106,10 @@ var ts;
171723
172106
  var info = infos && ts.firstOrUndefined(infos);
171724
172107
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
171725
172108
  }
171726
- function combineProjectOutputForReferences(projects, defaultProject, initialLocation) {
172109
+ function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
171727
172110
  var outputs = [];
171728
172111
  combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) {
172112
+ logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
171729
172113
  var _loop_8 = function (outputReferencedSymbol) {
171730
172114
  var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
171731
172115
  var definition = mappedDefinitionFile === undefined ?
@@ -173083,7 +173467,7 @@ var ts;
173083
173467
  var file = server.toNormalizedPath(args.file);
173084
173468
  var projects = this.getProjects(args);
173085
173469
  var position = this.getPositionInFile(args, file);
173086
- var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position });
173470
+ var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
173087
173471
  if (!simplifiedResult)
173088
173472
  return references;
173089
173473
  var defaultProject = this.getDefaultProject(args);