@typescript-deploys/pr-build 4.7.0-pr-48294-7 → 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
@@ -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 {
@@ -39445,6 +39457,13 @@ var ts;
39445
39457
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39446
39458
  defaultValueDescription: false,
39447
39459
  },
39460
+ {
39461
+ name: "noDtsResolution",
39462
+ type: "boolean",
39463
+ affectsModuleResolution: true,
39464
+ category: ts.Diagnostics.Modules,
39465
+ defaultValueDescription: false,
39466
+ },
39448
39467
  // Source Maps
39449
39468
  {
39450
39469
  name: "sourceRoot",
@@ -41824,7 +41843,8 @@ var ts;
41824
41843
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
41825
41844
  Extensions[Extensions["Json"] = 2] = "Json";
41826
41845
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
41827
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
41846
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
41847
+ Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
41828
41848
  })(Extensions || (Extensions = {}));
41829
41849
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
41830
41850
  function resolvedTypeScriptOnly(resolved) {
@@ -42769,7 +42789,21 @@ var ts;
42769
42789
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42770
42790
  }
42771
42791
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
42772
- 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);
42773
42807
  }
42774
42808
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42775
42809
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42778,6 +42812,10 @@ var ts;
42778
42812
  var failedLookupLocations = [];
42779
42813
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42780
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
+ }
42781
42819
  var state = {
42782
42820
  compilerOptions: compilerOptions,
42783
42821
  host: host,
@@ -42785,7 +42823,7 @@ var ts;
42785
42823
  failedLookupLocations: failedLookupLocations,
42786
42824
  packageJsonInfoCache: cache,
42787
42825
  features: features,
42788
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
42826
+ conditions: conditions,
42789
42827
  };
42790
42828
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42791
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);
@@ -42993,20 +43031,22 @@ var ts;
42993
43031
  default: return tryExtension(".d.ts" /* Dts */);
42994
43032
  }
42995
43033
  case Extensions.TypeScript:
43034
+ case Extensions.TypeScriptButNotDts:
43035
+ var useDts = extensions === Extensions.TypeScript;
42996
43036
  switch (originalExtension) {
42997
43037
  case ".mjs" /* Mjs */:
42998
43038
  case ".mts" /* Mts */:
42999
43039
  case ".d.mts" /* Dmts */:
43000
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43040
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43001
43041
  case ".cjs" /* Cjs */:
43002
43042
  case ".cts" /* Cts */:
43003
43043
  case ".d.cts" /* Dcts */:
43004
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43044
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43005
43045
  case ".json" /* Json */:
43006
43046
  candidate += ".json" /* Json */;
43007
- return tryExtension(".d.ts" /* Dts */);
43047
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43008
43048
  default:
43009
- 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);
43010
43050
  }
43011
43051
  case Extensions.JavaScript:
43012
43052
  switch (originalExtension) {
@@ -43224,6 +43264,7 @@ var ts;
43224
43264
  switch (extensions) {
43225
43265
  case Extensions.JavaScript:
43226
43266
  case Extensions.Json:
43267
+ case Extensions.TypeScriptButNotDts:
43227
43268
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43228
43269
  break;
43229
43270
  case Extensions.TypeScript:
@@ -43302,6 +43343,8 @@ var ts;
43302
43343
  return extension === ".json" /* Json */;
43303
43344
  case Extensions.TypeScript:
43304
43345
  return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43346
+ case Extensions.TypeScriptButNotDts:
43347
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
43305
43348
  case Extensions.DtsOnly:
43306
43349
  return extension === ".d.ts" /* Dts */;
43307
43350
  }
@@ -54918,7 +54961,7 @@ var ts;
54918
54961
  if (!omitTypeAlias) {
54919
54962
  return errorType;
54920
54963
  }
54921
- return getGlobalTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54964
+ return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54922
54965
  }
54923
54966
  var members = ts.createSymbolTable();
54924
54967
  for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
@@ -55370,7 +55413,7 @@ var ts;
55370
55413
  }
55371
55414
  }
55372
55415
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55373
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55416
+ type = getUnionType(sourceTypes);
55374
55417
  }
55375
55418
  }
55376
55419
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -56685,7 +56728,7 @@ var ts;
56685
56728
  }
56686
56729
  }
