@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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220314";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220316";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -8034,7 +8034,7 @@ var ts;
8034
8034
  Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
8035
8035
  _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
8036
8036
  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."),
8037
- 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."),
8037
+ 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."),
8038
8038
  Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
8039
8039
  Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
8040
8040
  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."),
@@ -14950,6 +14950,10 @@ var ts;
14950
14950
  }
14951
14951
  }
14952
14952
  ts.isAnyImportSyntax = isAnyImportSyntax;
14953
+ function isAnyImportOrBareOrAccessedRequire(node) {
14954
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
14955
+ }
14956
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
14953
14957
  function isLateVisibilityPaintedStatement(node) {
14954
14958
  switch (node.kind) {
14955
14959
  case 265 /* ImportDeclaration */:
@@ -16528,14 +16532,14 @@ var ts;
16528
16532
  }
16529
16533
  ts.isFunctionSymbol = isFunctionSymbol;
16530
16534
  function tryGetModuleSpecifierFromDeclaration(node) {
16531
- var _a, _b, _c;
16535
+ var _a, _b;
16532
16536
  switch (node.kind) {
16533
16537
  case 253 /* VariableDeclaration */:
16534
- return node.initializer.arguments[0].text;
16538
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16535
16539
  case 265 /* ImportDeclaration */:
16536
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16540
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16537
16541
  case 264 /* ImportEqualsDeclaration */:
16538
- 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;
16542
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16539
16543
  default:
16540
16544
  ts.Debug.assertNever(node);
16541
16545
  }
@@ -17062,21 +17066,28 @@ var ts;
17062
17066
  // export = <EntityNameExpression>
17063
17067
  // export default <EntityNameExpression>
17064
17068
  // module.exports = <EntityNameExpression>
17065
- // {<Identifier>}
17066
- // {name: <EntityNameExpression>}
17069
+ // module.exports.x = <EntityNameExpression>
17070
+ // const x = require("...")
17071
+ // const { x } = require("...")
17072
+ // const x = require("...").y
17073
+ // const { x } = require("...").y
17067
17074
  function isAliasSymbolDeclaration(node) {
17068
- return node.kind === 264 /* ImportEqualsDeclaration */ ||
17075
+ if (node.kind === 264 /* ImportEqualsDeclaration */ ||
17069
17076
  node.kind === 263 /* NamespaceExportDeclaration */ ||
17070
17077
  node.kind === 266 /* ImportClause */ && !!node.name ||
17071
17078
  node.kind === 267 /* NamespaceImport */ ||
17072
17079
  node.kind === 273 /* NamespaceExport */ ||
17073
17080
  node.kind === 269 /* ImportSpecifier */ ||
17074
17081
  node.kind === 274 /* ExportSpecifier */ ||
17075
- node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17076
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17077
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17078
- node.kind === 296 /* ShorthandPropertyAssignment */ ||
17079
- node.kind === 295 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17082
+ node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17083
+ return true;
17084
+ }
17085
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17086
+ ts.isPropertyAccessExpression(node)
17087
+ && ts.isBinaryExpression(node.parent)
17088
+ && node.parent.left === node
17089
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17090
+ && isAliasableExpression(node.parent.right));
17080
17091
  }
17081
17092
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17082
17093
  function getAliasDeclarationFromName(node) {
@@ -17087,6 +17098,7 @@ var ts;
17087
17098
  case 274 /* ExportSpecifier */:
17088
17099
  case 270 /* ExportAssignment */:
17089
17100
  case 264 /* ImportEqualsDeclaration */:
17101
+ case 273 /* NamespaceExport */:
17090
17102
  return node.parent;
17091
17103
  case 160 /* QualifiedName */:
17092
17104
  do {
@@ -31426,20 +31438,23 @@ var ts;
31426
31438
  return inContext(32768 /* AwaitContext */);
31427
31439
  }
31428
31440
  function parseErrorAtCurrentToken(message, arg0) {
31429
- parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
31441
+ return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
31430
31442
  }
31431
31443
  function parseErrorAtPosition(start, length, message, arg0) {
31432
31444
  // Don't report another error if it would just be at the same position as the last error.
31433
31445
  var lastError = ts.lastOrUndefined(parseDiagnostics);
31446
+ var result;
31434
31447
  if (!lastError || start !== lastError.start) {
31435
- parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
31448
+ result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
31449
+ parseDiagnostics.push(result);
31436
31450
  }
31437
31451
  // Mark that we've encountered an error. We'll set an appropriate bit on the next
31438
31452
  // node we finish so that it can't be reused incrementally.
31439
31453
  parseErrorBeforeNextFinishedNode = true;
31454
+ return result;
31440
31455
  }
31441
31456
  function parseErrorAt(start, end, message, arg0) {
31442
- parseErrorAtPosition(start, end - start, message, arg0);
31457
+ return parseErrorAtPosition(start, end - start, message, arg0);
31443
31458
  }
31444
31459
  function parseErrorAtRange(range, message, arg0) {
31445
31460
  parseErrorAt(range.pos, range.end, message, arg0);
@@ -31712,6 +31727,19 @@ var ts;
31712
31727
  parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
31713
31728
  return false;
31714
31729
  }
31730
+ function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
31731
+ if (token() === closeKind) {
31732
+ nextToken();
31733
+ return;
31734
+ }
31735
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
31736
+ if (!openParsed) {
31737
+ return;
31738
+ }
31739
+ if (lastError) {
31740
+ 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)));
31741
+ }
31742
+ }
31715
31743
  function parseOptional(t) {
31716
31744
  if (token() === t) {
31717
31745
  nextToken();
@@ -33360,7 +33388,7 @@ var ts;
33360
33388
  if (!parseExpected(19 /* CloseBraceToken */)) {
33361
33389
  var lastError = ts.lastOrUndefined(parseDiagnostics);
33362
33390
  if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33363
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33391
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
33364
33392
  }
33365
33393
  }
33366
33394
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
@@ -35170,10 +35198,11 @@ var ts;
35170
35198
  }
