typescript 4.8.0-dev.20220617 → 4.8.0-dev.20220620

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-dev.20220617";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220620";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -9944,6 +9944,9 @@ var ts;
9944
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."),
9945
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."),
9946
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."),
9947
9950
  };
9948
9951
  })(ts || (ts = {}));
9949
9952
  var ts;
@@ -34532,10 +34535,10 @@ var ts;
34532
34535
  setDecoratorContext(/*val*/ false);
34533
34536
  }
34534
34537
  var pos = getNodePos();
34535
- var expr = parseAssignmentExpressionOrHigher();
34538
+ var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
34536
34539
  var operatorToken;
34537
34540
  while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
34538
- expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
34541
+ expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
34539
34542
  }
34540
34543
  if (saveDecoratorContext) {
34541
34544
  setDecoratorContext(/*val*/ true);
@@ -34543,9 +34546,9 @@ var ts;
34543
34546
  return expr;
34544
34547
  }
34545
34548
  function parseInitializer() {
34546
- return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
34549
+ return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
34547
34550
  }
34548
- function parseAssignmentExpressionOrHigher() {
34551
+ function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
34549
34552
  // AssignmentExpression[in,yield]:
34550
34553
  // 1) ConditionalExpression[?in,?yield]
34551
34554
  // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -34571,7 +34574,7 @@ var ts;
34571
34574
  // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
34572
34575
  // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
34573
34576
  // with AssignmentExpression if we see one.
34574
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
34577
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
34575
34578
  if (arrowExpression) {
34576
34579
  return arrowExpression;
34577
34580
  }
@@ -34590,7 +34593,7 @@ var ts;
34590
34593
  // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
34591
34594
  // identifier and the current token is an arrow.
34592
34595
  if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
34593
- return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
34596
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
34594
34597
  }
34595
34598
  // Now see if we might be in cases '2' or '3'.
34596
34599
  // If the expression was a LHS expression, and we have an assignment operator, then
@@ -34599,10 +34602,10 @@ var ts;
34599
34602
  // Note: we call reScanGreaterToken so that we get an appropriately merged token
34600
34603
  // for cases like `> > =` becoming `>>=`
34601
34604
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
34602
- return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
34605
+ return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
34603
34606
  }
34604
34607
  // It wasn't an assignment or a lambda. This is a conditional expression:
34605
- return parseConditionalExpressionRest(expr, pos);
34608
+ return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
34606
34609
  }
34607
34610
  function isYieldExpression() {
34608
34611
  if (token() === 125 /* YieldKeyword */) {
@@ -34642,7 +34645,7 @@ var ts;
34642
34645
  nextToken();
34643
34646
  if (!scanner.hasPrecedingLineBreak() &&
34644
34647
  (token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
34645
- return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
34648
+ return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
34646
34649
  }
34647
34650
  else {
34648
34651
  // if the next token is not on the same line as yield. or we don't have an '*' or
@@ -34650,7 +34653,7 @@ var ts;
34650
34653
  return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
34651
34654
  }
34652
34655
  }
34653
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
34656
+ function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
34654
34657
  ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
34655
34658
  var parameter = factory.createParameterDeclaration(
34656
34659
  /*modifiers*/ undefined,
@@ -34661,11 +34664,11 @@ var ts;
34661
34664
  finishNode(parameter, identifier.pos);
34662
34665
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
34663
34666
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
34664
- var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
34667
+ var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
34665
34668
  var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
34666
34669
  return addJSDocComment(finishNode(node, pos));
34667
34670
  }
34668
- function tryParseParenthesizedArrowFunctionExpression() {
34671
+ function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34669
34672
  var triState = isParenthesizedArrowFunctionExpression();
34670
34673
  if (triState === 0 /* False */) {
34671
34674
  // It's definitely not a parenthesized arrow function expression.
@@ -34676,8 +34679,8 @@ var ts;
34676
34679
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
34677
34680
  // expression instead.
34678
34681
  return triState === 1 /* True */ ?
34679
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
34680
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
34682
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
34683
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
34681
34684
  }
34682
34685
  // True -> We definitely expect a parenthesized arrow function here.
34683
34686
  // False -> There *cannot* be a parenthesized arrow function here.
@@ -34811,25 +34814,25 @@ var ts;
34811
34814
  return 2 /* Unknown */;
34812
34815
  }
34813
34816
  }
34814
- function parsePossibleParenthesizedArrowFunctionExpression() {
34817
+ function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34815
34818
  var tokenPos = scanner.getTokenPos();
34816
34819
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
34817
34820
  return undefined;
34818
34821
  }
34819
- var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
34822
+ var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
34820
34823
  if (!result) {
34821
34824
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
34822
34825
  }
34823
34826
  return result;
34824
34827
  }
