typescript 5.1.0-dev.20230412 → 5.1.0-dev.20230414

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
@@ -980,6 +980,7 @@ __export(server_exports, {
980
980
  getRootDeclaration: () => getRootDeclaration,
981
981
  getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
982
982
  getRootLength: () => getRootLength,
983
+ getRootPathSplitLength: () => getRootPathSplitLength,
983
984
  getScriptKind: () => getScriptKind,
984
985
  getScriptKindFromFileName: () => getScriptKindFromFileName,
985
986
  getScriptTargetFeatures: () => getScriptTargetFeatures,
@@ -2293,7 +2294,7 @@ module.exports = __toCommonJS(server_exports);
2293
2294
 
2294
2295
  // src/compiler/corePublic.ts
2295
2296
  var versionMajorMinor = "5.1";
2296
- var version = `${versionMajorMinor}.0-dev.20230412`;
2297
+ var version = `${versionMajorMinor}.0-dev.20230414`;
2297
2298
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2298
2299
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2299
2300
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -8937,11 +8938,11 @@ function getPathComponents(path, currentDirectory = "") {
8937
8938
  path = combinePaths(currentDirectory, path);
8938
8939
  return pathComponents(path, getRootLength(path));
8939
8940
  }
8940
- function getPathFromPathComponents(pathComponents2) {
8941
+ function getPathFromPathComponents(pathComponents2, length2) {
8941
8942
  if (pathComponents2.length === 0)
8942
8943
  return "";
8943
8944
  const root = pathComponents2[0] && ensureTrailingDirectorySeparator(pathComponents2[0]);
8944
- return root + pathComponents2.slice(1).join(directorySeparator);
8945
+ return root + pathComponents2.slice(1, length2).join(directorySeparator);
8945
8946
  }
8946
8947
  function normalizeSlashes(path) {
8947
8948
  return path.indexOf("\\") !== -1 ? path.replace(backslashRegExp, directorySeparator) : path;
@@ -22747,7 +22748,7 @@ function createNodeFactory(flags, baseFactory2) {
22747
22748
  function createBigIntLiteral(value) {
22748
22749
  const node = createBaseToken(10 /* BigIntLiteral */);
22749
22750
  node.text = typeof value === "string" ? value : pseudoBigIntToString(value) + "n";
22750
- node.transformFlags |= 4 /* ContainsESNext */;
22751
+ node.transformFlags |= 32 /* ContainsES2020 */;
22751
22752
  return node;
22752
22753
  }
22753
22754
  function createBaseStringLiteral(text, isSingleQuote) {
@@ -24257,7 +24258,7 @@ function createNodeFactory(flags, baseFactory2) {
24257
24258
  node.transformFlags |= 1024 /* ContainsES2015 */;
24258
24259
  break;
24259
24260
  case 102 /* ImportKeyword */:
24260
- node.transformFlags |= 4 /* ContainsESNext */;
24261
+ node.transformFlags |= 32 /* ContainsES2020 */;
24261
24262
  break;
24262
24263
  default:
24263
24264
  return Debug.assertNever(keywordToken);
@@ -24785,7 +24786,7 @@ function createNodeFactory(flags, baseFactory2) {
24785
24786
  function createNamespaceExport(name) {
24786
24787
  const node = createBaseDeclaration(279 /* NamespaceExport */);
24787
24788
  node.name = name;
24788
- node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */;
24789
+ node.transformFlags |= propagateChildFlags(node.name) | 32 /* ContainsES2020 */;
24789
24790
  node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
24790
24791
  return node;
24791
24792
  }
@@ -49399,11 +49400,6 @@ function createTypeChecker(host) {
49399
49400
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
49400
49401
  } else if (result.flags & 256 /* RegularEnum */) {
49401
49402
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49402
- } else {
49403
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
49404
- if (shouldPreserveConstEnums(compilerOptions)) {
49405
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49406
- }
49407
49403
  }
49408
49404
  if (diagnosticMessage) {
49409
49405
  addRelatedInfo(
@@ -66231,40 +66227,31 @@ function createTypeChecker(host) {
66231
66227
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
66232
66228
  }
66233
66229
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
66234
- return findMatchingDiscriminantType(
66235
- source,
66236
- target,
66237
- isRelatedTo,
66238
- /*skipPartial*/
66239
- true
66240
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
66230
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
66241
66231
  }
66242
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
66243
- const discriminable = target.types.map((_) => void 0);
66232
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
66233
+ const types = target.types;
66234
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
66244
66235
  for (const [getDiscriminatingType, propertyName] of discriminators) {
66245
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
66246
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
66247
- continue;
66236
+ let matched = false;
66237
+ for (let i = 0; i < types.length; i++) {
66238
+ if (include[i]) {
66239
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
66240
+ if (targetType && related(getDiscriminatingType(), targetType)) {
66241
+ matched = true;
66242
+ } else {
66243
+ include[i] = 3 /* Maybe */;
66244
+ }
66245
+ }
66248
66246
  }
66249
- let i = 0;
66250
- for (const type of target.types) {
66251
- const targetType = getTypeOfPropertyOfType(type, propertyName);
66252
- if (targetType && related(getDiscriminatingType(), targetType)) {
66253
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
66254
- } else {
66255
- discriminable[i] = false;
66247
+ for (let i = 0; i < types.length; i++) {
66248
+ if (include[i] === 3 /* Maybe */) {
66249
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
66256
66250
  }
66257
- i++;
66258
66251
  }
66259
66252
  }
66260
- const match = discriminable.indexOf(
66261
- /*searchElement*/
66262
- true
66263
- );
66264
- if (match === -1) {
66265
- return defaultValue;
66266
- }
66267
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
66253
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
66254
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
66268
66255
  }
66269
66256
  function isWeakType(type) {
66270
66257
  if (type.flags & 524288 /* Object */) {
@@ -71568,8 +71555,7 @@ function createTypeChecker(host) {
71568
71555
  (s) => [() => undefinedType, s.escapedName]
71569
71556
  )
71570
71557
  ),
71571
- isTypeAssignableTo,
71572
- contextualType
71558
+ isTypeAssignableTo
71573
71559
  );
71574
71560
  }
71575
71561
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -71588,8 +71574,7 @@ function createTypeChecker(host) {
71588
71574
  (s) => [() => undefinedType, s.escapedName]
71589
71575
  )
71590
71576
  ),
71591
- isTypeAssignableTo,
71592
- contextualType
71577
+ isTypeAssignableTo
71593
71578
  );
71594
71579
  }
71595
71580
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -87603,7 +87588,7 @@ function createTypeChecker(host) {
87603
87588
  }
87604
87589
  return type;
87605
87590
  }
87606
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
87591
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
87607
87592
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
87608
87593
  const match = getMatchingUnionConstituentForType(target, source);
87609
87594
  if (match) {
@@ -87613,14 +87598,10 @@ function createTypeChecker(host) {
87613
87598
  if (sourceProperties) {
87614
87599
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
87615
87600
  if (sourcePropertiesFiltered) {
87616
- return discriminateTypeByDiscriminableItems(
87617
- target,
87618
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
87619
- isRelatedTo,
87620
- /*defaultValue*/
87621
- void 0,
87622
- skipPartial
87623
- );
87601
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
87602
+ if (discriminated !== target) {
87603
+ return discriminated;
87604
+ }
87624
87605
  }
87625
87606
  }
87626
87607
  }
@@ -123037,60 +123018,62 @@ function removeIgnoredPath(path) {
123037
123018
  }
123038
123019
  return some(ignoredPaths, (searchPath) => stringContains(path, searchPath)) ? void 0 : path;
123039
123020
  }
123040
- function canWatchDirectoryOrFile(dirPath) {
123041
- const rootLength = getRootLength(dirPath);
123042
- if (dirPath.length === rootLength) {
123043
- return false;
123044
- }
123045
- let nextDirectorySeparator = dirPath.indexOf(directorySeparator, rootLength);
123046
- if (nextDirectorySeparator === -1) {
123047
- return false;
123048
- }
123049
- let pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
123050
- const isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */;
123051
- if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123052
- pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) {
123053
- nextDirectorySeparator = dirPath.indexOf(directorySeparator, nextDirectorySeparator + 1);
123054
- if (nextDirectorySeparator === -1) {
123055
- return false;
123056
- }
123057
- pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
123058
- }
123059
- if (isNonDirectorySeparatorRoot && pathPartForUserCheck.search(/users\//i) !== 0) {
123060
- return true;
123021
+ function perceivedOsRootLengthForWatching(pathComponents2, length2) {
123022
+ if (length2 <= 1)
123023
+ return 1;
123024
+ let userCheckIndex = 1;
123025
+ let isDosStyle = pathComponents2[0].search(/[a-zA-Z]:/) === 0;
123026
+ if (pathComponents2[0] !== directorySeparator && !isDosStyle && // Non dos style paths
123027
+ pathComponents2[1].search(/[a-zA-Z]\$$/) === 0) {
123028
+ if (length2 === 2)
123029
+ return 2;
123030
+ userCheckIndex = 2;
123031
+ isDosStyle = true;
123061
123032
  }
123062
- for (let searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
123063
- searchIndex = dirPath.indexOf(directorySeparator, searchIndex) + 1;
123064
- if (searchIndex === 0) {
123065
- return false;
123066
- }
123033
+ if (isDosStyle && !pathComponents2[userCheckIndex].match(/^users$/i)) {
123034
+ return userCheckIndex;
123067
123035
  }
123068
- return true;
123036
+ return userCheckIndex + 2;
123069
123037
  }
123070
- function canWatchAtTypes(atTypes, rootPath) {
123071
- const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
123072
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
123038
+ function canWatchDirectoryOrFile(pathComponents2, length2) {
123039
+ if (length2 === void 0)
123040
+ length2 = pathComponents2.length;
123041
+ if (length2 <= 2)
123042
+ return false;
123043
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(pathComponents2, length2);
123044
+ return length2 > perceivedOsRootLength + 1;
123073
123045
  }
123074
- function isInDirectoryPath(dir, file) {
123075
- if (dir === void 0 || file.length <= dir.length) {
123046
+ function canWatchAtTypes(atTypes) {
123047
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(getDirectoryPath(atTypes));
123048
+ }
123049
+ function isInDirectoryPath(dirComponents, fileOrDirComponents) {
123050
+ if (fileOrDirComponents.length < fileOrDirComponents.length)
123076
123051
  return false;
123052
+ for (let i = 0; i < dirComponents.length; i++) {
123053
+ if (fileOrDirComponents[i] !== dirComponents[i])
123054
+ return false;
123077
123055
  }
123078
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
123056
+ return true;
123057
+ }
123058
+ function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
123059
+ return canWatchDirectoryOrFile(getPathComponents(fileOrDirPath));
123079
123060
  }
123080
123061
  function canWatchAffectingLocation(filePath) {
123081
- return canWatchDirectoryOrFile(filePath);
123082
- }
123083
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
123084
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
123085
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
123086
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
123087
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
123088
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
123089
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
123090
- return {
123091
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
123092
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
123093
- };
123062
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
123063
+ }
123064
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory) {
123065
+ const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
123066
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
123067
+ const failedLookupComponents = getPathComponents(failedLookupLocation);
123068
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(failedLookupPathComponents, failedLookupPathComponents.length);
123069
+ if (failedLookupPathComponents.length <= perceivedOsRootLength + 1)
123070
+ return void 0;
123071
+ const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
123072
+ if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1)
123073
+ return void 0;
123074
+ if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
123075
+ if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
123076
+ return getDirectoryOfFailedLookupWatch(failedLookupComponents, failedLookupPathComponents, Math.max(rootPathComponents.length + 1, perceivedOsRootLength + 1));
123094
123077
  } else {
123095
123078
  return {
123096
123079
  dir: rootDir,
@@ -123100,45 +123083,58 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
123100
123083
  }
123101
123084
  }
123102
123085
  return getDirectoryToWatchFromFailedLookupLocationDirectory(
123103
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
123104
- getDirectoryPath(failedLookupLocationPath),
123105
- rootPath
123086
+ failedLookupComponents,
123087
+ failedLookupPathComponents,
123088
+ failedLookupPathComponents.length - 1,
123089
+ perceivedOsRootLength,
123090
+ nodeModulesIndex,
123091
+ rootPathComponents
123106
123092
  );
123107
123093
  }
123108
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
123109
- while (pathContainsNodeModules(dirPath)) {
123110
- dir = getDirectoryPath(dir);
123111
- dirPath = getDirectoryPath(dirPath);
123112
- }
123113
- if (isNodeModulesDirectory(dirPath)) {
123114
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
123094
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents) {
123095
+ if (nodeModulesIndex !== -1) {
123096
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, nodeModulesIndex + 1);
123115
123097
  }
123116
123098
  let nonRecursive = true;
123117
- let subDirectoryPath, subDirectory;
123118
- if (rootPath !== void 0) {
123119
- while (!isInDirectoryPath(dirPath, rootPath)) {
123120
- const parentPath = getDirectoryPath(dirPath);
123121
- if (parentPath === dirPath) {
123122
- break;
123123
- }
123099
+ let length2 = dirPathComponentsLength;
123100
+ for (let i = 0; i < dirPathComponentsLength; i++) {
123101
+ if (dirPathComponents[i] !== rootPathComponents[i]) {
123124
123102
  nonRecursive = false;
123125
- subDirectoryPath = dirPath;
123126
- subDirectory = dir;
123127
- dirPath = parentPath;
123128
- dir = getDirectoryPath(dir);
123103
+ length2 = Math.max(i + 1, perceivedOsRootLength + 1);
123104
+ break;
123129
123105
  }
123130
123106
  }
123131
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
123107
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive);
123132
123108
  }
123133
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
123134
- if (isInDirectoryPath(rootPath, typeRootPath)) {
123109
+ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive) {
123110
+ return {
123111
+ dir: getPathFromPathComponents(dirComponents, length2),
123112
+ dirPath: getPathFromPathComponents(dirPathComponents, length2),
123113
+ nonRecursive
123114
+ };
123115
+ }
123116
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, filterCustomPath) {
123117
+ const typeRootPathComponents = getPathComponents(typeRootPath);
123118
+ if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
123135
123119
  return rootPath;
123136
123120
  }
123137
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
123121
+ typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
123122
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(
123123
+ getPathComponents(typeRoot),
123124
+ typeRootPathComponents,
123125
+ typeRootPathComponents.length,
123126
+ perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
123127
+ typeRootPathComponents.indexOf("node_modules"),
123128
+ rootPathComponents
123129
+ );
123138
123130
  return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
123139
123131
  }
123140
123132
  function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
123141
- return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
123133
+ const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory());
123134
+ return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized;
123135
+ }
123136
+ function getRootPathSplitLength(rootPath) {
123137
+ return rootPath.split(directorySeparator).length - (hasTrailingDirectorySeparator(rootPath) ? 1 : 0);
123142
123138
  }
123143
123139
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
123144
123140
  let filesWithChangedSetOfUnresolvedImports;
@@ -123170,13 +123166,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123170
123166
  resolutionHost.getCompilationSettings(),
123171
123167
  moduleResolutionCache.getPackageJsonInfoCache()
123172
123168
  );
123173
- const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
123174
- const customFailedLookupPaths = /* @__PURE__ */ new Map();
123175
123169
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
123176
123170
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
123177
123171
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
123178
- const rootPath = rootDir && resolutionHost.toPath(rootDir);
123179
- const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
123172
+ const rootPath = resolutionHost.toPath(rootDir);
123173
+ const rootPathComponents = getPathComponents(rootPath);
123180
123174
  const typeRootsWatches = /* @__PURE__ */ new Map();
123181
123175
  return {
123182
123176
  getModuleResolutionCache: () => moduleResolutionCache,
@@ -123210,7 +123204,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123210
123204
  function clear2() {
123211
123205
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
123212
123206
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
123213
- customFailedLookupPaths.clear();
123214
123207
  nonRelativeExternalModuleResolutions.clear();
123215
123208
  closeTypeRootsWatch();
123216
123209
  resolvedModuleNames.clear();
@@ -123490,9 +123483,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123490
123483
  function isNodeModulesAtTypesDirectory(dirPath) {
123491
123484
  return endsWith(dirPath, "/node_modules/@types");
123492
123485
  }
123493
- function isPathWithDefaultFailedLookupExtension(path) {
123494
- return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
123495
- }
123496
123486
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
123497
123487
  var _a2, _b;
123498
123488
  if (resolution.refCount) {
@@ -123533,15 +123523,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123533
123523
  failedLookupLocationPath,
123534
123524
  rootDir,
123535
123525
  rootPath,
123536
- rootSplitLength,
123526
+ rootPathComponents,
123537
123527
  getCurrentDirectory
123538
123528
  );
123539
123529
  if (toWatch) {
123540
123530
  const { dir, dirPath, nonRecursive } = toWatch;
123541
- if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
123542
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
123543
- customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
123544
- }
123545
123531
  if (dirPath === rootPath) {
123546
123532
  Debug.assert(nonRecursive);
123547
123533
  setAtRoot = true;
@@ -123676,20 +123662,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123676
123662
  failedLookupLocationPath,
123677
123663
  rootDir,
123678
123664
  rootPath,
123679
- rootSplitLength,
123665
+ rootPathComponents,
123680
123666
  getCurrentDirectory
123681
123667
  );
123682
123668
  if (toWatch) {
123683
123669
  const { dirPath } = toWatch;
123684
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
123685
- if (refCount) {
123686
- if (refCount === 1) {
123687
- customFailedLookupPaths.delete(failedLookupLocationPath);
123688
- } else {
123689
- Debug.assert(refCount > 1);
123690
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
123691
- }
123692
- }
123693
123670
  if (dirPath === rootPath) {
123694
123671
  removeAtRoot = true;
123695
123672
  } else {
@@ -123787,10 +123764,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123787
123764
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
123788
123765
  (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
123789
123766
  } else {
123790
- if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
123767
+ if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
123791
123768
  return false;
123792
123769
  }
123793
- if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
123770
+ if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
123794
123771
  return false;
123795
123772
  }
123796
123773
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
@@ -123837,7 +123814,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123837
123814
  return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
123838
123815
  }
123839
123816
  function isInvalidatedFailedLookup(locationPath) {
123840
- return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (fileOrDirectoryPath) => isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : void 0);
123817
+ return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (dirPath) => locationPath.length > dirPath.length && startsWith(locationPath, dirPath) && (isDiskPathRoot(dirPath) || locationPath[dirPath.length] === directorySeparator) ? true : void 0);
123841
123818
  }
123842
123819
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
123843
123820
  var _a2;
@@ -123858,6 +123835,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123858
123835
  typeRoot,
123859
123836
  typeRootPath,
123860
123837
  rootPath,
123838
+ rootPathComponents,
123839
+ getCurrentDirectory,
123861
123840
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
123862
123841
  );
123863
123842
  if (dirPath) {
@@ -123888,7 +123867,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
123888
123867
  function canWatchTypeRootPath(typeRoot) {
123889
123868
  if (resolutionHost.getCompilationSettings().typeRoots)
123890
123869
  return true;
123891
- return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
123870
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot));
123892
123871
  }
