@typescript-deploys/pr-build 4.8.0-pr-49554-2 → 4.8.0-pr-49627-10

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
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-insiders.20220615";
112
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220622";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -9672,6 +9672,8 @@ var ts;
9672
9672
  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}'."),
9673
9673
  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."),
9674
9674
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9675
+ 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."),
9676
+ 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."),
9675
9677
  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."),
9676
9678
  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."),
9677
9679
  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'."),
@@ -9942,6 +9944,9 @@ var ts;
9942
9944
  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."),
9943
9945
  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."),
9944
9946
  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."),
9947
+ _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."),
9948
+ 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."),
9949
+ _0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
9945
9950
  };
9946
9951
  })(ts || (ts = {}));
9947
9952
  var ts;
@@ -34530,10 +34535,10 @@ var ts;
34530
34535
  setDecoratorContext(/*val*/ false);
34531
34536
  }
34532
34537
  var pos = getNodePos();
34533
- var expr = parseAssignmentExpressionOrHigher();
34538
+ var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
34534
34539
  var operatorToken;
34535
34540
  while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
34536
- expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
34541
+ expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
34537
34542
  }
34538
34543
  if (saveDecoratorContext) {
34539
34544
  setDecoratorContext(/*val*/ true);
@@ -34541,9 +34546,9 @@ var ts;
34541
34546
  return expr;
34542
34547
  }
34543
34548
  function parseInitializer() {
34544
- return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
34549
+ return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
34545
34550
  }
34546
- function parseAssignmentExpressionOrHigher() {
34551
+ function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
34547
34552
  // AssignmentExpression[in,yield]:
34548
34553
  // 1) ConditionalExpression[?in,?yield]
34549
34554
  // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -34569,7 +34574,7 @@ var ts;
34569
34574
  // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
34570
34575
  // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
34571
34576
  // with AssignmentExpression if we see one.
34572
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
34577
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
34573
34578
  if (arrowExpression) {
34574
34579
  return arrowExpression;
34575
34580
  }
@@ -34588,7 +34593,7 @@ var ts;
34588
34593
  // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
34589
34594
  // identifier and the current token is an arrow.
34590
34595
  if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
34591
- return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
34596
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
34592
34597
  }
34593
34598
  // Now see if we might be in cases '2' or '3'.
34594
34599
  // If the expression was a LHS expression, and we have an assignment operator, then
@@ -34597,10 +34602,10 @@ var ts;
34597
34602
  // Note: we call reScanGreaterToken so that we get an appropriately merged token
34598
34603
  // for cases like `> > =` becoming `>>=`
34599
34604
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
34600
- return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
34605
+ return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
34601
34606
  }
34602
34607
  // It wasn't an assignment or a lambda. This is a conditional expression:
34603
- return parseConditionalExpressionRest(expr, pos);
34608
+ return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
34604
34609
  }
34605
34610
  function isYieldExpression() {
34606
34611
  if (token() === 125 /* YieldKeyword */) {
@@ -34640,7 +34645,7 @@ var ts;
34640
34645
  nextToken();
34641
34646
  if (!scanner.hasPrecedingLineBreak() &&
34642
34647
  (token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
34643
- return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
34648
+ return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
34644
34649
  }
34645
34650
  else {
34646
34651
  // if the next token is not on the same line as yield. or we don't have an '*' or
@@ -34648,7 +34653,7 @@ var ts;
34648
34653
  return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
34649
34654
  }
34650
34655
  }
34651
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
34656
+ function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
34652
34657
  ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
34653
34658
  var parameter = factory.createParameterDeclaration(
34654
34659
  /*modifiers*/ undefined,
@@ -34659,11 +34664,11 @@ var ts;
34659
34664
  finishNode(parameter, identifier.pos);
34660
34665
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
34661
34666
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
34662
- var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
34667
+ var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
34663
34668
  var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
34664
34669
  return addJSDocComment(finishNode(node, pos));
34665
34670
  }
34666
- function tryParseParenthesizedArrowFunctionExpression() {
34671
+ function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34667
34672
  var triState = isParenthesizedArrowFunctionExpression();
34668
34673
  if (triState === 0 /* False */) {
34669
34674
  // It's definitely not a parenthesized arrow function expression.
@@ -34674,8 +34679,8 @@ var ts;
34674
34679
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
34675
34680
  // expression instead.
34676
34681
  return triState === 1 /* True */ ?
34677
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
34678
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
34682
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
34683
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
34679
34684
  }
34680
34685
  // True -> We definitely expect a parenthesized arrow function here.
34681
34686
  // False -> There *cannot* be a parenthesized arrow function here.
@@ -34809,25 +34814,25 @@ var ts;
34809
34814
  return 2 /* Unknown */;
34810
34815
  }
34811
34816
  }
34812
- function parsePossibleParenthesizedArrowFunctionExpression() {
34817
+ function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34813
34818
  var tokenPos = scanner.getTokenPos();
34814
34819
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
34815
34820
  return undefined;
34816
34821
  }
34817
- var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
34822
+ var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
34818
34823
  if (!result) {
34819
34824
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
34820
34825
  }
34821
34826
  return result;
34822
34827
  }
