@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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220204";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220211";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -1274,11 +1274,11 @@ var ts;
1274
1274
  return result;
1275
1275
  }
1276
1276
  ts.getAllKeys = getAllKeys;
1277
- function getOwnValues(sparseArray) {
1277
+ function getOwnValues(collection) {
1278
1278
  var values = [];
1279
- for (var key in sparseArray) {
1280
- if (hasOwnProperty.call(sparseArray, key)) {
1281
- values.push(sparseArray[key]);
1279
+ for (var key in collection) {
1280
+ if (hasOwnProperty.call(collection, key)) {
1281
+ values.push(collection[key]);
1282
1282
  }
1283
1283
  }
1284
1284
  return values;
@@ -7636,18 +7636,6 @@ var ts;
7636
7636
  return getCanonicalFileName(nonCanonicalizedPath);
7637
7637
  }
7638
7638
  ts.toPath = toPath;
7639
- function normalizePathAndParts(path) {
7640
- path = normalizeSlashes(path);
7641
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7642
- if (parts.length) {
7643
- var joinedParts = root + parts.join(ts.directorySeparator);
7644
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7645
- }
7646
- else {
7647
- return { path: root, parts: parts };
7648
- }
7649
- }
7650
- ts.normalizePathAndParts = normalizePathAndParts;
7651
7639
  function removeTrailingDirectorySeparator(path) {
7652
7640
  if (hasTrailingDirectorySeparator(path)) {
7653
7641
  return path.substr(0, path.length - 1);
@@ -8045,10 +8033,10 @@ var ts;
8045
8033
  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."),
8046
8034
  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."),
8047
8035
  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."),
8048
- 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."),
8049
- 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."),
8036
+ 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."),
8037
+ 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."),
8050
8038
  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."),
8051
- 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."),
8039
+ 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."),
8052
8040
  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'."),
8053
8041
  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'."),
8054
8042
  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."),
@@ -8080,6 +8068,7 @@ var ts;
8080
8068
  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."),
8081
8069
  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."),
8082
8070
  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."),
8071
+ 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."),
8083
8072
  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."),
8084
8073
  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."),
8085
8074
  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."),
@@ -8216,6 +8205,8 @@ var ts;
8216
8205
  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."),
8217
8206
  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."),
8218
8207
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8208
+ 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."),
8209
+ 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."),
8219
8210
  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."),
8220
8211
  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."),
8221
8212
  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),
@@ -9635,6 +9626,10 @@ var ts;
9635
9626
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9636
9627
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9637
9628
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9629
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9630
+ Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
9631
+ Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
9632
+ 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}'"),
9638
9633
  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."),
9639
9634
  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'."),
9640
9635
  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?"),
@@ -13896,6 +13891,10 @@ var ts;
13896
13891
  return undefined;
13897
13892
  }
13898
13893
  ts.getDeclarationOfKind = getDeclarationOfKind;
13894
+ function getDeclarationsOfKind(symbol, kind) {
13895
+ return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
13896
+ }
13897
+ ts.getDeclarationsOfKind = getDeclarationsOfKind;
13899
13898
  function createSymbolTable(symbols) {
13900
13899
  var result = new ts.Map();
13901
13900
  if (symbols) {
@@ -14131,6 +14130,10 @@ var ts;
14131
14130
  return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
14132
14131
  }
14133
14132
  ts.getSourceFileOfModule = getSourceFileOfModule;
14133
+ function isPlainJsFile(file, checkJs) {
14134
+ return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
14135
+ }
14136
+ ts.isPlainJsFile = isPlainJsFile;
14134
14137
  function isStatementWithLocals(node) {
14135
14138
  switch (node.kind) {
14136
14139
  case 234 /* Block */:
@@ -41706,7 +41709,7 @@ var ts;
41706
41709
  result_4 = searchResult && searchResult.value;
41707
41710
  }
41708
41711
  else {
41709
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
41712
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
41710
41713
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
41711
41714
  }
41712
41715
  return resolvedTypeScriptOnly(result_4);
@@ -42409,13 +42412,25 @@ var ts;
42409
42412
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
42410
42413
  }
42411
42414
  else {
42412
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
42415
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
42413
42416
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
42414
42417
  // Treat explicit "node_modules" import as an external library import.
42415
42418
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
42416
42419
  }
42417
42420
  }
42418
42421
  }
42422
+ // If you import from "." inside a containing directory "/foo", the result of `normalizePath`
42423
+ // would be "/foo", but this loses the information that `foo` is a directory and we intended
42424
+ // to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
42425
+ // (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
42426
+ // in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
42427
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
42428
+ var combined = ts.combinePaths(containingDirectory, moduleName);
42429
+ var parts = ts.getPathComponents(combined);
42430
+ var lastPart = ts.lastOrUndefined(parts);
42431
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
42432
+ return { path: path, parts: parts };
42433
+ }
42419
42434
  function realPath(path, host, traceEnabled) {
42420
42435
  if (!host.realpath) {
42421
42436
  return path;
@@ -44163,7 +44178,7 @@ var ts;
44163
44178
  return ts.isDottedName(expr)
44164
44179
  || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
44165
44180
  || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right)
44166
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
44181
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isIdentifier(expr.argumentExpression)) && isNarrowableReference(expr.expression)
44167
44182
  || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
44168
44183
  }
44169
44184
  function containsNarrowableReference(expr) {
@@ -46908,6 +46923,9 @@ var ts;
46908
46923
  CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
46909
46924
  CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
46910
46925
  CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
46926
+ CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
46927
+ // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
46928
+ // we need to preserve generic types instead of substituting them for constraints
46911
46929
  })(CheckMode || (CheckMode = {}));
46912
46930
  var SignatureCheckMode;
46913
46931
  (function (SignatureCheckMode) {
@@ -47960,13 +47978,13 @@ var ts;
47960
47978
  else { // error
47961
47979
  var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
47962
47980
  var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
47963
- var message = isEitherEnum
47964
- ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
47965
- : isEitherBlockScoped_1
47966
- ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
47981
+ var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
47982
+ : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
47967
47983
  : ts.Diagnostics.Duplicate_identifier_0;
47968
47984
  var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
47969
47985
  var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
47986
+ var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
47987
+ var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
47970
47988
  var symbolName_1 = symbolToString(source);
47971
47989
  // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
47972
47990
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
@@ -47978,12 +47996,16 @@ var ts;
47978
47996
  var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
47979
47997
  return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
47980
47998
  });
47981
- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
47982
- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
47999
+ if (!isSourcePlainJs)
48000
+ addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
48001
+ if (!isTargetPlainJs)
48002
+ addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
47983
48003
  }
47984
48004
  else {
47985
- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
47986
- addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
48005
+ if (!isSourcePlainJs)
48006
+ addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
48007
+ if (!isTargetPlainJs)
48008
+ addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
47987
48009
  }
47988
48010
  }
47989
48011
  return target;
@@ -48440,6 +48462,8 @@ var ts;
48440
48462
  // type parameters are visible in parameter list, return type and type parameter list
48441
48463
  ? lastLocation === location.type ||
48442
48464
  lastLocation.kind === 163 /* Parameter */ ||
48465
+ lastLocation.kind === 338 /* JSDocParameterTag */ ||
48466
+ lastLocation.kind === 339 /* JSDocReturnTag */ ||
48443
48467
  lastLocation.kind === 162 /* TypeParameter */
48444
48468
  // local types not visible outside the function body
48445
48469
  : false;
@@ -48699,9 +48723,9 @@ var ts;
48699
48723
  lastSelfReferenceLocation = location;
