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.
@@ -106,4 +106,13 @@ declare namespace Intl {
106
106
  */
107
107
  supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
108
108
  };
109
+
110
+ /**
111
+ * Returns a sorted array of the supported collation, calendar, currency, numbering system, timezones, and units by the implementation.
112
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
113
+ *
114
+ * @param key A string indicating the category of values to return.
115
+ * @returns A sorted array of the supported values.
116
+ */
117
+ function supportedValuesOf(key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"): string[];
109
118
  }
package/lib/lib.es5.d.ts CHANGED
@@ -332,9 +332,14 @@ interface CallableFunction extends Function {
332
332
  /**
333
333
  * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
334
334
  * @param thisArg The object to be used as the this object.
335
- * @param args An array of argument values to be passed to the function.
336
335
  */
337
336
  apply<T, R>(this: (this: T) => R, thisArg: T): R;
337
+
338
+ /**
339
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
340
+ * @param thisArg The object to be used as the this object.
341
+ * @param args An array of argument values to be passed to the function.
342
+ */
338
343
  apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
339
344
 
340
345
  /**
@@ -348,23 +353,29 @@ interface CallableFunction extends Function {
348
353
  * For a given function, creates a bound function that has the same body as the original function.
349
354
  * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
350
355
  * @param thisArg The object to be used as the this object.
351
- * @param args Arguments to bind to the parameters of the function.
352
356
  */
353
357
  bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
354
- bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
355
- bind<T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R;
356
- bind<T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R;
357
- bind<T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R;
358
- bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
358
+
359
+ /**
360
+ * For a given function, creates a bound function that has the same body as the original function.
361
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
362
+ * @param thisArg The object to be used as the this object.
363
+ * @param args Arguments to bind to the parameters of the function.
364
+ */
365
+ bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
359
366
  }
360
367
 
361
368
  interface NewableFunction extends Function {
362
369
  /**
363
370
  * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
364
371
  * @param thisArg The object to be used as the this object.
365
- * @param args An array of argument values to be passed to the function.
366
372
  */
367
373
  apply<T>(this: new () => T, thisArg: T): void;
374
+ /**
375
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
376
+ * @param thisArg The object to be used as the this object.
377
+ * @param args An array of argument values to be passed to the function.
378
+ */
368
379
  apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;
369
380
 
370
381
  /**
@@ -378,14 +389,16 @@ interface NewableFunction extends Function {
378
389
  * For a given function, creates a bound function that has the same body as the original function.
379
390
  * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
380
391
  * @param thisArg The object to be used as the this object.
381
- * @param args Arguments to bind to the parameters of the function.
382
392
  */
383
393
  bind<T>(this: T, thisArg: any): T;
384
- bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
385
- bind<A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R;
386
- bind<A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R;
387
- bind<A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R;
388
- bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
394
+
395
+ /**
396
+ * For a given function, creates a bound function that has the same body as the original function.
397
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
398
+ * @param thisArg The object to be used as the this object.
399
+ * @param args Arguments to bind to the parameters of the function.
400
+ */
401
+ bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
389
402
  }
390
403
 