34823
- function tryParseAsyncSimpleArrowFunctionExpression() {
34828
+ function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34824
34829
  // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
34825
34830
  if (token() === 131 /* AsyncKeyword */) {
34826
34831
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
34827
34832
  var pos = getNodePos();
34828
34833
  var asyncModifier = parseModifiersForArrowFunction();
34829
34834
  var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
34830
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
34835
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
34831
34836
  }
34832
34837
  }
34833
34838
  return undefined;
@@ -34851,7 +34856,7 @@ var ts;
34851
34856
  }
34852
34857
  return 0 /* False */;
34853
34858
  }
34854
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
34859
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
34855
34860
  var pos = getNodePos();
34856
34861
  var hasJSDoc = hasPrecedingJSDocComment();
34857
34862
  var modifiers = parseModifiersForArrowFunction();
@@ -34886,6 +34891,7 @@ var ts;
34886
34891
  return undefined;
34887
34892
  }
34888
34893
  }
34894
+ var hasReturnColon = token() === 58 /* ColonToken */;
34889
34895
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
34890
34896
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
34891
34897
  return undefined;
@@ -34914,12 +34920,37 @@ var ts;
34914
34920
  var lastToken = token();
34915
34921
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
34916
34922
  var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
34917
- ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
34923
+ ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
34918
34924
  : parseIdentifier();
34925
+ // Given:
34926
+ // x ? y => ({ y }) : z => ({ z })
34927
+ // We try to parse the body of the first arrow function by looking at:
34928
+ // ({ y }) : z => ({ z })
34929
+ // This is a valid arrow function with "z" as the return type.
34930
+ //
34931
+ // But, if we're in the true side of a conditional expression, this colon
34932
+ // terminates the expression, so we cannot allow a return type if we aren't
34933
+ // certain whether or not the preceding text was parsed as a parameter list.
34934
+ //
34935
+ // For example,
34936
+ // a() ? (b: number, c?: string): void => d() : e
34937
+ // is determined by isParenthesizedArrowFunctionExpression to unambiguously
34938
+ // be an arrow expression, so we allow a return type.
34939
+ if (!allowReturnTypeInArrowFunction && hasReturnColon) {
34940
+ // However, if the arrow function we were able to parse is followed by another colon
34941
+ // as in:
34942
+ // a ? (x): string => x : null
34943
+ // Then allow the arrow function, and treat the second colon as terminating
34944
+ // the conditional expression. It's okay to do this because this code would
34945
+ // be a syntax error in JavaScript (as the second colon shouldn't be there).
34946
+ if (token() !== 58 /* ColonToken */) {
34947
+ return undefined;
34948
+ }
34949
+ }
34919
34950
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
34920
34951
  return withJSDoc(finishNode(node, pos), hasJSDoc);
34921
34952
  }
34922
- function parseArrowFunctionExpressionBody(isAsync) {
34953
+ function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
34923
34954
  if (token() === 18 /* OpenBraceToken */) {
34924
34955
  return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
34925
34956
  }
@@ -34947,12 +34978,12 @@ var ts;
34947
34978
  var savedTopLevel = topLevel;
34948
34979
  topLevel = false;
34949
34980
  var node = isAsync
34950
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
34951
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
34981
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
34982
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
34952
34983
  topLevel = savedTopLevel;
34953
34984
  return node;
34954
34985
  }
34955
- function parseConditionalExpressionRest(leftOperand, pos) {
34986
+ function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
34956
34987
  // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
34957
34988
  var questionToken = parseOptionalToken(57 /* QuestionToken */);
34958
34989
  if (!questionToken) {
@@ -34961,8 +34992,8 @@ var ts;
34961
34992
  // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
34962
34993
  // we do not that for the 'whenFalse' part.
34963
34994
  var colonToken;
34964
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
34965
- ? parseAssignmentExpressionOrHigher()
34995
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
34996
+ ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
34966
34997
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
34967
34998
  }
34968
34999
  function parseBinaryExpressionOrHigher(precedence) {
@@ -35877,13 +35908,13 @@ var ts;
35877
35908
  function parseSpreadElement() {
35878
35909
  var pos = getNodePos();
35879
35910
  parseExpected(25 /* DotDotDotToken */);
35880
- var expression = parseAssignmentExpressionOrHigher();
35911
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35881
35912
  return finishNode(factory.createSpreadElement(expression), pos);
35882
35913
  }
35883
35914
  function parseArgumentOrArrayLiteralElement() {
35884
35915
  return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
35885
35916
  token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
35886
- parseAssignmentExpressionOrHigher();
35917
+ parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35887
35918
  }
35888
35919
  function parseArgumentExpression() {
35889
35920
  return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
@@ -35901,7 +35932,7 @@ var ts;
35901
35932
  var pos = getNodePos();
35902
35933
  var hasJSDoc = hasPrecedingJSDocComment();
35903
35934
  if (parseOptionalToken(25 /* DotDotDotToken */)) {
35904
- var expression = parseAssignmentExpressionOrHigher();
35935
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35905
35936
  return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
35906
35937
  }
35907
35938
  var decorators = parseDecorators();
@@ -35930,7 +35961,7 @@ var ts;
35930
35961
  var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
35931
35962
  if (isShorthandPropertyAssignment) {
35932
35963
  var equalsToken = parseOptionalToken(63 /* EqualsToken */);
35933
- var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
35964
+ var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
35934
35965
  node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
35935
35966
  // Save equals token for error reporting.
35936
35967
  // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
@@ -35938,7 +35969,7 @@ var ts;
35938
35969
  }
35939
35970
  else {
35940
35971
  parseExpected(58 /* ColonToken */);
35941
- var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
35972
+ var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
35942
35973
  node = factory.createPropertyAssignment(name, initializer);
35943
35974
  }
35944
35975
  // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
@@ -36115,7 +36146,7 @@ var ts;
36115
36146
  }
36116
36147
  var node;
36117
36148
  if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
36118
- var expression = allowInAnd(parseAssignmentExpressionOrHigher);
36149
+ var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
36119
36150
  parseExpected(21 /* CloseParenToken */);
36120
36151
  node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
36121
36152
  }
@@ -37303,7 +37334,7 @@ var ts;
37303
37334
  var pos = getNodePos();
37304
37335
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
37305
37336
  parseExpected(58 /* ColonToken */);
37306
- var value = parseAssignmentExpressionOrHigher();
37337
+ var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37307
37338
  return finishNode(factory.createAssertEntry(name, value), pos);
37308
37339
  }