48700
48724
  }
48701
48725
  lastLocation = location;
48702
- location = ts.isJSDocTemplateTag(location) ?
48703
- ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
48704
- location.parent;
48726
+ location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
48727
+ ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
48728
+ location.parent;
48705
48729
  }
48706
48730
  // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
48707
48731
  // If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
@@ -49835,16 +49859,20 @@ var ts;
49835
49859
  return;
49836
49860
  }
49837
49861
  var host = ts.getJSDocHost(node);
49838
- if (host &&
49839
- ts.isExpressionStatement(host) &&
49840
- ts.isBinaryExpression(host.expression) &&
49841
- ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
49842
- // X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
49862
+ if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
49863
+ // /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
49843
49864
  var symbol = getSymbolOfNode(host.expression.left);
49844
49865
  if (symbol) {
49845
49866
  return getDeclarationOfJSPrototypeContainer(symbol);
49846
49867
  }
49847
49868
  }
49869
+ if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
49870
+ // X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
49871
+ var symbol = getSymbolOfNode(host.parent.left);
49872
+ if (symbol) {
49873
+ return getDeclarationOfJSPrototypeContainer(symbol);
49874
+ }
49875
+ }
49848
49876
  if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
49849
49877
  ts.isBinaryExpression(host.parent.parent) &&
49850
49878
  ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
@@ -54331,9 +54359,12 @@ var ts;
54331
54359
  }
54332
54360
  // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
54333
54361
  // assigned by contextual typing.
54334
- function getTypeForBindingElementParent(node) {
54362
+ function getTypeForBindingElementParent(node, checkMode) {
54363
+ if (checkMode !== 0 /* Normal */) {
54364
+ return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54365
+ }
54335
54366
  var symbol = getSymbolOfNode(node);
54336
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
54367
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54337
54368
  }
54338
54369
  function getRestType(source, properties, symbol) {
54339
54370
  source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
@@ -54451,7 +54482,8 @@ var ts;
54451
54482
  }
54452
54483
  /** Return the inferred type for a binding element */
54453
54484
  function getTypeForBindingElement(declaration) {
54454
- var parentType = getTypeForBindingElementParent(declaration.parent.parent);
54485
+ var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
54486
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
54455
54487
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
54456
54488
  }
54457
54489
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -54523,9 +54555,9 @@ var ts;
54523
54555
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
54524
54556
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
54525
54557
  // undefined from the final type.
54526
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54558
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54527
54559
  }
54528
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
54560
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
54529
54561
  }
54530
54562
  function getTypeForDeclarationFromJSDocComment(declaration) {
54531
54563
  var jsdocType = ts.getJSDocType(declaration);
@@ -54548,11 +54580,11 @@ var ts;
54548
54580
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
54549
54581
  }
54550
54582
  // Return the inferred type for a variable, parameter, or property declaration
54551
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
54583
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
54552
54584
  // A variable declared in a for..in statement is of type string, or of type keyof T when the
54553
54585
  // right hand expression is of a type parameter type.
54554
54586
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
54555
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
54587
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
54556
54588
  return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
54557
54589
  }
54558
54590
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
@@ -54607,12 +54639,9 @@ var ts;
54607
54639
  }
54608
54640
  }
54609
54641
  if (ts.isInJSFile(declaration)) {
54610
- var typeTag = ts.getJSDocType(func);
54611
- if (typeTag && ts.isFunctionTypeNode(typeTag)) {
54612
- var signature = getSignatureFromDeclaration(typeTag);
54613
- var pos = func.parameters.indexOf(declaration);
54614
- return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
54615
- }
54642
+ var type_1 = getParameterTypeOfTypeTag(func, declaration);
54643
+ if (type_1)
54644
+ return type_1;
54616
54645
  }
54617
54646
  // Use contextual parameter type if one is available
54618
54647
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
@@ -54629,7 +54658,7 @@ var ts;
54629
54658
  return containerObjectType;
54630
54659
  }
54631
54660
  }
54632
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
54661
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
54633
54662
  return addOptionality(type, isProperty, isOptional);
54634
54663
  }
54635
54664
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -55001,7 +55030,7 @@ var ts;
55001
55030
  // contextual type or, if the element itself is a binding pattern, with the type implied by that binding
55002
55031
  // pattern.
55003
55032
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
55004
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
55033
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
55005
55034
  }
55006
55035
  if (ts.isBindingPattern(element.name)) {
55007
55036
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -55090,7 +55119,7 @@ var ts;
55090
55119
  // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
55091
55120
  // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
55092
55121
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
55093
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
55122
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
55094
55123
  }
55095
55124
  function isGlobalSymbolConstructor(node) {
55096
55125
  var symbol = getSymbolOfNode(node);
@@ -55179,9 +55208,9 @@ var ts;
55179
55208
  if (typeNode === undefined) {
55180
55209
  return useUnknownInCatchVariables ? unknownType : anyType;
55181
55210
  }
55182
- var type_1 = getTypeOfNode(typeNode);
55211
+ var type_2 = getTypeOfNode(typeNode);
55183
55212
  // an errorType will make `checkTryStatement` issue an error
55184
- return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
55213
+ return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
55185
55214
  }
55186
55215
  // Handle export default expressions
55187
55216
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -55319,10 +55348,12 @@ var ts;
55319
55348
  if (writing === void 0) { writing = false; }
55320
55349
  var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
55321
55350
  var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
55322
- var setterType = getAnnotatedAccessorType(setter);
55323
55351
  // For write operations, prioritize type annotations on the setter
55324
- if (writing && setterType) {
55325
- return instantiateTypeIfNeeded(setterType, symbol);
55352
+ if (writing) {
55353
+ var setterType_1 = getAnnotatedAccessorType(setter);
55354
+ if (setterType_1) {
55355
+ return instantiateTypeIfNeeded(setterType_1, symbol);
55356
+ }
55326
55357
  }
55327
55358
  // Else defer to the getter type
55328
55359
  if (getter && ts.isInJSFile(getter)) {
@@ -55337,6 +55368,7 @@ var ts;
55337
55368
  return instantiateTypeIfNeeded(getterType, symbol);
55338
55369
  }
55339
55370
  // If the user didn't specify a return type, try to use the set-accessor's parameter type.
55371
+ var setterType = getAnnotatedAccessorType(setter);
55340
55372
  if (setterType) {
55341
55373
  return setterType;
55342
55374
  }
@@ -55407,11 +55439,11 @@ var ts;
55407
55439
  return errorType;
55408
55440
  }
55409
55441
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
55410
- var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
55442
+ var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
55411
55443
  if (!popTypeResolution()) {
55412
55444
  return reportCircularityError(symbol);
55413
55445
  }
55414
- return type_2;
55446
+ return type_3;
55415
55447
  }
55416
55448
  }
55417
55449
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -55485,6 +55517,39 @@ var ts;
55485
55517
  }
55486
55518
  return links.type;
55487
55519
  }
