@typescript-deploys/pr-build 4.7.0-pr-48094-5 → 4.7.0-pr-48264-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220314";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220316";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8228,7 +8228,7 @@ var ts;
8228
8228
  Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
8229
8229
  _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
8230
8230
  A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
8231
- The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."),
8231
+ The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."),
8232
8232
  Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
8233
8233
  Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
8234
8234
  An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
@@ -15144,6 +15144,10 @@ var ts;
15144
15144
  }
15145
15145
  }
15146
15146
  ts.isAnyImportSyntax = isAnyImportSyntax;
15147
+ function isAnyImportOrBareOrAccessedRequire(node) {
15148
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
15149
+ }
15150
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
15147
15151
  function isLateVisibilityPaintedStatement(node) {
15148
15152
  switch (node.kind) {
15149
15153
  case 265 /* ImportDeclaration */:
@@ -16722,14 +16726,14 @@ var ts;
16722
16726
  }
16723
16727
  ts.isFunctionSymbol = isFunctionSymbol;
16724
16728
  function tryGetModuleSpecifierFromDeclaration(node) {
16725
- var _a, _b, _c;
16729
+ var _a, _b;
16726
16730
  switch (node.kind) {
16727
16731
  case 253 /* VariableDeclaration */:
16728
- return node.initializer.arguments[0].text;
16732
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16729
16733
  case 265 /* ImportDeclaration */:
16730
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16734
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16731
16735
  case 264 /* ImportEqualsDeclaration */:
16732
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
16736
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16733
16737
  default:
16734
16738
  ts.Debug.assertNever(node);
16735
16739
  }
@@ -17256,21 +17260,28 @@ var ts;
17256
17260
  // export = <EntityNameExpression>
17257
17261
  // export default <EntityNameExpression>
17258
17262
  // module.exports = <EntityNameExpression>
17259
- // {<Identifier>}
17260
- // {name: <EntityNameExpression>}
17263
+ // module.exports.x = <EntityNameExpression>
17264
+ // const x = require("...")
17265
+ // const { x } = require("...")
17266
+ // const x = require("...").y
17267
+ // const { x } = require("...").y
17261
17268
  function isAliasSymbolDeclaration(node) {
17262
- return node.kind === 264 /* ImportEqualsDeclaration */ ||
17269
+ if (node.kind === 264 /* ImportEqualsDeclaration */ ||
17263
17270
  node.kind === 263 /* NamespaceExportDeclaration */ ||
17264
17271
  node.kind === 266 /* ImportClause */ && !!node.name ||
17265
17272
  node.kind === 267 /* NamespaceImport */ ||
17266
17273
  node.kind === 273 /* NamespaceExport */ ||
17267
17274
  node.kind === 269 /* ImportSpecifier */ ||
17268
17275
  node.kind === 274 /* ExportSpecifier */ ||
17269
- node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17270
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17271
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17272
- node.kind === 296 /* ShorthandPropertyAssignment */ ||
17273
- node.kind === 295 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17276
+ node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17277
+ return true;
17278
+ }
17279
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17280
+ ts.isPropertyAccessExpression(node)
17281
+ && ts.isBinaryExpression(node.parent)
17282
+ && node.parent.left === node
17283
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17284
+ && isAliasableExpression(node.parent.right));
17274
17285
  }
17275
17286
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17276
17287
  function getAliasDeclarationFromName(node) {
@@ -17281,6 +17292,7 @@ var ts;
17281
17292
  case 274 /* ExportSpecifier */:
17282
17293
  case 270 /* ExportAssignment */:
17283
17294
  case 264 /* ImportEqualsDeclaration */:
17295
+ case 273 /* NamespaceExport */:
17284
17296
  return node.parent;
17285
17297
  case 160 /* QualifiedName */:
17286
17298
  do {
@@ -31620,20 +31632,23 @@ var ts;
31620
31632
  return inContext(32768 /* AwaitContext */);
31621
31633
  }
31622
31634
  function parseErrorAtCurrentToken(message, arg0) {
31623
- parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
31635
+ return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
31624
31636
  }
31625
31637
  function parseErrorAtPosition(start, length, message, arg0) {
31626
31638
  // Don't report another error if it would just be at the same position as the last error.
31627
31639
  var lastError = ts.lastOrUndefined(parseDiagnostics);
31640
+ var result;
31628
31641
  if (!lastError || start !== lastError.start) {
31629
- parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
31642
+ result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
31643
+ parseDiagnostics.push(result);
31630
31644
  }
31631
31645
  // Mark that we've encountered an error. We'll set an appropriate bit on the next
31632
31646
  // node we finish so that it can't be reused incrementally.
31633
31647
  parseErrorBeforeNextFinishedNode = true;
31648
+ return result;
31634
31649
  }
31635
31650
  function parseErrorAt(start, end, message, arg0) {
31636
- parseErrorAtPosition(start, end - start, message, arg0);
31651
+ return parseErrorAtPosition(start, end - start, message, arg0);
31637
31652
  }
31638
31653
  function parseErrorAtRange(range, message, arg0) {
31639
31654
  parseErrorAt(range.pos, range.end, message, arg0);
@@ -31906,6 +31921,19 @@ var ts;
31906
31921
  parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
31907
31922
  return false;
31908
31923
  }
31924
+ function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
31925
+ if (token() === closeKind) {
31926
+ nextToken();
31927
+ return;
31928
+ }
31929
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
31930
+ if (!openParsed) {
31931
+ return;
31932
+ }
31933
+ if (lastError) {
31934
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind)));
31935
+ }
31936
+ }
31909
31937
  function parseOptional(t) {
31910
31938
  if (token() === t) {
31911
31939
  nextToken();
@@ -33554,7 +33582,7 @@ var ts;
33554
33582
  if (!parseExpected(19 /* CloseBraceToken */)) {
33555
33583
  var lastError = ts.lastOrUndefined(parseDiagnostics);
33556
33584
  if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33557
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33585
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
33558
33586
  }
33559
33587
  }
33560
33588
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
@@ -35364,10 +35392,11 @@ var ts;
35364
35392
  }
