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

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.20220315";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -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 {
@@ -39434,6 +39446,13 @@ var ts;
39434
39446
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39435
39447
  defaultValueDescription: false,
39436
39448
  },
39449
+ {
39450
+ name: "noDtsResolution",
39451
+ type: "boolean",
39452
+ affectsModuleResolution: true,
39453
+ category: ts.Diagnostics.Modules,
39454
+ defaultValueDescription: false,
39455
+ },
39437
39456
  // Source Maps
39438
39457
  {
39439
39458
  name: "sourceRoot",
@@ -41813,7 +41832,8 @@ var ts;
41813
41832
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
41814
41833
  Extensions[Extensions["Json"] = 2] = "Json";
41815
41834
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
41816
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
41835
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
41836
+ Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
41817
41837
  })(Extensions || (Extensions = {}));
41818
41838
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
41819
41839
  function resolvedTypeScriptOnly(resolved) {
@@ -42758,7 +42778,21 @@ var ts;
42758
42778
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42759
42779
  }
42760
42780
  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);
42781
+ var extensions;
42782
+ if (lookupConfig) {
42783
+ extensions = tsconfigExtensions;
42784
+ }
42785
+ else if (compilerOptions.noDtsResolution) {
42786
+ extensions = [Extensions.TypeScriptButNotDts];
42787
+ if (compilerOptions.allowJs)
42788
+ extensions.push(Extensions.JavaScript);
42789
+ if (compilerOptions.resolveJsonModule)
42790
+ extensions.push(Extensions.Json);
42791
+ }
42792
+ else {
42793
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
42794
+ }
42795
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
42762
42796
  }
42763
42797
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42764
42798
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42767,6 +42801,10 @@ var ts;
42767
42801
  var failedLookupLocations = [];
42768
42802
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42769
42803
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
42804
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
42805
+ if (compilerOptions.noDtsResolution) {
42806
+ conditions.pop();
42807
+ }
42770
42808
  var state = {
42771
42809
  compilerOptions: compilerOptions,
42772
42810
  host: host,
@@ -42774,7 +42812,7 @@ var ts;
42774
42812
  failedLookupLocations: failedLookupLocations,
42775
42813
  packageJsonInfoCache: cache,
42776
42814
  features: features,
42777
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
42815
+ conditions: conditions,
42778
42816
  };
42779
42817
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42780
42818
  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 +43020,22 @@ var ts;
42982
43020
  default: return tryExtension(".d.ts" /* Dts */);
42983
43021
  }
42984
43022
  case Extensions.TypeScript:
43023
+ case Extensions.TypeScriptButNotDts:
43024
+ var useDts = extensions === Extensions.TypeScript;
42985
43025
  switch (originalExtension) {
42986
43026
  case ".mjs" /* Mjs */:
42987
43027
  case ".mts" /* Mts */:
42988
43028
  case ".d.mts" /* Dmts */:
42989
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43029
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
42990
43030
  case ".cjs" /* Cjs */:
42991
43031
  case ".cts" /* Cts */:
42992
43032
  case ".d.cts" /* Dcts */:
42993
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43033
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
42994
43034
  case ".json" /* Json */:
42995
43035
  candidate += ".json" /* Json */;
42996
- return tryExtension(".d.ts" /* Dts */);
43036
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
42997
43037
  default:
42998
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43038
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
42999
43039
  }
43000
43040
  case Extensions.JavaScript:
43001
43041
  switch (originalExtension) {
@@ -43213,6 +43253,7 @@ var ts;
43213
43253
  switch (extensions) {
43214
43254
  case Extensions.JavaScript:
43215
43255
  case Extensions.Json:
43256
+ case Extensions.TypeScriptButNotDts:
43216
43257
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43217
43258
  break;
43218
43259
  case Extensions.TypeScript:
@@ -43291,6 +43332,8 @@ var ts;
43291
43332
  return extension === ".json" /* Json */;
43292
43333
  case Extensions.TypeScript:
43293
43334
  return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43335
+ case Extensions.TypeScriptButNotDts:
43336
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
43294
43337
  case Extensions.DtsOnly:
43295
43338
  return extension === ".d.ts" /* Dts */;
43296
43339
  }
@@ -55359,7 +55402,7 @@ var ts;
55359
55402
  }