55520
+ function getWriteTypeOfSymbolWithDeferredType(symbol) {
55521
+ var links = getSymbolLinks(symbol);
55522
+ if (!links.writeType && links.deferralWriteConstituents) {
55523
+ ts.Debug.assertIsDefined(links.deferralParent);
55524
+ ts.Debug.assertIsDefined(links.deferralConstituents);
55525
+ links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
55526
+ }
55527
+ return links.writeType;
55528
+ }
55529
+ /**
55530
+ * Distinct write types come only from set accessors, but union and intersection
55531
+ * properties deriving from set accessors will either pre-compute or defer the
55532
+ * union or intersection of the writeTypes of their constituents. To account for
55533
+ * this, we will assume that any deferred type or transient symbol may have a
55534
+ * `writeType` (or a deferred write type ready to be computed) that should be
55535
+ * used before looking for set accessor declarations.
55536
+ */
55537
+ function getWriteTypeOfSymbol(symbol) {
55538
+ var checkFlags = ts.getCheckFlags(symbol);
55539
+ if (checkFlags & 65536 /* DeferredType */) {
55540
+ var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
55541
+ if (writeType) {
55542
+ return writeType;
55543
+ }
55544
+ }
55545
+ if (symbol.flags & 33554432 /* Transient */) {
55546
+ var writeType = symbol.writeType;
55547
+ if (writeType) {
55548
+ return writeType;
55549
+ }
55550
+ }
55551
+ return getSetAccessorTypeOfSymbol(symbol);
55552
+ }
55488
55553
  function getSetAccessorTypeOfSymbol(symbol) {
55489
55554
  if (symbol.flags & 98304 /* Accessor */) {
55490
55555
  var type = getTypeOfSetAccessor(symbol);
@@ -57610,10 +57675,10 @@ var ts;
57610
57675
  var baseTypes = [];
57611
57676
  var different = false;
57612
57677
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
57613
- var type_3 = types_7[_i];
57614
- var baseType = getBaseConstraint(type_3);
57678
+ var type_4 = types_7[_i];
57679
+ var baseType = getBaseConstraint(type_4);
57615
57680
  if (baseType) {
57616
- if (baseType !== type_3) {
57681
+ if (baseType !== type_4) {
57617
57682
  different = true;
57618
57683
  }
57619
57684
  baseTypes.push(baseType);
@@ -57855,6 +57920,7 @@ var ts;
57855
57920
  var firstType;
57856
57921
  var nameType;
57857
57922
  var propTypes = [];
57923
+ var writeTypes;
57858
57924
  var firstValueDeclaration;
57859
57925
  var hasNonUniformValueDeclaration = false;
57860
57926
  for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
@@ -57871,6 +57937,10 @@ var ts;
57871
57937
  firstType = type;
57872
57938
  nameType = getSymbolLinks(prop).nameType;
57873
57939
  }
57940
+ var writeType = getWriteTypeOfSymbol(prop);
57941
+ if (writeTypes || writeType !== type) {
57942
+ writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
57943
+ }
57874
57944
  else if (type !== firstType) {
57875
57945
  checkFlags |= 64 /* HasNonUniformType */;
57876
57946
  }
@@ -57899,9 +57969,13 @@ var ts;
57899
57969
  result.checkFlags |= 65536 /* DeferredType */;
57900
57970
  result.deferralParent = containingType;
57901
57971
  result.deferralConstituents = propTypes;
57972
+ result.deferralWriteConstituents = writeTypes;
57902
57973
  }
57903
57974
  else {
57904
57975
  result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
57976
+ if (writeTypes) {
57977
+ result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
57978
+ }
57905
57979
  }
57906
57980
  return result;
57907
57981
  }
@@ -58317,6 +58391,13 @@ var ts;
58317
58391
  var typeTag = ts.getJSDocTypeTag(node);
58318
58392
  return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
58319
58393
  }
58394
+ function getParameterTypeOfTypeTag(func, parameter) {
58395
+ var signature = getSignatureOfTypeTag(func);
58396
+ if (!signature)
58397
+ return undefined;
58398
+ var pos = func.parameters.indexOf(parameter);
58399
+ return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
58400
+ }
58320
58401
  function getReturnTypeOfTypeTag(node) {
58321
58402
  var signature = getSignatureOfTypeTag(node);
58322
58403
  return signature && getReturnTypeOfSignature(signature);
@@ -59043,7 +59124,7 @@ var ts;
59043
59124
  }
59044
59125
  function getImpliedConstraint(type, checkNode, extendsNode) {
59045
59126
  return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
59046
- getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
59127
+ getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
59047
59128
  undefined;
59048
59129
  }
59049
59130
  function getConditionalFlowTypeOfType(type, node) {
@@ -59509,7 +59590,7 @@ var ts;
59509
59590
  }
59510
59591
  }
59511
59592
  var fixedLength = properties.length;
59512
- var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
59593
+ var lengthSymbol = createSymbol(4 /* Property */, "length");
59513
59594
  if (combinedFlags & 12 /* Variable */) {
59514
59595
  lengthSymbol.type = numberType;
59515
59596
  }
@@ -67724,8 +67805,9 @@ var ts;
67724
67805
  return isMatchingReference(source.expression, target);
67725
67806
  case 205 /* PropertyAccessExpression */:
67726
67807
  case 206 /* ElementAccessExpression */:
67727
- return ts.isAccessExpression(target) &&
67728
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
67808
+ var sourcePropertyName = getAccessedPropertyName(source);
67809
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
67810
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
67729
67811
  isMatchingReference(source.expression, target.expression);
67730
67812
  case 160 /* QualifiedName */:
67731
67813
  return ts.isAccessExpression(target) &&
@@ -67737,12 +67819,49 @@ var ts;
67737
67819
  return false;
67738
67820
  }
67739
67821
  function getAccessedPropertyName(access) {
67740
- var propertyName;
67741
- return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67742
- access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67743
- access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67744
- access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67745
- undefined;
67822
+ if (ts.isPropertyAccessExpression(access)) {
67823
+ return access.name.escapedText;
67824
+ }
67825
+ if (ts.isElementAccessExpression(access)) {
67826
+ return tryGetElementAccessExpressionName(access);
67827
+ }
67828
+ if (ts.isBindingElement(access)) {
67829
+ var name = getDestructuringPropertyName(access);
67830
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
67831
+ }
67832
+ if (ts.isParameter(access)) {
67833
+ return ("" + access.parent.parameters.indexOf(access));
67834
+ }
67835
+ return undefined;
67836
+ }
67837
+ function tryGetNameFromType(type) {
67838
+ return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName :
67839
+ type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
67840
+ }
67841
+ function tryGetElementAccessExpressionName(node) {
67842
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
67843
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
67844
+ }
67845
+ if (ts.isIdentifier(node.argumentExpression)) {
67846
+ var symbol = getResolvedSymbol(node.argumentExpression);
67847
+ if (!isConstVariable(symbol))
67848
+ return undefined;
67849
+ var declaration = symbol.valueDeclaration;
67850
+ if (declaration === undefined)
67851
+ return undefined;
67852
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
67853
+ if (type) {
67854
+ var name = tryGetNameFromType(type);
67855
+ if (name !== undefined) {
67856
+ return name;
67857
+ }
67858
+ }
67859
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
67860
+ var initializer = ts.getEffectiveInitializer(declaration);
67861
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
67862
+ }
67863
+ }
67864
+ return undefined;
67746
67865
  }