35171
35199
  function parseArrayLiteralExpression() {
35172
35200
  var pos = getNodePos();
35173
- parseExpected(22 /* OpenBracketToken */);
35201
+ var openBracketPosition = scanner.getTokenPos();
35202
+ var openBracketParsed = parseExpected(22 /* OpenBracketToken */);
35174
35203
  var multiLine = scanner.hasPrecedingLineBreak();
35175
35204
  var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
35176
- parseExpected(23 /* CloseBracketToken */);
35205
+ parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition);
35177
35206
  return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
35178
35207
  }
35179
35208
  function parseObjectLiteralElement() {
@@ -35230,15 +35259,10 @@ var ts;
35230
35259
  function parseObjectLiteralExpression() {
35231
35260
  var pos = getNodePos();
35232
35261
  var openBracePosition = scanner.getTokenPos();
35233
- parseExpected(18 /* OpenBraceToken */);
35262
+ var openBraceParsed = parseExpected(18 /* OpenBraceToken */);
35234
35263
  var multiLine = scanner.hasPrecedingLineBreak();
35235
35264
  var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
35236
- if (!parseExpected(19 /* CloseBraceToken */)) {
35237
- var lastError = ts.lastOrUndefined(parseDiagnostics);
35238
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35239
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35240
- }
35241
- }
35265
+ parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
35242
35266
  return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
35243
35267
  }
35244
35268
  function parseFunctionExpression() {
@@ -35294,15 +35318,11 @@ var ts;
35294
35318
  var pos = getNodePos();
35295
35319
  var hasJSDoc = hasPrecedingJSDocComment();
35296
35320
  var openBracePosition = scanner.getTokenPos();
35297
- if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
35321
+ var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage);
35322
+ if (openBraceParsed || ignoreMissingOpenBrace) {
35298
35323
  var multiLine = scanner.hasPrecedingLineBreak();
35299
35324
  var statements = parseList(1 /* BlockStatements */, parseStatement);
35300
- if (!parseExpected(19 /* CloseBraceToken */)) {
35301
- var lastError = ts.lastOrUndefined(parseDiagnostics);
35302
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35303
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35304
- }
35305
- }
35325
+ parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
35306
35326
  var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
35307
35327
  if (token() === 63 /* EqualsToken */) {
35308
35328
  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);
@@ -35347,9 +35367,10 @@ var ts;
35347
35367
  var pos = getNodePos();
35348
35368
  var hasJSDoc = hasPrecedingJSDocComment();
35349
35369
  parseExpected(99 /* IfKeyword */);
35350
- parseExpected(20 /* OpenParenToken */);
35370
+ var openParenPosition = scanner.getTokenPos();
35371
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35351
35372
  var expression = allowInAnd(parseExpression);
35352
- parseExpected(21 /* CloseParenToken */);
35373
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35353
35374
  var thenStatement = parseStatement();
35354
35375
  var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined;
35355
35376
  return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
@@ -35360,9 +35381,10 @@ var ts;
35360
35381
  parseExpected(90 /* DoKeyword */);
35361
35382
  var statement = parseStatement();
35362
35383
  parseExpected(115 /* WhileKeyword */);
35363
- parseExpected(20 /* OpenParenToken */);
35384
+ var openParenPosition = scanner.getTokenPos();
35385
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35364
35386
  var expression = allowInAnd(parseExpression);
35365
- parseExpected(21 /* CloseParenToken */);
35387
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35366
35388
  // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
35367
35389
  // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
35368
35390
  // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
@@ -35374,9 +35396,10 @@ var ts;
35374
35396
  var pos = getNodePos();
35375
35397
  var hasJSDoc = hasPrecedingJSDocComment();
35376
35398
  parseExpected(115 /* WhileKeyword */);
35377
- parseExpected(20 /* OpenParenToken */);
35399
+ var openParenPosition = scanner.getTokenPos();
35400
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35378
35401
  var expression = allowInAnd(parseExpression);
35379
- parseExpected(21 /* CloseParenToken */);
35402
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35380
35403
  var statement = parseStatement();
35381
35404
  return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
35382
35405
  }
@@ -35443,9 +35466,10 @@ var ts;
35443
35466
  var pos = getNodePos();
35444
35467
  var hasJSDoc = hasPrecedingJSDocComment();
35445
35468
  parseExpected(116 /* WithKeyword */);
35446
- parseExpected(20 /* OpenParenToken */);
35469
+ var openParenPosition = scanner.getTokenPos();
35470
+ var openParenParsed = parseExpected(20 /* OpenParenToken */);
35447
35471
  var expression = allowInAnd(parseExpression);
35448
- parseExpected(21 /* CloseParenToken */);
35472
+ parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35449
35473
  var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35450
35474
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35451
35475
  }
@@ -36579,7 +36603,7 @@ var ts;
36579
36603
  if (!parseExpected(19 /* CloseBraceToken */)) {
36580
36604
  var lastError = ts.lastOrUndefined(parseDiagnostics);
36581
36605
  if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
36582
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
36606
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
36583
36607
  }
36584
36608
  }
36585
36609
  return finishNode(factory.createAssertClause(elements, multiLine), pos);
@@ -37555,8 +37579,7 @@ var ts;
37555
37579
  hasChildren = true;
37556
37580
  if (child.kind === 342 /* JSDocTypeTag */) {
37557
37581
  if (childTypeTag) {
37558
- parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
37559
- var lastError = ts.lastOrUndefined(parseDiagnostics);
37582
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
37560
37583
  if (lastError) {
37561
37584
  ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
37562
37585
  }
@@ -39434,6 +39457,13 @@ var ts;
39434
39457
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39435
39458
  defaultValueDescription: false,
39436
39459
  },
39460
+ {
39461
+ name: "noDtsResolution",
39462
+ type: "boolean",
39463
+ affectsModuleResolution: true,
39464
+ category: ts.Diagnostics.Modules,
39465
+ defaultValueDescription: false,
39466
+ },
39437
39467
  // Source Maps
39438
39468
  {
39439
39469
  name: "sourceRoot",
@@ -41813,7 +41843,8 @@ var ts;
41813
41843
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
41814
41844
  Extensions[Extensions["Json"] = 2] = "Json";
41815
41845
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
41816
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
41846
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
41847
+ Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
41817
41848
  })(Extensions || (Extensions = {}));
41818
41849
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
41819
41850
  function resolvedTypeScriptOnly(resolved) {
@@ -42758,7 +42789,21 @@ var ts;
42758
42789
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42759
42790
  }