56687
56730
  if (memberTypeList.length) {
56688
- var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined);
56731
+ var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
56689
56732
  if (enumType_1.flags & 1048576 /* Union */) {
56690
56733
  enumType_1.flags |= 1024 /* EnumLiteral */;
56691
56734
  enumType_1.symbol = symbol;
@@ -59408,7 +59451,7 @@ var ts;
59408
59451
  type.resolvedTypeArguments = source.resolvedTypeArguments;
59409
59452
  return type;
59410
59453
  }
59411
- function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
59454
+ function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
59412
59455
  if (!aliasSymbol) {
59413
59456
  aliasSymbol = getAliasSymbolForTypeNode(node);
59414
59457
  var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
@@ -59420,7 +59463,6 @@ var ts;
59420
59463
  type.mapper = mapper;
59421
59464
  type.aliasSymbol = aliasSymbol;
59422
59465
  type.aliasTypeArguments = aliasTypeArguments;
59423
- type.aliasMapper = aliasMapper;
59424
59466
  return type;
59425
59467
  }
59426
59468
  function getTypeArguments(type) {
@@ -59485,7 +59527,7 @@ var ts;
59485
59527
  }
59486
59528
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59487
59529
  }
59488
- function getGlobalTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59530
+ function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59489
59531
  var type = getDeclaredTypeOfSymbol(symbol);
59490
59532
  if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59491
59533
  return getStringMappingType(symbol, typeArguments[0]);
@@ -59499,33 +59541,6 @@ var ts;
59499
59541
  }
59500
59542
  return instantiation;
59501
59543
  }
59502
- function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
59503
- var type = getDeclaredTypeOfSymbol(symbol);
59504
- if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59505
- return getStringMappingType(symbol, typeArguments[0]);
59506
- }
59507
- var links = getSymbolLinks(symbol);
59508
- var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
59509
- var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
59510
- var typeParameters = links.typeParameters;
59511
- var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
59512
- var instantiation = links.instantiations.get(id);
59513
- if (!instantiation) {
59514
- var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
59515
- var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
59516
- var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
59517
- links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
59518
- }
59519
- return instantiation;
59520
- }
59521
- function getOuterTypeParametersOfAlias(symbol) {
59522
- var _a;
59523
- var links = getSymbolLinks(symbol);
59524
- if (!links.outerTypeParameters) {
59525
- links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
59526
- }
59527
- return links.outerTypeParameters;
59528
- }
59529
59544
  /**
59530
59545
  * Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
59531
59546
  * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
@@ -59561,7 +59576,7 @@ var ts;
59561
59576
  // a .d.ts file. See #43622 for an example.
59562
59577
  var aliasSymbol = getAliasSymbolForTypeNode(node);
59563
59578
  var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
59564
- return getGlobalTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59579
+ return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59565
59580
  }
59566
59581
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59567
59582
  }
@@ -60476,7 +60491,14 @@ var ts;
60476
60491
  result.types = types;
60477
60492
  return result;
60478
60493
  }
60479
- function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60494
+ // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
60495
+ // flag is specified we also reduce the constituent type set to only include types that aren't subtypes
60496
+ // of other types. Subtype reduction is expensive for large union types and is possible only when union
60497
+ // types are known not to circularly reference themselves (as is the case with union types created by
60498
+ // expression constructs such as array literals and the || and ?: operators). Named types can
60499
+ // circularly reference themselves and therefore cannot be subtype reduced during their declaration.
60500
+ // For example, "type Item = string | (() => Item" is a named type that circularly references itself.
60501
+ function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
60480
60502
  if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
60481
60503
  if (types.length === 0) {
60482
60504
  return neverType;
@@ -60545,7 +60567,7 @@ var ts;
60545
60567
  }
60546
60568
  var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
60547
60569
  (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
60548
- return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60570
+ return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60549
60571
  }
60550
60572
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
60551
60573
  var first;
@@ -60583,7 +60605,7 @@ var ts;
60583
60605
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
60584
60606
  }
60585
60607
  // This function assumes the constituent type list is sorted and deduplicated.
60586
- function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60608
+ function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
60587
60609
  if (types.length === 0) {
60588
60610
  return neverType;
60589
60611
  }
@@ -60603,7 +60625,6 @@ var ts;
60603
60625
  type.origin = origin;
60604
60626
  type.aliasSymbol = aliasSymbol;
60605
60627
  type.aliasTypeArguments = aliasTypeArguments;
60606
- type.aliasMapper = aliasMapper;
60607
60628
  if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
60608
60629
  type.flags |= 16 /* Boolean */;
