typescript 4.8.0-dev.20220615 → 4.8.0-dev.20220618

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.
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220615";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220618";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -8677,9 +8677,11 @@ var ts;
8677
8677
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8678
8678
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8679
8679
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8680
- This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8680
+ This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
8681
8681
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8682
8682
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8683
+ Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
8684
+ Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
8683
8685
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8684
8686
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
8685
8687
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -9864,6 +9866,8 @@ var ts;
9864
9866
  Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
9865
9867
  A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
9866
9868
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9869
+ You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
9870
+ You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
9867
9871
  Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
9868
9872
  Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
9869
9873
  JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
@@ -10134,6 +10138,9 @@ var ts;
10134
10138
  For_await_loops_cannot_be_used_inside_a_class_static_block: diag(18038, ts.DiagnosticCategory.Error, "For_await_loops_cannot_be_used_inside_a_class_static_block_18038", "'For await' loops cannot be used inside a class static block."),
10135
10139
  Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block: diag(18039, ts.DiagnosticCategory.Error, "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039", "Invalid use of '{0}'. It cannot be used inside a class static block."),
10136
10140
  A_return_statement_cannot_be_used_inside_a_class_static_block: diag(18041, ts.DiagnosticCategory.Error, "A_return_statement_cannot_be_used_inside_a_class_static_block_18041", "A 'return' statement cannot be used inside a class static block."),
10141
+ _0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation: diag(18042, ts.DiagnosticCategory.Error, "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042", "'{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation."),
10142
+ Types_cannot_appear_in_export_declarations_in_JavaScript_files: diag(18043, ts.DiagnosticCategory.Error, "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043", "Types cannot appear in export declarations in JavaScript files."),
10143
+ _0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
10137
10144
  };
10138
10145
  })(ts || (ts = {}));
10139
10146
  var ts;
@@ -34722,10 +34729,10 @@ var ts;
34722
34729
  setDecoratorContext(/*val*/ false);
34723
34730
  }
34724
34731
  var pos = getNodePos();
34725
- var expr = parseAssignmentExpressionOrHigher();
34732
+ var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
34726
34733
  var operatorToken;
34727
34734
  while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
34728
- expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
34735
+ expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
34729
34736
  }
34730
34737
  if (saveDecoratorContext) {
34731
34738
  setDecoratorContext(/*val*/ true);
@@ -34733,9 +34740,9 @@ var ts;
34733
34740
  return expr;
34734
34741
  }
34735
34742
  function parseInitializer() {
34736
- return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
34743
+ return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
34737
34744
  }
34738
- function parseAssignmentExpressionOrHigher() {
34745
+ function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
34739
34746
  // AssignmentExpression[in,yield]:
34740
34747
  // 1) ConditionalExpression[?in,?yield]
34741
34748
  // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -34761,7 +34768,7 @@ var ts;
34761
34768
  // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
34762
34769
  // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
34763
34770
  // with AssignmentExpression if we see one.
34764
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
34771
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
34765
34772
  if (arrowExpression) {
34766
34773
  return arrowExpression;
34767
34774
  }
@@ -34780,7 +34787,7 @@ var ts;
34780
34787
  // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
34781
34788
  // identifier and the current token is an arrow.
34782
34789
  if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
34783
- return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
34790
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
34784
34791
  }
34785
34792
  // Now see if we might be in cases '2' or '3'.
34786
34793
  // If the expression was a LHS expression, and we have an assignment operator, then
@@ -34789,10 +34796,10 @@ var ts;
34789
34796
  // Note: we call reScanGreaterToken so that we get an appropriately merged token
34790
34797
  // for cases like `> > =` becoming `>>=`
34791
34798
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
34792
- return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
34799
+ return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
34793
34800
  }
34794
34801
  // It wasn't an assignment or a lambda. This is a conditional expression:
34795
- return parseConditionalExpressionRest(expr, pos);
34802
+ return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
34796
34803
  }