55360
55403
  }
55361
55404
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55362
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55405
+ type = getUnionType(sourceTypes);
55363
55406
  }
55364
55407
  }
55365
55408
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -67412,32 +67455,13 @@ var ts;
67412
67455
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
67413
67456
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
67414
67457
  }
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;
67458
+ function isValidBigIntString(s) {
67434
67459
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
67435
67460
  var success = true;
67436
67461
  scanner.setOnError(function () { return success = false; });
67437
67462
  scanner.setText(s + "n");
67438
67463
  var result = scanner.scan();
67439
- var negative = result === 40 /* MinusToken */;
67440
- if (negative) {
67464
+ if (result === 40 /* MinusToken */) {
67441
67465
  result = scanner.scan();
67442
67466
  }
67443
67467
  var flags = scanner.getTokenFlags();
@@ -67446,8 +67470,7 @@ var ts;
67446
67470
  // * a bigint can be scanned, and that when it is scanned, it is
67447
67471
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
67448
67472
  // * 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()) }));
67473
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
67451
67474
  }
67452
67475
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
67453
67476
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -67455,8 +67478,8 @@ var ts;
67455
67478
  }
67456
67479
  if (source.flags & 128 /* StringLiteral */) {
67457
67480
  var value = source.value;
67458
- return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
67459
- target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
67481
+ return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
67482
+ target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
67460
67483
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
67461
67484
  }
67462
67485
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68030,63 +68053,7 @@ var ts;
68030
68053
  // succeed. That would be a pointless and confusing outcome.
68031
68054
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68032
68055
  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
- }
68056
+ inferFromTypes(matches ? matches[i] : neverType, types[i]);
68090
68057
  }
68091
68058
  }
68092
68059
  }
@@ -127062,6 +127029,20 @@ var ts;
127062
127029
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
127063
127030
  }
127064
127031
  ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
127032
+ /**
127033
+ * Returns true if `node` is the declaration of `n` in:
127034
+ * - `import n from "m"`
127035
+ * - `import * as n from "m"`
127036
+ * - `import n = require("m")`
127037
+ * - `const n = require("m")`
127038
+ */
127039
+ function isFreelyNameableImport(node) {
127040
+ return node.kind === 266 /* ImportClause */
127041
+ || node.kind === 267 /* NamespaceImport */
127042
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
127043
+ || ts.isVariableDeclarationInitializedToRequire(node);
127044
+ }
127045
+ ts.isFreelyNameableImport = isFreelyNameableImport;
127065
127046
  function getScriptKind(fileName, host) {
127066
127047
  // First check to see if the script kind was specified by the host. Chances are the host
127067
127048
  // may override the default script kind for the file extension.
@@ -136076,6 +136057,29 @@ var ts;
136076
136057
  }
136077
136058
  }
136078
136059
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
136060
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
136061
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
136062
+ return candidates.reduce(function (topMost, decl) {
136063
+ var depth = getDepth(decl);
136064
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
136065
+ topMost.declarationNames.push(decl);
136066
+ }
136067
+ else if (depth < topMost.depth) {
136068
+ topMost.declarationNames = [decl];
136069
+ }
136070
+ topMost.depth = depth;
136071
+ return topMost;
136072
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
136073
+ function getDepth(declaration) {
136074
+ var depth = 0;
136075
+ while (declaration) {
136076
+ declaration = ts.getContainerNode(declaration);
136077
+ depth++;
136078
+ }
136079
+ return depth;
136080
+ }
136081
+ }
136082
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
136079
136083
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
136080
136084
  if (!signature.name || !ts.isIdentifier(signature.name))
136081
136085
  return false;