34825
- function tryParseAsyncSimpleArrowFunctionExpression() {
34828
+ function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
34826
34829
  // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
34827
34830
  if (token() === 131 /* AsyncKeyword */) {
34828
34831
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
34829
34832
  var pos = getNodePos();
34830
34833
  var asyncModifier = parseModifiersForArrowFunction();
34831
34834
  var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
34832
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
34835
+ return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
34833
34836
  }
34834
34837
  }
34835
34838
  return undefined;
@@ -34853,7 +34856,7 @@ var ts;
34853
34856
  }
34854
34857
  return 0 /* False */;
34855
34858
  }
34856
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
34859
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
34857
34860
  var pos = getNodePos();
34858
34861
  var hasJSDoc = hasPrecedingJSDocComment();
34859
34862
  var modifiers = parseModifiersForArrowFunction();
@@ -34888,6 +34891,7 @@ var ts;
34888
34891
  return undefined;
34889
34892
  }
34890
34893
  }
34894
+ var hasReturnColon = token() === 58 /* ColonToken */;
34891
34895
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
34892
34896
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
34893
34897
  return undefined;
@@ -34916,12 +34920,37 @@ var ts;
34916
34920
  var lastToken = token();
34917
34921
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
34918
34922
  var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
34919
- ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
34923
+ ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
34920
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
+ }
34921
34950
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
34922
34951
  return withJSDoc(finishNode(node, pos), hasJSDoc);
34923
34952
  }
34924
- function parseArrowFunctionExpressionBody(isAsync) {
34953
+ function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
34925
34954
  if (token() === 18 /* OpenBraceToken */) {
34926
34955
  return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
34927
34956
  }
@@ -34949,12 +34978,12 @@ var ts;
34949
34978
  var savedTopLevel = topLevel;
34950
34979
  topLevel = false;
34951
34980
  var node = isAsync
34952
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
34953
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
34981
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
34982
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
34954
34983
  topLevel = savedTopLevel;
34955
34984
  return node;
34956
34985
  }
34957
- function parseConditionalExpressionRest(leftOperand, pos) {
34986
+ function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
34958
34987
  // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
34959
34988
  var questionToken = parseOptionalToken(57 /* QuestionToken */);
34960
34989
  if (!questionToken) {
@@ -34963,8 +34992,8 @@ var ts;
34963
34992
  // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
34964
34993
  // we do not that for the 'whenFalse' part.
34965
34994
  var colonToken;
34966
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
34967
- ? 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)
34968
34997
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
34969
34998
  }