60609
60630
  type.intrinsicName = "boolean";
@@ -60616,7 +60637,7 @@ var ts;
60616
60637
  var links = getNodeLinks(node);
60617
60638
  if (!links.resolvedType) {
60618
60639
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60619
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60640
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60620
60641
  }
60621
60642
  return links.resolvedType;
60622
60643
  }
@@ -60775,16 +60796,25 @@ var ts;
60775
60796
  types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
60776
60797
  return true;
60777
60798
  }
60778
- function createIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60799
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60779
60800
  var result = createType(2097152 /* Intersection */);
60780
60801
  result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
60781
60802
  result.types = types;
60782
60803
  result.aliasSymbol = aliasSymbol;
60783
60804
  result.aliasTypeArguments = aliasTypeArguments;
60784
- result.aliasMapper = aliasMapper;
60785
60805
  return result;
60786
60806
  }
60787
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60807
+ // We normalize combinations of intersection and union types based on the distributive property of the '&'
60808
+ // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
60809
+ // types with union type constituents into equivalent union types with intersection type constituents and
60810
+ // effectively ensure that union types are always at the top level in type representations.
60811
+ //
60812
+ // We do not perform structural deduplication on intersection types. Intersection types are created only by the &
60813
+ // type operator and we can't reduce those because we want to support recursive intersection types. For example,
60814
+ // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
60815
+ // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
60816
+ // for intersections of types with signatures can be deterministic.
60817
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60788
60818
  var typeMembershipMap = new ts.Map();
60789
60819
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
60790
60820
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -60844,16 +60874,16 @@ var ts;
60844
60874
  // When the intersection creates a reduced set (which might mean that *all* union types have
60845
60875
  // disappeared), we restart the operation to get a new set of combined flags. Once we have
60846
60876
  // reduced we'll never reduce again, so this occurs at most once.
60847
- result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments, aliasMapper);
60877
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
60848
60878
  }
60849
60879
  else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
60850
60880
  var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
60851
60881
  removeFromEach(typeSet, 32768 /* Undefined */);
60852
- result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60882
+ result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60853
60883
  }
60854
60884
  else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
60855
60885
  removeFromEach(typeSet, 65536 /* Null */);
60856
- result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60886
+ result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60857
60887
  }
60858
60888
  else {
60859
60889
  // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
@@ -60866,7 +60896,7 @@ var ts;
60866
60896
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
60867
60897
  // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
60868
60898
  var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
60869
- result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60899
+ result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
60870
60900
  }
60871
60901
  }
60872
60902
  else {
@@ -60912,7 +60942,7 @@ var ts;
60912
60942
  var links = getNodeLinks(node);
60913
60943
  if (!links.resolvedType) {
60914
60944
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60915
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60945
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60916
60946
  }
60917
60947
  return links.resolvedType;
60918
60948
  }
@@ -61031,7 +61061,7 @@ var ts;
61031
61061
  var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
61032
61062
  info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
61033
61063
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
61034
- /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, origin);
61064
+ /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
61035
61065
  }
61036
61066
  /**
61037
61067
  * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
@@ -61064,7 +61094,7 @@ var ts;
61064
61094
  return type;
61065
61095
  }
61066
61096
  var extractTypeAlias = getGlobalExtractSymbol();
61067
- return extractTypeAlias ? getGlobalTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61097
+ return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61068
61098
  }
61069
61099
  function getIndexTypeOrString(type) {
61070
61100
  var indexType = getExtractStringType(getIndexType(type));
@@ -61194,14 +61224,13 @@ var ts;
61194
61224
  result.type = type;
61195
61225
  return result;
61196
61226
  }
61197
- function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments, aliasMapper) {
61227
+ function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
61198
61228
  var type = createType(8388608 /* IndexedAccess */);
61199
61229
  type.objectType = objectType;
61200
61230
  type.indexType = indexType;
61201
61231
  type.accessFlags = accessFlags;
61202
61232
  type.aliasSymbol = aliasSymbol;
61203
61233
  type.aliasTypeArguments = aliasTypeArguments;
61204
- type.aliasMapper = aliasMapper;
61205
61234
  return type;
61206
61235
  }