@@ -137708,7 +137712,9 @@ var ts;
137708
137712
  (function (ts) {
137709
137713
  var GoToDefinition;
137710
137714
  (function (GoToDefinition) {
137711
- function getDefinitionAtPosition(program, sourceFile, position) {
137715
+ function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
137716
+ var _a;
137717
+ var _b;
137712
137718
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
137713
137719
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
137714
137720
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -137731,17 +137737,50 @@ var ts;
137731
137737
  }
137732
137738
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
137733
137739
  var classDecl = node.parent.parent;
137734
- var symbol_1 = getSymbol(classDecl, typeChecker);
137740
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, isAliasTarget_1 = _c.isAliasTarget, failedAliasResolution_1 = _c.failedAliasResolution;
137741
+ if (aliasesOnly && !isAliasTarget_1)
137742
+ return undefined;
137735
137743
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
137736
137744
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
137737
137745
  var sourceFile_1 = node.getSourceFile();
137738
137746
  return ts.map(staticBlocks, function (staticBlock) {
137739
137747
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
137740
137748
  pos = ts.skipTrivia(sourceFile_1.text, pos);
137741
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
137749
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, isAliasTarget_1, failedAliasResolution_1, { start: pos, length: "static".length });
137742
137750
  });
137743
137751
  }
137744
- var symbol = getSymbol(node, typeChecker);
137752
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, isAliasTarget = _d.isAliasTarget, failedAliasResolution = _d.failedAliasResolution;
137753
+ var fallbackNode = node;
137754
+ if (aliasesOnly && failedAliasResolution) {
137755
+ // We couldn't resolve the specific import, try on the module specifier.
137756
+ var importDeclaration = ts.findAncestor(node, ts.isAnyImportOrBareOrAccessedRequire);
137757
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
137758
+ if (moduleSpecifier) {
137759
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, isAliasTarget = _a.isAliasTarget, failedAliasResolution = _a.failedAliasResolution);
137760
+ fallbackNode = moduleSpecifier;
137761
+ }
137762
+ }
137763
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
137764
+ // We couldn't resolve the module specifier as an external module, but it could
137765
+ // be that module resolution succeeded but the target was not a module.
137766
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
137767
+ if (ref) {
137768
+ return [{
137769
+ name: fallbackNode.text,
137770
+ fileName: ref.resolvedFileName,
137771
+ containerName: undefined,
137772
+ containerKind: undefined,
137773
+ kind: "script" /* scriptElement */,
137774
+ textSpan: ts.createTextSpan(0, 0),
137775
+ isAliasTarget: true,
137776
+ failedAliasResolution: failedAliasResolution,
137777
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
137778
+ unverified: fallbackNode !== node,
137779
+ }];
137780
+ }
137781
+ }
137782
+ if (aliasesOnly && !isAliasTarget)
137783
+ return undefined;
137745
137784
  // Could not find a symbol e.g. node is string or number keyword,
137746
137785
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
137747
137786
  if (!symbol) {
@@ -137750,14 +137789,14 @@ var ts;
137750
137789
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
137751
137790
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
137752
137791
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
137753
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
137792
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, isAliasTarget, failedAliasResolution);
137754
137793
  // For a function, if this is the original function definition, return just sigInfo.
137755
137794
  // If this is the original constructor definition, parent is the class.
137756
137795
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
137757
137796
  return [sigInfo];
137758
137797
  }
137759
137798
  else {
137760
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
137799
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution, calledDeclaration) || ts.emptyArray;
137761
137800
  // For a 'super()' call, put the signature first, else put the variable first.
137762
137801
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
137763
137802
  }
@@ -137769,7 +137808,7 @@ var ts;
137769
137808
  // assignment. This case and others are handled by the following code.
137770
137809
  if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
137771
137810
  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;
137811
+ 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, isAliasTarget, failedAliasResolution); }) : ts.emptyArray;
137773
137812
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
137774
137813
  }
137775
137814
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -137792,7 +137831,7 @@ var ts;
137792
137831
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
137793
137832
  });
137794
137833
  }
137795
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
137834
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution));
137796
137835
  }
137797
137836
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
137798
137837
  /**
@@ -137890,24 +137929,24 @@ var ts;
137890
137929
  return undefined;
137891
137930
  }
137892
137931
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
137893
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
137932
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*isAliasTarget*/ false, /*failedAliasResolution*/ false);
137894
137933
  }