42760
42791
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
42761
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
42792
+ var extensions;
42793
+ if (lookupConfig) {
42794
+ extensions = tsconfigExtensions;
42795
+ }
42796
+ else if (compilerOptions.noDtsResolution) {
42797
+ extensions = [Extensions.TypeScriptButNotDts];
42798
+ if (compilerOptions.allowJs)
42799
+ extensions.push(Extensions.JavaScript);
42800
+ if (compilerOptions.resolveJsonModule)
42801
+ extensions.push(Extensions.Json);
42802
+ }
42803
+ else {
42804
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
42805
+ }
42806
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
42762
42807
  }
42763
42808
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42764
42809
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42767,6 +42812,10 @@ var ts;
42767
42812
  var failedLookupLocations = [];
42768
42813
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42769
42814
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
42815
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
42816
+ if (compilerOptions.noDtsResolution) {
42817
+ conditions.pop();
42818
+ }
42770
42819
  var state = {
42771
42820
  compilerOptions: compilerOptions,
42772
42821
  host: host,
@@ -42774,7 +42823,7 @@ var ts;
42774
42823
  failedLookupLocations: failedLookupLocations,
42775
42824
  packageJsonInfoCache: cache,
42776
42825
  features: features,
42777
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
42826
+ conditions: conditions,
42778
42827
  };
42779
42828
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42780
42829
  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);
@@ -42982,20 +43031,22 @@ var ts;
42982
43031
  default: return tryExtension(".d.ts" /* Dts */);
42983
43032
  }
42984
43033
  case Extensions.TypeScript:
43034
+ case Extensions.TypeScriptButNotDts:
43035
+ var useDts = extensions === Extensions.TypeScript;
42985
43036
  switch (originalExtension) {
42986
43037
  case ".mjs" /* Mjs */:
42987
43038
  case ".mts" /* Mts */:
42988
43039
  case ".d.mts" /* Dmts */:
42989
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43040
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
42990
43041
  case ".cjs" /* Cjs */:
42991
43042
  case ".cts" /* Cts */:
42992
43043
  case ".d.cts" /* Dcts */:
42993
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43044
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
42994
43045
  case ".json" /* Json */:
42995
43046
  candidate += ".json" /* Json */;
42996
- return tryExtension(".d.ts" /* Dts */);
43047
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
42997
43048
  default:
42998
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43049
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
42999
43050
  }
43000
43051
  case Extensions.JavaScript:
43001
43052
  switch (originalExtension) {
@@ -43213,6 +43264,7 @@ var ts;
43213
43264
  switch (extensions) {
43214
43265
  case Extensions.JavaScript:
43215
43266
  case Extensions.Json:
43267
+ case Extensions.TypeScriptButNotDts:
43216
43268
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43217
43269
  break;
43218
43270
  case Extensions.TypeScript:
@@ -43291,6 +43343,8 @@ var ts;
43291
43343
  return extension === ".json" /* Json */;
43292
43344
  case Extensions.TypeScript:
43293
43345
  return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43346
+ case Extensions.TypeScriptButNotDts:
43347
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
43294
43348
  case Extensions.DtsOnly:
43295
43349
  return extension === ".d.ts" /* Dts */;
43296
43350
  }
@@ -55359,7 +55413,7 @@ var ts;
55359
55413
  }
55360
55414
  }
55361
55415
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55362
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55416
+ type = getUnionType(sourceTypes);
55363
55417
  }
55364
55418
  }
55365
55419
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -58294,8 +58348,10 @@ var ts;
58294
58348
  return type;
58295
58349
  }
58296
58350
  function isMappedTypeGenericIndexedAccess(type) {
58297
- return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
58298
- !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
58351
+ var objectType;
58352
+ return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58353
+ !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58354
+ !objectType.declaration.questionToken && !objectType.declaration.nameType);
58299
58355
  }
58300
58356
  /**
58301
58357
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -58883,7 +58939,19 @@ var ts;
58883
58939
  return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
58884
58940
  });
58885
58941
  var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */);