34797
34804
  function isYieldExpression() {
34798
34805
  if (token() === 125 /* YieldKeyword */) {
@@ -34832,7 +34839,7 @@ var ts;
34832
34839
  nextToken();
34833
34840
  if (!scanner.hasPrecedingLineBreak() &&
34834
34841
  (token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
34835
- return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
34842
+ return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
34836
34843
  }
34837
34844
  else {
34838
34845
  // if the next token is not on the same line as yield. or we don't have an '*' or
@@ -34840,7 +34847,7 @@ var ts;
34840
34847
  return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
34841
34848
  }
34842
34849
  }
34843
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
34850
+ function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
34844
34851
  ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
34845
34852
  var parameter = factory.createParameterDeclaration(
34846
34853
  /*modifiers*/ undefined,
@@ -34851,11 +34858,11 @@ var ts;
34851
34858
  finishNode(parameter, identifier.pos);
34852
34859
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
34853
34860
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
34854
- var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
34861
+ var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
34855
34862
  var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
34856
34863
  return addJSDocComment(finishNode(node, pos));
34857
34864
  }
34858
- function tryParseParenthesizedArrowFunctionExpression() {
34865
+ function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34859
34866
  var triState = isParenthesizedArrowFunctionExpression();
34860
34867
  if (triState === 0 /* False */) {
34861
34868
  // It's definitely not a parenthesized arrow function expression.
@@ -34866,8 +34873,8 @@ var ts;
34866
34873
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
34867
34874
  // expression instead.
34868
34875
  return triState === 1 /* True */ ?
34869
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
34870
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
34876
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
34877
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
34871
34878
  }
34872
34879
  // True -> We definitely expect a parenthesized arrow function here.
34873
34880
  // False -> There *cannot* be a parenthesized arrow function here.
@@ -35001,25 +35008,25 @@ var ts;
35001
35008
  return 2 /* Unknown */;
35002
35009
  }
35003
35010
  }
35004
- function parsePossibleParenthesizedArrowFunctionExpression() {
35011
+ function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
35005
35012
  var tokenPos = scanner.getTokenPos();
35006
35013
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
35007
35014
  return undefined;
35008
35015
  }
35009
- var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
35016
+ var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
35010
35017
  if (!result) {
35011
35018
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
35012
35019
  }
35013
35020
  return result;
35014
35021
  }
35015
- function tryParseAsyncSimpleArrowFunctionExpression() {
35022
+ function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
35016
35023
  // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
35017
35024
  if (token() === 131 /* AsyncKeyword */) {
35018
35025
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
35019
35026
  var pos = getNodePos();
35020
35027
  var asyncModifier = parseModifiersForArrowFunction();
35021
35028
  var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
35022
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
35029
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
35023
35030
  }
35024
35031
  }
35025
35032
  return undefined;
@@ -35043,7 +35050,7 @@ var ts;
35043
35050
  }
35044
35051
  return 0 /* False */;
35045
35052
  }
35046
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
35053
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
35047
35054
  var pos = getNodePos();
35048
35055
  var hasJSDoc = hasPrecedingJSDocComment();
35049
35056
  var modifiers = parseModifiersForArrowFunction();
@@ -35078,6 +35085,7 @@ var ts;
35078
35085
  return undefined;
35079
35086
  }
35080
35087
  }
35088
+ var hasReturnColon = token() === 58 /* ColonToken */;
35081
35089
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
35082
35090
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
35083
35091
  return undefined;
@@ -35106,12 +35114,37 @@ var ts;
35106
35114
  var lastToken = token();
35107
35115
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
35108
35116
  var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
35109
- ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
35117
+ ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
35110
35118
  : parseIdentifier();
35119
+ // Given:
35120
+ // x ? y => ({ y }) : z => ({ z })
35121
+ // We try to parse the body of the first arrow function by looking at:
35122
+ // ({ y }) : z => ({ z })
35123
+ // This is a valid arrow function with "z" as the return type.
35124
+ //
35125
+ // But, if we're in the true side of a conditional expression, this colon
35126
+ // terminates the expression, so we cannot allow a return type if we aren't
35127
+ // certain whether or not the preceding text was parsed as a parameter list.
35128
+ //
35129
+ // For example,
35130
+ // a() ? (b: number, c?: string): void => d() : e
35131
+ // is determined by isParenthesizedArrowFunctionExpression to unambiguously
35132
+ // be an arrow expression, so we allow a return type.
35133
+ if (!allowReturnTypeInArrowFunction && hasReturnColon) {
35134
+ // However, if the arrow function we were able to parse is followed by another colon
35135
+ // as in:
35136
+ // a ? (x): string => x : null
35137
+ // Then allow the arrow function, and treat the second colon as terminating
35138
+ // the conditional expression. It's okay to do this because this code would
35139
+ // be a syntax error in JavaScript (as the second colon shouldn't be there).
35140
+ if (token() !== 58 /* ColonToken */) {
35141
+ return undefined;
35142
+ }
35143
+ }
35111
35144
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
35112
35145
  return withJSDoc(finishNode(node, pos), hasJSDoc);
35113
35146
  }
35114
- function parseArrowFunctionExpressionBody(isAsync) {
35147
+ function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
35115
35148
  if (token() === 18 /* OpenBraceToken */) {
35116
35149
  return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
35117
35150
  }
@@ -35139,12 +35172,12 @@ var ts;
35139
35172
  var savedTopLevel = topLevel;
35140
35173
  topLevel = false;
35141
35174
  var node = isAsync
35142
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
35143
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
35175
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
35176
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
35144
35177
  topLevel = savedTopLevel;
35145
35178
  return node;
35146
35179
  }