137895
- var symbol = getSymbol(node, typeChecker);
137934
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, isAliasTarget = _a.isAliasTarget, failedAliasResolution = _a.failedAliasResolution;
137896
137935
  if (!symbol)
137897
137936
  return undefined;
137898
137937
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
137899
137938
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
137900
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
137939
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, isAliasTarget, failedAliasResolution);
137901
137940
  // 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);
137941
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, isAliasTarget, failedAliasResolution);
137903
137942
  return typeDefinitions.length ? typeDefinitions
137904
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
137943
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, isAliasTarget, failedAliasResolution)
137905
137944
  : undefined;
137906
137945
  }
137907
137946
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
137908
- function definitionFromType(type, checker, node) {
137947
+ function definitionFromType(type, checker, node, isAliasTarget, failedAliasResolution) {
137909
137948
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
137910
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
137949
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, isAliasTarget, failedAliasResolution);
137911
137950
  });
137912
137951
  }
137913
137952
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -137922,8 +137961,8 @@ var ts;
137922
137961
  }
137923
137962
  return undefined;
137924
137963
  }
137925
- function getDefinitionAndBoundSpan(program, sourceFile, position) {
137926
- var definitions = getDefinitionAtPosition(program, sourceFile, position);
137964
+ function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
137965
+ var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
137927
137966
  if (!definitions || definitions.length === 0) {
137928
137967
  return undefined;
137929
137968
  }
@@ -137949,13 +137988,17 @@ var ts;
137949
137988
  // get the aliased symbol instead. This allows for goto def on an import e.g.
137950
137989
  // import {A, B} from "mod";
137951
137990
  // to jump to the implementation directly.
137991
+ var failedAliasResolution = false;
137952
137992
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
137953
137993
  var aliased = checker.getAliasedSymbol(symbol);
137954
137994
  if (aliased.declarations) {
137955
- return aliased;
137995
+ return { symbol: aliased, isAliasTarget: true };
137996
+ }
137997
+ else {
137998
+ failedAliasResolution = true;
137956
137999
  }
137957
138000
  }
137958
- return symbol;
138001
+ return { symbol: symbol, isAliasTarget: !!(symbol && ts.isExternalModuleSymbol(symbol)), failedAliasResolution: failedAliasResolution };
137959
138002
  }
137960
138003
  // Go to the original declaration for cases:
137961
138004
  //
@@ -137969,26 +138012,45 @@ var ts;
137969
138012
  if (node.parent === declaration) {
137970
138013
  return true;
137971
138014
  }
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;
138015
+ if (declaration.kind === 267 /* NamespaceImport */) {
138016
+ return false;
137983
138017
  }
138018
+ return true;
137984
138019
  }
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); });
138020
+ /**
138021
+ * ```ts
138022
+ * function f() {}
138023
+ * f.foo = 0;
138024
+ * ```
138025
+ *
138026
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
138027
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
138028
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
138029
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
138030
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
138031
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
138032
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
138033
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
138034
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
138035
+ * up with a more precise definition of what counts as a definition.
138036
+ */
138037
+ function isExpandoDeclaration(node) {
138038
+ if (!ts.isAssignmentDeclaration(node))
138039
+ return false;
138040
+ var containingAssignment = ts.findAncestor(node, function (p) {
138041
+ if (ts.isAssignmentExpression(p))
138042
+ return true;
138043
+ if (!ts.isAssignmentDeclaration(p))
138044
+ return "quit";
138045
+ return false;
138046
+ });
138047
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
138048
+ }
138049
+ function getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution, excludeDeclaration) {
138050
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
138051
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
138052
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
138053
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, isAliasTarget, failedAliasResolution); });
137992
138054
  function getConstructSignatureDefinition() {
137993
138055
  // Applicable only if we are in a new expression, or we are on a constructor declaration
137994
138056
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -138012,26 +138074,27 @@ var ts;
138012
138074
  return declarations.length
138013
138075
  ? declarationsWithBody.length !== 0
138014
138076
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
138015
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
138077
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, isAliasTarget, failedAliasResolution)]
138016
138078
  : undefined;