35365
35393
  function parseArrayLiteralExpression() {
35366
35394
  var pos = getNodePos();
35367
- parseExpected(22 /* OpenBracketToken */);
35395
+ var openBracketPosition = scanner.getTokenPos();
35396
+ var openBracketParsed = parseExpected(22 /* OpenBracketToken */);
35368
35397
  var multiLine = scanner.hasPrecedingLineBreak();
35369
35398
  var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
35370
- parseExpected(23 /* CloseBracketToken */);
35399
+ parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition);
35371
35400
  return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
35372
35401
  }
35373
35402
  function parseObjectLiteralElement() {
@@ -35424,15 +35453,10 @@ var ts;
35424
35453
  function parseObjectLiteralExpression() {
35425
35454
  var pos = getNodePos();
35426
35455
  var openBracePosition = scanner.getTokenPos();
35427
- parseExpected(18 /* OpenBraceToken */);
35456
+ var openBraceParsed = parseExpected(18 /* OpenBraceToken */);
35428
35457
  var multiLine = scanner.hasPrecedingLineBreak();
35429
35458
  var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
35430
- if (!parseExpected(19 /* CloseBraceToken */)) {
35431
- var lastError = ts.lastOrUndefined(parseDiagnostics);
35432
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35433
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35434
- }
35435
- }
35459
+ parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
35436
35460
  return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
35437
35461
  }
35438
35462
  function parseFunctionExpression() {
@@ -35488,15 +35512,11 @@ var ts;
35488
35512
  var pos = getNodePos();
35489
35513
  var hasJSDoc = hasPrecedingJSDocComment();
35490
35514
  var openBracePosition = scanner.getTokenPos();
35491
- if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
35515
+ var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage);
35516
+ if (openBraceParsed || ignoreMissingOpenBrace) {
35492
35517
  var multiLine = scanner.hasPrecedingLineBreak();
35493
35518
  var statements = parseList(1 /* BlockStatements */, parseStatement);
35494
- if (!parseExpected(19 /* CloseBraceToken */)) {
35495
- var lastError = ts.lastOrUndefined(parseDiagnostics);
35496
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35497
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35498
- }
35499
- }
35519
+ parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
35500
35520
  var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
35501
35521
  if (token() === 63 /* EqualsToken */) {
35502
35522
  parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
@@ -35541,9 +35561,10 @@ var ts;
35541
35561
  var pos = getNodePos();
35542
35562
  var hasJSDoc = hasPrecedingJSDocComment();
35543
35563
  parseExpected(99 /* IfKeyword */);
35544
- parseExpected(20 /* OpenParenToken */);
35564
+ var openParenPosition = scanner.getTokenPos();
35565
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35545
35566
  var expression = allowInAnd(parseExpression);
35546
- parseExpected(21 /* CloseParenToken */);
35567
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35547
35568
  var thenStatement = parseStatement();
35548
35569
  var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined;
35549
35570
  return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
@@ -35554,9 +35575,10 @@ var ts;
35554
35575
  parseExpected(90 /* DoKeyword */);
35555
35576
  var statement = parseStatement();
35556
35577
  parseExpected(115 /* WhileKeyword */);
35557
- parseExpected(20 /* OpenParenToken */);
35578
+ var openParenPosition = scanner.getTokenPos();
35579
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35558
35580
  var expression = allowInAnd(parseExpression);
35559
- parseExpected(21 /* CloseParenToken */);
35581
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35560
35582
  // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
35561
35583
  // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
35562
35584
  // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
@@ -35568,9 +35590,10 @@ var ts;
35568
35590
  var pos = getNodePos();
35569
35591
  var hasJSDoc = hasPrecedingJSDocComment();
35570
35592
  parseExpected(115 /* WhileKeyword */);
35571
- parseExpected(20 /* OpenParenToken */);
35593
+ var openParenPosition = scanner.getTokenPos();
35594
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35572
35595
  var expression = allowInAnd(parseExpression);
35573
- parseExpected(21 /* CloseParenToken */);
35596
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35574
35597
  var statement = parseStatement();
35575
35598
  return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
35576
35599
  }
@@ -35637,9 +35660,10 @@ var ts;
35637
35660
  var pos = getNodePos();
35638
35661
  var hasJSDoc = hasPrecedingJSDocComment();
35639
35662
  parseExpected(116 /* WithKeyword */);
35640
- parseExpected(20 /* OpenParenToken */);
35663
+ var openParenPosition = scanner.getTokenPos();
35664
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35641
35665
  var expression = allowInAnd(parseExpression);
35642
- parseExpected(21 /* CloseParenToken */);
35666
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35643
35667
  var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35644
35668
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35645
35669
  }
@@ -36773,7 +36797,7 @@ var ts;
36773
36797
  if (!parseExpected(19 /* CloseBraceToken */)) {
36774
36798
  var lastError = ts.lastOrUndefined(parseDiagnostics);
36775
36799
  if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
36776
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
36800
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
36777
36801
  }
36778
36802
  }
36779
36803
  return finishNode(factory.createAssertClause(elements, multiLine), pos);
@@ -37749,8 +37773,7 @@ var ts;
37749
37773
  hasChildren = true;
37750
37774
  if (child.kind === 342 /* JSDocTypeTag */) {
37751
37775
  if (childTypeTag) {
37752
- parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
37753
- var lastError = ts.lastOrUndefined(parseDiagnostics);
37776
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
37754
37777
  if (lastError) {
37755
37778
  ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
37756
37779
  }
@@ -39628,6 +39651,13 @@ var ts;
39628
39651
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39629
39652
  defaultValueDescription: false,
39630
39653
  },
39654
+ {
39655
+ name: "noDtsResolution",
39656
+ type: "boolean",
39657
+ affectsModuleResolution: true,
39658
+ category: ts.Diagnostics.Modules,
39659
+ defaultValueDescription: false,
39660
+ },
39631
39661
  // Source Maps
39632
39662
  {
39633
39663
  name: "sourceRoot",
@@ -42007,7 +42037,8 @@ var ts;
42007
42037
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
42008
42038
  Extensions[Extensions["Json"] = 2] = "Json";
42009
42039
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
42010
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42040
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42041
+ Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
42011
42042
  })(Extensions || (Extensions = {}));
42012
42043
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
42013
42044
  function resolvedTypeScriptOnly(resolved) {
@@ -42952,7 +42983,21 @@ var ts;
42952
42983
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42953
42984
  }