67747
67866
  function containsMatchingReference(source, target) {
67748
67867
  while (ts.isAccessExpression(source)) {
@@ -69852,12 +69971,16 @@ var ts;
69852
69971
  function isGenericTypeWithoutNullableConstraint(type) {
69853
69972
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
69854
69973
  }
69855
- function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
69974
+ function hasContextualTypeWithNoGenericTypes(node, checkMode) {
69856
69975
  // Computing the contextual type for a child of a JSX element involves resolving the type of the
69857
69976
  // element's tag name, so we exclude that here to avoid circularities.
69977
+ // If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
69978
+ // as we want the type of a rest element to be generic when possible.
69858
69979
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
69859
69980
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
69860
- getContextualType(node, 8 /* SkipBindingPatterns */);
69981
+ (checkMode && checkMode & 32 /* RestBindingElement */ ?
69982
+ getContextualType(node, 8 /* SkipBindingPatterns */)
69983
+ : getContextualType(node));
69861
69984
  return contextualType && !isGenericType(contextualType);
69862
69985
  }
69863
69986
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -69870,7 +69993,7 @@ var ts;
69870
69993
  // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
69871
69994
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69872
69995
  someType(type, isGenericTypeWithUnionConstraint) &&
69873
- (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69996
+ (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
69874
69997
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69875
69998
  }
69876
69999
  function isExportOrExportExpression(location) {
@@ -69938,7 +70061,7 @@ var ts;
69938
70061
  var links = getNodeLinks(location);
69939
70062
  if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69940
70063
  links.flags |= 268435456 /* InCheckIdentifier */;
69941
- var parentType = getTypeForBindingElementParent(parent);
70064
+ var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
69942
70065
  links.flags &= ~268435456 /* InCheckIdentifier */;
69943
70066
  if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69944
70067
  var pattern = declaration.parent;
@@ -70791,7 +70914,7 @@ var ts;
70791
70914
  var parent = declaration.parent.parent;
70792
70915
  var name = declaration.propertyName || declaration.name;
70793
70916
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
70794
- parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
70917
+ parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
70795
70918
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
70796
70919
  return undefined;
70797
70920
  if (parent.name.kind === 201 /* ArrayBindingPattern */) {
@@ -73032,7 +73155,7 @@ var ts;
73032
73155
  error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
73033
73156
  return errorType;
73034
73157
  }
73035
- propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop);
73158
+ propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
73036
73159
  }
73037
73160
  return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
73038
73161
  }
@@ -75502,8 +75625,8 @@ var ts;
75502
75625
  if (hasDefaultOnly && type && !isErrorType(type)) {
75503
75626
  var synthType = type;
75504
75627
  if (!synthType.defaultOnlyType) {
75505
- var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
75506
- synthType.defaultOnlyType = type_4;
75628
+ var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
75629
+ synthType.defaultOnlyType = type_5;
75507
75630
  }
75508
75631
  return synthType.defaultOnlyType;
75509
75632
  }
@@ -75957,7 +76080,7 @@ var ts;
75957
76080
  var links = getSymbolLinks(parameter);
75958
76081
  if (!links.type) {
75959
76082
  var declaration = parameter.valueDeclaration;
75960
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
76083
+ links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
75961
76084
  if (declaration.name.kind !== 79 /* Identifier */) {
75962
76085
  // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
75963
76086
  if (links.type === unknownType) {
@@ -76230,12 +76353,12 @@ var ts;
76230
76353
  var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
76231
76354
  // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
76232
76355
  var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
76233
- var type_5 = getBaseConstraintOfType(operandType) || operandType;
76356
+ var type_6 = getBaseConstraintOfType(operandType) || operandType;
76234
76357
  // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
76235
- if (type_5.flags & 3 /* AnyOrUnknown */) {
76358
+ if (type_6.flags & 3 /* AnyOrUnknown */) {
76236
76359
  return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
76237
76360
  }
76238
- return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
76361
+ return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
76239
76362
  }
76240
76363
  var type = getTypeOfExpression(node.expression);
76241
76364
  if (!isLiteralType(type)) {
@@ -77688,11 +77811,11 @@ var ts;
77688
77811
  }
77689
77812
  }
77690
77813
  function checkExpressionCached(node, checkMode) {
77814
+ if (checkMode && checkMode !== 0 /* Normal */) {
77815
+ return checkExpression(node, checkMode);
77816
+ }
77691
77817
  var links = getNodeLinks(node);
77692
77818
  if (!links.resolvedType) {
77693
- if (checkMode && checkMode !== 0 /* Normal */) {
77694
- return checkExpression(node, checkMode);
77695
- }
77696
77819
  // When computing a type that we're going to cache, we need to ignore any ongoing control flow
77697
77820
  // analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
77698
77821
  // to the top of the stack ensures all transient types are computed from a known point.
@@ -77712,10 +77835,12 @@ var ts;
77712
77835
  node.kind === 228 /* AsExpression */ ||
77713
77836
  ts.isJSDocTypeAssertion(node);
77714
77837
  }
77715
- function checkDeclarationInitializer(declaration, contextualType) {
77838
+ function checkDeclarationInitializer(declaration, checkMode, contextualType) {
77716
77839
  var initializer = ts.getEffectiveInitializer(declaration);
77717
77840
  var type = getQuickTypeOfExpression(initializer) ||
77718
- (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer));
77841
+ (contextualType ?
77842
+ checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
77843
+ : checkExpressionCached(initializer, checkMode));
77719
77844
  return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
77720
77845
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
77721
77846
  padTupleType(type, declaration.name) : type;
@@ -78355,6 +78480,7 @@ var ts;
78355
78480
  }
78356
78481
  }
78357
78482
  checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
78483
+ checkUnmatchedJSDocParameters(node);
78358
78484
  ts.forEach(node.parameters, checkParameter);
78359
78485
  // TODO(rbuckton): Should we start checking JSDoc types?
78360
78486
  if (node.type) {
@@ -79926,31 +80052,6 @@ var ts;
79926
80052
  }
79927
80053
  function checkJSDocParameterTag(node) {
79928
80054
  checkSourceElement(node.typeExpression);
79929
- if (!ts.getParameterSymbolFromJSDoc(node)) {
79930
- var decl = ts.getHostSignatureFromJSDoc(node);
79931
- // don't issue an error for invalid hosts -- just functions --
79932
- // and give a better error message when the host function mentions `arguments`
79933
- // but the tag doesn't have an array type
79934
- if (decl) {
79935
- var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
79936
- if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
79937
- return;
79938
- }
79939
- if (!containsArgumentsReference(decl)) {
79940
- if (ts.isQualifiedName(node.name)) {
79941
- 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));
79942
- }
79943
- else {
79944
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
79945
- }
79946
- }
79947
- else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
79948
- node.typeExpression && node.typeExpression.type &&
79949
- !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
79950
- 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));
79951
- }
79952
- }
79953
- }
79954
80055
  }
79955
80056
  function checkJSDocPropertyTag(node) {
79956
80057
  checkSourceElement(node.typeExpression);
@@ -80652,7 +80753,8 @@ var ts;
80652
80753
  }
80653
80754
  // check private/protected variable access
80654
80755
  var parent = node.parent.parent;
80655
- var parentType = getTypeForBindingElementParent(parent);
80756
+ var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
80757
+ var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
80656
80758
  var name = node.propertyName || node.name;
80657
80759
  if (parentType && !ts.isBindingPattern(name)) {
80658
80760
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -81891,7 +81993,7 @@ var ts;
81891
81993
  var declaration = catchClause.variableDeclaration;
81892
81994
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
81893
81995
  if (typeNode) {
81894
- var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
81996
+ var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
81895
81997
  if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
81896
81998
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
81897
81999
  }
@@ -82022,6 +82124,45 @@ var ts;
82022
82124
  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
82023
82125
  }
82024
82126
  }