61207
61236
  /**
@@ -61559,9 +61588,9 @@ var ts;
61559
61588
  var templateMapper = combineTypeMappers(objectType.mapper, mapper);
61560
61589
  return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
61561
61590
  }
61562
- function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61591
+ function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61563
61592
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61564
- return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) || (accessNode ? errorType : unknownType);
61593
+ return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
61565
61594
  }
61566
61595
  function indexTypeLessThan(indexType, limit) {
61567
61596
  return everyType(indexType, function (t) {
@@ -61575,7 +61604,7 @@ var ts;
61575
61604
  return false;
61576
61605
  });
61577
61606
  }
61578
- function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61607
+ function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61579
61608
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61580
61609
  if (objectType === wildcardType || indexType === wildcardType) {
61581
61610
  return wildcardType;
@@ -61606,7 +61635,7 @@ var ts;
61606
61635
  var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
61607
61636
  var type = indexedAccessTypes.get(id);
61608
61637
  if (!type) {
61609
- indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments, aliasMapper));
61638
+ indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
61610
61639
  }
61611
61640
  return type;
61612
61641
  }
@@ -61636,8 +61665,8 @@ var ts;
61636
61665
  return undefined;
61637
61666
  }
61638
61667
  return accessFlags & 4 /* Writing */
61639
- ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments, aliasMapper)
61640
- : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
61668
+ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
61669
+ : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
61641
61670
  }
61642
61671
  return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
61643
61672
  }
@@ -61647,7 +61676,7 @@ var ts;
61647
61676
  var objectType = getTypeFromTypeNode(node.objectType);
61648
61677
  var indexType = getTypeFromTypeNode(node.indexType);
61649
61678
  var potentialAlias = getAliasSymbolForTypeNode(node);
61650
- var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias), /*aliasMapper*/ undefined);
61679
+ var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
61651
61680
  links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
61652
61681
  resolved.objectType === objectType &&
61653
61682
  resolved.indexType === indexType ?
@@ -61814,7 +61843,6 @@ var ts;
61814
61843
  result.combinedMapper = combinedMapper;
61815
61844
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61816
61845
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61817
- result.aliasMapper = result.aliasSymbol ? mapper : undefined;
61818
61846
  return "break";
61819
61847
  };
61820
61848
  // We loop here for an immediately nested conditional type in the false position, effectively treating
@@ -62610,7 +62638,7 @@ var ts;
62610
62638
  var result = target.instantiations.get(id);
62611
62639
  if (!result) {
62612
62640
  var newMapper = createTypeMapper(typeParameters, typeArguments);
62613
- result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments, mapper) :
62641
+ result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
62614
62642
  target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
62615
62643
  instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62616
62644
  target.instantiations.set(id, result);
@@ -62699,7 +62727,7 @@ var ts;
62699
62727
  return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62700
62728
  }
62701
62729
  return t;
62702
- }, aliasSymbol, aliasTypeArguments, mapper);
62730
+ }, aliasSymbol, aliasTypeArguments);
62703
62731
  }
62704
62732
  }
62705
62733
  // If the constraint type of the instantiation is the wildcard type, return the wildcard type.
@@ -62768,7 +62796,6 @@ var ts;
62768
62796
  result.mapper = mapper;
62769
62797
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
62770
62798
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62771
- result.aliasMapper = mapper;
62772
62799
  return result;
62773
62800
  }
62774
62801
  function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
@@ -62788,7 +62815,7 @@ var ts;
62788
62815
  // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
62789
62816
  // result is (A extends U ? X : Y) | (B extends U ? X : Y).
62790
62817
  result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
62791
- mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments, mapper) :
62818
+ mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
62792
62819
  getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
62793
62820
  root.instantiations.set(id, result);
62794
62821
  }
@@ -62848,8 +62875,8 @@ var ts;
62848
62875
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62849
62876
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62850
62877
  return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
62851
- getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments, mapper) :
62852
- getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments, mapper);
62878
+ getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
62879
+ getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
62853
62880
  }
62854
62881
  if (flags & 4194304 /* Index */) {
62855
62882
  return getIndexType(instantiateType(type.type, mapper));
@@ -62863,7 +62890,7 @@ var ts;
62863
62890
  if (flags & 8388608 /* IndexedAccess */) {
62864
62891
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62865
62892
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62866
- return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments, mapper);
62893
+ return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
62867
62894
  }