37309
37340
  function parseAssertClause(skipAssertKeyword) {
@@ -37544,7 +37575,7 @@ var ts;
37544
37575
  else {
37545
37576
  parseExpected(88 /* DefaultKeyword */);
37546
37577
  }
37547
- var expression = parseAssignmentExpressionOrHigher();
37578
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37548
37579
  parseSemicolon();
37549
37580
  setAwaitContext(savedAwaitContext);
37550
37581
  var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
@@ -48910,9 +48941,9 @@ var ts;
48910
48941
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
48911
48942
  },
48912
48943
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
48913
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
48944
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
48914
48945
  var node = ts.getParseTreeNode(nodeIn);
48915
- return node && tryGetThisTypeAt(node, includeGlobalThis);
48946
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
48916
48947
  },
48917
48948
  getTypeArgumentConstraint: function (nodeIn) {
48918
48949
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -49078,6 +49109,9 @@ var ts;
49078
49109
  var markerSubType = createTypeParameter();
49079
49110
  markerSubType.constraint = markerSuperType;
49080
49111
  var markerOtherType = createTypeParameter();
49112
+ var markerSuperTypeForCheck = createTypeParameter();
49113
+ var markerSubTypeForCheck = createTypeParameter();
49114
+ markerSubTypeForCheck.constraint = markerSuperTypeForCheck;
49081
49115
  var noTypePredicate = createTypePredicate(1 /* Identifier */, "<<unresolved>>", 0, anyType);
49082
49116
  var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
49083
49117
  var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
@@ -52905,7 +52939,7 @@ var ts;
52905
52939
  }
52906
52940
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
52907
52941
  type.flags & 262144 /* TypeParameter */ &&
52908
- !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
52942
+ typeParameterIsCachedOrNotAccessible(type, context)) {
52909
52943
  var name_2 = typeParameterToName(type, context);
52910
52944
  context.approximateLength += ts.idText(name_2).length;
52911
52945
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name_2)), /*typeArguments*/ undefined);
@@ -52914,8 +52948,8 @@ var ts;
52914
52948
  if (type.symbol) {
52915
52949
  return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
52916
52950
  }
52917
- var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ?
52918
- (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?";
52951
+ var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ?
52952
+ (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?";
52919
52953
  return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined);
52920
52954
  }
52921
52955
  if (type.flags & 1048576 /* Union */ && type.origin) {
@@ -53610,6 +53644,23 @@ var ts;
53610
53644
  else {
53611
53645
  typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
53612
53646
  }
53647
+ // For regular function/method declarations, the enclosing declaration will already be signature.declaration,
53648
+ // so this is a no-op, but for arrow functions and function expressions, the enclosing declaration will be
53649
+ // the declaration that the arrow function / function expression is assigned to, which is not the right scope.
53650
+ //
53651
+ // If the parameters or return type include "typeof globalThis.paramName", using the wrong scope will lead
53652
+ // us to believe that we can emit "typeof paramName" instead, even though that would refer to the parameter,
53653
+ // not the global. Make sure we are in the right scope by changing the enclosingDeclaration to the function.
53654
+ //
53655
+ // We check that this signature's declaration is within the existing enclosing declaration so we don't pull
53656
+ // in types from other files; if it is outside of the enclosing declaration, then we shouldn't be able to
53657
+ // access those parameter types via typeof anyway. The declaration should also not be in a JS file; those can
53658
+ // only be typed via JSDoc, but JSDoc annotations appear outside of the function and therefore are not in
53659
+ // the function's scope, unlike true type annotations.
53660
+ var saveEnclosingDeclaration = context.enclosingDeclaration;
53661
+ if (signature.declaration && !ts.isInJSFile(signature.declaration) && saveEnclosingDeclaration && ts.findAncestor(signature.declaration, function (n) { return n === saveEnclosingDeclaration; })) {
53662
+ context.enclosingDeclaration = signature.declaration;
53663
+ }
53613
53664
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
53614
53665
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
53615
53666
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
@@ -53661,6 +53712,7 @@ var ts;
53661
53712
  if (typeArguments) {
53662
53713
  node.typeArguments = ts.factory.createNodeArray(typeArguments);
53663
53714
  }
53715
+ context.enclosingDeclaration = saveEnclosingDeclaration;
53664
53716
  return node;
53665
53717
  }