34970
34999
  function parseBinaryExpressionOrHigher(precedence) {
@@ -35879,13 +35908,13 @@ var ts;
35879
35908
  function parseSpreadElement() {
35880
35909
  var pos = getNodePos();
35881
35910
  parseExpected(25 /* DotDotDotToken */);
35882
- var expression = parseAssignmentExpressionOrHigher();
35911
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35883
35912
  return finishNode(factory.createSpreadElement(expression), pos);
35884
35913
  }
35885
35914
  function parseArgumentOrArrayLiteralElement() {
35886
35915
  return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
35887
35916
  token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
35888
- parseAssignmentExpressionOrHigher();
35917
+ parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35889
35918
  }
35890
35919
  function parseArgumentExpression() {
35891
35920
  return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
@@ -35903,7 +35932,7 @@ var ts;
35903
35932
  var pos = getNodePos();
35904
35933
  var hasJSDoc = hasPrecedingJSDocComment();
35905
35934
  if (parseOptionalToken(25 /* DotDotDotToken */)) {
35906
- var expression = parseAssignmentExpressionOrHigher();
35935
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
35907
35936
  return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
35908
35937
  }
35909
35938
  var decorators = parseDecorators();
@@ -35932,7 +35961,7 @@ var ts;
35932
35961
  var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
35933
35962
  if (isShorthandPropertyAssignment) {
35934
35963
  var equalsToken = parseOptionalToken(63 /* EqualsToken */);
35935
- var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
35964
+ var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
35936
35965
  node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
35937
35966
  // Save equals token for error reporting.
35938
35967
  // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
@@ -35940,7 +35969,7 @@ var ts;
35940
35969
  }
35941
35970
  else {
35942
35971
  parseExpected(58 /* ColonToken */);
35943
- var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
35972
+ var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
35944
35973
  node = factory.createPropertyAssignment(name, initializer);
35945
35974
  }
35946
35975
  // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
@@ -36117,7 +36146,7 @@ var ts;
36117
36146
  }
36118
36147
  var node;
36119
36148
  if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
36120
- var expression = allowInAnd(parseAssignmentExpressionOrHigher);
36149
+ var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
36121
36150
  parseExpected(21 /* CloseParenToken */);
36122
36151
  node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
36123
36152
  }
@@ -37305,7 +37334,7 @@ var ts;
37305
37334
  var pos = getNodePos();
37306
37335
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
37307
37336
  parseExpected(58 /* ColonToken */);
37308
- var value = parseAssignmentExpressionOrHigher();
37337
+ var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37309
37338
  return finishNode(factory.createAssertEntry(name, value), pos);
37310
37339
  }
37311
37340
  function parseAssertClause(skipAssertKeyword) {
@@ -37546,7 +37575,7 @@ var ts;
37546
37575
  else {
37547
37576
  parseExpected(88 /* DefaultKeyword */);
37548
37577
  }
37549
- var expression = parseAssignmentExpressionOrHigher();
37578
+ var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
37550
37579
  parseSemicolon();
37551
37580
  setAwaitContext(savedAwaitContext);
37552
37581
  var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
@@ -85672,6 +85701,7 @@ var ts;
85672
85701
  return true;
85673
85702
  }
85674
85703
  function checkAliasSymbol(node) {
85704
+ var _a, _b, _c, _d, _e;
85675
85705
  var symbol = getSymbolOfNode(node);
85676
85706
  var target = resolveAlias(symbol);
85677
85707
  if (target !== unknownSymbol) {
@@ -85682,6 +85712,31 @@ var ts;
85682
85712
  // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
85683
85713
  // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
85684
85714
  symbol = getMergedSymbol(symbol.exportSymbol || symbol);
85715
+ // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
85716
+ if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
85717
+ var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
85718
+ ts.isNamedDeclaration(node) ? node.name :
85719
+ node;
85720
+ ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
85721
+ if (node.kind === 275 /* ExportSpecifier */) {
85722
+ var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
85723
+ 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);
85724
+ if (alreadyExportedSymbol === target) {
85725
+ var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
85726
+ if (exportingDeclaration) {
85727
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
85728
+ }
85729
+ }
85730
+ }
85731
+ else {
85732
+ ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
85733
+ var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
85734
+ var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
85735
+ var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
85736
+ 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);
85737
+ }
85738
+ return;
85739
+ }
85685
85740
  var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
85686
85741
  (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
85687
85742
  (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
@@ -130682,32 +130737,41 @@ var ts;
130682
130737
  || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
130683
130738
  || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
130684
130739
  }
130685
- function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
130740
+ function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
130686
130741
  var _a, _b;
130687
- forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
130742
+ var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
130743
+ var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
130744
+ // The client is expected to send rooted path specs since we don't know
130745
+ // what directory a relative path is relative to.
130746
+ var pattern = ts.getPatternFromSpec(spec, "", "exclude");
130747
+ return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
130748
+ });
130749
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
130688
130750
  var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