62868
62895
  if (flags & 16777216 /* Conditional */) {
62869
62896
  return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
@@ -64857,10 +64884,7 @@ var ts;
64857
64884
  if (variances === ts.emptyArray) {
64858
64885
  return 1 /* Unknown */;
64859
64886
  }
64860
- var outerTypeParameters = getOuterTypeParametersOfAlias(source.aliasSymbol);
64861
- var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
64862
- var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
64863
- var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
64887
+ var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
64864
64888
  if (varianceResult !== undefined) {
64865
64889
  return varianceResult;
64866
64890
  }
@@ -66149,11 +66173,8 @@ var ts;
66149
66173
  }
66150
66174
  function getAliasVariances(symbol) {
66151
66175
  var links = getSymbolLinks(symbol);
66152
- // outer type parameter aliases are last so they can be easily ignored by, eg, inference
66153
- var params = ts.concatenate(links.typeParameters, getOuterTypeParametersOfAlias(symbol));
66154
- return getVariancesWorker(params, links, function (_links, param, marker) {
66155
- var mapper = makeUnaryTypeMapper(param, marker);
66156
- var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
66176
+ return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
66177
+ var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
66157
66178
  type.aliasTypeArgumentsContainsMarker = true;
66158
66179
  return type;
66159
66180
  });
@@ -66810,7 +66831,7 @@ var ts;
66810
66831
  }
66811
66832
  // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
66812
66833
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
66813
- getGlobalTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66834
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66814
66835
  reducedType;
66815
66836
  }
66816
66837
  function getNonNullableType(type) {
@@ -69036,7 +69057,7 @@ var ts;
69036
69057
  newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
69037
69058
  }
69038
69059
  }
69039
- return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, newOrigin);
69060
+ return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
69040
69061
  }
69041
69062
  return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
69042
69063
  }
@@ -69072,9 +69093,9 @@ var ts;
69072
69093
  }
69073
69094
  return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
69074
69095
  }
69075
- function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
69096
+ function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
69076
69097
  return type.flags & 1048576 /* Union */ && aliasSymbol ?
69077
- getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper) :
69098
+ getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
69078
69099
  mapType(type, mapper);
69079
69100
  }
69080
69101
  function extractTypesOfKind(type, kind) {
@@ -72259,7 +72280,7 @@ var ts;
72259
72280
  var params = getSymbolLinks(managedSym).typeParameters;
72260
72281
  if (ts.length(params) >= 2) {
72261
72282
  var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
72262
- return getGlobalTypeAliasInstantiation(managedSym, args);
72283
+ return getTypeAliasInstantiation(managedSym, args);
72263
72284
  }
72264
72285
  }
72265
72286
  if (ts.length(declaredManagedType.typeParameters) >= 2) {
@@ -80403,7 +80424,7 @@ var ts;
80403
80424
  if (awaitedSymbol) {
80404
80425
  // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
80405
80426
  // an `Awaited<T | U>` would suffice.
80406
- return getGlobalTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80427
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80407
80428
  }
80408
80429
  }
80409
80430
  }
@@ -127037,6 +127058,20 @@ var ts;
127037
127058
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
127038
127059
  }
127039
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;
127040
127075
  function getScriptKind(fileName, host) {
127041
127076
  // First check to see if the script kind was specified by the host. Chances are the host
127042
127077
  // may override the default script kind for the file extension.
@@ -130330,14 +130365,15 @@ var ts;
130330
130365
  SortText["SuggestedClassMembers"] = "14";
130331
130366
  SortText["GlobalsOrKeywords"] = "15";
130332
130367
  SortText["AutoImportSuggestions"] = "16";
130333
- SortText["JavascriptIdentifiers"] = "17";
130334
- SortText["DeprecatedLocalDeclarationPriority"] = "18";
130335
- SortText["DeprecatedLocationPriority"] = "19";
130336
- SortText["DeprecatedOptionalMember"] = "20";
130337
- SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21";
130338
- SortText["DeprecatedSuggestedClassMembers"] = "22";
130339
- SortText["DeprecatedGlobalsOrKeywords"] = "23";
130340
- 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";
130341
130377
  })(SortText = Completions.SortText || (Completions.SortText = {}));
130342
130378
  var SortTextId;
130343
130379
  (function (SortTextId) {
@@ -130349,10 +130385,10 @@ var ts;
130349
130385
  SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
130350
130386
  SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
130351
130387
  // Don't use these directly.
130352
- SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers";
130353
- SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart";
130388
+ SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
130389
+ SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
130354
130390
  SortTextId[SortTextId["_First"] = 10] = "_First";
130355
- SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset";
130391
+ SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
130356
130392
  })(SortTextId || (SortTextId = {}));