53666
53718
  function tryGetThisParameterDeclaration(signature, context) {
@@ -54090,14 +54142,27 @@ var ts;
54090
54142
  }
54091
54143
  return false;
54092
54144
  }
54093
- function typeParameterToName(type, context) {
54094
- var _a, _b;
54145
+ // Returns true if this type parameter should be converted to a name via typeParameterToName,
54146
+ // either because it is not accessible, or because it's a use of a type variable that has
54147
+ // already been rewritten by typeParameterToName and so needs that rewritten name.
54148
+ function typeParameterIsCachedOrNotAccessible(type, context) {
54149
+ return !!getCachedTypeParameterName(type, context) || !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration);
54150
+ }
54151
+ function getCachedTypeParameterName(type, context) {
54095
54152
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) {
54096
54153
  var cached = context.typeParameterNames.get(getTypeId(type));
54097
54154
  if (cached) {
54098
54155
  return cached;
54099
54156
  }
54100
54157
  }
54158
+ return undefined;
54159
+ }
54160
+ function typeParameterToName(type, context) {
54161
+ var _a, _b;
54162
+ var cached = getCachedTypeParameterName(type, context);
54163
+ if (cached) {
54164
+ return cached;
54165
+ }
54101
54166
  var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true);
54102
54167
  if (!(result.kind & 79 /* Identifier */)) {
54103
54168
  return ts.factory.createIdentifier("(Missing type parameter)");
@@ -54330,7 +54395,7 @@ var ts;
54330
54395
  }
54331
54396
  if (ts.isIdentifier(node)) {
54332
54397
  var type = getDeclaredTypeOfSymbol(sym);
54333
- var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
54398
+ var name = sym.flags & 262144 /* TypeParameter */ && typeParameterIsCachedOrNotAccessible(type, context) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
54334
54399
  name.symbol = sym; // for quickinfo, which uses identifier symbol information
54335
54400
  return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
54336
54401
  }
@@ -59360,7 +59425,7 @@ var ts;
59360
59425
  }
59361
59426
  if (t.flags & 268435456 /* StringMapping */) {
59362
59427
  var constraint = getBaseConstraint(t.type);
59363
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59428
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59364
59429
  }
59365
59430
  if (t.flags & 8388608 /* IndexedAccess */) {
59366
59431
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62330,9 +62395,12 @@ var ts;
62330
62395
  }
62331
62396
  function getStringMappingType(symbol, type) {
62332
62397
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62333
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62334
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62335
- type;
62398
+ // Mapping<Mapping<T>> === Mapping<T>
62399
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62400
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62401
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62402
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62403
+ type;
62336
62404
  }
62337
62405
  function applyStringMapping(symbol, str) {
62338
62406
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62343,6 +62411,15 @@ var ts;
62343
62411
  }
62344
62412
  return str;
62345
62413
  }
62414
+ function applyTemplateStringMapping(symbol, texts, types) {
62415
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62416
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62417
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62418
+ 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];
62419
+ 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];
62420
+ }
62421
+ return [texts, types];
62422
+ }
62346
62423
  function getStringMappingTypeForGenericType(symbol, type) {
62347
62424
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62348
62425
  var result = stringMappingTypes.get(id);
@@ -62584,7 +62661,7 @@ var ts;
62584
62661
  accessNode;
62585
62662
  }
62586
62663
  function isPatternLiteralPlaceholderType(type) {
62587
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62664
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62588
62665
  }
62589
62666
  function isPatternLiteralType(type) {
62590
62667
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -64584,7 +64661,7 @@ var ts;
64584
64661
  });
64585
64662
  }
64586
64663
  function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
64587
- if (target.flags & 131068 /* Primitive */)
64664
+ if (target.flags & (131068 /* Primitive */ | 131072 /* Never */))
64588
64665
  return false;
64589
64666
  if (isTupleLikeType(source)) {
64590
64667
  return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
@@ -64651,7 +64728,7 @@ var ts;
64651
64728
  });
64652
64729
  }
64653
64730
  function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
64654
- if (target.flags & 131068 /* Primitive */)
64731
+ if (target.flags & (131068 /* Primitive */ | 131072 /* Never */))
64655
64732
  return false;
64656
64733
  return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
64657
64734
  }
@@ -65250,7 +65327,7 @@ var ts;
65250
65327
  ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
65251
65328
  generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
65252
65329
  }
65253
- if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) {
65330
+ if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) {
65254
65331
  var constraint = getBaseConstraintOfType(target);
65255
65332
  var needsOriginalSource = void 0;
65256
65333
  if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
@@ -66296,6 +66373,13 @@ var ts;
66296
66373
  return -1 /* True */;
66297
66374
  }