35147
- function parseConditionalExpressionRest(leftOperand, pos) {
35180
+ function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
35148
35181
  // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
35149
35182
  var questionToken = parseOptionalToken(57 /* QuestionToken */);
35150
35183
  if (!questionToken) {
@@ -35153,8 +35186,8 @@ var ts;
35153
35186
  // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
35154
35187
  // we do not that for the 'whenFalse' part.
35155
35188
  var colonToken;
35156
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
35157
- ? parseAssignmentExpressionOrHigher()
35189
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
35190
+ ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
35158
35191
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
35159
35192
  }
35160
35193
  function parseBinaryExpressionOrHigher(precedence) {
@@ -35981,10 +36014,11 @@ var ts;
35981
36014
  }
35982
36015
  nextToken();
35983
36016
  var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
35984
- if (!parseExpected(31 /* GreaterThanToken */)) {
36017
+ if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
35985
36018
  // If it doesn't have the closing `>` then it's definitely not an type argument list.
35986
36019
  return undefined;
35987
36020
  }
36021
+ nextToken();
35988
36022
  // We successfully parsed a type argument list. The next token determines whether we want to
35989
36023
  // treat it as such. If the type argument list is followed by `(` or a template literal, as in
35990
36024
  // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
@@ -36068,13 +36102,13 @@ var ts;
36068
36102
  function parseSpreadElement() {
36069
36103
  var pos = getNodePos();
36070
36104
  parseExpected(25 /* DotDotDotToken */);
36071
- var expression = parseAssignmentExpressionOrHigher();
36105
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
36072
36106
  return finishNode(factory.createSpreadElement(expression), pos);
36073
36107
  }
36074
36108
  function parseArgumentOrArrayLiteralElement() {
36075
36109
  return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
36076
36110
  token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
36077
- parseAssignmentExpressionOrHigher();
36111
+ parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
36078
36112
  }
36079
36113
  function parseArgumentExpression() {
36080
36114
  return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
@@ -36092,7 +36126,7 @@ var ts;
36092
36126
  var pos = getNodePos();
36093
36127
  var hasJSDoc = hasPrecedingJSDocComment();
36094
36128
  if (parseOptionalToken(25 /* DotDotDotToken */)) {
36095
- var expression = parseAssignmentExpressionOrHigher();
36129
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
36096
36130
  return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
36097
36131
  }
36098
36132
  var decorators = parseDecorators();
@@ -36121,7 +36155,7 @@ var ts;
36121
36155
  var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
36122
36156
  if (isShorthandPropertyAssignment) {
36123
36157
  var equalsToken = parseOptionalToken(63 /* EqualsToken */);
36124
- var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
36158
+ var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
36125
36159
  node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
36126
36160
  // Save equals token for error reporting.
36127
36161
  // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
@@ -36129,7 +36163,7 @@ var ts;
36129
36163
  }
36130
36164
  else {
36131
36165
  parseExpected(58 /* ColonToken */);
36132
- var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
36166
+ var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
36133
36167
  node = factory.createPropertyAssignment(name, initializer);
36134
36168
  }
36135
36169
  // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
@@ -36306,7 +36340,7 @@ var ts;
36306
36340
  }
36307
36341
  var node;
36308
36342
  if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
36309
- var expression = allowInAnd(parseAssignmentExpressionOrHigher);
36343
+ var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
36310
36344
  parseExpected(21 /* CloseParenToken */);
36311
36345
  node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
36312
36346
  }
@@ -37494,7 +37528,7 @@ var ts;
37494
37528
  var pos = getNodePos();
37495
37529
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
37496
37530
  parseExpected(58 /* ColonToken */);
37497
- var value = parseAssignmentExpressionOrHigher();
37531
+ var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37498
37532
  return finishNode(factory.createAssertEntry(name, value), pos);
37499
37533
  }
37500
37534
  function parseAssertClause(skipAssertKeyword) {
@@ -37735,7 +37769,7 @@ var ts;
37735
37769
  else {
37736
37770
  parseExpected(88 /* DefaultKeyword */);
37737
37771
  }
37738
- var expression = parseAssignmentExpressionOrHigher();
37772
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37739
37773
  parseSemicolon();
37740
37774
  setAwaitContext(savedAwaitContext);
37741
37775
  var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
@@ -49101,9 +49135,9 @@ var ts;
49101
49135
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
49102
49136
  },
49103
49137
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
49104
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
49138
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
49105
49139
  var node = ts.getParseTreeNode(nodeIn);
49106
- return node && tryGetThisTypeAt(node, includeGlobalThis);
49140
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
49107
49141
  },
49108
49142
  getTypeArgumentConstraint: function (nodeIn) {
49109
49143
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -52734,6 +52768,9 @@ var ts;
52734
52768
  if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
52735
52769
  return { accessibility: 0 /* Accessible */ };
52736
52770
  }
52771
+ if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
52772
+ return { accessibility: 0 /* Accessible */ };
52773
+ }
52737
52774
  // Verify if the symbol is accessible
52738
52775
  return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
52739
52776
  accessibility: 1 /* NotAccessible */,
@@ -59548,7 +59585,7 @@ var ts;
59548
59585
  }