82127
+ function checkUnmatchedJSDocParameters(node) {
82128
+ var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
82129
+ if (!ts.length(jsdocParameters))
82130
+ return;
82131
+ var isJs = ts.isInJSFile(node);
82132
+ var parameters = new ts.Set();
82133
+ var excludedParameters = new ts.Set();
82134
+ ts.forEach(node.parameters, function (_a, index) {
82135
+ var name = _a.name;
82136
+ if (ts.isIdentifier(name)) {
82137
+ parameters.add(name.escapedText);
82138
+ }
82139
+ if (ts.isBindingPattern(name)) {
82140
+ excludedParameters.add(index);
82141
+ }
82142
+ });
82143
+ var containsArguments = containsArgumentsReference(node);
82144
+ if (containsArguments) {
82145
+ var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82146
+ if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82147
+ lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82148
+ 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));
82149
+ }
82150
+ }
82151
+ else {
82152
+ ts.forEach(jsdocParameters, function (_a, index) {
82153
+ var name = _a.name;
82154
+ if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
82155
+ return;
82156
+ }
82157
+ if (ts.isQualifiedName(name)) {
82158
+ errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82159
+ }
82160
+ else {
82161
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
82162
+ }
82163
+ });
82164
+ }
82165
+ }
82025
82166
  /**
82026
82167
  * Check each type parameter and check that type parameters have no duplicate type parameter declarations
82027
82168
  */
@@ -82638,7 +82779,7 @@ var ts;
82638
82779
  }
82639
82780
  if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
82640
82781
  var propName = member.name;
82641
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
82782
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
82642
82783
  var type = getTypeOfSymbol(getSymbolOfNode(member));
82643
82784
  if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
82644
82785
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
@@ -82673,7 +82814,9 @@ var ts;
82673
82814
  return false;
82674
82815
  }
82675
82816
  function isPropertyInitializedInConstructor(propName, propType, constructor) {
82676
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
82817
+ var reference = ts.isComputedPropertyName(propName)
82818
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
82819
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
82677
82820
  ts.setParent(reference.expression, reference);
82678
82821
  ts.setParent(reference, constructor);
82679
82822
  reference.flowNode = constructor.returnFlowNode;
@@ -82997,7 +83140,7 @@ var ts;
82997
83140
  var isAmbientExternalModule = ts.isAmbientModule(node);
82998
83141
  var contextErrorMessage = isAmbientExternalModule
82999
83142
  ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
83000
- : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
83143
+ : ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
83001
83144
  if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
83002
83145
  // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
83003
83146
  return;
@@ -83230,6 +83373,9 @@ var ts;
83230
83373
  var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
83231
83374
  addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
83232
83375
  }
83376
+ if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
83377
+ error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
83378
+ }
83233
83379
  break;
83234
83380
  }
83235
83381
  case 274 /* ExportSpecifier */: {
@@ -83313,7 +83459,7 @@ var ts;
83313
83459
  }
83314
83460
  }
83315
83461
  function checkImportDeclaration(node) {
83316
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
83462
+ 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)) {
83317
83463
  // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
83318
83464
  return;
83319
83465
  }
@@ -83346,7 +83492,7 @@ var ts;
83346
83492
  checkAssertClause(node);
83347
83493
  }
83348
83494
  function checkImportEqualsDeclaration(node) {
83349
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
83495
+ 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)) {
83350
83496
  // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
83351
83497
  return;
83352
83498
  }
@@ -83383,7 +83529,7 @@ var ts;
83383
83529
  }
83384
83530
  }
83385
83531
  function checkExportDeclaration(node) {
83386
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
83532
+ 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)) {
83387
83533
  // If we hit an export in an illegal context, just bail out to avoid cascading errors.
83388
83534
  return;
83389
83535
  }
@@ -84617,7 +84763,7 @@ var ts;
84617
84763
  return errorType;
84618
84764
  }
84619
84765
  if (ts.isBindingPattern(node)) {
84620
- return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
84766
+ return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
84621
84767
  }
84622
84768
  if (isInRightSideOfImportOrExportAssignment(node)) {
84623
84769
  var symbol = getSymbolAtLocation(node);
@@ -114364,9 +114510,9 @@ var ts;
114364
114510
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
114365
114511
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
114366
114512
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
114367
- ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module.code,
114513
+ ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
114368
114514
  ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
114369
- ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module.code,
114515
+ ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
114370
114516
  ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
114371
114517
  ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
114372
114518
  ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
@@ -115434,7 +115580,7 @@ var ts;
115434
115580
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
115435
115581
  var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
115436
115582
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
115437
- var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
115583
+ var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
115438
115584
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
115439
115585
  // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
115440
115586
  // - plain JS: .js files with no // ts-check and checkJs: undefined
@@ -126828,6 +126974,10 @@ var ts;
126828
126974
  return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126829
126975
  }
126830
126976
  ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126977
+ function jsxModeNeedsExplicitImport(jsx) {
126978
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
126979
+ }
126980
+ ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
126831
126981
  // #endregion
126832
126982
  })(ts || (ts = {}));
126833
126983
  /*@internal*/
@@ -128772,9 +128922,18 @@ var ts;
128772
128922
  return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
128773
128923
  }
128774
128924
  }
128925
+ function isEmitResolutionKindUsingNodeModules(compilerOptions) {
128926
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
128927
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
128928
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
128929
+ }
128930
+ function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
128931
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
128932
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
128933
+ }
128775
128934
  function getSupportedExtensionsForModuleResolution(compilerOptions) {
128776
128935
  var extensions = ts.getSupportedExtensions(compilerOptions);
128777
- return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
128936
+ return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
128778
128937
  ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
128779
128938
  extensions;
128780
128939
  }
@@ -128937,7 +129096,7 @@ var ts;
128937
129096
  result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
128938
129097
  }
128939
129098
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
128940
- if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) {
129099
+ if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
128941
129100
  // If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
128942
129101
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
128943
129102
  var foundGlobal = false;
@@ -128954,12 +129113,68 @@ var ts;
128954
129113
  }
128955
129114
  }
128956
129115
  if (!foundGlobal) {
128957
- ts.forEachAncestorDirectory(scriptPath, function (ancestor) {
129116
+ var ancestorLookup = function (ancestor) {
128958
129117
  var nodeModules = ts.combinePaths(ancestor, "node_modules");
128959
129118
  if (ts.tryDirectoryExists(host, nodeModules)) {
128960
129119
  getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
128961
129120
  }
128962
- });
129121
+ };
129122
+ if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
129123
+ var nodeModulesDirectoryLookup_1 = ancestorLookup;
129124
+ ancestorLookup = function (ancestor) {
129125
+ var components = ts.getPathComponents(fragment);
129126
+ components.shift(); // shift off empty root
129127
+ var packagePath = components.shift();
129128
+ if (!packagePath) {
129129
+ return nodeModulesDirectoryLookup_1(ancestor);
129130
+ }
129131
+ if (ts.startsWith(packagePath, "@")) {
129132
+ var subName = components.shift();
129133
+ if (!subName) {
129134
+ return nodeModulesDirectoryLookup_1(ancestor);
129135
+ }
129136
+ packagePath = ts.combinePaths(packagePath, subName);
129137
+ }
129138
+ var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
129139
+ if (ts.tryFileExists(host, packageFile)) {
129140
+ var packageJson = ts.readJson(packageFile, host);
129141
+ var exports = packageJson.exports;
129142
+ if (exports) {
129143
+ if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
129144
+ return; // null exports or entrypoint only, no sub-modules available
129145
+ }
129146
+ var keys = ts.getOwnKeys(exports);
129147
+ var fragmentSubpath_1 = components.join("/");
129148
+ var processedKeys = ts.mapDefined(keys, function (k) {
129149
+ if (k === ".")
129150
+ return undefined;
129151
+ if (!ts.startsWith(k, "./"))
129152
+ return undefined;
129153
+ var subpath = k.substring(2);
129154
+ if (!ts.startsWith(subpath, fragmentSubpath_1))
129155
+ return undefined;
129156
+ // subpath is a valid export (barring conditions, which we don't currently check here)
129157
+ if (!ts.stringContains(subpath, "*")) {
129158
+ return subpath;
129159
+ }
129160
+ // pattern export - only return everything up to the `*`, so the user can autocomplete, then
129161
+ // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
129162
+ // but conditions will make that somewhat awkward, as each condition may have a different set of possible
129163
+ // options for the `*`.
129164
+ return subpath.slice(0, subpath.indexOf("*"));
129165
+ });
129166
+ ts.forEach(processedKeys, function (k) {
129167
+ if (k) {
129168
+ result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
129169
+ }
129170
+ });
129171
+ return;
129172
+ }
129173
+ }
129174
+ return nodeModulesDirectoryLookup_1(ancestor);
129175
+ };
129176
+ }
129177
+ ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
128963
129178
  }