66298
66375
  }
66376
+ else if (target.flags & 268435456 /* StringMapping */) {
66377
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66378
+ if (isMemberOfStringMapping(source, target)) {
66379
+ return -1 /* True */;
66380
+ }
66381
+ }
66382
+ }
66299
66383
  if (sourceFlags & 8650752 /* TypeVariable */) {
66300
66384
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66301
66385
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66339,7 +66423,10 @@ var ts;
66339
66423
  }
66340
66424
  }
66341
66425
  else if (sourceFlags & 268435456 /* StringMapping */) {
66342
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66426
+ if (targetFlags & 268435456 /* StringMapping */) {
66427
+ if (source.symbol !== target.symbol) {
66428
+ return 0 /* False */;
66429
+ }
66343
66430
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66344
66431
  resetErrorInfo(saveErrorInfo);
66345
66432
  return result;
@@ -67264,7 +67351,7 @@ var ts;
67264
67351
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67265
67352
  }
67266
67353
  }
67267
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67354
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67268
67355
  }
67269
67356
  function getExactOptionalUnassignableProperties(source, target) {
67270
67357
  if (isTupleType(source) && isTupleType(target))
@@ -68735,6 +68822,31 @@ var ts;
68735
68822
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68736
68823
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68737
68824
  }
68825
+ function isMemberOfStringMapping(source, target) {
68826
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68827
+ return true;
68828
+ }
68829
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68830
+ return isTypeAssignableTo(source, target);
68831
+ }
68832
+ if (target.flags & 268435456 /* StringMapping */) {
68833
+ // We need to see whether applying the same mappings of the target
68834
+ // onto the source would produce an identical type *and* that
68835
+ // it's compatible with the inner-most non-string-mapped type.
68836
+ //
68837
+ // The intuition here is that if same mappings don't affect the source at all,
68838
+ // and the source is compatible with the unmapped target, then they must
68839
+ // still reside in the same domain.
68840
+ var mappingStack = [];
68841
+ while (target.flags & 268435456 /* StringMapping */) {
68842
+ mappingStack.unshift(target.symbol);
68843
+ target = target.type;
68844
+ }
68845
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68846
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68847
+ }
68848
+ return false;
68849
+ }
68738
68850
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68739
68851
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68740
68852
  return true;
@@ -68743,7 +68855,8 @@ var ts;
68743
68855
  var value = source.value;
68744
68856
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68745
68857
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68746
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68858
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68859
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68747
68860
  }
68748
68861
  if (source.flags & 134217728 /* TemplateLiteral */) {
68749
68862
  var texts = source.texts;
@@ -76561,6 +76674,15 @@ var ts;
76561
76674
  if (result) {
76562
76675
  return result;
76563
76676
  }
76677
+ result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
76678
+ // Preemptively cache the result; getResolvedSignature will do this after we return, but
76679
+ // we need to ensure that the result is present for the error checks below so that if
76680
+ // this signature is encountered again, we handle the circularity (rather than producing a
76681
+ // different result which may produce no errors and assert). Callers of getResolvedSignature
76682
+ // don't hit this issue because they only observe this result after it's had a chance to
76683
+ // be cached, but the error reporting code below executes before getResolvedSignature sets
76684
+ // resolvedSignature.
76685
+ getNodeLinks(node).resolvedSignature = result;
76564
76686
  // No signatures were applicable. Now report errors based on the last applicable signature with
76565
76687
  // no arguments excluded from assignability checks.
76566
76688
  // If candidate is undefined, it means that no candidates had a suitable arity. In that case,
@@ -76652,7 +76774,7 @@ var ts;
76652
76774
  }
76653
76775
  }
76654
76776
  }
76655
- return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
76777
+ return result;
76656
76778
  function addImplementationSuccessElaboration(failed, diagnostic) {
76657
76779
  var _a, _b;
76658
76780
  var oldCandidatesForArgumentError = candidatesForArgumentError;
@@ -80455,8 +80577,8 @@ var ts;
80455
80577
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80456
80578
  }
80457
80579
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80458
- var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
80459
- var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
80580
+ var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80581
+ var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80460
80582
  var saveVarianceTypeParameter = typeParameter;
80461
80583
  varianceTypeParameter = typeParameter;
80462
80584
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
@@ -85622,6 +85744,7 @@ var ts;
85622
85744
  return true;
85623
85745
  }
85624
85746
  function checkAliasSymbol(node) {
85747
+ var _a, _b, _c, _d, _e;
85625
85748
  var symbol = getSymbolOfNode(node);
85626
85749
  var target = resolveAlias(symbol);
85627
85750
  if (target !== unknownSymbol) {
@@ -85632,6 +85755,31 @@ var ts;
85632
85755
  // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
85633
85756
  // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
85634
85757
  symbol = getMergedSymbol(symbol.exportSymbol || symbol);
85758
+ // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
85759
+ if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
85760
+ var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
85761
+ ts.isNamedDeclaration(node) ? node.name :
85762
+ node;
85763
+ ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
85764
+ if (node.kind === 275 /* ExportSpecifier */) {
85765
+ var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
85766
+ 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);
85767
+ if (alreadyExportedSymbol === target) {
85768
+ var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
85769
+ if (exportingDeclaration) {
85770
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
85771
+ }
85772
+ }
85773
+ }
85774
+ else {
85775
+ ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
85776
+ var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
85777
+ var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
85778
+ var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
85779
+ 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);
85780
+ }
85781
+ return;
85782
+ }
85635
85783
  var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