138017
138079
  }
138018
138080
  }
138019
138081
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
138020
- function createDefinitionInfo(declaration, checker, symbol, node) {
138082
+ function createDefinitionInfo(declaration, checker, symbol, node, isAliasTarget, failedAliasResolution) {
138021
138083
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
138022
138084
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
138023
138085
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
138024
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
138086
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, isAliasTarget, failedAliasResolution);
138025
138087
  }
138088
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
138026
138089
  /** Creates a DefinitionInfo directly from the name of a declaration. */
138027
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
138090
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, isAliasTarget, failedAliasResolution, textSpan) {
138028
138091
  var sourceFile = declaration.getSourceFile();
138029
138092
  if (!textSpan) {
138030
138093
  var name = ts.getNameOfDeclaration(declaration) || declaration;
138031
138094
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
138032
138095
  }
138033
138096
  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) });
138097
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 8388608 /* Ambient */), isAliasTarget: isAliasTarget, failedAliasResolution: failedAliasResolution });
138035
138098
  }
138036
138099
  function isDefinitionVisible(checker, declaration) {
138037
138100
  if (checker.isDeclarationVisible(declaration))
@@ -138064,8 +138127,8 @@ var ts;
138064
138127
  return false;
138065
138128
  }
138066
138129
  }
138067
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
138068
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
138130
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, isAliasTarget, failedAliasResolution) {
138131
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, isAliasTarget, failedAliasResolution);
138069
138132
  }
138070
138133
  function findReferenceInPosition(refs, pos) {
138071
138134
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -138080,6 +138143,7 @@ var ts;
138080
138143
  containerName: undefined,
138081
138144
  containerKind: undefined,
138082
138145
  unverified: unverified,
138146
+ isAliasTarget: true,
138083
138147
  };
138084
138148
  }
138085
138149
  /** Returns a CallLikeExpression where `node` is the target being invoked. */
@@ -151078,9 +151142,10 @@ var ts;
151078
151142
  // 2. add "member3" to the second import statement's import list
151079
151143
  // and it is up to the user to decide which one fits best.
151080
151144
  return ts.firstDefined(existingImports, function (_a) {
151145
+ var _b;
151081
151146
  var declaration = _a.declaration;
151082
151147
  var namespacePrefix = getNamespaceLikeImportText(declaration);
151083
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151148
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151084
151149
  if (namespacePrefix && moduleSpecifier) {
151085
151150
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
151086
151151
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -151256,8 +151321,9 @@ var ts;
151256
151321
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
151257
151322
  }
151258
151323
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
151324
+ var _b;
151259
151325
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
151260
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151326
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151261
151327
  if (moduleSpecifier) {
151262
151328
  var addAsTypeOnly = useRequire
151263
151329
  ? 4 /* NotAllowed */
@@ -163066,9 +163132,9 @@ var ts;
163066
163132
  synchronizeHostData();
163067
163133
  return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
163068
163134
  }
163069
- function getDefinitionAndBoundSpan(fileName, position) {
163135
+ function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
163070
163136
  synchronizeHostData();
163071
- return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
163137
+ return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
163072
163138
  }
163073
163139
  function getTypeDefinitionAtPosition(fileName, position) {
163074
163140
  synchronizeHostData();
@@ -166237,6 +166303,9 @@ var ts;
166237
166303
  CommandTypes["SignatureHelp"] = "signatureHelp";
166238
166304
  /* @internal */
166239
166305
  CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
166306
+ CommandTypes["SourceDefinitionAndBoundSpan"] = "sourceDefinitionAndBoundSpan";
166307
+ /* @internal */
166308
+ CommandTypes["SourceDefinitionAndBoundSpanFull"] = "sourceDefinitionAndBoundSpan-full";
166240
166309
  CommandTypes["Status"] = "status";
166241
166310
  CommandTypes["TypeDefinition"] = "typeDefinition";
166242
166311
  CommandTypes["ProjectInfo"] = "projectInfo";
@@ -167106,6 +167175,7 @@ var ts;
167106
167175
  ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
167107
167176
  ProjectKind[ProjectKind["External"] = 2] = "External";
167108
167177
  ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
167178
+ ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
167109
167179
  })(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
167110
167180
  /* @internal */
167111
167181
  function countEachFileTypes(infos, includeSizes) {
@@ -168551,6 +168621,17 @@ var ts;
168551
168621
  Project.prototype.getIncompleteCompletionsCache = function () {
168552
168622
  return this.projectService.getIncompleteCompletionsCache();
168553
168623
  };
168624
+ Project.prototype.withAuxiliaryProjectForFiles = function (fileNames, cb) {
168625
+ 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 });
168626
+ var project = new AuxiliaryProject(this.projectService, this.documentRegistry, options);
168627
+ for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
168628
+ var fileName = fileNames_1[_i];
168629
+ project.addRoot(this.getScriptInfo(fileName));
168630
+ }
168631
+ project.updateGraph();
168632
+ cb(project);
168633
+ project.close();
168634
+ };
168554
168635
  return Project;