42954
42985
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
42955
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
42986
+ var extensions;
42987
+ if (lookupConfig) {
42988
+ extensions = tsconfigExtensions;
42989
+ }
42990
+ else if (compilerOptions.noDtsResolution) {
42991
+ extensions = [Extensions.TypeScriptButNotDts];
42992
+ if (compilerOptions.allowJs)
42993
+ extensions.push(Extensions.JavaScript);
42994
+ if (compilerOptions.resolveJsonModule)
42995
+ extensions.push(Extensions.Json);
42996
+ }
42997
+ else {
42998
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
42999
+ }
43000
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
42956
43001
  }
42957
43002
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42958
43003
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42961,6 +43006,10 @@ var ts;
42961
43006
  var failedLookupLocations = [];
42962
43007
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42963
43008
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43009
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43010
+ if (compilerOptions.noDtsResolution) {
43011
+ conditions.pop();
43012
+ }
42964
43013
  var state = {
42965
43014
  compilerOptions: compilerOptions,
42966
43015
  host: host,
@@ -42968,7 +43017,7 @@ var ts;
42968
43017
  failedLookupLocations: failedLookupLocations,
42969
43018
  packageJsonInfoCache: cache,
42970
43019
  features: features,
42971
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43020
+ conditions: conditions,
42972
43021
  };
42973
43022
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42974
43023
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -43176,20 +43225,22 @@ var ts;
43176
43225
  default: return tryExtension(".d.ts" /* Dts */);
43177
43226
  }
43178
43227
  case Extensions.TypeScript:
43228
+ case Extensions.TypeScriptButNotDts:
43229
+ var useDts = extensions === Extensions.TypeScript;
43179
43230
  switch (originalExtension) {
43180
43231
  case ".mjs" /* Mjs */:
43181
43232
  case ".mts" /* Mts */:
43182
43233
  case ".d.mts" /* Dmts */:
43183
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43234
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43184
43235
  case ".cjs" /* Cjs */:
43185
43236
  case ".cts" /* Cts */:
43186
43237
  case ".d.cts" /* Dcts */:
43187
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43238
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43188
43239
  case ".json" /* Json */:
43189
43240
  candidate += ".json" /* Json */;
43190
- return tryExtension(".d.ts" /* Dts */);
43241
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43191
43242
  default:
43192
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43243
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43193
43244
  }
43194
43245
  case Extensions.JavaScript:
43195
43246
  switch (originalExtension) {
@@ -43407,6 +43458,7 @@ var ts;
43407
43458
  switch (extensions) {
43408
43459
  case Extensions.JavaScript:
43409
43460
  case Extensions.Json:
43461
+ case Extensions.TypeScriptButNotDts:
43410
43462
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43411
43463
  break;
43412
43464
  case Extensions.TypeScript:
@@ -43485,6 +43537,8 @@ var ts;
43485
43537
  return extension === ".json" /* Json */;
43486
43538
  case Extensions.TypeScript:
43487
43539
  return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43540
+ case Extensions.TypeScriptButNotDts:
43541
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
43488
43542
  case Extensions.DtsOnly:
43489
43543
  return extension === ".d.ts" /* Dts */;
43490
43544
  }
@@ -55553,7 +55607,7 @@ var ts;
55553
55607
  }
55554
55608
  }
55555
55609
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55556
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55610
+ type = getUnionType(sourceTypes);
55557
55611
  }
55558
55612
  }
55559
55613
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -58488,8 +58542,10 @@ var ts;
58488
58542
  return type;
58489
58543
  }
58490
58544
  function isMappedTypeGenericIndexedAccess(type) {
58491
- return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
58492
- !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
58545
+ var objectType;
58546
+ return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58547
+ !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58548
+ !objectType.declaration.questionToken && !objectType.declaration.nameType);
58493
58549
  }
58494
58550
  /**
58495
58551
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -59077,7 +59133,19 @@ var ts;
59077
59133
  return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
59078
59134
  });
59079
59135
  var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */);
