typescript 4.6.0-dev.20220111 → 4.6.0-dev.20220112

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-dev.20220111";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220112";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -19791,16 +19791,6 @@ var ts;
19791
19791
  (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
19792
19792
  }
19793
19793
  },
19794
- setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
19795
- this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
19796
- var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
19797
- if (commonResolved && commonOriginal) {
19798
- this.setSymlinkedDirectory(commonOriginal, {
19799
- real: commonResolved,
19800
- realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
19801
- });
19802
- }
19803
- },
19804
19794
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
19805
19795
  var _this = this;
19806
19796
  var _a;
@@ -41509,9 +41499,7 @@ var ts;
41509
41499
  }
41510
41500
  }
41511
41501
  var failedLookupLocations = [];
41512
- var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41513
- ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41514
- NodeResolutionFeatures.None;
41502
+ var features = getDefaultNodeResolutionFeatures(options);
41515
41503
  var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41516
41504
  var resolved = primaryLookup();
41517
41505
  var primary = true;
@@ -41596,6 +41584,34 @@ var ts;
41596
41584
  }
41597
41585
  }
41598
41586
  ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
41587
+ function getDefaultNodeResolutionFeatures(options) {
41588
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41589
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41590
+ NodeResolutionFeatures.None;
41591
+ }
41592
+ /**
41593
+ * @internal
41594
+ * Does not try `@types/${packageName}` - use a second pass if needed.
41595
+ */
41596
+ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
41597
+ var moduleResolutionState = {
41598
+ compilerOptions: options,
41599
+ host: host,
41600
+ traceEnabled: isTraceEnabled(options, host),
41601
+ failedLookupLocations: [],
41602
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
41603
+ conditions: ts.emptyArray,
41604
+ features: NodeResolutionFeatures.None,
41605
+ };
41606
+ return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
41607
+ if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
41608
+ var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
41609
+ var candidate = ts.combinePaths(nodeModulesFolder, packageName);
41610
+ return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
41611
+ }
41612
+ });
41613
+ }
41614
+ ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
41599
41615
  /**
41600
41616
  * Given a set of options, returns the set of type directive names
41601
41617
  * that should be included for this program automatically.
@@ -42169,11 +42185,6 @@ var ts;
42169
42185
  }
42170
42186
  ts.resolveJSModule = resolveJSModule;
42171
42187
  /* @internal */
42172
- function tryResolveJSModule(moduleName, initialDir, host) {
42173
- return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
42174
- }
42175
- ts.tryResolveJSModule = tryResolveJSModule;
42176
- /* @internal */
42177
42188
  var NodeResolutionFeatures;