130357
130393
  /**
130358
130394
  * Special values for `CompletionInfo['source']` used to disambiguate
@@ -130833,6 +130869,7 @@ var ts;
130833
130869
  isClassLikeMemberCompletion(symbol, location)) {
130834
130870
  var importAdder = void 0;
130835
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.
130836
130873
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
130837
130874
  hasAction = true;
130838
130875
  source = CompletionSource.ClassMemberSnippet;
@@ -131196,7 +131233,7 @@ var ts;
131196
131233
  }
131197
131234
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
131198
131235
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
131199
- var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131236
+ var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131200
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);
131201
131238
  if (!entry) {
131202
131239
  continue;
@@ -136051,6 +136088,29 @@ var ts;
136051
136088
  }
136052
136089
  }
136053
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;
136054
136114
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
136055
136115
  if (!signature.name || !ts.isIdentifier(signature.name))
136056
136116
  return false;
@@ -137683,7 +137743,9 @@ var ts;
137683
137743
  (function (ts) {
137684
137744
  var GoToDefinition;
137685
137745
  (function (GoToDefinition) {
137686
- function getDefinitionAtPosition(program, sourceFile, position) {
137746
+ function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
137747
+ var _a;
137748
+ var _b;
137687
137749
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
137688
137750
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
137689
137751
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -137706,33 +137768,63 @@ var ts;
137706
137768
  }
137707
137769
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
137708
137770
  var classDecl = node.parent.parent;
137709
- var symbol_1 = getSymbol(classDecl, typeChecker);
137771
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
137710
137772
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
137711
137773
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
137712
137774
  var sourceFile_1 = node.getSourceFile();
137713
137775
  return ts.map(staticBlocks, function (staticBlock) {
137714
137776
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
137715
137777
  pos = ts.skipTrivia(sourceFile_1.text, pos);
137716
- 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 });
137717
137779
  });
137718
137780
  }
137719
- 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
+ }
137720
137810
  // Could not find a symbol e.g. node is string or number keyword,
137721
137811
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
137722
137812
  if (!symbol) {
137723
137813
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
137724
137814
  }
137815
+ if (aliasesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
137816
+ return undefined;
137725
137817
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
137726
137818
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
137727
137819
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
137728
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
137820
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
137729
137821
  // For a function, if this is the original function definition, return just sigInfo.
137730
137822
  // If this is the original constructor definition, parent is the class.
137731
137823
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
137732
137824
  return [sigInfo];
137733
137825
  }
137734
137826
  else {
137735
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
137827
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
137736
137828
  // For a 'super()' call, put the signature first, else put the variable first.
137737
137829
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
137738
137830
  }
@@ -137744,7 +137836,7 @@ var ts;
137744
137836
  // assignment. This case and others are handled by the following code.
137745
137837
  if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
137746
137838
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
137747
- 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;
137748
137840
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
137749
137841
  }
137750
137842
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -137767,7 +137859,7 @@ var ts;
137767
137859
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
137768
137860
  });
137769
137861
  }
137770
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
137862
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
137771
137863
  }
137772
137864
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
137773
137865
  /**
@@ -137865,24 +137957,24 @@ var ts;
137865
137957
  return undefined;
137866
137958
  }
137867
137959
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
137868
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
137960
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
137869
137961
  }
137870
- var symbol = getSymbol(node, typeChecker);
137962
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
137871
137963
  if (!symbol)
137872
137964
  return undefined;
137873
137965
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
137874
137966
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
137875
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
137967
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
137876
137968
  // If a function returns 'void' or some other type with no definition, just return the function definition.
137877
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
137969
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
137878
137970
  return typeDefinitions.length ? typeDefinitions
137879
- : !(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)
137880
137972
  : undefined;
137881
137973
  }
137882
137974
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
137883
- function definitionFromType(type, checker, node) {
137975
+ function definitionFromType(type, checker, node, failedAliasResolution) {
137884
137976
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
137885
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
137977
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
137886
137978
  });
137887
137979
  }
137888
137980
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -137897,8 +137989,8 @@ var ts;
137897
137989
  }
137898
137990
  return undefined;
137899
137991
  }
137900
- function getDefinitionAndBoundSpan(program, sourceFile, position) {
137901
- var definitions = getDefinitionAtPosition(program, sourceFile, position);
137992
+ function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
137993
+ var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
137902
137994
  if (!definitions || definitions.length === 0) {
137903
137995
  return undefined;
137904
137996
  }
@@ -137924,13 +138016,17 @@ var ts;
137924
138016
  // get the aliased symbol instead. This allows for goto def on an import e.g.
137925
138017
  // import {A, B} from "mod";
137926
138018
  // to jump to the implementation directly.
138019
+ var failedAliasResolution = false;
137927
138020
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
137928
138021
  var aliased = checker.getAliasedSymbol(symbol);
137929
138022
  if (aliased.declarations) {
137930
- return aliased;
138023
+ return { symbol: aliased };
138024
+ }
138025
+ else {
138026
+ failedAliasResolution = true;
137931
138027
  }
137932
138028
  }
137933
- return symbol;
138029
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
137934
138030
  }
137935
138031
  // Go to the original declaration for cases:
137936
138032
  //
@@ -137944,26 +138040,45 @@ var ts;
137944
138040
  if (node.parent === declaration) {
137945
138041
  return true;
137946
138042
  }
137947
- switch (declaration.kind) {
137948
- case 266 /* ImportClause */:
137949
- case 264 /* ImportEqualsDeclaration */:
137950
- return true;
137951
- case 269 /* ImportSpecifier */:
137952
- return declaration.parent.kind === 268 /* NamedImports */;
137953
- case 202 /* BindingElement */:
137954
- case 253 /* VariableDeclaration */:
137955
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
137956
- default:
137957
- return false;
138043
+ if (declaration.kind === 267 /* NamespaceImport */) {
138044
+ return false;
137958
138045
  }