59080
- syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
59136
+ if (lastParamVariadicType) {
59137
+ // Parameter has effective annotation, lock in type
59138
+ syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type));
59139
+ }
59140
+ else {
59141
+ // Parameter has no annotation
59142
+ // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been
59143
+ // cached by `getTypeOfSymbol` yet.
59144
+ syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */;
59145
+ syntheticArgsSymbol.deferralParent = neverType;
59146
+ syntheticArgsSymbol.deferralConstituents = [anyArrayType];
59147
+ syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType];
59148
+ }
59081
59149
  if (lastParamVariadicType) {
59082
59150
  // Replace the last parameter with a rest parameter.
59083
59151
  parameters.pop();
@@ -61674,7 +61742,7 @@ var ts;
61674
61742
  // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
61675
61743
  // that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
61676
61744
  // construct the type Box<T[X]>.
61677
- if (isGenericMappedType(objectType)) {
61745
+ if (isGenericMappedType(objectType) && !objectType.declaration.nameType) {
61678
61746
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
61679
61747
  }
61680
61748
  return type[cache] = type;
@@ -63747,7 +63815,7 @@ var ts;
63747
63815
  var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
63748
63816
  : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
63749
63817
  : getReturnTypeOfSignature(target);
63750
- if (targetReturnType === voidType) {
63818
+ if (targetReturnType === voidType || targetReturnType === anyType) {
63751
63819
  return result;
63752
63820
  }
63753
63821
  var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
@@ -67606,32 +67674,13 @@ var ts;
67606
67674
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
67607
67675
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
67608
67676
  }
67609
- /**
67610
- * Tests whether the provided string can be parsed as a number.
67611
- * @param s The string to test.
67612
- * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
67613
- */
67614
- function isValidNumberString(s, roundTripOnly) {
67615
- if (s === "")
67616
- return false;
67617
- var n = +s;
67618
- return isFinite(n) && (!roundTripOnly || "" + n === s);
67619
- }
67620
- /**
67621
- * Tests whether the provided string can be parsed as a bigint.
67622
- * @param s The string to test.
67623
- * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
67624
- */
67625
- function isValidBigIntString(s, roundTripOnly) {
67626
- if (s === "")
67627
- return false;
67677
+ function isValidBigIntString(s) {
67628
67678
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
67629
67679
  var success = true;
67630
67680
  scanner.setOnError(function () { return success = false; });
67631
67681
  scanner.setText(s + "n");
67632
67682
  var result = scanner.scan();
67633
- var negative = result === 40 /* MinusToken */;
67634
- if (negative) {
67683
+ if (result === 40 /* MinusToken */) {
67635
67684
  result = scanner.scan();
67636
67685
  }
67637
67686
  var flags = scanner.getTokenFlags();
@@ -67640,8 +67689,7 @@ var ts;
67640
67689
  // * a bigint can be scanned, and that when it is scanned, it is
67641
67690
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
67642
67691
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
67643
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
67644
- && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
67692
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
67645
67693
  }
67646
67694
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
67647
67695
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -67649,8 +67697,8 @@ var ts;
67649
67697
  }
67650
67698
  if (source.flags & 128 /* StringLiteral */) {
67651
67699
  var value = source.value;
67652
- return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
67653
- target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
67700
+ return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
67701
+ target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
67654
67702
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
67655
67703
  }
67656
67704
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68224,63 +68272,7 @@ var ts;
68224
68272
  // succeed. That would be a pointless and confusing outcome.
68225
68273
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68226
68274
  for (var i = 0; i < types.length; i++) {
68227
- var source_1 = matches ? matches[i] : neverType;
68228
- var target_3 = types[i];
68229
- // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68230
- // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68231
- var sourceTypes = void 0;
68232
- if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68233
- var inferenceContext = getInferenceInfoForType(target_3);
68234
- var constraint = inferenceContext ? getConstraintOfTypeParameter(inferenceContext.typeParameter) : undefined;
68235
- if (inferenceContext && constraint) {
68236
- var str = source_1.value;
68237
- var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68238
- for (var _i = 0, constraintTypes_1 = constraintTypes; _i < constraintTypes_1.length; _i++) {
68239
- var constraintType = constraintTypes_1[_i];
68240
- if (constraintType.flags & 402653316 /* StringLike */) {
68241
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68242
- sourceTypes.push(source_1);
68243
- }
68244
- if (constraintType.flags & 296 /* NumberLike */ && isValidNumberString(str, /*roundTripOnly*/ true)) {
68245
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68246
- sourceTypes.push(getNumberLiteralType(+str));
68247
- }
68248
- if (constraintType.flags & 2112 /* BigIntLike */ && isValidBigIntString(str, /*roundTripOnly*/ true)) {
68249
- var negative = str.startsWith("-");
68250
- var base10Value = ts.parsePseudoBigInt((negative ? str.slice(1) : str) + "n");
68251
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68252
- sourceTypes.push(getBigIntLiteralType({ negative: negative, base10Value: base10Value }));
68253
- }
68254
- if (constraintType.flags & 528 /* BooleanLike */) {
68255
- if (str === trueType.intrinsicName) {
68256
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68257
- sourceTypes.push(trueType);
68258
- }
68259
- else if (str === falseType.intrinsicName) {
68260
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68261
- sourceTypes.push(falseType);
68262
- }
68263
- }
68264
- if (constraintType.flags & 65536 /* Null */ && str === nullType.intrinsicName) {
68265
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68266
- sourceTypes.push(nullType);
68267
- }
68268
- if (constraintType.flags & 32768 /* Undefined */ && str === undefinedType.intrinsicName) {
68269
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68270
- sourceTypes.push(undefinedType);
68271
- }
68272
- }
68273
- }
68274
- }
68275
- if (sourceTypes) {
68276
- for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) {
68277
- var source_2 = sourceTypes_3[_a];
68278
- inferFromTypes(source_2, target_3);
68279
- }
68280
- }
68281
- else {
68282
- inferFromTypes(source_1, target_3);
68283
- }
68275
+ inferFromTypes(matches ? matches[i] : neverType, types[i]);
68284
68276
  }
68285
68277
  }
68286
68278
  }