58886
- syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
58942
+ if (lastParamVariadicType) {
58943
+ // Parameter has effective annotation, lock in type
58944
+ syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type));
58945
+ }
58946
+ else {
58947
+ // Parameter has no annotation
58948
+ // 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
58949
+ // cached by `getTypeOfSymbol` yet.
58950
+ syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */;
58951
+ syntheticArgsSymbol.deferralParent = neverType;
58952
+ syntheticArgsSymbol.deferralConstituents = [anyArrayType];
58953
+ syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType];
58954
+ }
58887
58955
  if (lastParamVariadicType) {
58888
58956
  // Replace the last parameter with a rest parameter.
58889
58957
  parameters.pop();
@@ -61480,7 +61548,7 @@ var ts;
61480
61548
  // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
61481
61549
  // that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
61482
61550
  // construct the type Box<T[X]>.
61483
- if (isGenericMappedType(objectType)) {
61551
+ if (isGenericMappedType(objectType) && !objectType.declaration.nameType) {
61484
61552
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
61485
61553
  }
61486
61554
  return type[cache] = type;
@@ -63553,7 +63621,7 @@ var ts;
63553
63621
  var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
63554
63622
  : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
63555
63623
  : getReturnTypeOfSignature(target);
63556
- if (targetReturnType === voidType) {
63624
+ if (targetReturnType === voidType || targetReturnType === anyType) {
63557
63625
  return result;
63558
63626
  }
63559
63627
  var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
@@ -67412,32 +67480,13 @@ var ts;
67412
67480
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
67413
67481
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
67414
67482
  }
67415
- /**
67416
- * Tests whether the provided string can be parsed as a number.
67417
- * @param s The string to test.
67418
- * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
67419
- */
67420
- function isValidNumberString(s, roundTripOnly) {
67421
- if (s === "")
67422
- return false;
67423
- var n = +s;
67424
- return isFinite(n) && (!roundTripOnly || "" + n === s);
67425
- }
67426
- /**
67427
- * Tests whether the provided string can be parsed as a bigint.
67428
- * @param s The string to test.
67429
- * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
67430
- */
67431
- function isValidBigIntString(s, roundTripOnly) {
67432
- if (s === "")
67433
- return false;
67483
+ function isValidBigIntString(s) {
67434
67484
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
67435
67485
  var success = true;
67436
67486
  scanner.setOnError(function () { return success = false; });
67437
67487
  scanner.setText(s + "n");
67438
67488
  var result = scanner.scan();
67439
- var negative = result === 40 /* MinusToken */;
67440
- if (negative) {
67489
+ if (result === 40 /* MinusToken */) {
67441
67490
  result = scanner.scan();
67442
67491
  }
67443
67492
  var flags = scanner.getTokenFlags();
@@ -67446,8 +67495,7 @@ var ts;
67446
67495
  // * a bigint can be scanned, and that when it is scanned, it is
67447
67496
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
67448
67497
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
67449
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
67450
- && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
67498
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
67451
67499
  }
67452
67500
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
67453
67501
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -67455,8 +67503,8 @@ var ts;
67455
67503
  }
67456
67504
  if (source.flags & 128 /* StringLiteral */) {
67457
67505
  var value = source.value;
67458
- return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
67459
- target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
67506
+ return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
67507
+ target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
67460
67508
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
67461
67509
  }
67462
67510
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68030,63 +68078,7 @@ var ts;
68030
68078
  // succeed. That would be a pointless and confusing outcome.
68031
68079
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68032
68080
  for (var i = 0; i < types.length; i++) {
68033
- var source_1 = matches ? matches[i] : neverType;
68034
- var target_3 = types[i];
68035
- // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68036
- // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68037
- var sourceTypes = void 0;
68038
- if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68039
- var inferenceContext = getInferenceInfoForType(target_3);
68040
- var constraint = inferenceContext ? getConstraintOfTypeParameter(inferenceContext.typeParameter) : undefined;
68041
- if (inferenceContext && constraint) {
68042
- var str = source_1.value;
68043
- var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68044
- for (var _i = 0, constraintTypes_1 = constraintTypes; _i < constraintTypes_1.length; _i++) {
68045
- var constraintType = constraintTypes_1[_i];
68046
- if (constraintType.flags & 402653316 /* StringLike */) {
68047
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68048
- sourceTypes.push(source_1);
68049
- }
68050
- if (constraintType.flags & 296 /* NumberLike */ && isValidNumberString(str, /*roundTripOnly*/ true)) {
68051
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68052
- sourceTypes.push(getNumberLiteralType(+str));
68053
- }
68054
- if (constraintType.flags & 2112 /* BigIntLike */ && isValidBigIntString(str, /*roundTripOnly*/ true)) {
68055
- var negative = str.startsWith("-");
68056
- var base10Value = ts.parsePseudoBigInt((negative ? str.slice(1) : str) + "n");
68057
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68058
- sourceTypes.push(getBigIntLiteralType({ negative: negative, base10Value: base10Value }));
68059
- }
68060
- if (constraintType.flags & 528 /* BooleanLike */) {
68061
- if (str === trueType.intrinsicName) {
68062
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68063
- sourceTypes.push(trueType);
68064
- }
68065
- else if (str === falseType.intrinsicName) {
68066
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68067
- sourceTypes.push(falseType);
68068
- }
68069
- }
68070
- if (constraintType.flags & 65536 /* Null */ && str === nullType.intrinsicName) {
68071
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68072
- sourceTypes.push(nullType);
68073
- }
68074
- if (constraintType.flags & 32768 /* Undefined */ && str === undefinedType.intrinsicName) {
68075
- sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
68076
- sourceTypes.push(undefinedType);
68077
- }
68078
- }
68079
- }
68080
- }
68081
- if (sourceTypes) {
68082
- for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) {
68083
- var source_2 = sourceTypes_3[_a];
68084
- inferFromTypes(source_2, target_3);
68085
- }
68086
- }
68087
- else {
68088
- inferFromTypes(source_1, target_3);
68089
- }
68081
+ inferFromTypes(matches ? matches[i] : neverType, types[i]);
68090
68082
  }
68091
68083
  }
68092
68084
  }