42178
42189
  (function (NodeResolutionFeatures) {
42179
42190
  NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
@@ -42481,6 +42492,97 @@ var ts;
42481
42492
  var versionPaths = packageInfo && packageInfo.versionPaths;
42482
42493
  return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
42483
42494
  }
42495
+ /* @internal */
42496
+ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
42497
+ if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
42498
+ // Cached value excludes resolutions to JS files - those could be
42499
+ // cached separately, but they're used rarely.
42500
+ return packageJsonInfo.resolvedEntrypoints;
42501
+ }
42502
+ var entrypoints;
42503
+ var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
42504
+ var features = getDefaultNodeResolutionFeatures(options);
42505
+ var requireState = {
42506
+ compilerOptions: options,
42507
+ host: host,
42508
+ traceEnabled: isTraceEnabled(options, host),
42509
+ failedLookupLocations: [],
42510
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42511
+ conditions: ["node", "require", "types"],
42512
+ features: features,
42513
+ };
42514
+ var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
42515
+ /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
42516
+ entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
42517
+ if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
42518
+ for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
42519
+ var conditions = _a[_i];
42520
+ var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
42521
+ var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
42522
+ if (exportResolutions) {
42523
+ for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
42524
+ var resolution = exportResolutions_1[_b];
42525
+ entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
42526
+ }
42527
+ }
42528
+ }
42529
+ }
42530
+ return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
42531
+ }
42532
+ ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
42533
+ function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
42534
+ var entrypoints;
42535
+ if (ts.isArray(exports)) {
42536
+ for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
42537
+ var target = exports_1[_i];
42538
+ loadEntrypointsFromTargetExports(target);
42539
+ }
42540
+ }
42541
+ // eslint-disable-next-line no-null/no-null
42542
+ else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
42543
+ for (var key in exports) {
42544
+ loadEntrypointsFromTargetExports(exports[key]);
42545
+ }
42546
+ }
42547
+ else {
42548
+ loadEntrypointsFromTargetExports(exports);
42549
+ }
42550
+ return entrypoints;
42551
+ function loadEntrypointsFromTargetExports(target) {
42552
+ var _a, _b;
42553
+ if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
42554
+ var partsAfterFirst = ts.getPathComponents(target).slice(2);
42555
+ if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
42556
+ return false;
42557
+ }
42558
+ var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
42559
+ var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
42560
+ var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
42561
+ if (result) {
42562
+ entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
42563
+ return true;
42564
+ }
42565
+ }
42566
+ else if (Array.isArray(target)) {
42567
+ for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
42568
+ var t = target_1[_i];
42569
+ var success = loadEntrypointsFromTargetExports(t);
42570
+ if (success) {
42571
+ return true;
42572
+ }
42573
+ }
42574
+ }
42575
+ // eslint-disable-next-line no-null/no-null
42576
+ else if (typeof target === "object" && target !== null) {
42577
+ return ts.forEach(ts.getOwnKeys(target), function (key) {
42578
+ if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
42579
+ loadEntrypointsFromTargetExports(target[key]);
42580
+ return true;
42581
+ }
42582
+ });
42583
+ }
42584
+ }
42585
+ }
42484
42586
  /**
42485
42587
  * A function for locating the package.json scope for a given path
42486
42588
  */
@@ -42537,7 +42639,7 @@ var ts;
42537
42639
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
42538
42640
  }
42539
42641
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
42540
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
42642
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
42541
42643
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
42542
42644
  return result;
42543
42645
  }
@@ -42834,8 +42936,8 @@ var ts;
42834
42936
  }
42835
42937
  return toSearchResult(/*value*/ undefined);
42836
42938
  }
42837
- for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
42838
- var elem = target_1[_d];
42939
+ for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
42940
+ var elem = target_2[_d];
42839
42941
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
42840
42942
  if (result) {
42841
42943
  return result;
@@ -52068,8 +52170,8 @@ var ts;
52068
52170
  }
