@typescript-deploys/pr-build 4.5.0-pr-46071-13 → 4.5.0-pr-46218-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20211001";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20211005";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -42477,9 +42477,11 @@ var ts;
42477
42477
  return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
42478
42478
  }
42479
42479
  ts.parsePackageName = parsePackageName;
42480
+ /* @internal */
42480
42481
  function allKeysStartWithDot(obj) {
42481
42482
  return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42482
42483
  }
42484
+ ts.allKeysStartWithDot = allKeysStartWithDot;
42483
42485
  function noKeyStartsWithDot(obj) {
42484
42486
  return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42485
42487
  }
@@ -42686,17 +42688,19 @@ var ts;
42686
42688
  }
42687
42689
  return toSearchResult(/*value*/ undefined);
42688
42690
  }
42689
- function isApplicableVersionedTypesKey(conditions, key) {
42690
- if (conditions.indexOf("types") === -1)
42691
- return false; // only apply versioned types conditions if the types condition is applied
42692
- if (!ts.startsWith(key, "types@"))
42693
- return false;
42694
- var range = ts.VersionRange.tryParse(key.substring("types@".length));
42695
- if (!range)
42696
- return false;
42697
- return range.test(ts.version);
42698
- }
42699
42691
  }
42692
+ /* @internal */
42693
+ function isApplicableVersionedTypesKey(conditions, key) {
42694
+ if (conditions.indexOf("types") === -1)
42695
+ return false; // only apply versioned types conditions if the types condition is applied
42696
+ if (!ts.startsWith(key, "types@"))
42697
+ return false;
42698
+ var range = ts.VersionRange.tryParse(key.substring("types@".length));
42699
+ if (!range)
42700
+ return false;
42701
+ return range.test(ts.version);
42702
+ }
42703
+ ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
42700
42704
  function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
42701
42705
  return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
42702
42706
  }
@@ -61448,7 +61452,8 @@ var ts;
61448
61452
  return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
61449
61453
  if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
61450
61454
  if (!type.declaration.nameType) {
61451
- if (isArrayType(t)) {
61455
+ var constraint = void 0;
61456
+ if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61452
61457
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
61453
61458
  }
61454
61459
  if (isGenericTupleType(t)) {
@@ -62840,10 +62845,6 @@ var ts;
62840
62845
  }
62841
62846
  }
62842
62847
  message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
62843
- var typeLengthLimit = 30;
62844
- if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
62845
- message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
62846
- }
62847
62848
  }
62848
62849
  }
62849
62850
  else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
@@ -62853,15 +62854,6 @@ var ts;
62853
62854
  }
62854
62855
  reportError(message, generalizedSourceType, targetType);
62855
62856
  }
62856
- /** Move a printed type to be on its own line if it is longer than 30 characters */
62857
- function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
62858
- var message = diagnostic.message;
62859
- if (source.length > typeLengthLimit)
62860
- message = message.replace(" '{0}' ", ":\n{0}\n\n");
62861
- if (target.length > typeLengthLimit)
62862
- message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
62863
- return __assign(__assign({}, diagnostic), { message: message });
62864
- }
62865
62857
  function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
62866
62858
  var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
62867
62859
  var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
@@ -118952,6 +118944,78 @@ var ts;
118952
118944
  }
118953
118945
  }
118954
118946
  }