130689
130751
  if (autoImportProvider) {
130690
130752
  var start = ts.timestamp();
130691
- forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
130753
+ forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
130692
130754
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
130693
130755
  }
130694
130756
  }
130695
130757
  ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
130696
- function forEachExternalModule(checker, allSourceFiles, cb) {
130697
- for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) {
130698
- var ambient = _a[_i];
130699
- if (!ts.stringContains(ambient.name, "*")) {
130758
+ function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
130759
+ var _a;
130760
+ var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
130761
+ for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
130762
+ var ambient = _b[_i];
130763
+ if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
130700
130764
  cb(ambient, /*sourceFile*/ undefined);
130701
130765
  }
130702
130766
  }
130703
- for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) {
130704
- var sourceFile = allSourceFiles_1[_b];
130705
- if (ts.isExternalOrCommonJsModule(sourceFile)) {
130767
+ for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
130768
+ var sourceFile = allSourceFiles_1[_c];
130769
+ if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
130706
130770
  cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
130707
130771
  }
130708
130772
  }
130709
130773
  }
130710
- function getExportInfoMap(importingFile, host, program, cancellationToken) {
130774
+ function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
130711
130775
  var _a, _b, _c, _d, _e;
130712
130776
  var start = ts.timestamp();
130713
130777
  // Pulling the AutoImportProvider project will trigger its updateGraph if pending,
@@ -130727,7 +130791,7 @@ var ts;
130727
130791
  var compilerOptions = program.getCompilerOptions();
130728
130792
  var moduleCount = 0;
130729
130793
  try {
130730
- forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
130794
+ forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
130731
130795
  if (++moduleCount % 100 === 0)
130732
130796
  cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
130733
130797
  var seenExports = new ts.Map();
@@ -133123,7 +133187,7 @@ var ts;
133123
133187
  if (!previousResponse)
133124
133188
  return undefined;
133125
133189
  var lowerCaseTokenText = location.text.toLowerCase();
133126
- var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
133190
+ var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
133127
133191
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
133128
133192
  /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133129
133193
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
@@ -134935,7 +134999,7 @@ var ts;
134935
134999
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
134936
135000
  "";
134937
135001
  var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
134938
- var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
135002
+ var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
134939
135003
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
134940
135004
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
134941
135005
  resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
@@ -154132,7 +154196,7 @@ var ts;
154132
154196
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
154133
154197
  return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
154134
154198
  });
154135
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154199
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
154136
154200
  var checker = program.getTypeChecker();
154137
154201
  // Don't import from a re-export when looking "up" like to `./index` or `../index`.
154138
154202
  if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
@@ -154601,7 +154665,7 @@ var ts;
154601
154665
  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 });
154602
154666
  }
154603
154667
  }
154604
- ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
154668
+ ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
154605
154669
  var checker = program.getTypeChecker();
154606
154670
  cancellationToken.throwIfCancellationRequested();
154607
154671
  var compilerOptions = program.getCompilerOptions();
@@ -4138,6 +4138,7 @@ declare namespace ts {
4138
4138
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4139
4139
  readonly includeInlayEnumMemberValueHints?: boolean;
4140
4140
  readonly allowRenameOfImportPath?: boolean;
4141
+ readonly autoImportFileExcludePatterns?: string[];
4141
4142
  }
4142
4143
  /** Represents a bigint literal value without requiring bigint support */
4143
4144
  export interface PseudoBigInt {
@@ -9769,6 +9770,7 @@ declare namespace ts.server.protocol {
9769
9770
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
9770
9771
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
9771
9772
  readonly includeInlayEnumMemberValueHints?: boolean;
9773
+ readonly autoImportFileExcludePatterns?: string[];
9772
9774
  }
9773
9775
  interface CompilerOptions {
9774
9776
  allowJs?: boolean;