52069
52171
  else {
52070
52172
  if (parent && getExportsOfSymbol(parent)) {
52071
- var exports_1 = getExportsOfSymbol(parent);
52072
- ts.forEachEntry(exports_1, function (ex, name) {
52173
+ var exports_2 = getExportsOfSymbol(parent);
52174
+ ts.forEachEntry(exports_2, function (ex, name) {
52073
52175
  if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
52074
52176
  symbolName = ts.unescapeLeadingUnderscores(name);
52075
52177
  return true;
@@ -57180,6 +57282,11 @@ var ts;
57180
57282
  return simplified !== type ? simplified : getConstraintOfType(type);
57181
57283
  }
57182
57284
  function getConstraintFromIndexedAccess(type) {
57285
+ if (isMappedTypeGenericIndexedAccess(type)) {
57286
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57287
+ // we substitute an instantiation of E where P is replaced with X.
57288
+ return substituteIndexedMappedType(type.objectType, type.indexType);
57289
+ }
57183
57290
  var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
57184
57291
  if (indexConstraint && indexConstraint !== type.indexType) {
57185
57292
  var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
@@ -57384,6 +57491,11 @@ var ts;
57384
57491
  return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
57385
57492
  }
57386
57493
  if (t.flags & 8388608 /* IndexedAccess */) {
57494
+ if (isMappedTypeGenericIndexedAccess(t)) {
57495
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57496
+ // we substitute an instantiation of E where P is replaced with X.
57497
+ return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
57498
+ }
57387
57499
  var baseObjectType = getBaseConstraint(t.objectType);
57388
57500
  var baseIndexType = getBaseConstraint(t.indexType);
57389
57501
  var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
@@ -57468,13 +57580,7 @@ var ts;
57468
57580
  * type itself.
57469
57581
  */
57470
57582
  function getApparentType(type) {
57471
- // We obtain the base constraint for all instantiable types, except indexed access types of the form
57472
- // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57473
- // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57474
- // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57475
- var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57476
- isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57477
- getBaseConstraintOfType(type) || unknownType;
57583
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
57478
57584
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57479
57585
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57480
57586
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -64138,6 +64244,17 @@ var ts;
64138
64244
  resetErrorInfo(saveErrorInfo);
64139
64245
  return result;
64140
64246
  }
64247
+ if (isMappedTypeGenericIndexedAccess(source)) {
64248
+ // For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
64249
+ // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
64250
+ var indexConstraint = getConstraintOfType(source.indexType);
64251
+ if (indexConstraint) {
64252
+ if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
64253
+ resetErrorInfo(saveErrorInfo);
64254
+ return result;
64255
+ }
64256
+ }
64257
+ }
64141
64258
  }
64142
64259
  }
64143
64260
  else if (source.flags & 4194304 /* Index */) {
@@ -83256,9 +83373,9 @@ var ts;
83256
83373
  }
83257
83374
  }
83258
83375
  // Checks for export * conflicts
83259
- var exports_2 = getExportsOfModule(moduleSymbol);
83260
- if (exports_2) {
83261
- exports_2.forEach(function (_a, id) {
83376
+ var exports_3 = getExportsOfModule(moduleSymbol);
83377
+ if (exports_3) {
83378
+ exports_3.forEach(function (_a, id) {
83262
83379
  var declarations = _a.declarations, flags = _a.flags;
83263
83380
  if (id === "__export") {
83264
83381
  return;
@@ -92814,6 +92931,11 @@ var ts;
92814
92931
  ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
92815
92932
  ts.setCommentRange(statement, property);
92816
92933
  ts.setOriginalNode(statement, property);
92934
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
92935
+ // `statement` and `expression` have a copy of the synthesized comments.
92936
+ // Drop the comments from expression to avoid printing them twice.
92937
+ ts.setSyntheticLeadingComments(expression, undefined);
92938
+ ts.setSyntheticTrailingComments(expression, undefined);
92817
92939
  statements.push(statement);
92818
92940
  }
92819
92941
  }
@@ -119154,28 +119276,37 @@ var ts;
119154
119276
  useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
119155
119277
  };
119156
119278
  }
119157
- function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119158
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119279
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119280
+ // Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
119281
+ // while `importingSourceFileName` its *new* name. We need a source file just to get its
119282
+ // `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
119283
+ function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119284
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119159
119285
  if (res === oldImportSpecifier)
119160
119286
  return undefined;
119161
119287
  return res;
119162
119288
  }
119163
119289
  moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
119164
- // Note: importingSourceFile is just for usesJsExtensionOnImports
119290
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119291
+ // Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
119292
+ // file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
119293
+ // one currently being produced; the latter to the one being imported). We need an implementation file
119294
+ // just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
119295
+ // specifiers.
119165
119296
  function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
119166
- return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119297
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119167
119298
  }
119168
119299
  moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
119169
- function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
119170
- var info = getInfo(importingSourceFileName, host);
119171
- var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host, preferences);
119172
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
119300
+ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
119301
+ var info = getInfo(importingSourceFile.path, host);
119302
+ var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
119303
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
119173
119304
  }
119174
119305
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
119175
- function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119306
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119176
119307
  var info = getInfo(importingSourceFileName, host);
119177
119308
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
119178
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
119309
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
119179
119310
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
119180
119311
  }
119181
119312
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
@@ -119242,7 +119373,7 @@ var ts;
119242
119373
  var relativeSpecifiers;
119243
119374
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
119244
119375
  var modulePath = modulePaths_1[_i];
119245
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
119376
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
119246
119377
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
119247
119378
  if (specifier && modulePath.isRedirect) {
119248
119379
  // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -119634,7 +119765,7 @@ var ts;
119634
119765
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
119635
119766
  : ts.removeFileExtension(relativePath);
119636
119767
  }
119637
- function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
119768
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
119638
119769
  var path = _a.path, isRedirect = _a.isRedirect;
119639
119770
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
119640
119771
  if (!host.fileExists || !host.readFile) {
@@ -119697,11 +119828,19 @@ var ts;
119697
119828
  var moduleFileToTry = path;
119698
119829
  if (host.fileExists(packageJsonPath)) {
119699
119830
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119700
- // TODO: Inject `require` or `import` condition based on the intended import mode
119701
119831
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119702
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119832
+ // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
119833
+ // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
119834
+ // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
119835
+ // with, so for now we just stick with the mode of the file.
119836
+ var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
119837
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
119838
+ ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
119839
+ : undefined;
119703
119840
  if (fromExports) {
119704
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119841
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
119842
+ ? fromExports
119843
+ : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119705
119844
  return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119706
119845
  }
119707
119846
  if (packageJsonContent.exports) {
@@ -126020,7 +126159,7 @@ var ts;
126020
126159
  if (!ts.stringContains(importedFileName, "node_modules")) {
126021
126160
  return undefined;
126022
126161
  }
126023
- var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, preferences);
126162
+ var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
126024
126163
  if (!specifier) {
126025
126164
  return undefined;
126026
126165
  }
@@ -135666,7 +135805,7 @@ var ts;
135666
135805
  : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
135667
135806
  // Need an update if the imported file moved, or the importing file moved and was using a relative path.
135668
135807
  return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
135669
- ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
135808
+ ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
135670
135809
  : undefined;
135671
135810
  });
135672
135811
  };