@@ -72112,7 +72104,7 @@ var ts;
72112
72104
  function getTypeOfPropertyOfContextualType(type, name, nameType) {
72113
72105
  return mapType(type, function (t) {
72114
72106
  var _a;
72115
- if (isGenericMappedType(t)) {
72107
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
72116
72108
  var constraint = getConstraintTypeFromMappedType(t);
72117
72109
  var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
72118
72110
  var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
@@ -77040,7 +77032,11 @@ var ts;
77040
77032
  if (signatureHasRestParameter(signature)) {
77041
77033
  // parameter might be a transient symbol generated by use of `arguments` in the function body.
77042
77034
  var parameter = ts.last(signature.parameters);
77043
- if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
77035
+ if (parameter.valueDeclaration
77036
+ ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)
77037
+ // a declarationless parameter may still have a `.type` already set by its construction logic
77038
+ // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type
77039
+ : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) {
77044
77040
  var contextualParameterType = getRestTypeAtPosition(context, len);
77045
77041
  assignParameterType(parameter, contextualParameterType);
77046
77042
  }
@@ -77059,8 +77055,8 @@ var ts;
77059
77055
  var links = getSymbolLinks(parameter);
77060
77056
  if (!links.type) {
77061
77057
  var declaration = parameter.valueDeclaration;
77062
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
77063
- if (declaration.name.kind !== 79 /* Identifier */) {
77058
+ links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
77059
+ if (declaration && declaration.name.kind !== 79 /* Identifier */) {
77064
77060
  // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
77065
77061
  if (links.type === unknownType) {
77066
77062
  links.type = getTypeFromBindingPattern(declaration.name);
@@ -127673,6 +127669,20 @@ var ts;
127673
127669
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
127674
127670
  }
127675
127671
  ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
127672
+ /**
127673
+ * Returns true if `node` is the declaration of `n` in:
127674
+ * - `import n from "m"`
127675
+ * - `import * as n from "m"`
127676
+ * - `import n = require("m")`
127677
+ * - `const n = require("m")`
127678
+ */
127679
+ function isFreelyNameableImport(node) {
127680
+ return node.kind === 266 /* ImportClause */
127681
+ || node.kind === 267 /* NamespaceImport */
127682
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
127683
+ || ts.isVariableDeclarationInitializedToRequire(node);
127684
+ }
127685
+ ts.isFreelyNameableImport = isFreelyNameableImport;
127676
127686
  function getScriptKind(fileName, host) {
127677
127687
  // First check to see if the script kind was specified by the host. Chances are the host
127678
127688
  // may override the default script kind for the file extension.
@@ -130966,14 +130976,15 @@ var ts;
130966
130976
  SortText["SuggestedClassMembers"] = "14";
130967
130977
  SortText["GlobalsOrKeywords"] = "15";
130968
130978
  SortText["AutoImportSuggestions"] = "16";
130969
- SortText["JavascriptIdentifiers"] = "17";
130970
- SortText["DeprecatedLocalDeclarationPriority"] = "18";
130971
- SortText["DeprecatedLocationPriority"] = "19";
130972
- SortText["DeprecatedOptionalMember"] = "20";
130973
- SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21";
130974
- SortText["DeprecatedSuggestedClassMembers"] = "22";
130975
- SortText["DeprecatedGlobalsOrKeywords"] = "23";
130976
- SortText["DeprecatedAutoImportSuggestions"] = "24";
130979
+ SortText["ClassMemberSnippets"] = "17";
130980
+ SortText["JavascriptIdentifiers"] = "18";
130981
+ SortText["DeprecatedLocalDeclarationPriority"] = "19";
130982
+ SortText["DeprecatedLocationPriority"] = "20";
130983
+ SortText["DeprecatedOptionalMember"] = "21";
130984
+ SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
130985
+ SortText["DeprecatedSuggestedClassMembers"] = "23";
130986
+ SortText["DeprecatedGlobalsOrKeywords"] = "24";
130987
+ SortText["DeprecatedAutoImportSuggestions"] = "25";
130977
130988
  })(SortText = Completions.SortText || (Completions.SortText = {}));
130978
130989
  var SortTextId;
130979
130990
  (function (SortTextId) {
@@ -130985,10 +130996,10 @@ var ts;
130985
130996
  SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
130986
130997
  SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
130987
130998
  // Don't use these directly.
130988
- SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers";
130989
- SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart";
130999
+ SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
131000
+ SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
130990
131001
  SortTextId[SortTextId["_First"] = 10] = "_First";
130991
- SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset";
131002
+ SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
130992
131003
  })(SortTextId || (SortTextId = {}));
130993
131004
  /**
130994
131005
  * Special values for `CompletionInfo['source']` used to disambiguate
@@ -131469,6 +131480,7 @@ var ts;
131469
131480
  isClassLikeMemberCompletion(symbol, location)) {
131470
131481
  var importAdder = void 0;
131471
131482
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
131483
+ sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
131472
131484
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
131473
131485
  hasAction = true;
131474
131486
  source = CompletionSource.ClassMemberSnippet;
@@ -131832,7 +131844,7 @@ var ts;
131832
131844
  }
131833
131845
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
131834
131846
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
131835
- var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131847
+ var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131836
131848
  var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
131837
131849
  if (!entry) {
131838
131850
  continue;
@@ -136687,6 +136699,29 @@ var ts;
136687
136699
  }
136688
136700
  }
136689
136701
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
136702
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
136703
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
136704
+ return candidates.reduce(function (topMost, decl) {
136705
+ var depth = getDepth(decl);
136706
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
136707
+ topMost.declarationNames.push(decl);
136708
+ }
136709
+ else if (depth < topMost.depth) {
136710
+ topMost.declarationNames = [decl];
136711
+ }
136712
+ topMost.depth = depth;
136713
+ return topMost;
136714
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
136715
+ function getDepth(declaration) {
136716
+ var depth = 0;
136717
+ while (declaration) {
136718
+ declaration = ts.getContainerNode(declaration);
136719
+ depth++;
136720
+ }
136721
+ return depth;
136722
+ }
136723
+ }
136724
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
136690
136725
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
136691
136726
  if (!signature.name || !ts.isIdentifier(signature.name))
136692
136727
  return false;
@@ -138319,7 +138354,9 @@ var ts;
138319
138354
  (function (ts) {
138320
138355
  var GoToDefinition;
138321
138356
  (function (GoToDefinition) {
138322
- function getDefinitionAtPosition(program, sourceFile, position) {
138357
+ function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
138358
+ var _a;
138359
+ var _b;
138323
138360
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
138324
138361
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
138325
138362
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -138342,33 +138379,63 @@ var ts;
138342
138379
  }
138343
138380
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
138344
138381
  var classDecl = node.parent.parent;
138345
- var symbol_1 = getSymbol(classDecl, typeChecker);
138382
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
138346
138383
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
138347
138384
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
138348
138385
  var sourceFile_1 = node.getSourceFile();
138349
138386
  return ts.map(staticBlocks, function (staticBlock) {
138350
138387
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
138351
138388
  pos = ts.skipTrivia(sourceFile_1.text, pos);
138352
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
138389
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, failedAliasResolution_1, { start: pos, length: "static".length });
138353
138390
  });
138354
138391
  }
138355
- var symbol = getSymbol(node, typeChecker);
138392
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
138393
+ var fallbackNode = node;
138394
+ if (aliasesOnly && failedAliasResolution) {
138395
+ // We couldn't resolve the specific import, try on the module specifier.
138396
+ var importDeclaration = ts.findAncestor(node, ts.isAnyImportOrBareOrAccessedRequire);
138397
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
138398
+ if (moduleSpecifier) {
138399
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
138400
+ fallbackNode = moduleSpecifier;
138401
+ }
138402
+ }
138403
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
138404
+ // We couldn't resolve the module specifier as an external module, but it could
138405
+ // be that module resolution succeeded but the target was not a module.
138406
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
138407
+ if (ref) {
138408
+ return [{
138409
+ name: fallbackNode.text,
138410
+ fileName: ref.resolvedFileName,
138411
+ containerName: undefined,
138412
+ containerKind: undefined,
138413
+ kind: "script" /* scriptElement */,
138414
+ textSpan: ts.createTextSpan(0, 0),
138415
+ failedAliasResolution: failedAliasResolution,
138416
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
138417
+ unverified: fallbackNode !== node,
138418
+ }];
138419
+ }
138420
+ }
138356
138421
  // Could not find a symbol e.g. node is string or number keyword,
138357
138422
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
138358
138423
  if (!symbol) {
138359
138424
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
138360
138425
  }
138426
+ if (aliasesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
138427
+ return undefined;
138361
138428
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
138362
138429
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
138363
138430
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
138364
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
138431
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
138365
138432
  // For a function, if this is the original function definition, return just sigInfo.
138366
138433
  // If this is the original constructor definition, parent is the class.
138367
138434
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
138368
138435
  return [sigInfo];
138369
138436
  }
138370
138437
  else {
138371
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
138438
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
138372
138439
  // For a 'super()' call, put the signature first, else put the variable first.
138373
138440
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
138374
138441
  }
@@ -138380,7 +138447,7 @@ var ts;
138380
138447
  // assignment. This case and others are handled by the following code.
138381
138448
  if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
138382
138449
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
138383
- var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
138450
+ var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, failedAliasResolution); }) : ts.emptyArray;
138384
138451
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
138385
138452
  }