123893
123872
  }
123894
123873
  function resolutionIsSymlink(resolution) {
@@ -127746,7 +127725,8 @@ function getDefaultFormatCodeSettings(newLineCharacter) {
127746
127725
  placeOpenBraceOnNewLineForFunctions: false,
127747
127726
  placeOpenBraceOnNewLineForControlBlocks: false,
127748
127727
  semicolons: "ignore" /* Ignore */,
127749
- trimTrailingWhitespace: true
127728
+ trimTrailingWhitespace: true,
127729
+ indentSwitchCase: true
127750
127730
  };
127751
127731
  }
127752
127732
  var testFormatSettings = getDefaultFormatCodeSettings("\n");
@@ -128924,7 +128904,13 @@ function findPrecedingToken(position, sourceFile, startNode2, excludeJsdoc) {
128924
128904
  sourceFile,
128925
128905
  n.kind
128926
128906
  );
128927
- return candidate2 && findRightmostToken(candidate2, sourceFile);
128907
+ if (candidate2) {
128908
+ if (!excludeJsdoc && isJSDocCommentContainingNode(candidate2) && candidate2.getChildren(sourceFile).length) {
128909
+ return find2(candidate2);
128910
+ }
128911
+ return findRightmostToken(candidate2, sourceFile);
128912
+ }
128913
+ return void 0;
128928
128914
  } else {
128929
128915
  return find2(child);
128930
128916
  }
