@typescript-deploys/pr-build 5.1.0-pr-50092-15 → 5.1.0-pr-53591-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/tsc.js CHANGED
@@ -5294,6 +5294,10 @@ function isAnyDirectorySeparator(charCode) {
5294
5294
  function isRootedDiskPath(path) {
5295
5295
  return getEncodedRootLength(path) > 0;
5296
5296
  }
5297
+ function isDiskPathRoot(path) {
5298
+ const rootLength = getEncodedRootLength(path);
5299
+ return rootLength > 0 && rootLength === path.length;
5300
+ }
5297
5301
  function pathIsAbsolute(path) {
5298
5302
  return getEncodedRootLength(path) !== 0;
5299
5303
  }
@@ -5442,11 +5446,11 @@ function getPathComponents(path, currentDirectory = "") {
5442
5446
  path = combinePaths(currentDirectory, path);
5443
5447
  return pathComponents(path, getRootLength(path));
5444
5448
  }
5445
- function getPathFromPathComponents(pathComponents2) {
5449
+ function getPathFromPathComponents(pathComponents2, length2) {
5446
5450
  if (pathComponents2.length === 0)
5447
5451
  return "";
5448
5452
  const root = pathComponents2[0] && ensureTrailingDirectorySeparator(pathComponents2[0]);
5449
- return root + pathComponents2.slice(1).join(directorySeparator);
5453
+ return root + pathComponents2.slice(1, length2).join(directorySeparator);
5450
5454
  }
5451
5455
  function normalizeSlashes(path) {
5452
5456
  return path.indexOf("\\") !== -1 ? path.replace(backslashRegExp, directorySeparator) : path;
@@ -118108,60 +118112,62 @@ function removeIgnoredPath(path) {
118108
118112
  }
118109
118113
  return some(ignoredPaths, (searchPath) => stringContains(path, searchPath)) ? void 0 : path;
118110
118114
  }
118111
- function canWatchDirectoryOrFile(dirPath) {
118112
- const rootLength = getRootLength(dirPath);
118113
- if (dirPath.length === rootLength) {
118114
- return false;
118115
- }
118116
- let nextDirectorySeparator = dirPath.indexOf(directorySeparator, rootLength);
118117
- if (nextDirectorySeparator === -1) {
118118
- return false;
118119
- }
118120
- let pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
118121
- const isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */;
118122
- if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
118123
- pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) {
118124
- nextDirectorySeparator = dirPath.indexOf(directorySeparator, nextDirectorySeparator + 1);
118125
- if (nextDirectorySeparator === -1) {
118126
- return false;
118127
- }
118128
- pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
118129
- }
118130
- if (isNonDirectorySeparatorRoot && pathPartForUserCheck.search(/users\//i) !== 0) {
118131
- return true;
118115
+ function perceivedOsRootLengthForWatching(pathComponents2, length2) {
118116
+ if (length2 <= 1)
118117
+ return 1;
118118
+ let userCheckIndex = 1;
118119
+ let isDosStyle = pathComponents2[0].search(/[a-zA-Z]:/) === 0;
118120
+ if (pathComponents2[0] !== directorySeparator && !isDosStyle && // Non dos style paths
118121
+ pathComponents2[1].search(/[a-zA-Z]\$$/) === 0) {
118122
+ if (length2 === 2)
118123
+ return 2;
118124
+ userCheckIndex = 2;
118125
+ isDosStyle = true;
118132
118126
  }
118133
- for (let searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
118134
- searchIndex = dirPath.indexOf(directorySeparator, searchIndex) + 1;
118135
- if (searchIndex === 0) {
118136
- return false;
118137
- }
118127
+ if (isDosStyle && !pathComponents2[userCheckIndex].match(/^users$/i)) {
118128
+ return userCheckIndex;
118138
118129
  }
118139
- return true;
118130
+ return userCheckIndex + 2;
118140
118131
  }
118141
- function canWatchAtTypes(atTypes, rootPath) {
118142
- const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
118143
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
118132
+ function canWatchDirectoryOrFile(pathComponents2, length2) {
118133
+ if (length2 === void 0)
118134
+ length2 = pathComponents2.length;
118135
+ if (length2 <= 2)
118136
+ return false;
118137
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(pathComponents2, length2);
118138
+ return length2 > perceivedOsRootLength + 1;
118139
+ }
118140
+ function canWatchAtTypes(atTypes) {
118141
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(getDirectoryPath(atTypes));
118144
118142
  }
118145
- function isInDirectoryPath(dir, file) {
118146
- if (dir === void 0 || file.length <= dir.length) {
118143
+ function isInDirectoryPath(dirComponents, fileOrDirComponents) {
118144
+ if (fileOrDirComponents.length < fileOrDirComponents.length)
118147
118145
  return false;
118146
+ for (let i = 0; i < dirComponents.length; i++) {
118147
+ if (fileOrDirComponents[i] !== dirComponents[i])
118148
+ return false;
118148
118149
  }
118149
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
118150
+ return true;
118151
+ }
118152
+ function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
118153
+ return canWatchDirectoryOrFile(getPathComponents(fileOrDirPath));
118150
118154
  }
118151
118155
  function canWatchAffectingLocation(filePath) {
118152
- return canWatchDirectoryOrFile(filePath);
118153
- }
118154
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
118155
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
118156
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118157
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
118158
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
118159
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
118160
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
118161
- return {
118162
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
118163
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
118164
- };
118156
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
118157
+ }
118158
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory) {
118159
+ const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
118160
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118161
+ const failedLookupComponents = getPathComponents(failedLookupLocation);
118162
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(failedLookupPathComponents, failedLookupPathComponents.length);
118163
+ if (failedLookupPathComponents.length <= perceivedOsRootLength + 1)
118164
+ return void 0;
118165
+ const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
118166
+ if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1)
118167
+ return void 0;
118168
+ if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
118169
+ if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
118170
+ return getDirectoryOfFailedLookupWatch(failedLookupComponents, failedLookupPathComponents, Math.max(rootPathComponents.length + 1, perceivedOsRootLength + 1));
118165
118171
  } else {
118166
118172
  return {
118167
118173
  dir: rootDir,
@@ -118171,45 +118177,55 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
118171
118177
  }
118172
118178
  }
118173
118179
  return getDirectoryToWatchFromFailedLookupLocationDirectory(
118174
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
118175
- getDirectoryPath(failedLookupLocationPath),
118176
- rootPath
118180
+ failedLookupComponents,
118181
+ failedLookupPathComponents,
118182
+ failedLookupPathComponents.length - 1,
118183
+ perceivedOsRootLength,
118184
+ nodeModulesIndex,
118185
+ rootPathComponents
118177
118186
  );
118178
118187
  }
118179
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
118180
- while (pathContainsNodeModules(dirPath)) {
118181
- dir = getDirectoryPath(dir);
118182
- dirPath = getDirectoryPath(dirPath);
118183
- }
118184
- if (isNodeModulesDirectory(dirPath)) {
118185
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
118188
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents) {
118189
+ if (nodeModulesIndex !== -1) {
118190
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, nodeModulesIndex + 1);
118186
118191
  }
118187
118192
  let nonRecursive = true;
118188
- let subDirectoryPath, subDirectory;
118189
- if (rootPath !== void 0) {
118190
- while (!isInDirectoryPath(dirPath, rootPath)) {
118191
- const parentPath = getDirectoryPath(dirPath);
118192
- if (parentPath === dirPath) {
118193
- break;
118194
- }
118193
+ let length2 = dirPathComponentsLength;
118194
+ for (let i = 0; i < dirPathComponentsLength; i++) {
118195
+ if (dirPathComponents[i] !== rootPathComponents[i]) {
118195
118196
  nonRecursive = false;
118196
- subDirectoryPath = dirPath;
118197
- subDirectory = dir;
118198
- dirPath = parentPath;
118199
- dir = getDirectoryPath(dir);
118197
+ length2 = Math.max(i + 1, perceivedOsRootLength + 1);
118198
+ break;
118200
118199
  }
118201
118200
  }
118202
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
118201
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive);
118202
+ }
118203
+ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive) {
118204
+ return {
118205
+ dir: getPathFromPathComponents(dirComponents, length2),
118206
+ dirPath: getPathFromPathComponents(dirPathComponents, length2),
118207
+ nonRecursive
118208
+ };
118203
118209
  }
118204
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
118205
- if (isInDirectoryPath(rootPath, typeRootPath)) {
118210
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, filterCustomPath) {
118211
+ const typeRootPathComponents = getPathComponents(typeRootPath);
118212
+ if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
118206
118213
  return rootPath;
118207
118214
  }
118208
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
118215
+ typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
118216
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(
118217
+ getPathComponents(typeRoot),
118218
+ typeRootPathComponents,
118219
+ typeRootPathComponents.length,
118220
+ perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
118221
+ typeRootPathComponents.indexOf("node_modules"),
118222
+ rootPathComponents
118223
+ );
118209
118224
  return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
118210
118225
  }
118211
118226
  function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
118212
- return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
118227
+ const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory());
118228
+ return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized;
118213
118229
  }