138046
+ return true;
137959
138047
  }
137960
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
137961
- // There are cases when you extend a function by adding properties to it afterwards,
137962
- // we want to strip those extra properties.
137963
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
137964
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
137965
- || undefined;
137966
- 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); });
137967
138082
  function getConstructSignatureDefinition() {
137968
138083
  // Applicable only if we are in a new expression, or we are on a constructor declaration
137969
138084
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -137987,26 +138102,27 @@ var ts;
137987
138102
  return declarations.length
137988
138103
  ? declarationsWithBody.length !== 0
137989
138104
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
137990
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
138105
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, failedAliasResolution)]
137991
138106
  : undefined;
137992
138107
  }
137993
138108
  }
137994
138109
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
137995
- function createDefinitionInfo(declaration, checker, symbol, node) {
138110
+ function createDefinitionInfo(declaration, checker, symbol, node, failedAliasResolution) {
137996
138111
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
137997
138112
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
137998
138113
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
137999
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
138114
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution);
138000
138115
  }
138116
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
138001
138117
  /** Creates a DefinitionInfo directly from the name of a declaration. */
138002
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
138118
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution, textSpan) {
138003
138119
  var sourceFile = declaration.getSourceFile();
138004
138120
  if (!textSpan) {
138005
138121
  var name = ts.getNameOfDeclaration(declaration) || declaration;
138006
138122
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
138007
138123
  }
138008
138124
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
138009
- 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 });
138010
138126
  }
138011
138127
  function isDefinitionVisible(checker, declaration) {
138012
138128
  if (checker.isDeclarationVisible(declaration))
@@ -138039,8 +138155,8 @@ var ts;
138039
138155
  return false;
138040
138156
  }
138041
138157
  }
138042
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
138043
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
138158
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
138159
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, failedAliasResolution);
138044
138160
  }