118947
+ var MatchingMode;
118948
+ (function (MatchingMode) {
118949
+ MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
118950
+ MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
118951
+ MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
118952
+ })(MatchingMode || (MatchingMode = {}));
118953
+ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
118954
+ if (mode === void 0) { mode = 0 /* Exact */; }
118955
+ if (typeof exports === "string") {
118956
+ var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
118957
+ var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
118958
+ switch (mode) {
118959
+ case 0 /* Exact */:
118960
+ if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
118961
+ return { moduleFileToTry: packageName };
118962
+ }
118963
+ break;
118964
+ case 1 /* Directory */:
118965
+ if (ts.containsPath(pathOrPattern, targetFilePath)) {
118966
+ var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
118967
+ return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
118968
+ }
118969
+ break;
118970
+ case 2 /* Pattern */:
118971
+ var starPos = pathOrPattern.indexOf("*");
118972
+ var leadingSlice = pathOrPattern.slice(0, starPos);
118973
+ var trailingSlice = pathOrPattern.slice(starPos + 1);
118974
+ if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
118975
+ var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
118976
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
118977
+ }
118978
+ if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
118979
+ var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
118980
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
118981
+ }
118982
+ break;
118983
+ }
118984
+ }
118985
+ else if (Array.isArray(exports)) {
118986
+ return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
118987
+ }
118988
+ else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
118989
+ if (ts.allKeysStartWithDot(exports)) {
118990
+ // sub-mappings
118991
+ // 3 cases:
118992
+ // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
118993
+ // * pattern mappings (contains a *)
118994
+ // * exact mappings (no *, does not end with /)
118995
+ return ts.forEach(ts.getOwnKeys(exports), function (k) {
118996
+ var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
118997
+ var mode = ts.endsWith(k, "/") ? 1 /* Directory */
118998
+ : ts.stringContains(k, "*") ? 2 /* Pattern */
118999
+ : 0 /* Exact */;
119000
+ return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
119001
+ });
119002
+ }
119003
+ else {
119004
+ // conditional mapping
119005
+ for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
119006
+ var key = _a[_i];
119007
+ if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
119008
+ var subTarget = exports[key];
119009
+ var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
119010
+ if (result) {
119011
+ return result;
119012
+ }
119013
+ }
119014
+ }
119015
+ }
119016
+ }
119017
+ return undefined;
119018
+ }
118955
119019
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
118956
119020
  var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
118957
119021
  if (normalizedTargetPath === undefined) {
@@ -118981,7 +119045,15 @@ var ts;
118981
119045
  var moduleFileNameForExtensionless = void 0;
118982
119046
  while (true) {
118983
119047
  // If the module could be imported by a directory name, use that directory's name
118984
- var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
119048
+ var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
119049
+ if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
119050
+ if (blockedByExports) {
119051
+ return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
119052
+ }
119053
+ if (verbatimFromExports) {
119054
+ return moduleFileToTry;
119055
+ }
119056
+ }
118985
119057
  if (packageRootPath) {
118986
119058
  moduleSpecifier = packageRootPath;
118987
119059
  isPackageRootPath = true;
@@ -119018,6 +119090,15 @@ var ts;
119018
119090
  var moduleFileToTry = path;
119019
119091
  if (host.fileExists(packageJsonPath)) {
119020
119092
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119093
+ // TODO: Inject `require` or `import` condition based on the intended import mode
119094
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119095
+ if (fromExports) {
119096
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119097
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119098
+ }
119099
+ if (packageJsonContent.exports) {
119100
+ return { moduleFileToTry: path, blockedByExports: true };
119101
+ }
119021
119102
  var versionPaths = packageJsonContent.typesVersions
119022
119103
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
119023
119104
  : undefined;
@@ -138150,6 +138231,7 @@ var ts;
138150
138231
  return false;
138151
138232
  }
138152
138233
  }
138234
+ Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
138153
138235
  })(Rename = ts.Rename || (ts.Rename = {}));
138154
138236
  })(ts || (ts = {}));
138155
138237
  /* @internal */
@@ -159446,6 +159528,8 @@ var ts;
159446
159528
  synchronizeHostData();
159447
159529
  var sourceFile = getValidSourceFile(fileName);
159448
159530
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
159531
+ if (!ts.Rename.nodeIsEligibleForRename(node))
159532
+ return undefined;
159449
159533
  if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
159450
159534
  var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
159451
159535
  return [openingElement, closingElement].map(function (node) {
@@ -170544,11 +170628,13 @@ var ts;
170544
170628
  var file = server.toNormalizedPath(args.file);
170545
170629
  var position = this.getPositionInFile(args, file);
170546
170630
  var projects = this.getProjects(args);
170547
- var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170548
- if (!simplifiedResult)
170549
- return locations;
170550
170631
  var defaultProject = this.getDefaultProject(args);
170551
170632
  var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
170633
+ if (!renameInfo.canRename)
170634
+ return simplifiedResult ? { info: renameInfo, locs: [] } : [];
170635
+ var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170636
+ if (!simplifiedResult)
170637
+ return locations;
170552
170638
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
170553
170639
  };
170554
170640
  Session.prototype.mapRenameInfo = function (info, scriptInfo) {
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20211001";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20211005";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -42671,9 +42671,11 @@ var ts;
42671
42671
  return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
42672
42672
  }
42673
42673
  ts.parsePackageName = parsePackageName;
42674
+ /* @internal */
42674
42675
  function allKeysStartWithDot(obj) {
42675
42676
  return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42676
42677
  }
42678
+ ts.allKeysStartWithDot = allKeysStartWithDot;
42677
42679
  function noKeyStartsWithDot(obj) {
42678
42680
  return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42679
42681
  }
@@ -42880,17 +42882,19 @@ var ts;
42880
42882
  }