59549
59586
  if (t.flags & 268435456 /* StringMapping */) {
59550
59587
  var constraint = getBaseConstraint(t.type);
59551
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59588
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59552
59589
  }
59553
59590
  if (t.flags & 8388608 /* IndexedAccess */) {
59554
59591
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62518,9 +62555,12 @@ var ts;
62518
62555
  }
62519
62556
  function getStringMappingType(symbol, type) {
62520
62557
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62521
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62522
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62523
- type;
62558
+ // Mapping<Mapping<T>> === Mapping<T>
62559
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62560
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62561
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62562
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62563
+ type;
62524
62564
  }
62525
62565
  function applyStringMapping(symbol, str) {
62526
62566
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62531,6 +62571,15 @@ var ts;
62531
62571
  }
62532
62572
  return str;
62533
62573
  }
62574
+ function applyTemplateStringMapping(symbol, texts, types) {
62575
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62576
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62577
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62578
+ case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62579
+ case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62580
+ }
62581
+ return [texts, types];
62582
+ }
62534
62583
  function getStringMappingTypeForGenericType(symbol, type) {
62535
62584
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62536
62585
  var result = stringMappingTypes.get(id);
@@ -62772,7 +62821,7 @@ var ts;
62772
62821
  accessNode;
62773
62822
  }
62774
62823
  function isPatternLiteralPlaceholderType(type) {
62775
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62824
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62776
62825
  }
62777
62826
  function isPatternLiteralType(type) {
62778
62827
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -65694,8 +65743,13 @@ var ts;
65694
65743
  return;
65695
65744
  }
65696
65745
  reportRelationError(headMessage, source, target);
65697
- if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65698
- associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65746
+ if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
65747
+ var syntheticParam = cloneTypeParameter(source);
65748
+ syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
65749
+ if (hasNonCircularBaseConstraint(syntheticParam)) {
65750
+ var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
65751
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
65752
+ }
65699
65753
  }
65700
65754
  }
65701
65755
  function traceUnionsOrIntersectionsTooLarge(source, target) {
@@ -66479,6 +66533,13 @@ var ts;
66479
66533
  return -1 /* True */;
66480
66534
  }
66481
66535
  }
66536
+ else if (target.flags & 268435456 /* StringMapping */) {
66537
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66538
+ if (isMemberOfStringMapping(source, target)) {
66539
+ return -1 /* True */;
66540
+ }
66541
+ }
66542
+ }
66482
66543
  if (sourceFlags & 8650752 /* TypeVariable */) {
66483
66544
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66484
66545
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66522,7 +66583,10 @@ var ts;
66522
66583
  }
66523
66584
  }
66524
66585
  else if (sourceFlags & 268435456 /* StringMapping */) {
66525
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66586
+ if (targetFlags & 268435456 /* StringMapping */) {
66587
+ if (source.symbol !== target.symbol) {
66588
+ return 0 /* False */;
66589
+ }
66526
66590
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66527
66591
  resetErrorInfo(saveErrorInfo);
66528
66592
  return result;
@@ -67447,7 +67511,7 @@ var ts;
67447
67511
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67448
67512
  }
67449
67513
  }
67450
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67514
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67451
67515
  }
67452
67516
  function getExactOptionalUnassignableProperties(source, target) {
67453
67517
  if (isTupleType(source) && isTupleType(target))
@@ -68918,6 +68982,31 @@ var ts;
68918
68982
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68919
68983
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68920
68984
  }
68985
+ function isMemberOfStringMapping(source, target) {
68986
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68987
+ return true;
68988
+ }
68989
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68990
+ return isTypeAssignableTo(source, target);
68991
+ }
68992
+ if (target.flags & 268435456 /* StringMapping */) {
68993
+ // We need to see whether applying the same mappings of the target
68994
+ // onto the source would produce an identical type *and* that
68995
+ // it's compatible with the inner-most non-string-mapped type.
68996
+ //
68997
+ // The intuition here is that if same mappings don't affect the source at all,
68998
+ // and the source is compatible with the unmapped target, then they must
68999
+ // still reside in the same domain.
69000
+ var mappingStack = [];
69001
+ while (target.flags & 268435456 /* StringMapping */) {
69002
+ mappingStack.unshift(target.symbol);
69003
+ target = target.type;
69004
+ }
69005
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
69006
+ return mappedSource === source && isMemberOfStringMapping(source, target);
69007
+ }
69008
+ return false;
69009
+ }
68921
69010
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68922
69011
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68923
69012
  return true;
@@ -68926,7 +69015,8 @@ var ts;
68926
69015
  var value = source.value;
68927
69016
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68928
69017
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68929
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
69018
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
69019
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68930
69020
  }
68931
69021
  if (source.flags & 134217728 /* TemplateLiteral */) {
68932
69022
  var texts = source.texts;
@@ -85805,6 +85895,7 @@ var ts;
85805
85895
  return true;
85806
85896
  }