@@ -137311,6 +137450,9 @@ var ts;
137311
137450
  // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
137312
137451
  // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
137313
137452
  function areSameModule(a, b) {
137453
+ if (!a.body || !b.body) {
137454
+ return a.body === b.body;
137455
+ }
137314
137456
  return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
137315
137457
  }
137316
137458
  /** Merge source into target. Source should be thrown away after this is called. */
@@ -154525,7 +154667,7 @@ var ts;
154525
154667
  defaultToNamedAction.kind,
154526
154668
  namedToDefaultAction.kind
154527
154669
  ],
154528
- getAvailableActions: function (context) {
154670
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
154529
154671
  var info = getInfo(context, context.triggerReason === "invoked");
154530
154672
  if (!info)
154531
154673
  return ts.emptyArray;
@@ -154543,7 +154685,7 @@ var ts;
154543
154685
  }
154544
154686
  return ts.emptyArray;
154545
154687
  },
154546
- getEditsForAction: function (context, actionName) {
154688
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
154547
154689
  ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
154548
154690
  var info = getInfo(context);
154549
154691
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -154771,7 +154913,7 @@ var ts;
154771
154913
  namespaceToNamedAction.kind,
154772
154914
  namedToNamespaceAction.kind
154773
154915
  ],
154774
- getAvailableActions: function (context) {
154916
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
154775
154917
  var info = getImportToConvert(context, context.triggerReason === "invoked");
154776
154918
  if (!info)
154777
154919
  return ts.emptyArray;
@@ -154790,7 +154932,7 @@ var ts;
154790
154932
  }
154791
154933
  return ts.emptyArray;
154792
154934
  },
154793
- getEditsForAction: function (context, actionName) {
154935
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
154794
154936
  ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
154795
154937
  var info = getImportToConvert(context);
154796
154938
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -154956,10 +155098,10 @@ var ts;
154956
155098
  };