168555
168636
  }());
168556
168637
  server.Project = Project;
@@ -168662,6 +168743,22 @@ var ts;
168662
168743
  return InferredProject;
168663
168744
  }(Project));
168664
168745
  server.InferredProject = InferredProject;
168746
+ var AuxiliaryProject = /** @class */ (function (_super) {
168747
+ __extends(AuxiliaryProject, _super);
168748
+ function AuxiliaryProject(projectService, documentRegistry, parentCompilerOptions) {
168749
+ var _this = this;
168750
+ 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 });
168751
+ _this = _super.call(this, "js-analysis", ProjectKind.Auxiliary, projectService, documentRegistry,
168752
+ /*hasExplicitListOfFiles*/ false,
168753
+ /*lastFileExceededProgramSize*/ undefined, options,
168754
+ /*compileOnSaveEnabled*/ false,
168755
+ /*watchOptions*/ undefined, projectService.host,
168756
+ /*currentDirectory*/ undefined) || this;
168757
+ return _this;
168758
+ }
168759
+ return AuxiliaryProject;
168760
+ }(Project));
168761
+ server.AuxiliaryProject = AuxiliaryProject;
168665
168762
  var AutoImportProviderProject = /** @class */ (function (_super) {
168666
168763
  __extends(AutoImportProviderProject, _super);
168667
168764
  /*@internal*/
@@ -170550,8 +170647,8 @@ var ts;
170550
170647
  this.projectToSizeMap.set(name, 0);
170551
170648
  this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); });
170552
170649
  var totalNonTsFileSize = 0;
170553
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
170554
- var f = fileNames_1[_i];
170650
+ for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
170651
+ var f = fileNames_2[_i];
170555
170652
  var fileName = propertyReader.getFileName(f);
170556
170653
  if (ts.hasTSFileExtension(fileName)) {
170557
170654
  continue;
@@ -173264,6 +173361,12 @@ var ts;
173264
173361
  _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
173265
173362
  return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173266
173363
  },
173364
+ // [CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173365
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
173366
+ // },
173367
+ // [CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
173368
+ // return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173369
+ // },
173267
173370
  _a[server.CommandNames.EmitOutput] = function (request) {
173268
173371
  return _this.requiredResponse(_this.getEmitOutput(request.arguments));
173269
173372
  },
@@ -174000,10 +174103,34 @@ var ts;
174000
174103
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
174001
174104
  return definitions.map(function (info) {
174002
174105
  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 });
174106
+ return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, isAliasTarget: info.isAliasTarget, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
174004
174107
  });
174005
174108
  };
174006
174109
  Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
174110
+ // const { file, project } = this.getFileAndProject(args);
174111
+ // const position = this.getPositionInFile(args, file);
174112
+ // const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
174113
+ // const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);
174114
+ // if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
174115
+ // return {
174116
+ // definitions: emptyArray,
174117
+ // textSpan: undefined! // TODO: GH#18217
174118
+ // };
174119
+ // }
174120
+ // const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174121
+ // const { textSpan } = unmappedDefinitionAndBoundSpan;
174122
+ // if (simplifiedResult) {
174123
+ // return {
174124
+ // definitions: this.mapDefinitionInfo(definitions, project),
174125
+ // textSpan: toProtocolTextSpan(textSpan, scriptInfo)
174126
+ // };
174127
+ // }
174128
+ // return {
174129
+ // definitions: definitions.map(Session.mapToOriginalLocation),
174130
+ // textSpan,
174131
+ // };
174132
+ // }
174133
+ // private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
174007
174134
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
174008
174135
  var position = this.getPositionInFile(args, file);