85807
85897
  function checkAliasSymbol(node) {
85898
+ var _a, _b, _c, _d, _e;
85808
85899
  var symbol = getSymbolOfNode(node);
85809
85900
  var target = resolveAlias(symbol);
85810
85901
  if (target !== unknownSymbol) {
@@ -85815,6 +85906,31 @@ var ts;
85815
85906
  // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
85816
85907
  // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
85817
85908
  symbol = getMergedSymbol(symbol.exportSymbol || symbol);
85909
+ // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
85910
+ if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
85911
+ var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
85912
+ ts.isNamedDeclaration(node) ? node.name :
85913
+ node;
85914
+ ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
85915
+ if (node.kind === 275 /* ExportSpecifier */) {
85916
+ var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
85917
+ var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText);
85918
+ if (alreadyExportedSymbol === target) {
85919
+ var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
85920
+ if (exportingDeclaration) {
85921
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
85922
+ }
85923
+ }
85924
+ }
85925
+ else {
85926
+ ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
85927
+ var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
85928
+ var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
85929
+ var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
85930
+ error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier);
85931
+ }
85932
+ return;
85933
+ }
85818
85934
  var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
85819
85935
  (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
85820
85936
  (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
@@ -131234,32 +131350,41 @@ var ts;
131234
131350
  || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
131235
131351
  || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
131236
131352
  }
131237
- function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
131353
+ function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
131238
131354
  var _a, _b;
131239
- forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
131355
+ var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
131356
+ var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
131357
+ // The client is expected to send rooted path specs since we don't know
131358
+ // what directory a relative path is relative to.
131359
+ var pattern = ts.getPatternFromSpec(spec, "", "exclude");
131360
+ return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
131361
+ });
131362
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
131240
131363
  var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
131241
131364
  if (autoImportProvider) {
131242
131365
  var start = ts.timestamp();
131243
- forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
131366
+ forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
131244
131367
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
131245
131368
  }
131246
131369
  }
131247
131370
  ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
131248
- function forEachExternalModule(checker, allSourceFiles, cb) {
131249
- for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) {
131250
- var ambient = _a[_i];
131251
- if (!ts.stringContains(ambient.name, "*")) {
131371
+ function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
131372
+ var _a;
131373
+ var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
131374
+ for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
131375
+ var ambient = _b[_i];
131376
+ if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
131252
131377
  cb(ambient, /*sourceFile*/ undefined);
131253
131378
  }
131254
131379
  }
131255
- for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) {
131256
- var sourceFile = allSourceFiles_1[_b];
131257
- if (ts.isExternalOrCommonJsModule(sourceFile)) {
131380
+ for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
131381
+ var sourceFile = allSourceFiles_1[_c];
131382
+ if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
131258
131383
  cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
131259
131384
  }
131260
131385
  }
131261
131386
  }