154957
155099
  refactor.registerRefactor(refactorName, {
154958
155100
  kinds: [toOptionalChainAction.kind],
154959
- getAvailableActions: getAvailableActions,
154960
- getEditsForAction: getEditsForAction
155101
+ getEditsForAction: getRefactorEditsToConvertToOptionalChain,
155102
+ getAvailableActions: getRefactorActionsToConvertToOptionalChain,
154961
155103
  });
154962
- function getAvailableActions(context) {
155104
+ function getRefactorActionsToConvertToOptionalChain(context) {
154963
155105
  var info = getInfo(context, context.triggerReason === "invoked");
154964
155106
  if (!info)
154965
155107
  return ts.emptyArray;
@@ -154979,7 +155121,7 @@ var ts;
154979
155121
  }
154980
155122
  return ts.emptyArray;
154981
155123
  }
154982
- function getEditsForAction(context, actionName) {
155124
+ function getRefactorEditsToConvertToOptionalChain(context, actionName) {
154983
155125
  var info = getInfo(context);
154984
155126
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
154985
155127
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -155222,10 +155364,10 @@ var ts;
155222
155364
  };
155223
155365
  refactor.registerRefactor(refactorName, {
155224
155366
  kinds: [functionOverloadAction.kind],
155225
- getEditsForAction: getEditsForAction,
155226
- getAvailableActions: getAvailableActions
155367
+ getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
155368
+ getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
155227
155369
  });
155228
- function getAvailableActions(context) {
155370
+ function getRefactorActionsToConvertOverloadsToOneSignature(context) {
155229
155371
  var file = context.file, startPosition = context.startPosition, program = context.program;
155230
155372
  var info = getConvertableOverloadListAtPosition(file, startPosition, program);
155231
155373
  if (!info)
@@ -155236,7 +155378,7 @@ var ts;
155236
155378
  actions: [functionOverloadAction]
155237
155379
  }];
155238
155380
  }
155239
- function getEditsForAction(context) {
155381
+ function getRefactorEditsToConvertOverloadsToOneSignature(context) {
155240
155382
  var file = context.file, startPosition = context.startPosition, program = context.program;
155241
155383
  var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
155242
155384
  if (!signatureDecls)
@@ -155392,14 +155534,14 @@ var ts;
155392
155534
  extractConstantAction.kind,
155393
155535
  extractFunctionAction.kind
155394
155536
  ],
155395
- getAvailableActions: getAvailableActions,
155396
- getEditsForAction: getEditsForAction
155537
+ getEditsForAction: getRefactorEditsToExtractSymbol,
155538
+ getAvailableActions: getRefactorActionsToExtractSymbol,
155397
155539
  });
155398
155540
  /**
155399
155541
  * Compute the associated code actions
155400
155542
  * Exported for tests.
155401
155543
  */
155402
- function getAvailableActions(context) {
155544
+ function getRefactorActionsToExtractSymbol(context) {
155403
155545
  var requestedRefactor = context.kind;
155404
155546
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
155405
155547
  var targetRange = rangeToExtract.targetRange;
@@ -155528,9 +155670,9 @@ var ts;
155528
155670
  return error;
155529
155671
  }
155530
155672
  }
155531
- extractSymbol.getAvailableActions = getAvailableActions;
155673
+ extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
155532
155674
  /* Exported for tests */
155533
- function getEditsForAction(context, actionName) {
155675
+ function getRefactorEditsToExtractSymbol(context, actionName) {
155534
155676
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
155535
155677
  var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
155536
155678
  var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
@@ -155547,7 +155689,7 @@ var ts;
155547
155689
  }
155548
155690
  ts.Debug.fail("Unrecognized action name");
155549
155691
  }
155550
- extractSymbol.getEditsForAction = getEditsForAction;
155692
+ extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
155551
155693
  // Move these into diagnostic messages if they become user-facing
155552
155694
  var Messages;