391
404
  interface IArguments {
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.1";
21
- var version = `${versionMajorMinor}.0-dev.20230412`;
21
+ var version = `${versionMajorMinor}.0-dev.20230414`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -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;
@@ -18559,7 +18563,7 @@ function createNodeFactory(flags, baseFactory2) {
18559
18563
  function createBigIntLiteral(value) {
18560
18564
  const node = createBaseToken(10 /* BigIntLiteral */);
18561
18565
  node.text = typeof value === "string" ? value : pseudoBigIntToString(value) + "n";
18562
- node.transformFlags |= 4 /* ContainsESNext */;
18566
+ node.transformFlags |= 32 /* ContainsES2020 */;
18563
18567
  return node;
18564
18568
  }
18565
18569
  function createBaseStringLiteral(text, isSingleQuote) {
@@ -20069,7 +20073,7 @@ function createNodeFactory(flags, baseFactory2) {
20069
20073
  node.transformFlags |= 1024 /* ContainsES2015 */;
20070
20074
  break;
20071
20075
  case 102 /* ImportKeyword */:
20072
- node.transformFlags |= 4 /* ContainsESNext */;
20076
+ node.transformFlags |= 32 /* ContainsES2020 */;
20073
20077
  break;
20074
20078
  default:
20075
20079
  return Debug.assertNever(keywordToken);
@@ -20597,7 +20601,7 @@ function createNodeFactory(flags, baseFactory2) {
20597
20601
  function createNamespaceExport(name) {
20598
20602
  const node = createBaseDeclaration(279 /* NamespaceExport */);
20599
20603
  node.name = name;
20600
- node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */;
20604
+ node.transformFlags |= propagateChildFlags(node.name) | 32 /* ContainsES2020 */;
20601
20605
  node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
20602
20606
  return node;
20603
20607
  }
@@ -44749,11 +44753,6 @@ function createTypeChecker(host) {
44749
44753
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
44750
44754
  } else if (result.flags & 256 /* RegularEnum */) {
44751
44755
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44752
- } else {
44753
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
44754
- if (shouldPreserveConstEnums(compilerOptions)) {
44755
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44756
- }
44757
44756
  }
44758
44757
  if (diagnosticMessage) {
44759
44758
  addRelatedInfo(
@@ -61581,40 +61580,31 @@ function createTypeChecker(host) {
61581
61580
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
61582
61581
  }
61583
61582
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
61584
- return findMatchingDiscriminantType(
61585
- source,
61586
- target,
61587
- isRelatedTo,
61588
- /*skipPartial*/
61589
- true
61590
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
61583
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
61591
61584
  }
61592
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
61593
- const discriminable = target.types.map((_) => void 0);
61585
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
61586
+ const types = target.types;
61587
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
61594
61588
  for (const [getDiscriminatingType, propertyName] of discriminators) {
61595
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
61596
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
61597
- continue;
61589
+ let matched = false;
61590
+ for (let i = 0; i < types.length; i++) {
61591
+ if (include[i]) {
61592
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
61593
+ if (targetType && related(getDiscriminatingType(), targetType)) {
61594
+ matched = true;
61595
+ } else {
61596
+ include[i] = 3 /* Maybe */;
61597
+ }
61598
+ }
61598
61599
  }
61599
- let i = 0;
61600
- for (const type of target.types) {
61601
- const targetType = getTypeOfPropertyOfType(type, propertyName);
61602
- if (targetType && related(getDiscriminatingType(), targetType)) {
61603
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
61604
- } else {
61605
- discriminable[i] = false;
61600
+ for (let i = 0; i < types.length; i++) {
61601
+ if (include[i] === 3 /* Maybe */) {
61602
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
61606
61603
  }
61607
- i++;
61608
61604
  }
61609
61605
  }
61610
- const match = discriminable.indexOf(
61611
- /*searchElement*/
61612
- true
61613
- );
61614
- if (match === -1) {
61615
- return defaultValue;
61616
- }
61617
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
61606
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
61607
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
61618
61608
  }
61619
61609
  function isWeakType(type) {
61620
61610
  if (type.flags & 524288 /* Object */) {
@@ -66918,8 +66908,7 @@ function createTypeChecker(host) {
66918
66908
  (s) => [() => undefinedType, s.escapedName]
66919
66909
  )
66920
66910
  ),
66921
- isTypeAssignableTo,
66922
- contextualType
66911
+ isTypeAssignableTo
66923
66912
  );
66924
66913
  }
66925
66914
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -66938,8 +66927,7 @@ function createTypeChecker(host) {
66938
66927
  (s) => [() => undefinedType, s.escapedName]
66939
66928
  )
66940
66929
  ),
66941
- isTypeAssignableTo,
66942
- contextualType
66930
+ isTypeAssignableTo
66943
66931
  );
66944
66932
  }
66945
66933
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -82953,7 +82941,7 @@ function createTypeChecker(host) {
82953
82941
  }
82954
82942
  return type;
82955
82943
  }
82956
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
82944
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
82957
82945
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
82958
82946
  const match = getMatchingUnionConstituentForType(target, source);
82959
82947
  if (match) {
@@ -82963,14 +82951,10 @@ function createTypeChecker(host) {
82963
82951
  if (sourceProperties) {
82964
82952
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
82965
82953
  if (sourcePropertiesFiltered) {
82966
- return discriminateTypeByDiscriminableItems(
82967
- target,
82968
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
82969
- isRelatedTo,
82970
- /*defaultValue*/
82971
- void 0,
82972
- skipPartial
82973
- );
82954
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
82955
+ if (discriminated !== target) {
82956
+ return discriminated;
82957
+ }
82974
82958
  }
82975
82959
  }
82976
82960
  }
@@ -118119,60 +118103,62 @@ function removeIgnoredPath(path) {
118119
118103
  }
118120
118104
  return some(ignoredPaths, (searchPath) => stringContains(path, searchPath)) ? void 0 : path;
118121
118105
  }
118122
- function canWatchDirectoryOrFile(dirPath) {
118123
- const rootLength = getRootLength(dirPath);
118124
- if (dirPath.length === rootLength) {
118125
- return false;
118126
- }
118127
- let nextDirectorySeparator = dirPath.indexOf(directorySeparator, rootLength);
118128
- if (nextDirectorySeparator === -1) {
118129
- return false;
118130
- }
118131
- let pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
118132
- const isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */;
118133
- if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
118134
- pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) {
118135
- nextDirectorySeparator = dirPath.indexOf(directorySeparator, nextDirectorySeparator + 1);
118136
- if (nextDirectorySeparator === -1) {
118137
- return false;
118138
- }
118139
- pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
118140
- }
118141
- if (isNonDirectorySeparatorRoot && pathPartForUserCheck.search(/users\//i) !== 0) {
118142
- return true;
118106
+ function perceivedOsRootLengthForWatching(pathComponents2, length2) {
118107
+ if (length2 <= 1)
118108
+ return 1;
118109
+ let userCheckIndex = 1;
118110
+ let isDosStyle = pathComponents2[0].search(/[a-zA-Z]:/) === 0;
118111
+ if (pathComponents2[0] !== directorySeparator && !isDosStyle && // Non dos style paths
118112
+ pathComponents2[1].search(/[a-zA-Z]\$$/) === 0) {
118113
+ if (length2 === 2)
118114
+ return 2;
118115
+ userCheckIndex = 2;
118116
+ isDosStyle = true;
118143
118117
  }
118144
- for (let searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
118145
- searchIndex = dirPath.indexOf(directorySeparator, searchIndex) + 1;
118146
- if (searchIndex === 0) {
118147
- return false;
118148
- }
118118
+ if (isDosStyle && !pathComponents2[userCheckIndex].match(/^users$/i)) {
118119
+ return userCheckIndex;
118149
118120
  }
118150
- return true;
118121
+ return userCheckIndex + 2;
118122
+ }
118123
+ function canWatchDirectoryOrFile(pathComponents2, length2) {
118124
+ if (length2 === void 0)
118125
+ length2 = pathComponents2.length;
118126
+ if (length2 <= 2)
118127
+ return false;
118128
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(pathComponents2, length2);
118129
+ return length2 > perceivedOsRootLength + 1;
118151
118130
  }
118152
- function canWatchAtTypes(atTypes, rootPath) {
118153
- const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
118154
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
118131
+ function canWatchAtTypes(atTypes) {
118132
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(getDirectoryPath(atTypes));
118155
118133
  }
118156
- function isInDirectoryPath(dir, file) {
118157
- if (dir === void 0 || file.length <= dir.length) {
118134
+ function isInDirectoryPath(dirComponents, fileOrDirComponents) {
118135
+ if (fileOrDirComponents.length < fileOrDirComponents.length)
118158
118136
  return false;
118137
+ for (let i = 0; i < dirComponents.length; i++) {
118138
+ if (fileOrDirComponents[i] !== dirComponents[i])
118139
+ return false;
118159
118140
  }
118160
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
118141
+ return true;
118142
+ }
118143
+ function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
118144
+ return canWatchDirectoryOrFile(getPathComponents(fileOrDirPath));
118161
118145
  }
118162
118146
  function canWatchAffectingLocation(filePath) {
118163
- return canWatchDirectoryOrFile(filePath);
118164
- }
118165
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
118166
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
118167
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118168
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
118169
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
118170
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
118171
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
118172
- return {
118173
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
118174
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
118175
- };
118147
+ return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
118148
+ }
118149
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory) {
118150
+ const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
118151
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
118152
+ const failedLookupComponents = getPathComponents(failedLookupLocation);
118153
+ const perceivedOsRootLength = perceivedOsRootLengthForWatching(failedLookupPathComponents, failedLookupPathComponents.length);
118154
+ if (failedLookupPathComponents.length <= perceivedOsRootLength + 1)
118155
+ return void 0;
118156
+ const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
118157
+ if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1)
118158
+ return void 0;
118159
+ if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
118160
+ if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
118161
+ return getDirectoryOfFailedLookupWatch(failedLookupComponents, failedLookupPathComponents, Math.max(rootPathComponents.length + 1, perceivedOsRootLength + 1));
118176
118162
  } else {
118177
118163
  return {
118178
118164
  dir: rootDir,
@@ -118182,45 +118168,55 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
118182
118168
  }
118183
118169
  }
118184
118170
  return getDirectoryToWatchFromFailedLookupLocationDirectory(
118185
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
118186
- getDirectoryPath(failedLookupLocationPath),
118187
- rootPath
118171
+ failedLookupComponents,
118172
+ failedLookupPathComponents,
118173
+ failedLookupPathComponents.length - 1,
118174
+ perceivedOsRootLength,
118175
+ nodeModulesIndex,
118176
+ rootPathComponents
118188
118177
  );
118189
118178
  }
118190
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
118191
- while (pathContainsNodeModules(dirPath)) {
118192
- dir = getDirectoryPath(dir);
118193
- dirPath = getDirectoryPath(dirPath);
118194
- }
118195
- if (isNodeModulesDirectory(dirPath)) {
118196
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
118179
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents) {
118180
+ if (nodeModulesIndex !== -1) {
118181
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, nodeModulesIndex + 1);
118197
118182
  }
118198
118183
  let nonRecursive = true;
118199
- let subDirectoryPath, subDirectory;
118200
- if (rootPath !== void 0) {
118201
- while (!isInDirectoryPath(dirPath, rootPath)) {
118202
- const parentPath = getDirectoryPath(dirPath);
118203
- if (parentPath === dirPath) {
118204
- break;
118205
- }
118184
+ let length2 = dirPathComponentsLength;
118185
+ for (let i = 0; i < dirPathComponentsLength; i++) {
118186
+ if (dirPathComponents[i] !== rootPathComponents[i]) {
118206
118187
  nonRecursive = false;
118207
- subDirectoryPath = dirPath;
118208
- subDirectory = dir;
118209
- dirPath = parentPath;
118210
- dir = getDirectoryPath(dir);
118188
+ length2 = Math.max(i + 1, perceivedOsRootLength + 1);
118189
+ break;
118211
118190
  }
118212
118191
  }
118213
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
118192
+ return getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive);
118193
+ }
118194
+ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, length2, nonRecursive) {
118195
+ return {
118196
+ dir: getPathFromPathComponents(dirComponents, length2),
118197
+ dirPath: getPathFromPathComponents(dirPathComponents, length2),
118198
+ nonRecursive
118199
+ };
118214
118200
  }
118215
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
118216
- if (isInDirectoryPath(rootPath, typeRootPath)) {
118201
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, filterCustomPath) {
118202
+ const typeRootPathComponents = getPathComponents(typeRootPath);
118203
+ if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
118217
118204
  return rootPath;
118218
118205
  }
118219
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
118206
+ typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
118207
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(
118208
+ getPathComponents(typeRoot),
118209
+ typeRootPathComponents,
118210
+ typeRootPathComponents.length,
118211
+ perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
118212
+ typeRootPathComponents.indexOf("node_modules"),
118213
+ rootPathComponents
118214
+ );
118220
118215
  return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
118221
118216
  }
118222
118217
  function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
118223
- return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
118218
+ const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory());
118219
+ return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized;
118224
118220
  }