85636
85784
  (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
85637
85785
  (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
@@ -130632,32 +130780,41 @@ var ts;
130632
130780
  || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
130633
130781
  || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
130634
130782
  }
130635
- function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
130783
+ function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
130636
130784
  var _a, _b;
130637
- forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
130785
+ var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
130786
+ var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
130787
+ // The client is expected to send rooted path specs since we don't know
130788
+ // what directory a relative path is relative to.
130789
+ var pattern = ts.getPatternFromSpec(spec, "", "exclude");
130790
+ return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
130791
+ });
130792
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
130638
130793
  var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
130639
130794
  if (autoImportProvider) {
130640
130795
  var start = ts.timestamp();
130641
- forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
130796
+ forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
130642
130797
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
130643
130798
  }
130644
130799
  }
130645
130800
  ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
130646
- function forEachExternalModule(checker, allSourceFiles, cb) {
130647
- for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) {
130648
- var ambient = _a[_i];
130649
- if (!ts.stringContains(ambient.name, "*")) {
130801
+ function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
130802
+ var _a;
130803
+ var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
130804
+ for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
130805
+ var ambient = _b[_i];
130806
+ if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
130650
130807
  cb(ambient, /*sourceFile*/ undefined);
130651
130808
  }
130652
130809
  }
130653
- for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) {
130654
- var sourceFile = allSourceFiles_1[_b];
130655
- if (ts.isExternalOrCommonJsModule(sourceFile)) {
130810
+ for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
130811
+ var sourceFile = allSourceFiles_1[_c];
130812
+ if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
130656
130813
  cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
130657
130814
  }
130658
130815
  }
130659
130816
  }
130660
- function getExportInfoMap(importingFile, host, program, cancellationToken) {
130817
+ function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
130661
130818
  var _a, _b, _c, _d, _e;
130662
130819
  var start = ts.timestamp();
130663
130820
  // Pulling the AutoImportProvider project will trigger its updateGraph if pending,
@@ -130677,7 +130834,7 @@ var ts;
130677
130834
  var compilerOptions = program.getCompilerOptions();
130678
130835
  var moduleCount = 0;
130679
130836
  try {
130680
- forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
130837
+ forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
130681
130838
  if (++moduleCount % 100 === 0)
130682
130839
  cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
130683
130840
  var seenExports = new ts.Map();
@@ -133073,7 +133230,7 @@ var ts;
133073
133230
  if (!previousResponse)
133074
133231
  return undefined;
133075
133232
  var lowerCaseTokenText = location.text.toLowerCase();
133076
- var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
133233
+ var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
133077
133234
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
133078
133235
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133079
133236
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
@@ -134782,7 +134939,7 @@ var ts;
134782
134939
  }
134783
134940
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
134784
134941
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
134785
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
134942
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
134786
134943
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
134787
134944
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
134788
134945
  var symbol = _a[_i];
@@ -134885,7 +135042,7 @@ var ts;
134885
135042
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
134886
135043
  "";
134887
135044
  var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
134888
- var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
135045
+ var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
134889
135046
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
134890
135047
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
134891
135048
  resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
@@ -136085,6 +136242,10 @@ var ts;
136085
136242
  }
136086
136243
  break;
136087
136244
  case 79 /* Identifier */: {
136245
+ var originalKeywordKind = location.originalKeywordKind;
136246
+ if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) {
136247
+ return undefined;
136248
+ }
136088
136249
  // class c { public prop = c| }
136089
136250
  if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
136090
136251
  return undefined;