138045
138161
  function findReferenceInPosition(refs, pos) {
138046
138162
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -151088,9 +151204,10 @@ var ts;
151088
151204
  // 2. add "member3" to the second import statement's import list
151089
151205
  // and it is up to the user to decide which one fits best.
151090
151206
  return ts.firstDefined(existingImports, function (_a) {
151207
+ var _b;
151091
151208
  var declaration = _a.declaration;
151092
151209
  var namespacePrefix = getNamespaceLikeImportText(declaration);
151093
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151210
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151094
151211
  if (namespacePrefix && moduleSpecifier) {
151095
151212
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
151096
151213
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -151266,8 +151383,9 @@ var ts;
151266
151383
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
151267
151384
  }
151268
151385
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
151386
+ var _b;
151269
151387
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
151270
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
151388
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151271
151389
  if (moduleSpecifier) {
151272
151390
  var addAsTypeOnly = useRequire
151273
151391
  ? 4 /* NotAllowed */
@@ -163076,9 +163194,9 @@ var ts;
163076
163194
  synchronizeHostData();
163077
163195
  return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
163078
163196
  }
163079
- function getDefinitionAndBoundSpan(fileName, position) {
163197
+ function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
163080
163198
  synchronizeHostData();
163081
- return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
163199
+ return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
163082
163200
  }
163083
163201
  function getTypeDefinitionAtPosition(fileName, position) {
163084
163202
  synchronizeHostData();
@@ -166247,6 +166365,9 @@ var ts;
166247
166365
  CommandTypes["SignatureHelp"] = "signatureHelp";
166248
166366
  /* @internal */
166249
166367
  CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
166368
+ CommandTypes["SourceDefinitionAndBoundSpan"] = "sourceDefinitionAndBoundSpan";
166369
+ /* @internal */
166370
+ CommandTypes["SourceDefinitionAndBoundSpanFull"] = "sourceDefinitionAndBoundSpan-full";
166250
166371
  CommandTypes["Status"] = "status";
166251
166372
  CommandTypes["TypeDefinition"] = "typeDefinition";
166252
166373
  CommandTypes["ProjectInfo"] = "projectInfo";
@@ -167116,6 +167237,7 @@ var ts;
167116
167237
  ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
167117
167238
  ProjectKind[ProjectKind["External"] = 2] = "External";
167118
167239
  ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
167240
+ ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
167119
167241
  })(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
167120
167242
  /* @internal */
167121
167243
  function countEachFileTypes(infos, includeSizes) {
@@ -168561,6 +168683,17 @@ var ts;
168561
168683
  Project.prototype.getIncompleteCompletionsCache = function () {
168562
168684
  return this.projectService.getIncompleteCompletionsCache();
168563
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
+ };
168564
168697
  return Project;
168565
168698
  }());
168566
168699
  server.Project = Project;
@@ -168672,6 +168805,22 @@ var ts;
168672
168805
  return InferredProject;
168673
168806
  }(Project));
168674
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;
168675
168824
  var AutoImportProviderProject = /** @class */ (function (_super) {
168676
168825
  __extends(AutoImportProviderProject, _super);
168677
168826
  /*@internal*/
@@ -170560,8 +170709,8 @@ var ts;
170560
170709
  this.projectToSizeMap.set(name, 0);
170561
170710
  this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); });
170562
170711
  var totalNonTsFileSize = 0;
170563
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
170564
- var f = fileNames_1[_i];
170712
+ for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
170713
+ var f = fileNames_2[_i];
170565
170714
  var fileName = propertyReader.getFileName(f);
170566
170715
  if (ts.hasTSFileExtension(fileName)) {
170567
170716
  continue;
@@ -173274,6 +173423,12 @@ var ts;
173274
173423
  _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
173275
173424
  return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
173276
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
+ // },
173277
173432
  _a[server.CommandNames.EmitOutput] = function (request) {
173278
173433
  return _this.requiredResponse(_this.getEmitOutput(request.arguments));
173279
173434
  },
@@ -174010,10 +174165,34 @@ var ts;
174010
174165
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
174011
174166
  return definitions.map(function (info) {
174012
174167
  var newDocumentSpan = getMappedDocumentSpan(info, project);
174013
- 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 });
174014
174169
  });
174015
174170
  };
174016
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 {
174017
174196
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
174018
174197
  var position = this.getPositionInFile(args, file);
174019
174198
  var scriptInfo = ts.Debug.checkDefined(project.getScriptInfo(file));
@@ -174024,7 +174203,31 @@ var ts;
174024
174203
  textSpan: undefined // TODO: GH#18217
174025
174204
  };
174026
174205
  }
174027
- 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; });
174028
174231
  var textSpan = unmappedDefinitionAndBoundSpan.textSpan;
174029
174232
  if (simplifiedResult) {
174030
174233
  return {
@@ -174036,6 +174239,32 @@ var ts;
174036
174239
  definitions: definitions.map(Session.mapToOriginalLocation),
174037
174240
  textSpan: textSpan,
174038
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
+ }
174039
174268
  };
174040
174269
  Session.prototype.getEmitOutput = function (args) {
174041
174270
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;