118225
118221
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
118226
118222
  let filesWithChangedSetOfUnresolvedImports;
@@ -118252,13 +118248,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118252
118248
  resolutionHost.getCompilationSettings(),
118253
118249
  moduleResolutionCache.getPackageJsonInfoCache()
118254
118250
  );
118255
- const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
118256
- const customFailedLookupPaths = /* @__PURE__ */ new Map();
118257
118251
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
118258
118252
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
118259
118253
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
118260
- const rootPath = rootDir && resolutionHost.toPath(rootDir);
118261
- const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
118254
+ const rootPath = resolutionHost.toPath(rootDir);
118255
+ const rootPathComponents = getPathComponents(rootPath);
118262
118256
  const typeRootsWatches = /* @__PURE__ */ new Map();
118263
118257
  return {
118264
118258
  getModuleResolutionCache: () => moduleResolutionCache,
@@ -118292,7 +118286,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118292
118286
  function clear2() {
118293
118287
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
118294
118288
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
118295
- customFailedLookupPaths.clear();
118296
118289
  nonRelativeExternalModuleResolutions.clear();
118297
118290
  closeTypeRootsWatch();
118298
118291
  resolvedModuleNames.clear();
@@ -118572,9 +118565,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118572
118565
  function isNodeModulesAtTypesDirectory(dirPath) {
118573
118566
  return endsWith(dirPath, "/node_modules/@types");
118574
118567
  }
118575
- function isPathWithDefaultFailedLookupExtension(path) {
118576
- return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
118577
- }
118578
118568
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118579
118569
  var _a2, _b;
118580
118570
  if (resolution.refCount) {
@@ -118615,15 +118605,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118615
118605
  failedLookupLocationPath,
118616
118606
  rootDir,
118617
118607
  rootPath,
118618
- rootSplitLength,
118608
+ rootPathComponents,
118619
118609
  getCurrentDirectory
118620
118610
  );
118621
118611
  if (toWatch) {
118622
118612
  const { dir, dirPath, nonRecursive } = toWatch;
118623
- if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
118624
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
118625
- customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
118626
- }
118627
118613
  if (dirPath === rootPath) {
118628
118614
  Debug.assert(nonRecursive);
118629
118615
  setAtRoot = true;
@@ -118758,20 +118744,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118758
118744
  failedLookupLocationPath,
118759
118745
  rootDir,
118760
118746
  rootPath,
118761
- rootSplitLength,
118747
+ rootPathComponents,
118762
118748
  getCurrentDirectory
118763
118749
  );
118764
118750
  if (toWatch) {
118765
118751
  const { dirPath } = toWatch;
118766
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
118767
- if (refCount) {
118768
- if (refCount === 1) {
118769
- customFailedLookupPaths.delete(failedLookupLocationPath);
118770
- } else {
118771
- Debug.assert(refCount > 1);
118772
- customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
118773
- }
118774
- }
118775
118752
  if (dirPath === rootPath) {
118776
118753
  removeAtRoot = true;
118777
118754
  } else {
@@ -118869,10 +118846,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118869
118846
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
118870
118847
  (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
118871
118848
  } else {
118872
- if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
118849
+ if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
118873
118850
  return false;
118874
118851
  }
118875
- if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
118852
+ if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
118876
118853
  return false;
118877
118854
  }
118878
118855
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
@@ -118919,7 +118896,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118919
118896
  return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
118920
118897
  }
118921
118898
  function isInvalidatedFailedLookup(locationPath) {
118922
- 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);
118899
+ 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);
118923
118900
  }
118924
118901
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
118925
118902
  var _a2;
@@ -118940,6 +118917,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118940
118917
  typeRoot,
118941
118918
  typeRootPath,
118942
118919
  rootPath,
118920
+ rootPathComponents,
118921
+ getCurrentDirectory,
118943
118922
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
118944
118923
  );
118945
118924
  if (dirPath) {
@@ -118970,7 +118949,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118970
118949
  function canWatchTypeRootPath(typeRoot) {
118971
118950
  if (resolutionHost.getCompilationSettings().typeRoots)
118972
118951
  return true;
118973
- return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
118952
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot));
118974
118953
  }
118975
118954
  }
118976
118955
  function resolutionIsSymlink(resolution) {