@@ -71918,7 +71910,7 @@ var ts;
71918
71910
  function getTypeOfPropertyOfContextualType(type, name, nameType) {
71919
71911
  return mapType(type, function (t) {
71920
71912
  var _a;
71921
- if (isGenericMappedType(t)) {
71913
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
71922
71914
  var constraint = getConstraintTypeFromMappedType(t);
71923
71915
  var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
71924
71916
  var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
@@ -76846,7 +76838,11 @@ var ts;
76846
76838
  if (signatureHasRestParameter(signature)) {
76847
76839
  // parameter might be a transient symbol generated by use of `arguments` in the function body.
76848
76840
  var parameter = ts.last(signature.parameters);
76849
- if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
76841
+ if (parameter.valueDeclaration
76842
+ ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)
76843
+ // a declarationless parameter may still have a `.type` already set by its construction logic
76844
+ // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type
76845
+ : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) {
76850
76846
  var contextualParameterType = getRestTypeAtPosition(context, len);
76851
76847
  assignParameterType(parameter, contextualParameterType);
76852
76848
  }
@@ -76865,8 +76861,8 @@ var ts;
76865
76861
  var links = getSymbolLinks(parameter);
76866
76862
  if (!links.type) {
76867
76863
  var declaration = parameter.valueDeclaration;
76868
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
76869
- if (declaration.name.kind !== 79 /* Identifier */) {
76864
+ links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
76865
+ if (declaration && declaration.name.kind !== 79 /* Identifier */) {
76870
76866
  // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
76871
76867
  if (links.type === unknownType) {
76872
76868
  links.type = getTypeFromBindingPattern(declaration.name);
@@ -127062,6 +127058,20 @@ var ts;
127062
127058
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
127063
127059
  }
127064
127060
  ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
127061
+ /**
127062
+ * Returns true if `node` is the declaration of `n` in:
127063
+ * - `import n from "m"`
127064
+ * - `import * as n from "m"`
127065
+ * - `import n = require("m")`
127066
+ * - `const n = require("m")`
127067
+ */
127068
+ function isFreelyNameableImport(node) {
127069
+ return node.kind === 266 /* ImportClause */
127070
+ || node.kind === 267 /* NamespaceImport */
127071
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
127072
+ || ts.isVariableDeclarationInitializedToRequire(node);
127073
+ }
127074
+ ts.isFreelyNameableImport = isFreelyNameableImport;
127065
127075
  function getScriptKind(fileName, host) {
127066
127076
  // First check to see if the script kind was specified by the host. Chances are the host
127067
127077
  // may override the default script kind for the file extension.
@@ -130355,14 +130365,15 @@ var ts;
130355
130365
  SortText["SuggestedClassMembers"] = "14";
130356
130366
  SortText["GlobalsOrKeywords"] = "15";
130357
130367
  SortText["AutoImportSuggestions"] = "16";
130358
- SortText["JavascriptIdentifiers"] = "17";
130359
- SortText["DeprecatedLocalDeclarationPriority"] = "18";
130360
- SortText["DeprecatedLocationPriority"] = "19";
130361
- SortText["DeprecatedOptionalMember"] = "20";
130362
- SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21";
130363
- SortText["DeprecatedSuggestedClassMembers"] = "22";
130364
- SortText["DeprecatedGlobalsOrKeywords"] = "23";
130365
- SortText["DeprecatedAutoImportSuggestions"] = "24";
130368
+ SortText["ClassMemberSnippets"] = "17";
130369
+ SortText["JavascriptIdentifiers"] = "18";
130370
+ SortText["DeprecatedLocalDeclarationPriority"] = "19";
130371
+ SortText["DeprecatedLocationPriority"] = "20";
130372
+ SortText["DeprecatedOptionalMember"] = "21";
130373
+ SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
130374
+ SortText["DeprecatedSuggestedClassMembers"] = "23";
130375
+ SortText["DeprecatedGlobalsOrKeywords"] = "24";
130376
+ SortText["DeprecatedAutoImportSuggestions"] = "25";
130366
130377
  })(SortText = Completions.SortText || (Completions.SortText = {}));
130367
130378
  var SortTextId;
130368
130379
  (function (SortTextId) {
@@ -130374,10 +130385,10 @@ var ts;
130374
130385
  SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
130375
130386
  SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
130376
130387
  // Don't use these directly.
130377
- SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers";
130378
- SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart";
130388
+ SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
130389
+ SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
130379
130390
  SortTextId[SortTextId["_First"] = 10] = "_First";
130380
- SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset";
130391
+ SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
130381
130392
  })(SortTextId || (SortTextId = {}));
130382
130393
  /**
130383
130394
  * Special values for `CompletionInfo['source']` used to disambiguate
@@ -130858,6 +130869,7 @@ var ts;
130858
130869
  isClassLikeMemberCompletion(symbol, location)) {
130859
130870
  var importAdder = void 0;
130860
130871
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
130872
+ sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
130861
130873
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
130862
130874
  hasAction = true;
130863
130875
  source = CompletionSource.ClassMemberSnippet;
@@ -131221,7 +131233,7 @@ var ts;
131221
131233
  }
131222
131234
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
131223
131235
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
131224
- var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131236
+ var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131225
131237
  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);
131226
131238
  if (!entry) {
131227
131239
  continue;
@@ -136076,6 +136088,29 @@ var ts;
136076
136088
  }
136077
136089
  }
136078
136090
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
136091
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
136092
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
136093
+ return candidates.reduce(function (topMost, decl) {
136094
+ var depth = getDepth(decl);
136095
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
136096
+ topMost.declarationNames.push(decl);
136097
+ }
136098
+ else if (depth < topMost.depth) {
136099
+ topMost.declarationNames = [decl];
136100
+ }
136101
+ topMost.depth = depth;
136102
+ return topMost;
136103
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
136104
+ function getDepth(declaration) {
136105
+ var depth = 0;
136106
+ while (declaration) {
136107
+ declaration = ts.getContainerNode(declaration);
136108
+ depth++;
136109
+ }
136110
+ return depth;
136111
+ }
136112
+ }
136113
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
136079
136114
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
136080
136115
  if (!signature.name || !ts.isIdentifier(signature.name))
136081
136116
  return false;
@@ -137708,7 +137743,9 @@ var ts;
137708
137743
  (function (ts) {
137709
137744
  var GoToDefinition;
137710
137745
  (function (GoToDefinition) {
137711
- function getDefinitionAtPosition(program, sourceFile, position) {
137746
+ function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
137747
+ var _a;
137748
+ var _b;
137712
137749
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
137713
137750
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
137714
137751
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -137731,33 +137768,63 @@ var ts;
137731
137768
  }
137732
137769
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
137733
137770
  var classDecl = node.parent.parent;
137734
- var symbol_1 = getSymbol(classDecl, typeChecker);
137771
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
137735
137772
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
137736
137773
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
137737
137774
  var sourceFile_1 = node.getSourceFile();
137738
137775
  return ts.map(staticBlocks, function (staticBlock) {
137739
137776
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
137740
137777
  pos = ts.skipTrivia(sourceFile_1.text, pos);
137741
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
137778
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, failedAliasResolution_1, { start: pos, length: "static".length });
137742
137779
  });
137743
137780
  }
137744
- var symbol = getSymbol(node, typeChecker);
137781
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
137782
+ var fallbackNode = node;
137783
+ if (aliasesOnly && failedAliasResolution) {
137784
+ // We couldn't resolve the specific import, try on the module specifier.
137785
+ var importDeclaration = ts.findAncestor(node, ts.isAnyImportOrBareOrAccessedRequire);
137786
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
137787
+ if (moduleSpecifier) {
137788
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
137789
+ fallbackNode = moduleSpecifier;
137790
+ }
137791
+ }
137792
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
137793
+ // We couldn't resolve the module specifier as an external module, but it could
137794
+ // be that module resolution succeeded but the target was not a module.
137795
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
137796
+ if (ref) {
137797
+ return [{
137798
+ name: fallbackNode.text,
137799
+ fileName: ref.resolvedFileName,
137800
+ containerName: undefined,
137801
+ containerKind: undefined,
137802
+ kind: "script" /* scriptElement */,
137803
+ textSpan: ts.createTextSpan(0, 0),
137804
+ failedAliasResolution: failedAliasResolution,
137805
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
137806
+ unverified: fallbackNode !== node,
137807
+ }];
137808
+ }
137809
+ }
137745
137810
  // Could not find a symbol e.g. node is string or number keyword,
137746
137811
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
137747
137812
  if (!symbol) {
137748
137813
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
137749
137814
  }
137815
+ if (aliasesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
137816
+ return undefined;
137750
137817
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
137751
137818
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
137752
137819
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
137753
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
137820
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
137754
137821
  // For a function, if this is the original function definition, return just sigInfo.
137755
137822
  // If this is the original constructor definition, parent is the class.
137756
137823
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
137757
137824
  return [sigInfo];
137758
137825
  }
137759
137826
  else {
137760
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
137827
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
137761
137828
  // For a 'super()' call, put the signature first, else put the variable first.
137762
137829
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
137763
137830
  }
@@ -137769,7 +137836,7 @@ var ts;
137769
137836
  // assignment. This case and others are handled by the following code.
137770
137837
  if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
137771
137838
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
137772
- 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;
137839
+ 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;
137773
137840
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
137774
137841
  }
137775
137842
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -137792,7 +137859,7 @@ var ts;
137792
137859
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
137793
137860
  });