42881
42883
  return toSearchResult(/*value*/ undefined);
42882
42884
  }
42883
- function isApplicableVersionedTypesKey(conditions, key) {
42884
- if (conditions.indexOf("types") === -1)
42885
- return false; // only apply versioned types conditions if the types condition is applied
42886
- if (!ts.startsWith(key, "types@"))
42887
- return false;
42888
- var range = ts.VersionRange.tryParse(key.substring("types@".length));
42889
- if (!range)
42890
- return false;
42891
- return range.test(ts.version);
42892
- }
42893
42885
  }
42886
+ /* @internal */
42887
+ function isApplicableVersionedTypesKey(conditions, key) {
42888
+ if (conditions.indexOf("types") === -1)
42889
+ return false; // only apply versioned types conditions if the types condition is applied
42890
+ if (!ts.startsWith(key, "types@"))
42891
+ return false;
42892
+ var range = ts.VersionRange.tryParse(key.substring("types@".length));
42893
+ if (!range)
42894
+ return false;
42895
+ return range.test(ts.version);
42896
+ }
42897
+ ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
42894
42898
  function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
42895
42899
  return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
42896
42900
  }
@@ -61642,7 +61646,8 @@ var ts;
61642
61646
  return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
61643
61647
  if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
61644
61648
  if (!type.declaration.nameType) {
61645
- if (isArrayType(t)) {
61649
+ var constraint = void 0;
61650
+ if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61646
61651
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
61647
61652
  }
61648
61653
  if (isGenericTupleType(t)) {
@@ -63034,10 +63039,6 @@ var ts;
63034
63039
  }
63035
63040
  }
63036
63041
  message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
63037
- var typeLengthLimit = 30;
63038
- if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
63039
- message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
63040
- }
63041
63042
  }
63042
63043
  }
63043
63044
  else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
@@ -63047,15 +63048,6 @@ var ts;
63047
63048
  }
63048
63049
  reportError(message, generalizedSourceType, targetType);
63049
63050
  }
63050
- /** Move a printed type to be on its own line if it is longer than 30 characters */
63051
- function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
63052
- var message = diagnostic.message;
63053
- if (source.length > typeLengthLimit)
63054
- message = message.replace(" '{0}' ", ":\n{0}\n\n");
63055
- if (target.length > typeLengthLimit)
63056
- message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
63057
- return __assign(__assign({}, diagnostic), { message: message });
63058
- }
63059
63051
  function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
63060
63052
  var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
63061
63053
  var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
@@ -119146,6 +119138,78 @@ var ts;
119146
119138
  }
119147
119139
  }
119148
119140
  }