128964
129179
  }
128965
129180
  return result;
@@ -130327,7 +130542,8 @@ var ts;
130327
130542
  case 103 /* NewKeyword */:
130328
130543
  return checker.getContextualType(parent);
130329
130544
  case 82 /* CaseKeyword */:
130330
- return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker);
130545
+ var caseClause = ts.tryCast(parent, ts.isCaseClause);
130546
+ return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
130331
130547
  case 18 /* OpenBraceToken */:
130332
130548
  return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
130333
130549
  default:
@@ -132972,7 +133188,24 @@ var ts;
132972
133188
  function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
132973
133189
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
132974
133190
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
133191
+ var oldBucketCount = buckets.size;
132975
133192
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
133193
+ if (ts.tracing) {
133194
+ if (buckets.size > oldBucketCount) {
133195
+ // It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
133196
+ // perhaps they are for two projects that don't have any overlap.
133197
+ // Bonus: these events can help us interpret the more interesting event below.
133198
+ ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
133199
+ }
133200
+ // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
133201
+ // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
133202
+ // Skip .d.ts files to reduce noise (should also cover most of node_modules).
133203
+ var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
133204
+ ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
133205
+ if (otherBucketKey) {
133206
+ ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
133207
+ }
133208
+ }
132976
133209
  var bucketEntry = bucket.get(path);
132977
133210
  var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
132978
133211
  if (!entry && externalCache) {
@@ -137046,7 +137279,27 @@ var ts;
137046
137279
  case 326 /* JSDocAugmentsTag */:
137047
137280
  return withNode(tag.class);
137048
137281
  case 342 /* JSDocTemplateTag */:
137049
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137282
+ var templateTag = tag;
137283
+ var displayParts_3 = [];
137284
+ if (templateTag.constraint) {
137285
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137286
+ }
137287
+ if (ts.length(templateTag.typeParameters)) {
137288
+ if (ts.length(displayParts_3)) {
137289
+ displayParts_3.push(ts.spacePart());
137290
+ }
137291
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137292
+ ts.forEach(templateTag.typeParameters, function (tp) {
137293
+ displayParts_3.push(namePart(tp.getText()));
137294
+ if (lastTypeParameter_1 !== tp) {
137295
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137296
+ }
137297
+ });
137298
+ }
137299
+ if (comment) {
137300
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137301
+ }
137302
+ return displayParts_3;
137050
137303
  case 341 /* JSDocTypeTag */:
137051
137304
  return withNode(tag.typeExpression);
137052
137305
  case 343 /* JSDocTypedefTag */:
@@ -138414,6 +138667,7 @@ var ts;
138414
138667
  return oldImports;
138415
138668
  }
138416
138669
  var typeChecker = program.getTypeChecker();
138670
+ var compilerOptions = program.getCompilerOptions();
138417
138671
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
138418
138672
  var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
138419
138673
  var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
@@ -138470,7 +138724,7 @@ var ts;
138470
138724
  return usedImports;
138471
138725
  function isDeclarationUsed(identifier) {
138472
138726
  // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
138473
- return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
138727
+ return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
138474
138728
  ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
138475
138729
  }
138476
138730
  }
@@ -145088,6 +145342,8 @@ var ts;
145088
145342
  case 179 /* ConstructorType */:
145089
145343
  case 174 /* ConstructSignature */:
145090
145344
  return getList(node.typeParameters) || getList(node.parameters);
145345
+ case 171 /* GetAccessor */:
145346
+ return getList(node.parameters);
145091
145347
  case 256 /* ClassDeclaration */:
145092
145348
  case 225 /* ClassExpression */:
145093
145349
  case 257 /* InterfaceDeclaration */:
@@ -145708,8 +145964,18 @@ var ts;
145708
145964
  var indent = sourceFile.text.slice(startPosition, fnStart);
145709
145965
  this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
145710
145966
  };
145967
+ ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
145968
+ var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
145969
+ return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
145970
+ });
145971
+ var jsDoc = ts.singleOrUndefined(node.jsDoc);
145972
+ return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
145973
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145974
+ };
145975
+ ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
145976
+ this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
145977
+ };
145711
145978
  ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
145712
- var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
145713
145979
  var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
145714
145980
  var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
145715
145981
  var merged = tryMergeJsdocTags(tag, newTag);
@@ -145717,20 +145983,10 @@ var ts;
145717
145983
  oldTags[i] = merged;
145718
145984
  return !!merged;
145719
145985
  }); });
145720
- var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145721
- var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145722
- var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145723
- ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145724
- var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145725
- var host = updateJSDocHost(parent);
145726
- this.insertJsdocCommentBefore(sourceFile, host, tag);
145986
+ this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
145727
145987
  };
145728
145988
  ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
145729
- var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
145730
- var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
145731
- 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)));
145732
- var host = updateJSDocHost(parent);
145733
- this.insertJsdocCommentBefore(sourceFile, host, tag);
145989
+ this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
145734
145990
  };
145735
145991
  ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
145736
145992
  this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
@@ -149525,9 +149781,9 @@ var ts;
149525
149781
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149526
149782
  var checker = program.getTypeChecker();
149527
149783
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149528
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149784
+ var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149529
149785
  var useRequire = shouldUseRequire(sourceFile, program);
149530
- var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149786
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149531
149787
  if (fix) {
149532
149788
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149533
149789
  }
@@ -149716,7 +149972,7 @@ var ts;
149716
149972
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149717
149973
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149718
149974
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
149719
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
149975
+ return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
149720
149976
  }
149721
149977
  function codeFixActionToCodeAction(_a) {
149722
149978
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -149776,7 +150032,7 @@ var ts;
149776
150032
  /*position*/ undefined,
149777
150033
  /*isValidTypeOnlyUseSite*/ false,
149778
150034
  /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
149779
- var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
150035
+ var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
149780
150036
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
149781
150037
  }
149782
150038
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
@@ -149946,7 +150202,7 @@ var ts;
149946
150202
  // 5. Literally nothing to go on
149947
150203
  return true;
149948
150204
  }