@@ -144120,10 +144281,10 @@ var ts;
144120
144281
  (function (ts) {
144121
144282
  var Rename;
144122
144283
  (function (Rename) {
144123
- function getRenameInfo(program, sourceFile, position, options) {
144284
+ function getRenameInfo(program, sourceFile, position, preferences) {
144124
144285
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144125
144286
  if (nodeIsEligibleForRename(node)) {
144126
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144287
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144127
144288
  if (renameInfo) {
144128
144289
  return renameInfo;
144129
144290
  }
@@ -144131,7 +144292,7 @@ var ts;
144131
144292
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144132
144293
  }
144133
144294
  Rename.getRenameInfo = getRenameInfo;
144134
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144295
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144135
144296
  var symbol = typeChecker.getSymbolAtLocation(node);
144136
144297
  if (!symbol) {
144137
144298
  if (ts.isStringLiteralLike(node)) {
@@ -144159,7 +144320,12 @@ var ts;
144159
144320
  return undefined;
144160
144321
  }
144161
144322
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144162
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144323
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144324
+ }
144325
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144326
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144327
+ if (wouldRenameNodeModules) {
144328
+ return getRenameInfoError(wouldRenameNodeModules);
144163
144329
  }
144164
144330
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144165
144331
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144173,6 +144339,49 @@ var ts;
144173
144339
  var sourceFile = declaration.getSourceFile();
144174
144340
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144175
144341
  }
144342
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144343
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144344
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144345
+ if (importSpecifier && !importSpecifier.propertyName) {
144346
+ symbol = checker.getAliasedSymbol(symbol);
144347
+ }
144348
+ }
144349
+ var declarations = symbol.declarations;
144350
+ if (!declarations) {
144351
+ return undefined;
144352
+ }
144353
+ var originalPackage = getPackagePathComponents(originalFile.path);
144354
+ if (originalPackage === undefined) { // original source file is not in node_modules
144355
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144356
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144357
+ }
144358
+ else {
144359
+ return undefined;
144360
+ }
144361
+ }
144362
+ // original source file is in node_modules
144363
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144364
+ var declaration = declarations_4[_i];
144365
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144366
+ if (declPackage) {
144367
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144368
+ for (var i = 0; i <= length_2; i++) {
144369
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144370
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144371
+ }
144372
+ }
144373
+ }
144374
+ }
144375
+ return undefined;
144376
+ }
144377
+ function getPackagePathComponents(filePath) {
144378
+ var components = ts.getPathComponents(filePath);
144379
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144380
+ if (nodeModulesIdx === -1) {
144381
+ return undefined;
144382
+ }
144383
+ return components.slice(0, nodeModulesIdx + 2);
144384
+ }
144176
144385
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144177
144386
  if (!ts.isExternalModuleNameRelative(node.text)) {
144178
144387
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -154034,7 +154243,7 @@ var ts;
154034
154243
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
154035
154244
  return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
154036
154245
  });
154037
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154246
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154038
154247
  var checker = program.getTypeChecker();
154039
154248
  // Don't import from a re-export when looking "up" like to `./index` or `../index`.
154040
154249
  if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
@@ -154503,7 +154712,7 @@ var ts;
154503
154712
  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 });
154504
154713
  }
154505
154714
  }
154506
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
154715
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
154507
154716
  var checker = program.getTypeChecker();
154508
154717
  cancellationToken.throwIfCancellationRequested();
154509
154718
  var compilerOptions = program.getCompilerOptions();
@@ -161221,11 +161430,11 @@ var ts;
161221
161430
  }
161222
161431
  }
161223
161432
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161224
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161433
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161225
161434
  var numInitializers = 0;
161226
161435
  var lastInitializer = void 0;
161227
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161228
- var declaration = declarations_4[_i];
161436
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161437
+ var declaration = declarations_5[_i];
161229
161438
  if (declaration.initializer) {
161230
161439
  numInitializers++;
161231
161440
  lastInitializer = declaration.initializer;
@@ -165362,8 +165571,8 @@ var ts;
165362
165571
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165363
165572
  }
165364
165573
  };
165365
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165366
- var declaration = declarations_6[_i];
165574
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165575
+ var declaration = declarations_7[_i];
165367
165576
  _loop_21(declaration);
165368
165577
  }
165369
165578
  }
@@ -165389,8 +165598,8 @@ var ts;
165389
165598
  if (inheritedDocs)
165390
165599
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165391
165600
  };
165392
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165393
- var declaration = declarations_7[_i];
165601
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
165602
+ var declaration = declarations_8[_i];
165394
165603
  _loop_22(declaration);
165395
165604
  }
165396
165605
  }
@@ -166967,9 +167176,9 @@ var ts;
166967
167176
  return ts.stringContains(path, "/node_modules/");
166968
167177
  }
166969
167178
  }
166970
- function getRenameInfo(fileName, position, options) {
167179
+ function getRenameInfo(fileName, position, preferences) {
166971
167180
  synchronizeHostData();
166972
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167181
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
166973
167182
  }
166974
167183
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
166975
167184
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168335,9 +168544,9 @@ var ts;
168335
168544
  var _this = this;
168336
168545
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168337
168546
  };
168338
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
168547
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168339
168548
  var _this = this;
168340
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
168549
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168341
168550
  };
168342
168551
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168343
168552
  var _this = this;
@@ -176507,7 +176716,7 @@ var ts;
176507
176716
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176508
176717
  }