137794
137861
  }
137795
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
137862
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
137796
137863
  }
137797
137864
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
137798
137865
  /**
@@ -137890,24 +137957,24 @@ var ts;
137890
137957
  return undefined;
137891
137958
  }
137892
137959
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
137893
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
137960
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
137894
137961
  }
137895
- var symbol = getSymbol(node, typeChecker);
137962
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
137896
137963
  if (!symbol)
137897
137964
  return undefined;
137898
137965
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
137899
137966
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
137900
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
137967
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
137901
137968
  // If a function returns 'void' or some other type with no definition, just return the function definition.
137902
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
137969
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
137903
137970
  return typeDefinitions.length ? typeDefinitions
137904
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
137971
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
137905
137972
  : undefined;
137906
137973
  }
137907
137974
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
137908
- function definitionFromType(type, checker, node) {
137975
+ function definitionFromType(type, checker, node, failedAliasResolution) {
137909
137976
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
137910
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
137977
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
137911
137978
  });
137912
137979
  }
137913
137980
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -137922,8 +137989,8 @@ var ts;
137922
137989
  }
137923
137990
  return undefined;
137924
137991
  }
137925
- function getDefinitionAndBoundSpan(program, sourceFile, position) {
137926
- var definitions = getDefinitionAtPosition(program, sourceFile, position);
137992
+ function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
137993
+ var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
137927
137994
  if (!definitions || definitions.length === 0) {
137928
137995
  return undefined;
137929
137996
  }
@@ -137949,13 +138016,17 @@ var ts;
137949
138016
  // get the aliased symbol instead. This allows for goto def on an import e.g.
137950
138017
  // import {A, B} from "mod";
137951
138018
  // to jump to the implementation directly.
138019
+ var failedAliasResolution = false;
137952
138020
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
137953
138021
  var aliased = checker.getAliasedSymbol(symbol);
137954
138022
  if (aliased.declarations) {
137955
- return aliased;
138023
+ return { symbol: aliased };
138024
+ }
138025
+ else {
138026
+ failedAliasResolution = true;
137956
138027
  }
137957
138028
  }
137958
- return symbol;
138029
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
137959
138030
  }
137960
138031
  // Go to the original declaration for cases:
137961
138032
  //
@@ -137969,26 +138040,45 @@ var ts;
137969
138040
  if (node.parent === declaration) {
137970
138041
  return true;
137971
138042
  }
137972
- switch (declaration.kind) {
137973
- case 266 /* ImportClause */:
137974
- case 264 /* ImportEqualsDeclaration */:
137975
- return true;
137976
- case 269 /* ImportSpecifier */:
137977
- return declaration.parent.kind === 268 /* NamedImports */;
137978
- case 202 /* BindingElement */:
137979
- case 253 /* VariableDeclaration */:
137980
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
137981
- default:
137982
- return false;
138043
+ if (declaration.kind === 267 /* NamespaceImport */) {
138044
+ return false;
137983
138045
  }
138046
+ return true;
137984
138047
  }
137985
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
137986
- // There are cases when you extend a function by adding properties to it afterwards,
137987
- // we want to strip those extra properties.
137988
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
137989
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
137990
- || undefined;
137991
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
138048
+ /**
138049
+ * ```ts
138050
+ * function f() {}
138051
+ * f.foo = 0;
138052
+ * ```
138053
+ *
138054
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
138055
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
138056
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
138057
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
138058
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
138059
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
138060
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
138061
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
138062
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
138063
+ * up with a more precise definition of what counts as a definition.
138064
+ */
138065
+ function isExpandoDeclaration(node) {
138066
+ if (!ts.isAssignmentDeclaration(node))
138067
+ return false;
138068
+ var containingAssignment = ts.findAncestor(node, function (p) {
138069
+ if (ts.isAssignmentExpression(p))
138070
+ return true;
138071
+ if (!ts.isAssignmentDeclaration(p))
138072
+ return "quit";
138073
+ return false;
138074
+ });
138075
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
138076
+ }
138077
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
138078
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
138079
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
138080
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
138081
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, failedAliasResolution); });
137992
138082
  function getConstructSignatureDefinition() {
137993
138083
  // Applicable only if we are in a new expression, or we are on a constructor declaration
137994
138084
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -138012,26 +138102,27 @@ var ts;
138012
138102
  return declarations.length
138013
138103
  ? declarationsWithBody.length !== 0
138014
138104
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
138015
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
138105
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, failedAliasResolution)]
138016
138106
  : undefined;
138017
138107
  }
138018
138108
  }
138019
138109
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
138020
- function createDefinitionInfo(declaration, checker, symbol, node) {
138110
+ function createDefinitionInfo(declaration, checker, symbol, node, failedAliasResolution) {
138021
138111
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
138022
138112
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
138023
138113
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
138024
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
138114
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution);
138025
138115
  }
138116
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
138026
138117
  /** Creates a DefinitionInfo directly from the name of a declaration. */
138027
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
138118
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution, textSpan) {
138028
138119
  var sourceFile = declaration.getSourceFile();
138029
138120
  if (!textSpan) {
138030
138121
  var name = ts.getNameOfDeclaration(declaration) || declaration;
138031
138122
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
138032
138123
  }
138033
138124
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
138034
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
138125
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 8388608 /* Ambient */), failedAliasResolution: failedAliasResolution });
138035
138126
  }