138386
138453
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -138403,7 +138470,7 @@ var ts;
138403
138470
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
138404
138471
  });
138405
138472
  }
138406
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
138473
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
138407
138474
  }
138408
138475
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
138409
138476
  /**
@@ -138501,24 +138568,24 @@ var ts;
138501
138568
  return undefined;
138502
138569
  }
138503
138570
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
138504
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
138571
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
138505
138572
  }
138506
- var symbol = getSymbol(node, typeChecker);
138573
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
138507
138574
  if (!symbol)
138508
138575
  return undefined;
138509
138576
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
138510
138577
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
138511
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
138578
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
138512
138579
  // If a function returns 'void' or some other type with no definition, just return the function definition.
138513
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
138580
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
138514
138581
  return typeDefinitions.length ? typeDefinitions
138515
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
138582
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
138516
138583
  : undefined;
138517
138584
  }
138518
138585
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
138519
- function definitionFromType(type, checker, node) {
138586
+ function definitionFromType(type, checker, node, failedAliasResolution) {
138520
138587
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
138521
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
138588
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
138522
138589
  });
138523
138590
  }
138524
138591
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -138533,8 +138600,8 @@ var ts;
138533
138600
  }
138534
138601
  return undefined;
138535
138602
  }
138536
- function getDefinitionAndBoundSpan(program, sourceFile, position) {
138537
- var definitions = getDefinitionAtPosition(program, sourceFile, position);
138603
+ function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
138604
+ var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
138538
138605
  if (!definitions || definitions.length === 0) {
138539
138606
  return undefined;
138540
138607
  }
@@ -138560,13 +138627,17 @@ var ts;
138560
138627
  // get the aliased symbol instead. This allows for goto def on an import e.g.
138561
138628
  // import {A, B} from "mod";
138562
138629
  // to jump to the implementation directly.
138630
+ var failedAliasResolution = false;
138563
138631
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
138564
138632
  var aliased = checker.getAliasedSymbol(symbol);
138565
138633
  if (aliased.declarations) {
138566
- return aliased;
138634
+ return { symbol: aliased };
138635
+ }
138636
+ else {
138637
+ failedAliasResolution = true;
138567
138638
  }
138568
138639
  }
138569
- return symbol;
138640
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
138570
138641
  }
138571
138642
  // Go to the original declaration for cases:
138572
138643
  //
@@ -138580,26 +138651,45 @@ var ts;
138580
138651
  if (node.parent === declaration) {
138581
138652
  return true;
138582
138653
  }
138583
- switch (declaration.kind) {
138584
- case 266 /* ImportClause */:
138585
- case 264 /* ImportEqualsDeclaration */:
138586
- return true;
138587
- case 269 /* ImportSpecifier */:
138588
- return declaration.parent.kind === 268 /* NamedImports */;
138589
- case 202 /* BindingElement */:
138590
- case 253 /* VariableDeclaration */:
138591
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
138592
- default:
138593
- return false;
138654
+ if (declaration.kind === 267 /* NamespaceImport */) {
138655
+ return false;
138594
138656
  }
138657
+ return true;
138595
138658
  }
138596
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
138597
- // There are cases when you extend a function by adding properties to it afterwards,
138598
- // we want to strip those extra properties.
138599
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
138600
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
138601
- || undefined;
138602
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
138659
+ /**
138660
+ * ```ts
138661
+ * function f() {}
138662
+ * f.foo = 0;
138663
+ * ```
138664
+ *
138665
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
138666
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
138667
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
138668
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
138669
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
138670
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
138671
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
138672
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
138673
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
138674
+ * up with a more precise definition of what counts as a definition.
138675
+ */
138676
+ function isExpandoDeclaration(node) {
138677
+ if (!ts.isAssignmentDeclaration(node))
138678
+ return false;
138679
+ var containingAssignment = ts.findAncestor(node, function (p) {
138680
+ if (ts.isAssignmentExpression(p))
138681
+ return true;
138682
+ if (!ts.isAssignmentDeclaration(p))
138683
+ return "quit";
138684
+ return false;
138685
+ });
138686
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
138687
+ }
138688
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
138689
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
138690
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
138691
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
138692
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, failedAliasResolution); });
138603
138693
  function getConstructSignatureDefinition() {
138604
138694
  // Applicable only if we are in a new expression, or we are on a constructor declaration
138605
138695
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -138623,26 +138713,27 @@ var ts;
138623
138713
  return declarations.length
138624
138714
  ? declarationsWithBody.length !== 0
138625
138715
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
138626
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
138716
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, failedAliasResolution)]
138627
138717
  : undefined;
138628
138718
  }
138629
138719
  }
138630
138720
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
138631
- function createDefinitionInfo(declaration, checker, symbol, node) {
138721
+ function createDefinitionInfo(declaration, checker, symbol, node, failedAliasResolution) {
138632
138722
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
138633
138723
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
138634
138724
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
138635
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
138725
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution);
138636
138726
  }
138727
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
138637
138728
  /** Creates a DefinitionInfo directly from the name of a declaration. */
138638
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
138729
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution, textSpan) {
138639
138730
  var sourceFile = declaration.getSourceFile();
138640
138731
  if (!textSpan) {
138641
138732
  var name = ts.getNameOfDeclaration(declaration) || declaration;
138642
138733
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
138643
138734
  }
138644
138735
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
138645
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
138736
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 8388608 /* Ambient */), failedAliasResolution: failedAliasResolution });
138646
138737
  }
138647
138738
  function isDefinitionVisible(checker, declaration) {
138648
138739
  if (checker.isDeclarationVisible(declaration))
@@ -138675,8 +138766,8 @@ var ts;
138675
138766
  return false;
138676
138767
  }