174009
174136
  var scriptInfo = ts.Debug.checkDefined(project.getScriptInfo(file));
@@ -174014,7 +174141,31 @@ var ts;
174014
174141
  textSpan: undefined // TODO: GH#18217
174015
174142
  };
174016
174143
  }
174017
- var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
174144
+ var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project).slice();
174145
+ var needsJsResolution = !ts.some(definitions, function (d) { return !!d.isAliasTarget && !d.isAmbient; }) || ts.some(definitions, function (d) { return !!d.failedAliasResolution; });
174146
+ if (needsJsResolution) {
174147
+ project.withAuxiliaryProjectForFiles([file], function (auxiliaryProject) {
174148
+ var ls = auxiliaryProject.getLanguageService();
174149
+ var jsDefinitions = ls.getDefinitionAndBoundSpan(file, position, /*aliasesOnly*/ true);
174150
+ if (ts.some(jsDefinitions === null || jsDefinitions === void 0 ? void 0 : jsDefinitions.definitions)) {
174151
+ for (var _i = 0, _a = jsDefinitions.definitions; _i < _a.length; _i++) {
174152
+ var jsDefinition = _a[_i];
174153
+ if (jsDefinition.unverified) {
174154
+ var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
174155
+ if (ts.some(refined)) {
174156
+ for (var _b = 0, _c = refined || server.emptyArray; _b < _c.length; _b++) {
174157
+ var def = _c[_b];
174158
+ ts.pushIfUnique(definitions, def, ts.documentSpansEqual);
174159
+ }
174160
+ continue;
174161
+ }
174162
+ }
174163
+ ts.pushIfUnique(definitions, jsDefinition, ts.documentSpansEqual);
174164
+ }
174165
+ }
174166
+ });
174167
+ }
174168
+ definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
174018
174169
  var textSpan = unmappedDefinitionAndBoundSpan.textSpan;
174019
174170
  if (simplifiedResult) {
174020
174171
  return {
@@ -174026,6 +174177,32 @@ var ts;
174026
174177
  definitions: definitions.map(Session.mapToOriginalLocation),
174027
174178
  textSpan: textSpan,
174028
174179
  };
174180
+ function tryRefineDefinition(definition, program, auxiliaryProgram) {
174181
+ var _a, _b;
174182
+ var fileToSearch = auxiliaryProgram.getSourceFile(definition.fileName);
174183
+ if (!fileToSearch) {
174184
+ return undefined;
174185
+ }
174186
+ var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
174187
+ var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
174188
+ if (!symbol || !symbol.declarations || ts.some(symbol.declarations, ts.isFreelyNameableImport)) {
174189
+ return undefined;
174190
+ }
174191
+ 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;
174192
+ return searchForDeclaration(nameToSearch, fileToSearch, auxiliaryProgram);
174193
+ }
174194
+ function searchForDeclaration(declarationName, fileToSearch, auxiliaryProgram) {
174195
+ var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
174196
+ return ts.mapDefined(matches, function (match) {
174197
+ var symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
174198
+ var decl = ts.getDeclarationFromName(match);
174199
+ if (symbol && decl) {
174200
+ // I think the last argument to this is supposed to be the start node, but it doesn't seem important.
174201
+ // Callers internal to GoToDefinition already get confused about this.
174202
+ return ts.GoToDefinition.createDefinitionInfo(decl, auxiliaryProgram.getTypeChecker(), symbol, decl);
174203
+ }
174204
+ });
174205
+ }
174029
174206
  };
174030
174207
  Session.prototype.getEmitOutput = function (args) {
174031
174208
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;