138036
138127
  function isDefinitionVisible(checker, declaration) {
138037
138128
  if (checker.isDeclarationVisible(declaration))
@@ -138064,8 +138155,8 @@ var ts;
138064
138155
  return false;
138065
138156
  }
138066
138157
  }
138067
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
138068
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
138158
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
138159
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, failedAliasResolution);
138069
138160
  }
138070
138161
  function findReferenceInPosition(refs, pos) {
138071
138162
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -141133,6 +141224,41 @@ var ts;
141133
141224
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
141134
141225
  break;
141135
141226
  }
141227
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
141228
+ var stack = [ts.scanner.getToken()];
141229
+ var token = ts.scanner.scan();
141230
+ loop: while (ts.length(stack)) {
141231
+ switch (token) {
141232
+ case 1 /* EndOfFileToken */:
141233
+ break loop;
141234
+ case 100 /* ImportKeyword */:
141235
+ tryConsumeImport();
141236
+ break;
141237
+ case 15 /* TemplateHead */:
141238
+ stack.push(token);
141239
+ break;
141240
+ case 18 /* OpenBraceToken */:
141241
+ if (ts.length(stack)) {
141242
+ stack.push(token);
141243
+ }
141244
+ break;
141245
+ case 19 /* CloseBraceToken */:
141246
+ if (ts.length(stack)) {
141247
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
141248
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
141249
+ stack.pop();
141250
+ }
141251
+ }
141252
+ else {
141253
+ stack.pop();
141254
+ }
141255
+ }
141256
+ break;
141257
+ }
141258
+ token = ts.scanner.scan();
141259
+ }
141260
+ nextToken();
141261
+ }
141136
141262
  // check if at least one of alternative have moved scanner forward
141137
141263
  if (tryConsumeDeclare() ||
141138
141264
  tryConsumeImport() ||
@@ -142426,7 +142552,7 @@ var ts;
142426
142552
  if (!typeDisplayString) {
142427
142553
  continue;
142428
142554
  }
142429
- addTypeHints(typeDisplayString, param.name.end);
142555
+ addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
142430
142556
  }
142431
142557
  }
142432
142558
  function getParameterDeclarationTypeDisplayString(symbol) {
@@ -151078,9 +151204,10 @@ var ts;
151078
151204
  // 2. add "member3" to the second import statement's import list
151079
151205
  // and it is up to the user to decide which one fits best.
151080
151206
  return ts.firstDefined(existingImports, function (_a) {
151207
+ var _b;
151081
151208
  var declaration = _a.declaration;
151082
151209
  var namespacePrefix = getNamespaceLikeImportText(declaration);
151083
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151210
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151084
151211
  if (namespacePrefix && moduleSpecifier) {
151085
151212
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
151086
151213
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -151256,8 +151383,9 @@ var ts;
151256
151383
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
151257
151384
  }
151258
151385
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
151386
+ var _b;
151259
151387
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
151260
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151388
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151261
151389
  if (moduleSpecifier) {
151262
151390
  var addAsTypeOnly = useRequire
151263
151391
  ? 4 /* NotAllowed */
@@ -163066,9 +163194,9 @@ var ts;
163066
163194
  synchronizeHostData();
163067
163195
  return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
163068
163196
  }
163069
- function getDefinitionAndBoundSpan(fileName, position) {
163197
+ function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
163070
163198
  synchronizeHostData();
163071
- return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
163199
+ return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
163072
163200
  }
163073
163201
  function getTypeDefinitionAtPosition(fileName, position) {
163074
163202
  synchronizeHostData();
@@ -166237,6 +166365,9 @@ var ts;
166237
166365
  CommandTypes["SignatureHelp"] = "signatureHelp";
166238
166366
  /* @internal */
166239
166367
  CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
166368
+ CommandTypes["SourceDefinitionAndBoundSpan"] = "sourceDefinitionAndBoundSpan";
166369
+ /* @internal */
166370
+ CommandTypes["SourceDefinitionAndBoundSpanFull"] = "sourceDefinitionAndBoundSpan-full";
166240
166371
  CommandTypes["Status"] = "status";
166241
166372
  CommandTypes["TypeDefinition"] = "typeDefinition";
166242
166373
  CommandTypes["ProjectInfo"] = "projectInfo";
@@ -167106,6 +167237,7 @@ var ts;
167106
167237
  ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
167107
167238
  ProjectKind[ProjectKind["External"] = 2] = "External";
167108
167239
  ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
167240
+ ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
167109
167241
  })(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
167110
167242
  /* @internal */
167111
167243
  function countEachFileTypes(infos, includeSizes) {
@@ -168551,6 +168683,17 @@ var ts;
168551
168683
  Project.prototype.getIncompleteCompletionsCache = function () {
168552
168684
  return this.projectService.getIncompleteCompletionsCache();
168553
168685
  };
168686
+ Project.prototype.withAuxiliaryProjectForFiles = function (fileNames, cb) {
168687
+ 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 });
168688
+ var project = new AuxiliaryProject(this.projectService, this.documentRegistry, options);
168689
+ for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
168690
+ var fileName = fileNames_1[_i];
168691
+ project.addRoot(this.getScriptInfo(fileName));
168692
+ }
168693
+ project.updateGraph();
168694
+ cb(project);
168695
+ project.close();
168696
+ };
168554
168697
  return Project;
168555
168698
  }());
168556
168699
  server.Project = Project;
@@ -168662,6 +168805,22 @@ var ts;
168662
168805
  return InferredProject;
168663
168806
  }(Project));
168664
168807
  server.InferredProject = InferredProject;