149949
- function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, moduleSymbols, host, preferences, fromCacheOnly) {
150205
+ function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
149950
150206
  var isJs = ts.isSourceFileJS(sourceFile);
149951
150207
  var compilerOptions = program.getCompilerOptions();
149952
150208
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
@@ -149955,7 +150211,7 @@ var ts;
149955
150211
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
149956
150212
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
149957
150213
  var computedWithoutCacheCount = 0;
149958
- var fixes = ts.flatMap(moduleSymbols, function (exportInfo) {
150214
+ var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
149959
150215
  var checker = getChecker(exportInfo.isFromPackageJson);
149960
150216
  var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
149961
150217
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
@@ -149964,7 +150220,7 @@ var ts;
149964
150220
  return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
149965
150221
  // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
149966
150222
  return !importedSymbolHasValueMeaning && isJs && position !== undefined
149967
- ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
150223
+ ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
149968
150224
  : {
149969
150225
  kind: 3 /* AddNew */,
149970
150226
  moduleSpecifier: moduleSpecifier,
@@ -149972,6 +150228,7 @@ var ts;
149972
150228
  useRequire: useRequire,
149973
150229
  addAsTypeOnly: addAsTypeOnly,
149974
150230
  exportInfo: exportInfo,
150231
+ isReExport: i > 0,
149975
150232
  };
149976
150233
  });
149977
150234
  });
@@ -150009,12 +150266,13 @@ var ts;
150009
150266
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150010
150267
  }
150011
150268
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150012
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150269
+ return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
150013
150270
  }
150014
- function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
150015
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
150271
+ function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
150272
+ var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
150273
+ return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
150016
150274
  }
150017
- function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
150275
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
150018
150276
  if (!ts.some(fixes))
150019
150277
  return;
150020
150278
  // These will always be placed first if available, and are better than other kinds
@@ -150023,22 +150281,37 @@ var ts;
150023
150281
  }
150024
150282
  return fixes.reduce(function (best, fix) {
150025
150283
  // Takes true branch of conditional if `fix` is better than `best`
150026
- return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
150284
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
150027
150285
  });
150028
150286
  }
150029
150287
  /** @returns `Comparison.LessThan` if `a` is better than `b`. */
150030
- function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
150288
+ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
150031
150289
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
150032
150290
  return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
150033
150291
  || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
150034
- || ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
150292
+ || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
150035
150293
  || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
150036
150294
  }
150037
150295
  return 0 /* EqualTo */;
150038
150296
  }
150039
- var notDotOrSlashPattern = /[^.\/]/;
150040
- function isOnlyDotsAndSlashes(path) {
150041
- return !notDotOrSlashPattern.test(path);
150297
+ // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
150298
+ // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
150299
+ // This can produce false positives or negatives if re-exports cross into sibling directories
150300
+ // (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
150301
+ // this if we're in a resolution mode where you can't drop trailing "/index" from paths).
150302
+ function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
150303
+ var _a;
150304
+ if (fix.isReExport &&
150305
+ ((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
150306
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
150307
+ isIndexFileName(fix.exportInfo.moduleFileName)) {
150308
+ var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
150309
+ return ts.startsWith((importingFile.path), reExportDir);
150310
+ }
150311
+ return false;
150312
+ }
150313
+ function isIndexFileName(fileName) {
150314
+ return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
150042
150315
  }
150043
150316
  function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
150044
150317
  if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
@@ -150056,9 +150329,9 @@ var ts;
150056
150329
  return undefined;
150057
150330
  var symbol = checker.getAliasedSymbol(umdSymbol);
150058
150331
  var symbolName = umdSymbol.name;
150059
- var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150332
+ var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150060
150333
  var useRequire = shouldUseRequire(sourceFile, program);
150061
- var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150334
+ var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150062
150335
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
150063
150336
  }
150064
150337
  function getUmdSymbol(token, checker) {
@@ -150125,8 +150398,8 @@ var ts;
150125
150398
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
150126
150399
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
150127
150400
  var useRequire = shouldUseRequire(sourceFile, program);
150128
- var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150129
- var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
150401
+ var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150402
+ var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
150130
150403
  var _ = _a[0], exportInfos = _a[1];
150131
150404
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150132
150405
  }));
@@ -150142,12 +150415,9 @@ var ts;
150142
150415
  return undefined;
150143
150416
  return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150144
150417
  }
150145
- function jsxModeNeedsExplicitImport(jsx) {
150146
- return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150147
- }
150148
150418
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
150149
150419
  var parent = symbolToken.parent;
150150
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150420
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150151
150421
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150152
150422
  if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150153
150423
  return jsxNamespace;
@@ -152227,6 +152497,95 @@ var ts;
152227
152497
  })(ts || (ts = {}));
152228
152498
  /* @internal */
152229
152499
  var ts;
152500
+ (function (ts) {
152501
+ var codefix;
152502
+ (function (codefix) {
152503
+ var deleteUnmatchedParameter = "deleteUnmatchedParameter";
152504
+ var renameUnmatchedParameter = "renameUnmatchedParameter";
152505
+ var errorCodes = [
152506
+ ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
152507
+ ];
152508
+ codefix.registerCodeFix({
152509
+ fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
152510
+ errorCodes: errorCodes,
152511
+ getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
152512
+ var sourceFile = context.sourceFile, span = context.span;
152513
+ var actions = [];
152514
+ var info = getInfo(sourceFile, span.start);
152515
+ if (info) {
152516
+ ts.append(actions, getDeleteAction(context, info));
152517
+ ts.append(actions, getRenameAction(context, info));
152518
+ return actions;
152519
+ }
152520
+ return undefined;
152521
+ },
152522
+ getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
152523
+ var tagsToSignature = new ts.Map();
152524
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
152525
+ codefix.eachDiagnostic(context, errorCodes, function (_a) {
152526
+ var file = _a.file, start = _a.start;
152527
+ var info = getInfo(file, start);
152528
+ if (info) {
152529
+ tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
152530
+ }
152531
+ });
152532
+ tagsToSignature.forEach(function (tags, signature) {
152533
+ if (context.fixId === deleteUnmatchedParameter) {
152534
+ var tagsSet_1 = new ts.Set(tags);
152535
+ changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
152536
+ }
152537
+ });
152538
+ }));
152539
+ }
152540
+ });
152541
+ function getDeleteAction(context, _a) {
152542
+ var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
152543
+ var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
152544
+ return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
152545
+ });
152546
+ return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
152547
+ }
152548
+ function getRenameAction(context, _a) {
152549
+ var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
152550
+ if (!ts.length(signature.parameters))
152551
+ return undefined;
152552
+ var sourceFile = context.sourceFile;
152553
+ var tags = ts.getJSDocTags(signature);
152554
+ var names = new ts.Set();
152555
+ for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
152556
+ var tag = tags_2[_i];
152557
+ if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
152558
+ names.add(tag.name.escapedText);
152559
+ }
152560
+ }
152561
+ // @todo - match to all available names instead to the first parameter name
152562
+ // @see /codeFixRenameUnmatchedParameter3.ts
152563
+ var parameterName = ts.firstDefined(signature.parameters, function (p) {
152564
+ return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
152565
+ });
152566
+ if (parameterName === undefined)
152567
+ return undefined;
152568
+ var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
152569
+ var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
152570
+ return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
152571
+ });
152572
+ return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
152573
+ }
152574
+ function getInfo(sourceFile, pos) {
152575
+ var token = ts.getTokenAtPosition(sourceFile, pos);
152576
+ if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
152577
+ var jsDocParameterTag = token.parent;
152578
+ var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
152579
+ if (signature) {
152580
+ return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
152581
+ }
152582
+ }
152583
+ return undefined;
152584
+ }
152585
+ })(codefix = ts.codefix || (ts.codefix = {}));
152586
+ })(ts || (ts = {}));
152587
+ /* @internal */
152588
+ var ts;
152230
152589
  (function (ts) {
152231
152590
  var codefix;
152232
152591
  (function (codefix) {
@@ -152524,6 +152883,9 @@ var ts;
152524
152883
  case 172 /* SetAccessor */:
152525
152884
  // Setter must have a parameter
152526
152885
  return false;
152886
+ case 171 /* GetAccessor */:
152887
+ // Getter cannot have parameters
152888
+ return true;
152527
152889
  default:
152528
152890
  return ts.Debug.failBadSyntaxKind(parent);
152529
152891
  }
@@ -155134,10 +155496,12 @@ var ts;
155134
155496
  });
155135
155497
  function getInfo(sourceFile, pos) {
155136
155498
  var token = ts.getTokenAtPosition(sourceFile, pos);
155137
- var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration);
155138
- if (ts.isClassDeclaration(indexSignature.parent))
155499
+ var indexSignature = ts.tryCast(token.parent.parent, ts.isIndexSignatureDeclaration);
155500
+ if (!indexSignature)
155501
+ return undefined;
155502
+ var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.tryCast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
155503
+ if (!container)
155139
155504
  return undefined;
155140
- var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
155141
155505
  return { indexSignature: indexSignature, container: container };
155142
155506
  }