155553
155695
  (function (Messages) {
@@ -157098,7 +157240,7 @@ var ts;
157098
157240
  extractToInterfaceAction.kind,
157099
157241
  extractToTypeDefAction.kind
157100
157242
  ],
157101
- getAvailableActions: function (context) {
157243
+ getAvailableActions: function getRefactorActionsToExtractType(context) {
157102
157244
  var info = getRangeToExtract(context, context.triggerReason === "invoked");
157103
157245
  if (!info)
157104
157246
  return ts.emptyArray;
@@ -157123,7 +157265,7 @@ var ts;
157123
157265
  }
157124
157266
  return ts.emptyArray;
157125
157267
  },
157126
- getEditsForAction: function (context, actionName) {
157268
+ getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
157127
157269
  var file = context.file;
157128
157270
  var info = getRangeToExtract(context);
157129
157271
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
@@ -157291,7 +157433,7 @@ var ts;
157291
157433
  };
157292
157434
  refactor.registerRefactor(actionName, {
157293
157435
  kinds: [generateGetSetAction.kind],
157294
- getEditsForAction: function (context, actionName) {
157436
+ getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
157295
157437
  if (!context.endPosition)
157296
157438
  return undefined;
157297
157439
  var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
@@ -157370,7 +157512,7 @@ var ts;
157370
157512
  };
157371
157513
  refactor.registerRefactor(refactorName, {
157372
157514
  kinds: [moveToNewFileAction.kind],
157373
- getAvailableActions: function (context) {
157515
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
157374
157516
  var statements = getStatementsToMove(context);
157375
157517
  if (context.preferences.allowTextChangesInNewFiles && statements) {
157376
157518
  return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
@@ -157381,7 +157523,7 @@ var ts;
157381
157523
  }
157382
157524
  return ts.emptyArray;
157383
157525
  },
157384
- getEditsForAction: function (context, actionName) {
157526
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
157385
157527
  ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
157386
157528
  var statements = ts.Debug.checkDefined(getStatementsToMove(context));
157387
157529
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
@@ -158112,10 +158254,10 @@ var ts;
158112
158254
  };
158113
158255
  refactor.registerRefactor(refactorName, {
158114
158256
  kinds: [removeBracesAction.kind],
158115
- getEditsForAction: getEditsForAction,
158116
- getAvailableActions: getAvailableActions
158257
+ getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
158258
+ getAvailableActions: getRefactorActionsToRemoveFunctionBraces
158117
158259
  });
158118
- function getAvailableActions(context) {
158260
+ function getRefactorActionsToRemoveFunctionBraces(context) {
158119
158261
  var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
158120
158262
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
158121
158263
  if (!info)
@@ -158141,7 +158283,7 @@ var ts;
158141
158283
  }
158142
158284
  return ts.emptyArray;
158143
158285
  }
158144
- function getEditsForAction(context, actionName) {
158286
+ function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
158145
158287
  var file = context.file, startPosition = context.startPosition;
158146
158288
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
158147
158289
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -158215,10 +158357,10 @@ var ts;
158215
158357
  };
158216
158358
  refactor.registerRefactor(refactorName, {
158217
158359
  kinds: [toDestructuredAction.kind],
158218
- getEditsForAction: getEditsForAction,
158219
- getAvailableActions: getAvailableActions
158360
+ getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
158361
+ getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
158220
158362
  });
158221
- function getAvailableActions(context) {
158363
+ function getRefactorActionsToConvertParametersToDestructuredObject(context) {
158222
158364
  var file = context.file, startPosition = context.startPosition;
158223
158365
  var isJSFile = ts.isSourceFileJS(file);
158224
158366
  if (isJSFile)
@@ -158232,7 +158374,7 @@ var ts;
158232
158374
  actions: [toDestructuredAction]
158233
158375
  }];
158234
158376
  }
158235
- function getEditsForAction(context, actionName) {
158377
+ function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
158236
158378
  ts.Debug.assert(actionName === refactorName, "Unexpected action name");
158237
158379
  var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
158238
158380
  var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
@@ -158742,10 +158884,10 @@ var ts;
158742
158884
  };
158743
158885
  refactor.registerRefactor(refactorName, {
158744
158886
  kinds: [convertStringAction.kind],
158745
- getEditsForAction: getEditsForAction,
158746
- getAvailableActions: getAvailableActions
158887
+ getEditsForAction: getRefactorEditsToConvertToTemplateString,
158888
+ getAvailableActions: getRefactorActionsToConvertToTemplateString
158747
158889
  });
158748
- function getAvailableActions(context) {
158890
+ function getRefactorActionsToConvertToTemplateString(context) {
158749
158891
  var file = context.file, startPosition = context.startPosition;
158750
158892
  var node = getNodeOrParentOfParentheses(file, startPosition);
158751
158893
  var maybeBinary = getParentBinaryExpression(node);
@@ -158771,7 +158913,7 @@ var ts;
158771
158913
  }
158772
158914
  return node;
158773
158915
  }
158774
- function getEditsForAction(context, actionName) {
158916
+ function getRefactorEditsToConvertToTemplateString(context, actionName) {
158775
158917
  var file = context.file, startPosition = context.startPosition;
158776
158918
  var node = getNodeOrParentOfParentheses(file, startPosition);
158777
158919
  switch (actionName) {
@@ -158985,10 +159127,10 @@ var ts;
158985
159127
  toNamedFunctionAction.kind,
158986
159128
  toArrowFunctionAction.kind
158987
159129
  ],
158988
- getEditsForAction: getEditsForAction,
158989
- getAvailableActions: getAvailableActions
159130
+ getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
159131
+ getAvailableActions: getRefactorActionsToConvertFunctionExpressions
158990
159132
  });
158991
- function getAvailableActions(context) {
159133
+ function getRefactorActionsToConvertFunctionExpressions(context) {
158992
159134
  var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
158993
159135
  var info = getFunctionInfo(file, startPosition, program);
158994
159136
  if (!info)
@@ -159032,7 +159174,7 @@ var ts;
159032
159174
  errors : possibleActions
159033
159175
  }];
159034
159176
  }
159035
- function getEditsForAction(context, actionName) {
159177
+ function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
159036
159178
  var file = context.file, startPosition = context.startPosition, program = context.program;
159037
159179
  var info = getFunctionInfo(file, startPosition, program);
159038
159180
  if (!info)
@@ -159192,10 +159334,10 @@ var ts;
159192
159334
  };
159193
159335
  refactor.registerRefactor(refactorName, {
159194
159336
  kinds: [inferReturnTypeAction.kind],
159195
- getEditsForAction: getEditsForAction,
159196
- getAvailableActions: getAvailableActions
159337
+ getEditsForAction: getRefactorEditsToInferReturnType,
159338
+ getAvailableActions: getRefactorActionsToInferReturnType
159197
159339
  });
159198
- function getEditsForAction(context) {
159340
+ function getRefactorEditsToInferReturnType(context) {
159199
159341
  var info = getInfo(context);
159200
159342
  if (info && !refactor.isRefactorErrorInfo(info)) {
159201
159343
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
@@ -159203,7 +159345,7 @@ var ts;
159203
159345
  }
159204
159346
  return undefined;
159205
159347
  }
159206
- function getAvailableActions(context) {
159348
+ function getRefactorActionsToInferReturnType(context) {
159207
159349
  var info = getInfo(context);
159208
159350
  if (!info)
159209
159351
  return ts.emptyArray;
@@ -166303,30 +166445,43 @@ var ts;
166303
166445
  (_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
166304
166446
  }
166305
166447
  if (dependencyNames) {
166306
- var resolutions = ts.mapDefined(ts.arrayFrom(dependencyNames.keys()), function (name) {
166307
- var types = ts.resolveTypeReferenceDirective(name, rootFileName, compilerOptions, moduleResolutionHost);
166308
- if (types.resolvedTypeReferenceDirective) {
166309
- return types.resolvedTypeReferenceDirective;
166310
- }
166311
- if (compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
166312
- return ts.tryResolveJSModule(name, hostProject.currentDirectory, moduleResolutionHost);
166313
- }
166314
- });
166448
+ var dependenciesAdded = 0;
166315
166449
  var symlinkCache = hostProject.getSymlinkCache();
166316
- for (var _c = 0, resolutions_1 = resolutions; _c < resolutions_1.length; _c++) {
166317
- var resolution = resolutions_1[_c];
166318
- if (!resolution.resolvedFileName)
166450
+ for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
166451
+ var name = _d[_c];
166452
+ // Avoid creating a large project that would significantly slow down time to editor interactivity
166453
+ if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
166454
+ hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
166455
+ return ts.emptyArray;
166456
+ }
166457
+ // 1. Try to load from the implementation package. For many dependencies, the
166458
+ // package.json will exist, but the package will not contain any typings,
166459
+ // so `entrypoints` will be undefined. In that case, or if the dependency
166460
+ // is missing altogether, we will move on to trying the @types package (2).
166461
+ var packageJson = ts.resolvePackageNameToPackageJson(name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
166462
+ if (packageJson) {
166463
+ var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache);
166464
+ if (entrypoints) {
166465
+ rootNames = ts.concatenate(rootNames, entrypoints);
166466
+ dependenciesAdded += entrypoints.length ? 1 : 0;
166467
+ continue;
166468
+ }
166469
+ }
166470
+ // 2. Try to load from the @types package.
166471
+ var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
166472
+ if (typesPackageJson) {
166473
+ var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache);
166474
+ rootNames = ts.concatenate(rootNames, entrypoints);
166475
+ dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
166319
166476
  continue;
166320
- var resolvedFileName = resolution.resolvedFileName, originalPath = resolution.originalPath;
166321
- if (originalPath) {
166322
- symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
166323
166477
  }
166324
- if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) {
166325
- rootNames = ts.append(rootNames, resolvedFileName);
166326
- // Avoid creating a large project that would significantly slow down time to editor interactivity
166327
- if (dependencySelection === 2 /* Auto */ && rootNames.length > this.maxDependencies) {
166328
- return ts.emptyArray;
166329
- }
166478
+ // 3. If the @types package did not exist and the user has settings that
166479
+ // allow processing JS from node_modules, go back to the implementation
166480
+ // package and load the JS.
166481
+ if (packageJson && compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
166482
+ var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache, /*allowJs*/ true);
166483
+ rootNames = ts.concatenate(rootNames, entrypoints);
166484
+ dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
166330
166485
  }
166331
166486
  }
166332
166487
  }
@@ -166336,6 +166491,26 @@ var ts;
166336
166491
  (dependencyNames || (dependencyNames = new ts.Set())).add(dependency);
166337
166492
  }
166338
166493
  }
166494
+ function getRootNamesFromPackageJson(packageJson, program, symlinkCache, resolveJs) {
166495
+ var _a;
166496
+ var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache(), resolveJs);
166497
+ if (entrypoints) {
166498
+ var real_1 = (_a = moduleResolutionHost.realpath) === null || _a === void 0 ? void 0 : _a.call(moduleResolutionHost, packageJson.packageDirectory);
166499
+ var isSymlink_1 = real_1 && real_1 !== packageJson.packageDirectory;
166500
+ if (isSymlink_1) {
166501
+ symlinkCache.setSymlinkedDirectory(packageJson.packageDirectory, {
166502
+ real: real_1,
166503
+ realPath: hostProject.toPath(real_1),
166504
+ });
166505
+ }
166506
+ return ts.mapDefined(entrypoints, function (entrypoint) {
166507
+ var resolvedFileName = isSymlink_1 ? entrypoint.replace(packageJson.packageDirectory, real_1) : entrypoint;
166508
+ if (!program.getSourceFile(resolvedFileName) && !(isSymlink_1 && program.getSourceFile(entrypoint))) {
166509
+ return resolvedFileName;
166510
+ }
166511
+ });
166512
+ }
166513
+ }
166339
166514
  };
166340
166515
  /*@internal*/
166341
166516
  AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) {