131262
- function getExportInfoMap(importingFile, host, program, cancellationToken) {
131387
+ function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
131263
131388
  var _a, _b, _c, _d, _e;
131264
131389
  var start = ts.timestamp();
131265
131390
  // Pulling the AutoImportProvider project will trigger its updateGraph if pending,
@@ -131279,7 +131404,7 @@ var ts;
131279
131404
  var compilerOptions = program.getCompilerOptions();
131280
131405
  var moduleCount = 0;
131281
131406
  try {
131282
- forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
131407
+ forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
131283
131408
  if (++moduleCount % 100 === 0)
131284
131409
  cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
131285
131410
  var seenExports = new ts.Map();
@@ -133675,7 +133800,7 @@ var ts;
133675
133800
  if (!previousResponse)
133676
133801
  return undefined;
133677
133802
  var lowerCaseTokenText = location.text.toLowerCase();
133678
- var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
133803
+ var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
133679
133804
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
133680
133805
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133681
133806
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
@@ -135384,7 +135509,7 @@ var ts;
135384
135509
  }
135385
135510
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
135386
135511
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
135387
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
135512
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
135388
135513
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
135389
135514
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
135390
135515
  var symbol = _a[_i];
@@ -135487,7 +135612,7 @@ var ts;
135487
135612
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
135488
135613
  "";
135489
135614
  var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
135490
- var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
135615
+ var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
135491
135616
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
135492
135617
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
135493
135618
  resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
@@ -144722,10 +144847,10 @@ var ts;
144722
144847
  (function (ts) {
144723
144848
  var Rename;
144724
144849
  (function (Rename) {
144725
- function getRenameInfo(program, sourceFile, position, options) {
144850
+ function getRenameInfo(program, sourceFile, position, preferences) {
144726
144851
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144727
144852
  if (nodeIsEligibleForRename(node)) {
144728
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144853
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144729
144854
  if (renameInfo) {
144730
144855
  return renameInfo;
144731
144856
  }
@@ -144733,7 +144858,7 @@ var ts;
144733
144858
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144734
144859
  }
144735
144860
  Rename.getRenameInfo = getRenameInfo;
144736
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144861
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144737
144862
  var symbol = typeChecker.getSymbolAtLocation(node);
144738
144863
  if (!symbol) {
144739
144864
  if (ts.isStringLiteralLike(node)) {
@@ -144761,7 +144886,12 @@ var ts;
144761
144886
  return undefined;
144762
144887
  }
144763
144888
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144764
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144889
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144890
+ }
144891
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144892
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144893
+ if (wouldRenameNodeModules) {
144894
+ return getRenameInfoError(wouldRenameNodeModules);
144765
144895
  }
144766
144896
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144767
144897
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144775,6 +144905,49 @@ var ts;
144775
144905
  var sourceFile = declaration.getSourceFile();
144776
144906
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144777
144907
  }
144908
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144909
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144910
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144911
+ if (importSpecifier && !importSpecifier.propertyName) {
144912
+ symbol = checker.getAliasedSymbol(symbol);
144913
+ }
144914
+ }
144915
+ var declarations = symbol.declarations;
144916
+ if (!declarations) {
144917
+ return undefined;
144918
+ }
144919
+ var originalPackage = getPackagePathComponents(originalFile.path);
144920
+ if (originalPackage === undefined) { // original source file is not in node_modules
144921
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144922
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144923
+ }
144924
+ else {
144925
+ return undefined;
144926
+ }
144927
+ }
144928
+ // original source file is in node_modules
144929
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144930
+ var declaration = declarations_4[_i];
144931
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144932
+ if (declPackage) {
144933
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144934
+ for (var i = 0; i <= length_2; i++) {
144935
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144936
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144937
+ }
144938
+ }
144939
+ }
144940
+ }
144941
+ return undefined;
144942
+ }
144943
+ function getPackagePathComponents(filePath) {
144944
+ var components = ts.getPathComponents(filePath);
144945
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144946
+ if (nodeModulesIdx === -1) {
144947
+ return undefined;
144948
+ }
144949
+ return components.slice(0, nodeModulesIdx + 2);
144950
+ }
144778
144951
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144779
144952
  if (!ts.isExternalModuleNameRelative(node.text)) {
144780
144953
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -145829,7 +146002,7 @@ var ts;
145829
146002
  return type.symbol && (type.symbol.flags & 1536 /* Module */);
145830
146003
  }
145831
146004
  function visitVariableLikeDeclaration(decl) {
145832
- if (!decl.initializer || ts.isBindingPattern(decl.name)) {
146005
+ if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
145833
146006
  return;
145834
146007
  }
145835
146008
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
@@ -145957,6 +146130,9 @@ var ts;
145957
146130
  }
145958
146131
  for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
145959
146132
  var param = node.parameters[i];
146133
+ if (!isHintableDeclaration(param)) {
146134
+ continue;
146135
+ }
145960
146136
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
145961
146137
  if (effectiveTypeAnnotation) {
145962
146138
  continue;
@@ -145998,6 +146174,13 @@ var ts;
145998
146174
  function isUndefined(name) {
145999
146175
  return name === "undefined";
146000
146176
  }
146177
+ function isHintableDeclaration(node) {
146178
+ if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
146179
+ var initializer = ts.skipParentheses(node.initializer);
146180
+ return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
146181
+ }
146182
+ return true;
146183
+ }
146001
146184
  }
146002
146185
  InlayHints.provideInlayHints = provideInlayHints;
146003
146186
  })(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
@@ -154626,7 +154809,7 @@ var ts;
154626
154809
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
154627
154810
  return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
154628
154811
  });
154629
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154812
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154630
154813
  var checker = program.getTypeChecker();
154631
154814
  // Don't import from a re-export when looking "up" like to `./index` or `../index`.
154632
154815
  if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
@@ -155095,7 +155278,7 @@ var ts;
155095
155278
  originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, isFromPackageJson: isFromPackageJson });
155096
155279
  }
155097
155280
  }
155098
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
155281
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
155099
155282
  var checker = program.getTypeChecker();
155100
155283
  cancellationToken.throwIfCancellationRequested();
155101
155284
  var compilerOptions = program.getCompilerOptions();
@@ -155436,6 +155619,77 @@ var ts;
155436
155619
  })(ts || (ts = {}));
155437
155620
  /* @internal */
155438
155621
  var ts;