138677
138768
  }
138678
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
138679
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
138769
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
138770
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, failedAliasResolution);
138680
138771
  }
138681
138772
  function findReferenceInPosition(refs, pos) {
138682
138773
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -141744,6 +141835,41 @@ var ts;
141744
141835
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
141745
141836
  break;
141746
141837
  }
141838
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
141839
+ var stack = [ts.scanner.getToken()];
141840
+ var token = ts.scanner.scan();
141841
+ loop: while (ts.length(stack)) {
141842
+ switch (token) {
141843
+ case 1 /* EndOfFileToken */:
141844
+ break loop;
141845
+ case 100 /* ImportKeyword */:
141846
+ tryConsumeImport();
141847
+ break;
141848
+ case 15 /* TemplateHead */:
141849
+ stack.push(token);
141850
+ break;
141851
+ case 18 /* OpenBraceToken */:
141852
+ if (ts.length(stack)) {
141853
+ stack.push(token);
141854
+ }
141855
+ break;
141856
+ case 19 /* CloseBraceToken */:
141857
+ if (ts.length(stack)) {
141858
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
141859
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
141860
+ stack.pop();
141861
+ }
141862
+ }
141863
+ else {
141864
+ stack.pop();
141865
+ }
141866
+ }
141867
+ break;
141868
+ }
141869
+ token = ts.scanner.scan();
141870
+ }
141871
+ nextToken();
141872
+ }
141747
141873
  // check if at least one of alternative have moved scanner forward
141748
141874
  if (tryConsumeDeclare() ||
141749
141875
  tryConsumeImport() ||
@@ -143037,7 +143163,7 @@ var ts;
143037
143163
  if (!typeDisplayString) {
143038
143164
  continue;
143039
143165
  }
143040
- addTypeHints(typeDisplayString, param.name.end);
143166
+ addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
143041
143167
  }
143042
143168
  }
143043
143169
  function getParameterDeclarationTypeDisplayString(symbol) {
@@ -151689,9 +151815,10 @@ var ts;
151689
151815
  // 2. add "member3" to the second import statement's import list
151690
151816
  // and it is up to the user to decide which one fits best.
151691
151817
  return ts.firstDefined(existingImports, function (_a) {
151818
+ var _b;
151692
151819
  var declaration = _a.declaration;
151693
151820
  var namespacePrefix = getNamespaceLikeImportText(declaration);
151694
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151821
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151695
151822
  if (namespacePrefix && moduleSpecifier) {
151696
151823
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
151697
151824
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -151867,8 +151994,9 @@ var ts;
151867
151994
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
151868
151995
  }
151869
151996
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
151997
+ var _b;
151870
151998
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
151871
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151999
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151872
152000
  if (moduleSpecifier) {
151873
152001
  var addAsTypeOnly = useRequire
151874
152002
  ? 4 /* NotAllowed */
@@ -163677,9 +163805,9 @@ var ts;
163677
163805
  synchronizeHostData();
163678
163806
  return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
163679
163807
  }
163680
- function getDefinitionAndBoundSpan(fileName, position) {
163808
+ function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
163681
163809
  synchronizeHostData();
163682
- return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
163810
+ return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
163683
163811
  }
163684
163812
  function getTypeDefinitionAtPosition(fileName, position) {
163685
163813
  synchronizeHostData();
@@ -166431,6 +166559,9 @@ var ts;
166431
166559
  CommandTypes["SignatureHelp"] = "signatureHelp";
166432
166560
  /* @internal */
166433
166561
  CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
166562
+ CommandTypes["SourceDefinitionAndBoundSpan"] = "sourceDefinitionAndBoundSpan";
166563
+ /* @internal */
166564
+ CommandTypes["SourceDefinitionAndBoundSpanFull"] = "sourceDefinitionAndBoundSpan-full";
166434
166565
  CommandTypes["Status"] = "status";
166435
166566
  CommandTypes["TypeDefinition"] = "typeDefinition";
166436
166567
  CommandTypes["ProjectInfo"] = "projectInfo";
@@ -167300,6 +167431,7 @@ var ts;
167300
167431
  ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
167301
167432
  ProjectKind[ProjectKind["External"] = 2] = "External";
167302
167433
  ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
167434
+ ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
167303
167435
  })(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
167304
167436
  /* @internal */
167305
167437
  function countEachFileTypes(infos, includeSizes) {
@@ -168745,6 +168877,17 @@ var ts;
168745
168877
  Project.prototype.getIncompleteCompletionsCache = function () {
168746
168878
  return this.projectService.getIncompleteCompletionsCache();
168747
168879
  };
168880
+ Project.prototype.withAuxiliaryProjectForFiles = function (fileNames, cb) {
168881
+ var options = __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
168882
+ var project = new AuxiliaryProject(this.projectService, this.documentRegistry, options);
168883
+ for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
168884
+ var fileName = fileNames_1[_i];
168885
+ project.addRoot(this.getScriptInfo(fileName));
168886
+ }
168887
+ project.updateGraph();
168888
+ cb(project);
168889
+ project.close();
168890
+ };
168748
168891
  return Project;
168749
168892
  }());
168750
168893
  server.Project = Project;
@@ -168856,6 +168999,22 @@ var ts;
168856
168999
  return InferredProject;
168857
169000
  }(Project));
168858
169001
  server.InferredProject = InferredProject;