118214
118230
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
118215
118231
  let filesWithChangedSetOfUnresolvedImports;
@@ -118241,13 +118257,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118241
118257
  resolutionHost.getCompilationSettings(),
118242
118258
  moduleResolutionCache.getPackageJsonInfoCache()
118243
118259
  );
118244
- const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
118245
- const customFailedLookupPaths = /* @__PURE__ */ new Map();
118246
118260
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
118247
118261
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
118248
118262
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
118249
- const rootPath = rootDir && resolutionHost.toPath(rootDir);
118250
- const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
118263
+ const rootPath = resolutionHost.toPath(rootDir);
118264
+ const rootPathComponents = getPathComponents(rootPath);
118251
118265
  const typeRootsWatches = /* @__PURE__ */ new Map();
118252
118266
  return {
118253
118267
  getModuleResolutionCache: () => moduleResolutionCache,
@@ -118281,7 +118295,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118281
118295
  function clear2() {
118282
118296
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
118283
118297
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
118284
- customFailedLookupPaths.clear();
118285
118298
  nonRelativeExternalModuleResolutions.clear();
118286
118299
  closeTypeRootsWatch();
118287
118300
  resolvedModuleNames.clear();
@@ -118561,9 +118574,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118561
118574
  function isNodeModulesAtTypesDirectory(dirPath) {
118562
118575
  return endsWith(dirPath, "/node_modules/@types");
118563
118576
  }
118564
- function isPathWithDefaultFailedLookupExtension(path) {
118565
- return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
118566
- }
118567
118577
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118568
118578
  var _a2, _b;
118569
118579
  if (resolution.refCount) {
@@ -118604,15 +118614,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118604
118614
  failedLookupLocationPath,
118605
118615
  rootDir,
118606
118616
  rootPath,
118607
- rootSplitLength,
118617
+ rootPathComponents,
118608
118618
  getCurrentDirectory
118609
118619
  );
118610
118620
  if (toWatch) {
118611
118621
  const { dir, dirPath, nonRecursive } = toWatch;
118612
- if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
118613
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
118614
- customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
118615
- }
118616
118622
  if (dirPath === rootPath) {
118617
118623
  Debug.assert(nonRecursive);
118618
118624
  setAtRoot = true;
@@ -118747,20 +118753,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118747
118753
  failedLookupLocationPath,
118748
118754
  rootDir,
118749
118755
  rootPath,
118750
- rootSplitLength,
118756
+ rootPathComponents,
118751
118757
  getCurrentDirectory
118752
118758
  );
118753
118759
  if (toWatch) {
118754
118760
  const { dirPath } = toWatch;
118755
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
118756
- if (refCount) {
118757
- if (refCount === 1) {
118758
- customFailedLookupPaths.delete(failedLookupLocationPath);
118759
- } else {
118760
- Debug.assert(refCount > 1);
118761
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
118762
- }
118763
- }
118764
118761
  if (dirPath === rootPath) {
118765
118762
  removeAtRoot = true;
118766
118763
  } else {
@@ -118858,10 +118855,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118858
118855
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
118859
118856
  (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
118860
118857
  } else {
118861
- if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
118858
+ if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
118862
118859
  return false;
118863
118860
  }
118864
- if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
118861
+ if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
118865
118862
  return false;
118866
118863
  }
118867
118864
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
@@ -118908,7 +118905,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118908
118905
  return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
118909
118906
  }
118910
118907
  function isInvalidatedFailedLookup(locationPath) {
118911
- 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);
118908
+ 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);
118912
118909
  }
118913
118910
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
118914
118911
  var _a2;
@@ -118929,6 +118926,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118929
118926
  typeRoot,
118930
118927
  typeRootPath,
118931
118928
  rootPath,
118929
+ rootPathComponents,
118930
+ getCurrentDirectory,
118932
118931
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
118933
118932
  );
118934
118933
  if (dirPath) {
@@ -118959,7 +118958,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118959
118958
  function canWatchTypeRootPath(typeRoot) {
118960
118959
  if (resolutionHost.getCompilationSettings().typeRoots)
118961
118960
  return true;
118962
- return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
118961
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot));
118963
118962
  }
118964
118963
  }
118965
118964
  function resolutionIsSymlink(resolution) {