@@ -156196,7 +156182,7 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
156196
156182
  false,
156197
156183
  failedAliasResolution
156198
156184
  )) : emptyArray;
156199
- return concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || emptyArray);
156185
+ return concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node));
156200
156186
  }
156201
156187
  if (isPropertyName(node) && isBindingElement(parent2) && isObjectBindingPattern(parent2.parent) && node === (parent2.propertyName || parent2.name)) {
156202
156188
  const name = getNameFromPropertyName(node);
@@ -156206,7 +156192,8 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
156206
156192
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
156207
156193
  });
156208
156194
  }
156209
- return concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
156195
+ const objectLiteralElementDefinition = getDefinitionFromObjectLiteralElement(typeChecker, node);
156196
+ return concatenate(fileReferenceDefinition, objectLiteralElementDefinition.length ? objectLiteralElementDefinition : getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
156210
156197
  }
156211
156198
  function symbolMatchesSignature(s, calledDeclaration) {
156212
156199
  var _a2;
@@ -156226,6 +156213,7 @@ function getDefinitionFromObjectLiteralElement(typeChecker, node) {
156226
156213
  ), (propertySymbol) => getDefinitionFromSymbol(typeChecker, propertySymbol, node));
156227
156214
  }
156228
156215
  }
156216
+ return emptyArray;
156229
156217
  }