168808
+ var AuxiliaryProject = /** @class */ (function (_super) {
168809
+ __extends(AuxiliaryProject, _super);
168810
+ function AuxiliaryProject(projectService, documentRegistry, parentCompilerOptions) {
168811
+ var _this = this;
168812
+ 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 });
168813
+ _this = _super.call(this, "js-analysis", ProjectKind.Auxiliary, projectService, documentRegistry,
168814
+ /*hasExplicitListOfFiles*/ false,
168815
+ /*lastFileExceededProgramSize*/ undefined, options,
168816
+ /*compileOnSaveEnabled*/ false,
168817
+ /*watchOptions*/ undefined, projectService.host,
168818
+ /*currentDirectory*/ undefined) || this;
168819
+ return _this;
168820
+ }
168821
+ return AuxiliaryProject;
168822
+ }(Project));
168823
+ server.AuxiliaryProject = AuxiliaryProject;
168665
168824
  var AutoImportProviderProject = /** @class */ (function (_super) {
168666
168825
  __extends(AutoImportProviderProject, _super);
168667
168826
  /*@internal*/
@@ -170550,8 +170709,8 @@ var ts;
170550
170709
  this.projectToSizeMap.set(name, 0);
170551
170710
  this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); });
170552
170711
  var totalNonTsFileSize = 0;
170553
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
170554
- var f = fileNames_1[_i];
170712
+ for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
170713
+ var f = fileNames_2[_i];
170555
170714
  var fileName = propertyReader.getFileName(f);
170556
170715
  if (ts.hasTSFileExtension(fileName)) {
170557
170716
  continue;
@@ -173264,6 +173423,12 @@ var ts;
173264
173423
  _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
173265
173424
  return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173266
173425
  },
173426
+ // [CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173427
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
173428
+ // },
173429
+ // [CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173430
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173431
+ // },
173267
173432
  _a[server.CommandNames.EmitOutput] = function (request) {
173268
173433
  return _this.requiredResponse(_this.getEmitOutput(request.arguments));
173269
173434
  },
@@ -174000,10 +174165,34 @@ var ts;
174000
174165
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
174001
174166
  return definitions.map(function (info) {
174002
174167
  var newDocumentSpan = getMappedDocumentSpan(info, project);
174003
- return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
174168
+ 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 });
174004
174169
  });
174005
174170
  };
174006
174171
  Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
174172
+ // const { file, project } = this.getFileAndProject(args);
174173
+ // const position = this.getPositionInFile(args, file);
174174
+ // const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
174175
+ // const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);
174176
+ // if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
174177
+ // return {
174178
+ // definitions: emptyArray,
174179
+ // textSpan: undefined! // TODO: GH#18217
174180
+ // };
174181
+ // }
174182
+ // const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174183
+ // const { textSpan } = unmappedDefinitionAndBoundSpan;
174184
+ // if (simplifiedResult) {
174185
+ // return {
174186
+ // definitions: this.mapDefinitionInfo(definitions, project),
174187
+ // textSpan: toProtocolTextSpan(textSpan, scriptInfo)
174188
+ // };
174189
+ // }
174190
+ // return {
174191
+ // definitions: definitions.map(Session.mapToOriginalLocation),
174192
+ // textSpan,
174193
+ // };
174194
+ // }
174195
+ // private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
174007
174196
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
174008
174197
  var position = this.getPositionInFile(args, file);
174009
174198
  var scriptInfo = ts.Debug.checkDefined(project.getScriptInfo(file));
@@ -174014,7 +174203,31 @@ var ts;
174014
174203
  textSpan: undefined // TODO: GH#18217
174015
174204
  };
174016
174205
  }
174017
- var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174206
+ var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project).slice();
174207
+ var needsJsResolution = !ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) || ts.some(definitions, function (d) { return !!d.failedAliasResolution; });
174208
+ if (needsJsResolution) {
174209
+ project.withAuxiliaryProjectForFiles([file], function (auxiliaryProject) {
174210
+ var ls = auxiliaryProject.getLanguageService();
174211
+ var jsDefinitions = ls.getDefinitionAndBoundSpan(file, position, /*aliasesOnly*/ true);
174212
+ if (ts.some(jsDefinitions === null || jsDefinitions === void 0 ? void 0 : jsDefinitions.definitions)) {
174213
+ for (var _i = 0, _a = jsDefinitions.definitions; _i < _a.length; _i++) {
174214
+ var jsDefinition = _a[_i];
174215
+ if (jsDefinition.unverified) {
174216
+ var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
174217
+ if (ts.some(refined)) {
174218
+ for (var _b = 0, _c = refined || server.emptyArray; _b < _c.length; _b++) {
174219
+ var def = _c[_b];
174220
+ ts.pushIfUnique(definitions, def, ts.documentSpansEqual);
174221
+ }
174222
+ continue;
174223
+ }
174224
+ }
174225
+ ts.pushIfUnique(definitions, jsDefinition, ts.documentSpansEqual);
174226
+ }
174227
+ }
174228
+ });
174229
+ }
174230
+ definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
174018
174231
  var textSpan = unmappedDefinitionAndBoundSpan.textSpan;
174019
174232
  if (simplifiedResult) {
174020
174233
  return {
@@ -174026,6 +174239,32 @@ var ts;
174026
174239
  definitions: definitions.map(Session.mapToOriginalLocation),
174027
174240
  textSpan: textSpan,
174028
174241
  };
174242
+ function tryRefineDefinition(definition, program, auxiliaryProgram) {
174243
+ var _a, _b;
174244
+ var fileToSearch = auxiliaryProgram.getSourceFile(definition.fileName);
174245
+ if (!fileToSearch) {
174246
+ return undefined;
174247
+ }
174248
+ var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
174249
+ var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
174250
+ if (!symbol || !symbol.declarations || ts.some(symbol.declarations, ts.isFreelyNameableImport)) {
174251
+ return undefined;
174252
+ }
174253
+ 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;
174254
+ return searchForDeclaration(nameToSearch, fileToSearch, auxiliaryProgram);
174255
+ }
174256
+ function searchForDeclaration(declarationName, fileToSearch, auxiliaryProgram) {
174257
+ var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
174258
+ return ts.mapDefined(matches, function (match) {
174259
+ var symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
174260
+ var decl = ts.getDeclarationFromName(match);
174261
+ if (symbol && decl) {
174262
+ // I think the last argument to this is supposed to be the start node, but it doesn't seem important.
174263
+ // Callers internal to GoToDefinition already get confused about this.
174264
+ return ts.GoToDefinition.createDefinitionInfo(decl, auxiliaryProgram.getTypeChecker(), symbol, decl);
174265
+ }
174266
+ });
174267
+ }
174029
174268
  };
174030
174269
  Session.prototype.getEmitOutput = function (args) {
174031
174270
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;