155622
+ (function (ts) {
155623
+ var codefix;
155624
+ (function (codefix) {
155625
+ var fixId = "addMissingConstraint";
155626
+ var errorCodes = [
155627
+ // We want errors this could be attached to:
155628
+ // Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
155629
+ ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
155630
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
155631
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
155632
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
155633
+ ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
155634
+ ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
155635
+ ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
155636
+ ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
155637
+ ];
155638
+ codefix.registerCodeFix({
155639
+ errorCodes: errorCodes,
155640
+ getCodeActions: function (context) {
155641
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
155642
+ var related = getDiagnosticRelatedInfo(program, sourceFile, span);
155643
+ if (!related) {
155644
+ return;
155645
+ }
155646
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
155647
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
155648
+ },
155649
+ fixIds: [fixId],
155650
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
155651
+ var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
155652
+ if (!info)
155653
+ return;
155654
+ return addMissingConstraint(changes, info);
155655
+ }); },
155656
+ });
155657
+ function getDiagnosticRelatedInfo(program, sourceFile, span) {
155658
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
155659
+ if (!diag || !diag.relatedInformation)
155660
+ return;
155661
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
155662
+ if (!related)
155663
+ return;
155664
+ return related;
155665
+ }
155666
+ function addMissingConstraint(changes, related) {
155667
+ var decl = findAncestorMatchingSpan(related.file, related);
155668
+ if (!decl)
155669
+ return;
155670
+ if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
155671
+ decl = decl.parent;
155672
+ }
155673
+ if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
155674
+ return; // should only issue fix on type parameters written using `extends`
155675
+ var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
155676
+ if (!newConstraint)
155677
+ return;
155678
+ var newConstraintText = newConstraint[1];
155679
+ changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155680
+ }
155681
+ function findAncestorMatchingSpan(sourceFile, span) {
155682
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
155683
+ var end = ts.textSpanEnd(span);
155684
+ while (token.end < end) {
155685
+ token = token.parent;
155686
+ }
155687
+ return token;
155688
+ }
155689
+ })(codefix = ts.codefix || (ts.codefix = {}));
155690
+ })(ts || (ts = {}));
155691
+ /* @internal */
155692
+ var ts;
155439
155693
  (function (ts) {
155440
155694
  var codefix;
155441
155695
  (function (codefix) {
@@ -161733,11 +161987,11 @@ var ts;
161733
161987
  }
161734
161988
  }
161735
161989
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161736
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161990
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161737
161991
  var numInitializers = 0;
161738
161992
  var lastInitializer = void 0;
161739
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161740
- var declaration = declarations_4[_i];
161993
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161994
+ var declaration = declarations_5[_i];
161741
161995
  if (declaration.initializer) {
161742
161996
  numInitializers++;
161743
161997
  lastInitializer = declaration.initializer;
@@ -165874,8 +166128,8 @@ var ts;
165874
166128
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165875
166129
  }
165876
166130
  };
165877
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165878
- var declaration = declarations_6[_i];
166131
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166132
+ var declaration = declarations_7[_i];
165879
166133
  _loop_21(declaration);
165880
166134
  }
165881
166135
  }
@@ -165901,8 +166155,8 @@ var ts;
165901
166155
  if (inheritedDocs)
165902
166156
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165903
166157
  };
165904
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165905
- var declaration = declarations_7[_i];
166158
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166159
+ var declaration = declarations_8[_i];
165906
166160
  _loop_22(declaration);
165907
166161
  }
165908
166162
  }
@@ -167479,9 +167733,9 @@ var ts;
167479
167733
  return ts.stringContains(path, "/node_modules/");
167480
167734
  }
167481
167735
  }
167482
- function getRenameInfo(fileName, position, options) {
167736
+ function getRenameInfo(fileName, position, preferences) {
167483
167737
  synchronizeHostData();
167484
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167738
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
167485
167739
  }
167486
167740
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
167487
167741
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168847,9 +169101,9 @@ var ts;
168847
169101
  var _this = this;
168848
169102
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168849
169103
  };
168850
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
169104
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168851
169105
  var _this = this;
168852
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
169106
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168853
169107
  };
168854
169108
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168855
169109
  var _this = this;
@@ -176600,7 +176854,7 @@ var ts;
176600
176854
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176601
176855
  }