156230
156218
  function getDefinitionFromOverriddenMember(typeChecker, node) {
156231
156219
  const classElement = findAncestor(node, isClassElement);
@@ -168608,6 +168596,7 @@ var SmartIndenter;
168608
168596
  }
168609
168597
  SmartIndenter2.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn;
168610
168598
  function nodeWillIndentChild(settings, parent2, child, sourceFile, indentByDefault) {
168599
+ var _a2;
168611
168600
  const childKind = child ? child.kind : 0 /* Unknown */;
168612
168601
  switch (parent2.kind) {
168613
168602
  case 243 /* ExpressionStatement */:
@@ -168623,9 +168612,6 @@ var SmartIndenter;
168623
168612
  case 186 /* TypeLiteral */:
168624
168613
  case 199 /* MappedType */:
168625
168614
  case 188 /* TupleType */:
168626
- case 268 /* CaseBlock */:
168627
- case 295 /* DefaultClause */:
168628
- case 294 /* CaseClause */:
168629
168615
  case 216 /* ParenthesizedExpression */:
168630
168616
  case 210 /* PropertyAccessExpression */:
168631
168617
  case 212 /* CallExpression */:
@@ -168654,7 +168640,11 @@ var SmartIndenter;
168654
168640
  case 280 /* ExportSpecifier */:
168655
168641
  case 275 /* ImportSpecifier */:
168656
168642
  case 171 /* PropertyDeclaration */:
168643
+ case 294 /* CaseClause */:
168644
+ case 295 /* DefaultClause */:
168657
168645
  return true;
168646
+ case 268 /* CaseBlock */:
168647
+ return (_a2 = settings.indentSwitchCase) != null ? _a2 : true;
168658
168648
  case 259 /* VariableDeclaration */:
168659
168649
  case 301 /* PropertyAssignment */:
168660
168650
  case 225 /* BinaryExpression */:
@@ -169683,6 +169673,7 @@ __export(ts_exports2, {
169683
169673
  getRootDeclaration: () => getRootDeclaration,
169684
169674
  getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
169685
169675
  getRootLength: () => getRootLength,
169676
+ getRootPathSplitLength: () => getRootPathSplitLength,
169686
169677
  getScriptKind: () => getScriptKind,
169687
169678
  getScriptKindFromFileName: () => getScriptKindFromFileName,
169688
169679
  getScriptTargetFeatures: () => getScriptTargetFeatures,
@@ -172807,7 +172798,7 @@ var Project3 = class {
172807
172798
  this.globalCacheResolutionModuleName = ts_JsTyping_exports.nonRelativeModuleNameForTypingCache;
172808
172799
  this.projectName = projectName;
172809
172800
  this.directoryStructureHost = directoryStructureHost;
172810
- this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || "");
172801
+ this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory);
172811
172802
  this.getCanonicalFileName = this.projectService.toCanonicalFileName;
172812
172803
  this.cancellationToken = new ThrottledCancellationToken(this.projectService.cancellationToken, this.projectService.throttleWaitMilliseconds);
172813
172804
  if (!this.compilerOptions) {
@@ -172844,7 +172835,7 @@ var Project3 = class {
172844
172835
  this.realpath = maybeBind(host, host.realpath);
172845
172836
  this.resolutionCache = createResolutionCache(
172846
172837
  this,
172847
- currentDirectory && this.currentDirectory,
172838
+ this.currentDirectory,
172848
172839
  /*logChangesWhenResolvingModule*/
172849
172840
  true
172850
172841
  );
@@ -174230,7 +174221,7 @@ var Project3 = class {
174230
174221
  getNoDtsResolutionProject(rootFileNames) {
174231
174222
  Debug.assert(this.projectService.serverMode === 0 /* Semantic */);
174232
174223
  if (!this.noDtsResolutionProject) {
174233
- this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
174224
+ this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject(), this.currentDirectory);
174234
174225
  }
174235
174226
  enumerateInsertsAndDeletes(
174236
174227
  rootFileNames.map(toNormalizedPath),
@@ -174383,7 +174374,7 @@ var InferredProject2 = class extends Project3 {
174383
174374
  }
174384
174375
  };
174385
174376
  var AuxiliaryProject = class extends Project3 {
174386
- constructor(projectService, documentRegistry, compilerOptions) {
174377
+ constructor(projectService, documentRegistry, compilerOptions, currentDirectory) {
174387
174378
  super(
174388
174379
  projectService.newAuxiliaryProjectName(),
174389
174380
  4 /* Auxiliary */,
@@ -174399,8 +174390,7 @@ var AuxiliaryProject = class extends Project3 {
174399
174390
  /*watchOptions*/
174400
174391
  void 0,
174401
174392
  projectService.host,
174402
- /*currentDirectory*/
174403
- void 0
174393
+ currentDirectory
174404
174394
  );
174405
174395
  }
174406
174396
  isOrphan() {
@@ -176020,7 +176010,7 @@ var _ProjectService = class {
176020
176010
  Debug.checkDefined(configFileExistenceInfo.watcher);
176021
176011
  if ((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) == null ? void 0 : _c.size) {
176022
176012
  if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) {
176023
- if (!canWatchDirectoryOrFile(getDirectoryPath(canonicalConfigFilePath))) {
176013
+ if (!canWatchDirectoryOrFile(getPathComponents(getDirectoryPath(canonicalConfigFilePath)))) {
176024
176014
  configFileExistenceInfo.watcher.close();
176025
176015
  configFileExistenceInfo.watcher = noopConfigFileWatcher;
176026
176016
  }
@@ -176080,7 +176070,7 @@ var _ProjectService = class {
176080
176070
  this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo);
176081
176071
  }
176082
176072
  (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = /* @__PURE__ */ new Map())).set(info.path, true);
176083
- configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = canWatchDirectoryOrFile(getDirectoryPath(canonicalConfigFilePath)) ? this.watchFactory.watchFile(
176073
+ configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = canWatchDirectoryOrFile(getPathComponents(getDirectoryPath(canonicalConfigFilePath))) ? this.watchFactory.watchFile(
176084
176074
  configFileName,
176085
176075
  (_filename, eventKind) => this.onConfigFileChanged(canonicalConfigFilePath, eventKind),
176086
176076
  2e3 /* High */,
@@ -176709,15 +176699,14 @@ var _ProjectService = class {
176709
176699
  return this.inferredProjects[0];
176710
176700
  }
176711
176701
  return this.createInferredProject(
176712
- /*currentDirectory*/
176713
- void 0,
176702
+ "",
176714
176703
  /*isSingleInferredProject*/
176715
176704
  true
176716
176705
  );
176717
176706
  }
176718
176707
  getOrCreateSingleInferredWithoutProjectRoot(currentDirectory) {
176719
176708
  Debug.assert(!this.useSingleInferredProject);
176720
- const expectedCurrentDirectory = this.toCanonicalFileName(this.getNormalizedAbsolutePath(currentDirectory || ""));
176709
+ const expectedCurrentDirectory = this.toCanonicalFileName(this.getNormalizedAbsolutePath(currentDirectory));
176721
176710
  for (const inferredProject of this.inferredProjects) {
176722
176711
  if (!inferredProject.projectRootPath && inferredProject.isOrphan() && inferredProject.canonicalCurrentDirectory === expectedCurrentDirectory) {
176723
176712
  return inferredProject;
@@ -184118,6 +184107,7 @@ start(initializeNodeSystem(), require("os").platform());
184118
184107
  getRootDeclaration,
184119
184108
  getRootDirectoryOfResolutionCache,
184120
184109
  getRootLength,
184110
+ getRootPathSplitLength,
184121
184111
  getScriptKind,
184122
184112
  getScriptKindFromFileName,
184123
184113
  getScriptTargetFeatures,