176509
176718
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
176510
- var _a;
176719
+ var _a, _b;
176511
176720
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
176512
176721
  /*isForRename*/ false, function (project, position) {
176513
176722
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -176527,7 +176736,7 @@ var ts;
176527
176736
  // have started the other project searches from related symbols. Propagate the
176528
176737
  // correct results to all other projects.
176529
176738
  var defaultProjectResults = perProjectResults.get(defaultProject);
176530
- if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
176739
+ 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) {
176531
176740
  // Clear all isDefinition properties
176532
176741
  perProjectResults.forEach(function (projectResults) {
176533
176742
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -176544,8 +176753,8 @@ var ts;
176544
176753
  var knownSymbolSpans_1 = createDocumentSpanSet();
176545
176754
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
176546
176755
  var referencedSymbol = defaultProjectResults_1[_i];
176547
- for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
176548
- var ref = _c[_b];
176756
+ for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
176757
+ var ref = _d[_c];
176549
176758
  if (ref.isDefinition) {
176550
176759
  knownSymbolSpans_1.add(ref);
176551
176760
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -176664,23 +176873,30 @@ var ts;
176664
176873
  var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
176665
176874
  defaultDefinition :
176666
176875
  defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
176667
- // Track which projects we have already searched so that we don't repeat searches.
176668
- // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
176669
- // (For that same reason, we don't use `resultsMap` for this check.)
176670
- var searchedProjects = new ts.Set();
176876
+ // The keys of resultsMap allow us to check which projects have already been searched, but we also
176877
+ // maintain a set of strings because that's what `loadAncestorProjectTree` wants.
176878
+ var searchedProjectKeys = new ts.Set();
176671
176879
  onCancellation: while (queue.length) {
176672
176880
  while (queue.length) {
176673
176881
  if (cancellationToken.isCancellationRequested())
176674
176882
  break onCancellation;
176883
+ var skipCount = 0;
176884
+ for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
176885
+ ;
176886
+ if (skipCount === queue.length) {
176887
+ queue.length = 0;
176888
+ break;
176889
+ }
176890
+ if (skipCount > 0) {
176891
+ queue.splice(0, skipCount);
176892
+ }
176893
+ // NB: we may still skip if it's a project reference redirect
176675
176894
  var _a = queue.shift(), project = _a.project, location = _a.location;
176676
176895
  if (isLocationProjectReferenceRedirect(project, location))
176677
176896
  continue;
176678
- if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
176679
- continue;
176680
176897
  var projectResults = searchPosition(project, location);
176681
- if (projectResults) {
176682
- resultsMap.set(project, projectResults);
176683
- }
176898
+ resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
176899
+ searchedProjectKeys.add(getProjectKey(project));
176684
176900
  }
176685
176901
  // At this point, we know about all projects passed in as arguments and any projects in which
176686
176902
  // `getResultsForPosition` has returned results. We expand that set to include any projects
@@ -176688,11 +176904,11 @@ var ts;
176688
176904
  // containing `initialLocation`.
176689
176905
  if (defaultDefinition) {
176690
176906
  // This seems to mean "load all projects downstream from any member of `seenProjects`".
176691
- projectService.loadAncestorProjectTree(searchedProjects);
176907
+ projectService.loadAncestorProjectTree(searchedProjectKeys);
176692
176908
  projectService.forEachEnabledProject(function (project) {
176693
176909
  if (cancellationToken.isCancellationRequested())
176694
176910
  return; // There's no mechanism for skipping the remaining projects
176695
- if (searchedProjects.has(getProjectKey(project)))
176911
+ if (resultsMap.has(project))
176696
176912
  return; // Can loop forever without this (enqueue here, dequeue above, repeat)
176697
176913
  var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
176698
176914
  if (location) {
@@ -176703,9 +176919,10 @@ var ts;
176703
176919
  }
176704
176920
  // In the common case where there's only one project, return a simpler result to make
176705
176921
  // it easier for the caller to skip post-processing.
176706
- if (searchedProjects.size === 1) {
176922
+ if (resultsMap.size === 1) {
176707
176923
  var it = resultsMap.values().next();
176708
- return it.done ? server.emptyArray : it.value; // There may not be any results at all
176924
+ ts.Debug.assert(!it.done);
176925
+ return it.value;
176709
176926
  }
176710
176927
  return resultsMap;
176711
176928
  function searchPosition(project, location) {
@@ -176722,7 +176939,7 @@ var ts;
176722
176939
  var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
176723
176940
  for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
176724
176941
  var project_1 = _a[_i];
176725
- if (!project_1.isOrphan()) {
176942
+ if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
176726
176943
  queue.push({ project: project_1, location: originalLocation });
176727
176944
  }
176728
176945
  }
@@ -176731,7 +176948,7 @@ var ts;
176731
176948
  symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
176732
176949
  for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
176733
176950
  var symlinkedProject = symlinkedProjects_2[_i];
176734
- if (!symlinkedProject.isOrphan()) {
176951
+ if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
176735
176952
  queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
176736
176953
  }
176737
176954
  }
@@ -178024,7 +178241,8 @@ var ts;
178024
178241
  Session.prototype.getRenameInfo = function (args) {
178025
178242
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
178026
178243
  var position = this.getPositionInFile(args, file);
178027
- return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
178244
+ var preferences = this.getPreferences(file);
178245
+ return project.getLanguageService().getRenameInfo(file, position, preferences);
178028
178246
  };
178029
178247
  Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
178030
178248
  var _a;
@@ -178075,10 +178293,11 @@ var ts;
178075
178293
  var position = this.getPositionInFile(args, file);
178076
178294
  var projects = this.getProjects(args);
178077
178295
  var defaultProject = this.getDefaultProject(args);
178078
- var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178296
+ var preferences = this.getPreferences(file);
178297
+ var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178079
178298
  if (!renameInfo.canRename)
178080
178299
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
178081
- var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
178300
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
178082
178301
  if (!simplifiedResult)
178083
178302
  return locations;
178084
178303
  return { info: renameInfo, locs: this.toSpanGroups(locations) };