169002
+ var AuxiliaryProject = /** @class */ (function (_super) {
169003
+ __extends(AuxiliaryProject, _super);
169004
+ function AuxiliaryProject(projectService, documentRegistry, parentCompilerOptions) {
169005
+ var _this = this;
169006
+ var options = __assign(__assign({}, parentCompilerOptions), { resolveJsOnly: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
169007
+ _this = _super.call(this, "js-analysis", ProjectKind.Auxiliary, projectService, documentRegistry,
169008
+ /*hasExplicitListOfFiles*/ false,
169009
+ /*lastFileExceededProgramSize*/ undefined, options,
169010
+ /*compileOnSaveEnabled*/ false,
169011
+ /*watchOptions*/ undefined, projectService.host,
169012
+ /*currentDirectory*/ undefined) || this;
169013
+ return _this;
169014
+ }
169015
+ return AuxiliaryProject;
169016
+ }(Project));
169017
+ server.AuxiliaryProject = AuxiliaryProject;
168859
169018
  var AutoImportProviderProject = /** @class */ (function (_super) {
168860
169019
  __extends(AutoImportProviderProject, _super);
168861
169020
  /*@internal*/
@@ -170744,8 +170903,8 @@ var ts;
170744
170903
  this.projectToSizeMap.set(name, 0);
170745
170904
  this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); });
170746
170905
  var totalNonTsFileSize = 0;
170747
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
170748
- var f = fileNames_1[_i];
170906
+ for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
170907
+ var f = fileNames_2[_i];
170749
170908
  var fileName = propertyReader.getFileName(f);
170750
170909
  if (ts.hasTSFileExtension(fileName)) {
170751
170910
  continue;
@@ -173458,6 +173617,12 @@ var ts;
173458
173617
  _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
173459
173618
  return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173460
173619
  },
173620
+ // [CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173621
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
173622
+ // },
173623
+ // [CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173624
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173625
+ // },
173461
173626
  _a[server.CommandNames.EmitOutput] = function (request) {
173462
173627
  return _this.requiredResponse(_this.getEmitOutput(request.arguments));
173463
173628
  },
@@ -174194,10 +174359,34 @@ var ts;
174194
174359
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
174195
174360
  return definitions.map(function (info) {
174196
174361
  var newDocumentSpan = getMappedDocumentSpan(info, project);
174197
- return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
174362
+ return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
174198
174363
  });
174199
174364
  };
174200
174365
  Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
174366
+ // const { file, project } = this.getFileAndProject(args);
174367
+ // const position = this.getPositionInFile(args, file);
174368
+ // const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
174369
+ // const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);
174370
+ // if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
174371
+ // return {
174372
+ // definitions: emptyArray,
174373
+ // textSpan: undefined! // TODO: GH#18217
174374
+ // };
174375
+ // }
174376
+ // const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174377
+ // const { textSpan } = unmappedDefinitionAndBoundSpan;
174378
+ // if (simplifiedResult) {
174379
+ // return {
174380
+ // definitions: this.mapDefinitionInfo(definitions, project),
174381
+ // textSpan: toProtocolTextSpan(textSpan, scriptInfo)
174382
+ // };
174383
+ // }
174384
+ // return {
174385
+ // definitions: definitions.map(Session.mapToOriginalLocation),
174386
+ // textSpan,
174387
+ // };
174388
+ // }
174389
+ // private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
174201
174390
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
174202
174391
  var position = this.getPositionInFile(args, file);
174203
174392
  var scriptInfo = ts.Debug.checkDefined(project.getScriptInfo(file));
@@ -174208,7 +174397,31 @@ var ts;
174208
174397
  textSpan: undefined // TODO: GH#18217
174209
174398
  };
174210
174399
  }
174211
- var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174400
+ var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project).slice();
174401
+ var needsJsResolution = !ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) || ts.some(definitions, function (d) { return !!d.failedAliasResolution; });
174402
+ if (needsJsResolution) {
174403
+ project.withAuxiliaryProjectForFiles([file], function (auxiliaryProject) {
174404
+ var ls = auxiliaryProject.getLanguageService();
174405
+ var jsDefinitions = ls.getDefinitionAndBoundSpan(file, position, /*aliasesOnly*/ true);
174406
+ if (ts.some(jsDefinitions === null || jsDefinitions === void 0 ? void 0 : jsDefinitions.definitions)) {
174407
+ for (var _i = 0, _a = jsDefinitions.definitions; _i < _a.length; _i++) {
174408
+ var jsDefinition = _a[_i];
174409
+ if (jsDefinition.unverified) {
174410
+ var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
174411
+ if (ts.some(refined)) {
174412
+ for (var _b = 0, _c = refined || server.emptyArray; _b < _c.length; _b++) {
174413
+ var def = _c[_b];
174414
+ ts.pushIfUnique(definitions, def, ts.documentSpansEqual);
174415
+ }
174416
+ continue;
174417
+ }
174418
+ }
174419
+ ts.pushIfUnique(definitions, jsDefinition, ts.documentSpansEqual);
174420
+ }
174421
+ }
174422
+ });
174423
+ }
174424
+ definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
174212
174425
  var textSpan = unmappedDefinitionAndBoundSpan.textSpan;
174213
174426
  if (simplifiedResult) {
174214
174427
  return {
@@ -174220,6 +174433,32 @@ var ts;
174220
174433
  definitions: definitions.map(Session.mapToOriginalLocation),
174221
174434
  textSpan: textSpan,
174222
174435
  };
174436
+ function tryRefineDefinition(definition, program, auxiliaryProgram) {
174437
+ var _a, _b;
174438
+ var fileToSearch = auxiliaryProgram.getSourceFile(definition.fileName);
174439
+ if (!fileToSearch) {
174440
+ return undefined;
174441
+ }
174442
+ var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
174443
+ var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
174444
+ if (!symbol || !symbol.declarations || ts.some(symbol.declarations, ts.isFreelyNameableImport)) {
174445
+ return undefined;
174446
+ }
174447
+ var nameToSearch = ((_b = (_a = ts.find(symbol.declarations, ts.isImportSpecifier)) === null || _a === void 0 ? void 0 : _a.propertyName) === null || _b === void 0 ? void 0 : _b.text) || symbol.name;
174448
+ return searchForDeclaration(nameToSearch, fileToSearch, auxiliaryProgram);
174449
+ }
174450
+ function searchForDeclaration(declarationName, fileToSearch, auxiliaryProgram) {
174451
+ var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
174452
+ return ts.mapDefined(matches, function (match) {
174453
+ var symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
174454
+ var decl = ts.getDeclarationFromName(match);
174455
+ if (symbol && decl) {
174456
+ // I think the last argument to this is supposed to be the start node, but it doesn't seem important.
174457
+ // Callers internal to GoToDefinition already get confused about this.
174458
+ return ts.GoToDefinition.createDefinitionInfo(decl, auxiliaryProgram.getTypeChecker(), symbol, decl);
174459
+ }
174460
+ });
174461
+ }
174223
174462
  };
174224
174463
  Session.prototype.getEmitOutput = function (args) {
174225
174464
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;