155143
155507
  function createTypeAliasFromInterface(declaration, type) {
@@ -155674,51 +156038,53 @@ var ts;
155674
156038
  (function (ts) {
155675
156039
  var refactor;
155676
156040
  (function (refactor) {
156041
+ var _a;
155677
156042
  var refactorName = "Convert import";
155678
- var namespaceToNamedAction = {
155679
- name: "Convert namespace import to named imports",
155680
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155681
- kind: "refactor.rewrite.import.named",
155682
- };
155683
- var namedToNamespaceAction = {
155684
- name: "Convert named imports to namespace import",
155685
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155686
- kind: "refactor.rewrite.import.namespace",
155687
- };
156043
+ var actions = (_a = {},
156044
+ _a[0 /* Named */] = {
156045
+ name: "Convert namespace import to named imports",
156046
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156047
+ kind: "refactor.rewrite.import.named",
156048
+ },
156049
+ _a[2 /* Namespace */] = {
156050
+ name: "Convert named imports to namespace import",
156051
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156052
+ kind: "refactor.rewrite.import.namespace",
156053
+ },
156054
+ _a[1 /* Default */] = {
156055
+ name: "Convert named imports to default import",
156056
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
156057
+ kind: "refactor.rewrite.import.default",
156058
+ },
156059
+ _a);
155688
156060
  refactor.registerRefactor(refactorName, {
155689
- kinds: [
155690
- namespaceToNamedAction.kind,
155691
- namedToNamespaceAction.kind
155692
- ],
156061
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
155693
156062
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155694
- var info = getImportToConvert(context, context.triggerReason === "invoked");
156063
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
155695
156064
  if (!info)
155696
156065
  return ts.emptyArray;
155697
156066
  if (!refactor.isRefactorErrorInfo(info)) {
155698
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
155699
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
156067
+ var action = actions[info.convertTo];
155700
156068
  return [{ name: refactorName, description: action.description, actions: [action] }];
155701
156069
  }
155702
156070
  if (context.preferences.provideRefactorNotApplicableReason) {
155703
- return [
155704
- { name: refactorName, description: namespaceToNamedAction.description,
155705
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
155706
- { name: refactorName, description: namedToNamespaceAction.description,
155707
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
155708
- ];
156071
+ return ts.getOwnValues(actions).map(function (action) { return ({
156072
+ name: refactorName,
156073
+ description: action.description,
156074
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
156075
+ }); });
155709
156076
  }
155710
156077
  return ts.emptyArray;
155711
156078
  },
155712
156079
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155713
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155714
- var info = getImportToConvert(context);
156080
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
156081
+ var info = getImportConversionInfo(context);
155715
156082
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155716
156083
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
155717
156084
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
155718
156085
  }
155719
156086
  });
155720
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
155721
- function getImportToConvert(context, considerPartialSpans) {
156087
+ function getImportConversionInfo(context, considerPartialSpans) {
155722
156088
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
155723
156089
  var file = context.file;
155724
156090
  var span = ts.getRefactorContextSpan(context);
@@ -155737,15 +156103,23 @@ var ts;
155737
156103
  if (!importClause.namedBindings) {
155738
156104
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
155739
156105
  }
155740
- return importClause.namedBindings;
156106
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
156107
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
156108
+ }
156109
+ var compilerOptions = context.program.getCompilerOptions();
156110
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
156111
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
156112
+ return shouldUseDefault
156113
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
156114
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
155741
156115
  }
155742
- function doChange(sourceFile, program, changes, toConvert) {
156116
+ function doChange(sourceFile, program, changes, info) {
155743
156117
  var checker = program.getTypeChecker();
155744
- if (toConvert.kind === 267 /* NamespaceImport */) {
155745
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156118
+ if (info.convertTo === 0 /* Named */) {
156119
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155746
156120
  }
155747
156121
  else {
155748
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
156122
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
155749
156123
  }
155750
156124
  }
155751
156125
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -155795,7 +156169,7 @@ var ts;
155795
156169
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
155796
156170
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
155797
156171
  }
155798
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
156172
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
155799
156173
  var importDecl = toConvert.parent.parent;
155800
156174
  var moduleSpecifier = importDecl.moduleSpecifier;
155801
156175
  var toConvertSymbols = new ts.Set();
@@ -155846,7 +156220,9 @@ var ts;
155846
156220
  var element = _a[_i];
155847
156221
  _loop_17(element);
155848
156222
  }
155849
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156223
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
156224
+ ? ts.factory.createIdentifier(namespaceImportName)
156225
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155850
156226
  if (neededNamedImports.size) {
155851
156227
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
155852
156228
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -155854,6 +156230,13 @@ var ts;
155854
156230
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
155855
156231
  }
155856
156232
  }
156233
+ function isExportEqualsModule(moduleSpecifier, checker) {
156234
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
156235
+ if (!externalModule)
156236
+ return false;
156237
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
156238
+ return externalModule !== exportEquals;
156239
+ }
155857
156240
  function updateImport(old, defaultImportName, elements) {
155858
156241
  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);
155859
156242
  }
@@ -156709,8 +157092,8 @@ var ts;
156709
157092
  // but a super *method call* simply implies a 'this' reference
156710
157093
  if (node.parent.kind === 207 /* CallExpression */) {
156711
157094
  // Super constructor call
156712
- var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217
156713
- if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
157095
+ var containingClass_1 = ts.getContainingClass(node);
157096
+ if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
156714
157097
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
156715
157098
  return true;
156716
157099
  }
@@ -171529,9 +171912,10 @@ var ts;
171529
171912
  var info = infos && ts.firstOrUndefined(infos);
171530
171913
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
171531
171914
  }
171532
- function combineProjectOutputForReferences(projects, defaultProject, initialLocation) {
171915
+ function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
171533
171916
  var outputs = [];
171534
171917
  combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) {
171918
+ logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
171535
171919
  var _loop_8 = function (outputReferencedSymbol) {
171536
171920
  var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
171537
171921
  var definition = mappedDefinitionFile === undefined ?
@@ -172889,7 +173273,7 @@ var ts;
172889
173273
  var file = server.toNormalizedPath(args.file);
172890
173274
  var projects = this.getProjects(args);
172891
173275
  var position = this.getPositionInFile(args, file);
172892
- var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position });
173276
+ var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
172893
173277
  if (!simplifiedResult)
172894
173278
  return references;
172895
173279
  var defaultProject = this.getDefaultProject(args);