176602
176856
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
176603
- var _a;
176857
+ var _a, _b;
176604
176858
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
176605
176859
  /*isForRename*/ false, function (project, position) {
176606
176860
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -176620,7 +176874,7 @@ var ts;
176620
176874
  // have started the other project searches from related symbols. Propagate the
176621
176875
  // correct results to all other projects.
176622
176876
  var defaultProjectResults = perProjectResults.get(defaultProject);
176623
- if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
176877
+ if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
176624
176878
  // Clear all isDefinition properties
176625
176879
  perProjectResults.forEach(function (projectResults) {
176626
176880
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -176637,8 +176891,8 @@ var ts;
176637
176891
  var knownSymbolSpans_1 = createDocumentSpanSet();
176638
176892
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
176639
176893
  var referencedSymbol = defaultProjectResults_1[_i];
176640
- for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
176641
- var ref = _c[_b];
176894
+ for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
176895
+ var ref = _d[_c];
176642
176896
  if (ref.isDefinition) {
176643
176897
  knownSymbolSpans_1.add(ref);
176644
176898
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -176757,23 +177011,30 @@ var ts;
176757
177011
  var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
176758
177012
  defaultDefinition :
176759
177013
  defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
176760
- // Track which projects we have already searched so that we don't repeat searches.
176761
- // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
176762
- // (For that same reason, we don't use `resultsMap` for this check.)
176763
- var searchedProjects = new ts.Set();
177014
+ // The keys of resultsMap allow us to check which projects have already been searched, but we also
177015
+ // maintain a set of strings because that's what `loadAncestorProjectTree` wants.
177016
+ var searchedProjectKeys = new ts.Set();
176764
177017
  onCancellation: while (queue.length) {
176765
177018
  while (queue.length) {
176766
177019
  if (cancellationToken.isCancellationRequested())
176767
177020
  break onCancellation;
177021
+ var skipCount = 0;
177022
+ for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
177023
+ ;
177024
+ if (skipCount === queue.length) {
177025
+ queue.length = 0;
177026
+ break;
177027
+ }
177028
+ if (skipCount > 0) {
177029
+ queue.splice(0, skipCount);
177030
+ }
177031
+ // NB: we may still skip if it's a project reference redirect
176768
177032
  var _a = queue.shift(), project = _a.project, location = _a.location;
176769
177033
  if (isLocationProjectReferenceRedirect(project, location))
176770
177034
  continue;
176771
- if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
176772
- continue;
176773
177035
  var projectResults = searchPosition(project, location);
176774
- if (projectResults) {
176775
- resultsMap.set(project, projectResults);
176776
- }
177036
+ resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
177037
+ searchedProjectKeys.add(getProjectKey(project));
176777
177038
  }
176778
177039
  // At this point, we know about all projects passed in as arguments and any projects in which
176779
177040
  // `getResultsForPosition` has returned results. We expand that set to include any projects
@@ -176781,11 +177042,11 @@ var ts;
176781
177042
  // containing `initialLocation`.
176782
177043
  if (defaultDefinition) {
176783
177044
  // This seems to mean "load all projects downstream from any member of `seenProjects`".
176784
- projectService.loadAncestorProjectTree(searchedProjects);
177045
+ projectService.loadAncestorProjectTree(searchedProjectKeys);
176785
177046
  projectService.forEachEnabledProject(function (project) {
176786
177047
  if (cancellationToken.isCancellationRequested())
176787
177048
  return; // There's no mechanism for skipping the remaining projects
176788
- if (searchedProjects.has(getProjectKey(project)))
177049
+ if (resultsMap.has(project))
176789
177050
  return; // Can loop forever without this (enqueue here, dequeue above, repeat)
176790
177051
  var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
176791
177052
  if (location) {
@@ -176796,9 +177057,10 @@ var ts;
176796
177057
  }
176797
177058
  // In the common case where there's only one project, return a simpler result to make
176798
177059
  // it easier for the caller to skip post-processing.
176799
- if (searchedProjects.size === 1) {
177060
+ if (resultsMap.size === 1) {
176800
177061
  var it = resultsMap.values().next();
176801
- return it.done ? server.emptyArray : it.value; // There may not be any results at all
177062
+ ts.Debug.assert(!it.done);
177063
+ return it.value;
176802
177064
  }
176803
177065
  return resultsMap;
176804
177066
  function searchPosition(project, location) {
@@ -176815,7 +177077,7 @@ var ts;
176815
177077
  var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
176816
177078
  for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
176817
177079
  var project_1 = _a[_i];
176818
- if (!project_1.isOrphan()) {
177080
+ if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
176819
177081
  queue.push({ project: project_1, location: originalLocation });
176820
177082
  }
176821
177083
  }
@@ -176824,7 +177086,7 @@ var ts;
176824
177086
  symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
176825
177087
  for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
176826
177088
  var symlinkedProject = symlinkedProjects_2[_i];
176827
- if (!symlinkedProject.isOrphan()) {
177089
+ if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
176828
177090
  queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
176829
177091
  }
176830
177092
  }
@@ -178117,7 +178379,8 @@ var ts;
178117
178379
  Session.prototype.getRenameInfo = function (args) {
178118
178380
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
178119
178381
  var position = this.getPositionInFile(args, file);
178120
- return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
178382
+ var preferences = this.getPreferences(file);
178383
+ return project.getLanguageService().getRenameInfo(file, position, preferences);
178121
178384
  };
178122
178385
  Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
178123
178386
  var _a;
@@ -178168,10 +178431,11 @@ var ts;
178168
178431
  var position = this.getPositionInFile(args, file);
178169
178432
  var projects = this.getProjects(args);
178170
178433
  var defaultProject = this.getDefaultProject(args);
178171
- var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178434
+ var preferences = this.getPreferences(file);
178435
+ var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178172
178436
  if (!renameInfo.canRename)
178173
178437
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
178174
- var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
178438
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
178175
178439
  if (!simplifiedResult)
178176
178440
  return locations;
178177
178441
  return { info: renameInfo, locs: this.toSpanGroups(locations) };