119141
+ var MatchingMode;
119142
+ (function (MatchingMode) {
119143
+ MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
119144
+ MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
119145
+ MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
119146
+ })(MatchingMode || (MatchingMode = {}));
119147
+ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
119148
+ if (mode === void 0) { mode = 0 /* Exact */; }
119149
+ if (typeof exports === "string") {
119150
+ var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
119151
+ var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
119152
+ switch (mode) {
119153
+ case 0 /* Exact */:
119154
+ if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
119155
+ return { moduleFileToTry: packageName };
119156
+ }
119157
+ break;
119158
+ case 1 /* Directory */:
119159
+ if (ts.containsPath(pathOrPattern, targetFilePath)) {
119160
+ var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
119161
+ return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
119162
+ }
119163
+ break;
119164
+ case 2 /* Pattern */:
119165
+ var starPos = pathOrPattern.indexOf("*");
119166
+ var leadingSlice = pathOrPattern.slice(0, starPos);
119167
+ var trailingSlice = pathOrPattern.slice(starPos + 1);
119168
+ if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
119169
+ var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
119170
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
119171
+ }
119172
+ if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
119173
+ var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
119174
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
119175
+ }
119176
+ break;
119177
+ }
119178
+ }
119179
+ else if (Array.isArray(exports)) {
119180
+ return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
119181
+ }
119182
+ else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
119183
+ if (ts.allKeysStartWithDot(exports)) {
119184
+ // sub-mappings
119185
+ // 3 cases:
119186
+ // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
119187
+ // * pattern mappings (contains a *)
119188
+ // * exact mappings (no *, does not end with /)
119189
+ return ts.forEach(ts.getOwnKeys(exports), function (k) {
119190
+ var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
119191
+ var mode = ts.endsWith(k, "/") ? 1 /* Directory */
119192
+ : ts.stringContains(k, "*") ? 2 /* Pattern */
119193
+ : 0 /* Exact */;
119194
+ return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
119195
+ });
119196
+ }
119197
+ else {
119198
+ // conditional mapping
119199
+ for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
119200
+ var key = _a[_i];
119201
+ if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
119202
+ var subTarget = exports[key];
119203
+ var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
119204
+ if (result) {
119205
+ return result;
119206
+ }
119207
+ }
119208
+ }
119209
+ }
119210
+ }
119211
+ return undefined;
119212
+ }
119149
119213
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
119150
119214
  var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
119151
119215
  if (normalizedTargetPath === undefined) {
@@ -119175,7 +119239,15 @@ var ts;
119175
119239
  var moduleFileNameForExtensionless = void 0;
119176
119240
  while (true) {
119177
119241
  // If the module could be imported by a directory name, use that directory's name
119178
- var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
119242
+ var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
119243
+ if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
119244
+ if (blockedByExports) {
119245
+ return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
119246
+ }
119247
+ if (verbatimFromExports) {
119248
+ return moduleFileToTry;
119249
+ }
119250
+ }
119179
119251
  if (packageRootPath) {
119180
119252
  moduleSpecifier = packageRootPath;
119181
119253
  isPackageRootPath = true;
@@ -119212,6 +119284,15 @@ var ts;
119212
119284
  var moduleFileToTry = path;
119213
119285
  if (host.fileExists(packageJsonPath)) {
119214
119286
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119287
+ // TODO: Inject `require` or `import` condition based on the intended import mode
119288
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119289
+ if (fromExports) {
119290
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119291
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119292
+ }
119293
+ if (packageJsonContent.exports) {
119294
+ return { moduleFileToTry: path, blockedByExports: true };
119295
+ }
119215
119296
  var versionPaths = packageJsonContent.typesVersions
119216
119297
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
119217
119298
  : undefined;
@@ -138732,6 +138813,7 @@ var ts;
138732
138813
  return false;
138733
138814
  }
138734
138815
  }
138816
+ Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
138735
138817
  })(Rename = ts.Rename || (ts.Rename = {}));
138736
138818
  })(ts || (ts = {}));
138737
138819
  /* @internal */
@@ -160028,6 +160110,8 @@ var ts;
160028
160110
  synchronizeHostData();
160029
160111
  var sourceFile = getValidSourceFile(fileName);
160030
160112
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
160113
+ if (!ts.Rename.nodeIsEligibleForRename(node))
160114
+ return undefined;
160031
160115
  if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
160032
160116
  var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
160033
160117
  return [openingElement, closingElement].map(function (node) {
@@ -170738,11 +170822,13 @@ var ts;
170738
170822
  var file = server.toNormalizedPath(args.file);
170739
170823
  var position = this.getPositionInFile(args, file);
170740
170824
  var projects = this.getProjects(args);
170741
- var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170742
- if (!simplifiedResult)
170743
- return locations;
170744
170825
  var defaultProject = this.getDefaultProject(args);
170745
170826
  var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
170827
+ if (!renameInfo.canRename)
170828
+ return simplifiedResult ? { info: renameInfo, locs: [] } : [];
170829
+ var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170830
+ if (!simplifiedResult)
170831
+ return locations;
170746
170832
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
170747
170833
  };
170748
170834
  Session.prototype.mapRenameInfo = function (info, scriptInfo) {