typescript 5.1.0-dev.20230330 → 5.1.0-dev.20230401

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/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230330`;
38
+ version = `${versionMajorMinor}.0-dev.20230401`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5336,7 +5336,7 @@ ${lanes.join("\n")}
5336
5336
  queue.pollScheduled = false;
5337
5337
  return queue;
5338
5338
  }
5339
- function pollPollingIntervalQueue(queue) {
5339
+ function pollPollingIntervalQueue(_timeoutType, queue) {
5340
5340
  queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
5341
5341
  if (queue.length) {
5342
5342
  scheduleNextPoll(queue.pollingInterval);
@@ -5345,7 +5345,7 @@ ${lanes.join("\n")}
5345
5345
  queue.pollScheduled = false;
5346
5346
  }
5347
5347
  }
5348
- function pollLowPollingIntervalQueue(queue) {
5348
+ function pollLowPollingIntervalQueue(_timeoutType, queue) {
5349
5349
  pollQueue(
5350
5350
  changedFilesInLastPoll,
5351
5351
  250 /* Low */,
@@ -5353,7 +5353,7 @@ ${lanes.join("\n")}
5353
5353
  0,
5354
5354
  changedFilesInLastPoll.length
5355
5355
  );
5356
- pollPollingIntervalQueue(queue);
5356
+ pollPollingIntervalQueue(_timeoutType, queue);
5357
5357
  if (!queue.pollScheduled && changedFilesInLastPoll.length) {
5358
5358
  scheduleNextPoll(250 /* Low */);
5359
5359
  }
@@ -5410,7 +5410,7 @@ ${lanes.join("\n")}
5410
5410
  }
5411
5411
  }
5412
5412
  function scheduleNextPoll(pollingInterval) {
5413
- pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
5413
+ pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
5414
5414
  }
5415
5415
  }
5416
5416
  function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
@@ -5489,7 +5489,7 @@ ${lanes.join("\n")}
5489
5489
  function scheduleNextPoll() {
5490
5490
  if (!watchedFiles.length || pollScheduled)
5491
5491
  return;
5492
- pollScheduled = host.setTimeout(pollQueue, 2e3 /* High */);
5492
+ pollScheduled = host.setTimeout(pollQueue, 2e3 /* High */, "pollQueue");
5493
5493
  }
5494
5494
  }
5495
5495
  function createSingleWatcherPerName(cache, useCaseSensitiveFileNames, name, callback, createWatcher) {
@@ -5655,7 +5655,7 @@ ${lanes.join("\n")}
5655
5655
  clearTimeout2(timerToUpdateChildWatches);
5656
5656
  timerToUpdateChildWatches = void 0;
5657
5657
  }
5658
- timerToUpdateChildWatches = setTimeout2(onTimerToUpdateChildWatches, 1e3);
5658
+ timerToUpdateChildWatches = setTimeout2(onTimerToUpdateChildWatches, 1e3, "timerToUpdateChildWatches");
5659
5659
  }
5660
5660
  function onTimerToUpdateChildWatches() {
5661
5661
  timerToUpdateChildWatches = void 0;
@@ -7532,7 +7532,6 @@ ${lanes.join("\n")}
7532
7532
  Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, 1 /* Error */, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
7533
7533
  A_get_accessor_must_return_a_value: diag(2378, 1 /* Error */, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
7534
7534
  Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, 1 /* Error */, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
7535
- The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, 1 /* Error */, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"),
7536
7535
  Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, 1 /* Error */, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."),
7537
7536
  Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, 1 /* Error */, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."),
7538
7537
  Overload_signatures_must_all_be_public_private_or_protected: diag(2385, 1 /* Error */, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."),
@@ -18056,6 +18055,9 @@ ${lanes.join("\n")}
18056
18055
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
18057
18056
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
18058
18057
  }
18058
+ function shouldResolveJsRequire(compilerOptions) {
18059
+ return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
18060
+ }
18059
18061
  function getResolvePackageJsonExports(compilerOptions) {
18060
18062
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
18061
18063
  if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@@ -38031,7 +38033,8 @@ ${lanes.join("\n")}
38031
38033
  affectsBuildInfo: true,
38032
38034
  category: Diagnostics.Modules,
38033
38035
  description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
38034
- defaultValueDescription: false
38036
+ defaultValueDescription: false,
38037
+ transpileOptionValue: void 0
38035
38038
  },
38036
38039
  {
38037
38040
  name: "resolvePackageJsonExports",
@@ -43787,7 +43790,7 @@ ${lanes.join("\n")}
43787
43790
  }
43788
43791
  if (!isBindingPattern(node.name)) {
43789
43792
  const possibleVariableDecl = node.kind === 258 /* VariableDeclaration */ ? node : node.parent.parent;
43790
- if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
43793
+ if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
43791
43794
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
43792
43795
  } else if (isBlockOrCatchScoped(node)) {
43793
43796
  bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@@ -47354,7 +47357,7 @@ ${lanes.join("\n")}
47354
47357
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
47355
47358
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
47356
47359
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
47357
- if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
47360
+ if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
47358
47361
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
47359
47362
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
47360
47363
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -47522,7 +47525,7 @@ ${lanes.join("\n")}
47522
47525
  if (!isIdentifier(name)) {
47523
47526
  return void 0;
47524
47527
  }
47525
- const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
47528
+ const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
47526
47529
  const targetSymbol = resolveESModuleSymbol(
47527
47530
  moduleSymbol,
47528
47531
  moduleSpecifier,
@@ -52164,7 +52167,7 @@ ${lanes.join("\n")}
52164
52167
  return;
52165
52168
  }
52166
52169
  let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
52167
- if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
52170
+ if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
52168
52171
  verbatimTargetName = "default" /* Default */;
52169
52172
  }
52170
52173
  const targetName = getInternalSymbolName(target, verbatimTargetName);
@@ -73387,7 +73390,7 @@ ${lanes.join("\n")}
73387
73390
  return anyType;
73388
73391
  }
73389
73392
  }
73390
- if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
73393
+ if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
73391
73394
  return resolveExternalModuleTypeByLiteral(node.arguments[0]);
73392
73395
  }
73393
73396
  const returnType = getReturnTypeOfSignature(signature);
@@ -77092,11 +77095,6 @@ ${lanes.join("\n")}
77092
77095
  error(getter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
77093
77096
  error(setter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
77094
77097
  }
77095
- const getterType = getAnnotatedAccessorType(getter);
77096
- const setterType = getAnnotatedAccessorType(setter);
77097
- if (getterType && setterType) {
77098
- checkTypeAssignableTo(getterType, setterType, getter, Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type);
77099
- }
77100
77098
  }
77101
77099
  }
77102
77100
  const returnType = getTypeOfAccessors(getSymbolOfDeclaration(node));
@@ -117577,7 +117575,7 @@ ${lanes.join("\n")}
117577
117575
  false
117578
117576
  );
117579
117577
  }
117580
- const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
117578
+ const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
117581
117579
  if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
117582
117580
  collectDynamicImportOrRequireCalls(file);
117583
117581
  }
@@ -121177,6 +121175,79 @@ ${lanes.join("\n")}
121177
121175
  }
121178
121176
  return true;
121179
121177
  }
121178
+ function canWatchAtTypes(atTypes, rootPath) {
121179
+ const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
121180
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
121181
+ }
121182
+ function isInDirectoryPath(dir, file) {
121183
+ if (dir === void 0 || file.length <= dir.length) {
121184
+ return false;
121185
+ }
121186
+ return startsWith(file, dir) && file[dir.length] === directorySeparator;
121187
+ }
121188
+ function canWatchAffectingLocation(filePath) {
121189
+ return canWatchDirectoryOrFile(filePath);
121190
+ }
121191
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
121192
+ if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
121193
+ failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
121194
+ const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
121195
+ const failedLookupSplit = failedLookupLocation.split(directorySeparator);
121196
+ Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
121197
+ if (failedLookupPathSplit.length > rootSplitLength + 1) {
121198
+ return {
121199
+ dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
121200
+ dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
121201
+ };
121202
+ } else {
121203
+ return {
121204
+ dir: rootDir,
121205
+ dirPath: rootPath,
121206
+ nonRecursive: false
121207
+ };
121208
+ }
121209
+ }
121210
+ return getDirectoryToWatchFromFailedLookupLocationDirectory(
121211
+ getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
121212
+ getDirectoryPath(failedLookupLocationPath),
121213
+ rootPath
121214
+ );
121215
+ }
121216
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
121217
+ while (pathContainsNodeModules(dirPath)) {
121218
+ dir = getDirectoryPath(dir);
121219
+ dirPath = getDirectoryPath(dirPath);
121220
+ }
121221
+ if (isNodeModulesDirectory(dirPath)) {
121222
+ return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
121223
+ }
121224
+ let nonRecursive = true;
121225
+ let subDirectoryPath, subDirectory;
121226
+ if (rootPath !== void 0) {
121227
+ while (!isInDirectoryPath(dirPath, rootPath)) {
121228
+ const parentPath = getDirectoryPath(dirPath);
121229
+ if (parentPath === dirPath) {
121230
+ break;
121231
+ }
121232
+ nonRecursive = false;
121233
+ subDirectoryPath = dirPath;
121234
+ subDirectory = dir;
121235
+ dirPath = parentPath;
121236
+ dir = getDirectoryPath(dir);
121237
+ }
121238
+ }
121239
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
121240
+ }
121241
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
121242
+ if (isInDirectoryPath(rootPath, typeRootPath)) {
121243
+ return rootPath;
121244
+ }
121245
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
121246
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
121247
+ }
121248
+ function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
121249
+ return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121250
+ }
121180
121251
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
121181
121252
  let filesWithChangedSetOfUnresolvedImports;
121182
121253
  let filesWithInvalidatedResolutions;
@@ -121211,7 +121282,7 @@ ${lanes.join("\n")}
121211
121282
  const customFailedLookupPaths = /* @__PURE__ */ new Map();
121212
121283
  const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
121213
121284
  const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
121214
- const rootDir = rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
121285
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
121215
121286
  const rootPath = rootDir && resolutionHost.toPath(rootDir);
121216
121287
  const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
121217
121288
  const typeRootsWatches = /* @__PURE__ */ new Map();
@@ -121244,12 +121315,6 @@ ${lanes.join("\n")}
121244
121315
  function getResolvedTypeReferenceDirective2(resolution) {
121245
121316
  return resolution.resolvedTypeReferenceDirective;
121246
121317
  }
121247
- function isInDirectoryPath(dir, file) {
121248
- if (dir === void 0 || file.length <= dir.length) {
121249
- return false;
121250
- }
121251
- return startsWith(file, dir) && file[dir.length] === directorySeparator;
121252
- }
121253
121318
  function clear2() {
121254
121319
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
121255
121320
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -121533,55 +121598,6 @@ ${lanes.join("\n")}
121533
121598
  function isNodeModulesAtTypesDirectory(dirPath) {
121534
121599
  return endsWith(dirPath, "/node_modules/@types");
121535
121600
  }
121536
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
121537
- if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
121538
- failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
121539
- const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
121540
- const failedLookupSplit = failedLookupLocation.split(directorySeparator);
121541
- Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
121542
- if (failedLookupPathSplit.length > rootSplitLength + 1) {
121543
- return {
121544
- dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
121545
- dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
121546
- };
121547
- } else {
121548
- return {
121549
- dir: rootDir,
121550
- dirPath: rootPath,
121551
- nonRecursive: false
121552
- };
121553
- }
121554
- }
121555
- return getDirectoryToWatchFromFailedLookupLocationDirectory(
121556
- getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
121557
- getDirectoryPath(failedLookupLocationPath)
121558
- );
121559
- }
121560
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
121561
- while (pathContainsNodeModules(dirPath)) {
121562
- dir = getDirectoryPath(dir);
121563
- dirPath = getDirectoryPath(dirPath);
121564
- }
121565
- if (isNodeModulesDirectory(dirPath)) {
121566
- return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
121567
- }
121568
- let nonRecursive = true;
121569
- let subDirectoryPath, subDirectory;
121570
- if (rootPath !== void 0) {
121571
- while (!isInDirectoryPath(dirPath, rootPath)) {
121572
- const parentPath = getDirectoryPath(dirPath);
121573
- if (parentPath === dirPath) {
121574
- break;
121575
- }
121576
- nonRecursive = false;
121577
- subDirectoryPath = dirPath;
121578
- subDirectory = dir;
121579
- dirPath = parentPath;
121580
- dir = getDirectoryPath(dir);
121581
- }
121582
- }
121583
- return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
121584
- }
121585
121601
  function isPathWithDefaultFailedLookupExtension(path) {
121586
121602
  return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
121587
121603
  }
@@ -121620,7 +121636,14 @@ ${lanes.join("\n")}
121620
121636
  if (failedLookupLocations) {
121621
121637
  for (const failedLookupLocation of failedLookupLocations) {
121622
121638
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
121623
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
121639
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
121640
+ failedLookupLocation,
121641
+ failedLookupLocationPath,
121642
+ rootDir,
121643
+ rootPath,
121644
+ rootSplitLength,
121645
+ getCurrentDirectory
121646
+ );
121624
121647
  if (toWatch) {
121625
121648
  const { dir, dirPath, nonRecursive } = toWatch;
121626
121649
  if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
@@ -121688,7 +121711,7 @@ ${lanes.join("\n")}
121688
121711
  }
121689
121712
  const paths = /* @__PURE__ */ new Set();
121690
121713
  paths.add(locationToWatch);
121691
- let actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
121714
+ let actualWatcher = canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
121692
121715
  cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
121693
121716
  const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
121694
121717
  paths.forEach((path) => {
@@ -121756,7 +121779,14 @@ ${lanes.join("\n")}
121756
121779
  let removeAtRoot = false;
121757
121780
  for (const failedLookupLocation of failedLookupLocations) {
121758
121781
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
121759
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
121782
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
121783
+ failedLookupLocation,
121784
+ failedLookupLocationPath,
121785
+ rootDir,
121786
+ rootPath,
121787
+ rootSplitLength,
121788
+ getCurrentDirectory
121789
+ );
121760
121790
  if (toWatch) {
121761
121791
  const { dirPath } = toWatch;
121762
121792
  const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
@@ -121924,13 +121954,6 @@ ${lanes.join("\n")}
121924
121954
  function closeTypeRootsWatch() {
121925
121955
  clearMap(typeRootsWatches, closeFileWatcher);
121926
121956
  }
121927
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
121928
- if (isInDirectoryPath(rootPath, typeRootPath)) {
121929
- return rootPath;
121930
- }
121931
- const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
121932
- return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
121933
- }
121934
121957
  function createTypeRootsWatch(typeRootPath, typeRoot) {
121935
121958
  return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
121936
121959
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
@@ -121939,7 +121962,12 @@ ${lanes.join("\n")}
121939
121962
  }
121940
121963
  hasChangedAutomaticTypeDirectiveNames = true;
121941
121964
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
121942
- const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
121965
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
121966
+ typeRoot,
121967
+ typeRootPath,
121968
+ rootPath,
121969
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
121970
+ );
121943
121971
  if (dirPath) {
121944
121972
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
121945
121973
  }
@@ -121965,12 +121993,10 @@ ${lanes.join("\n")}
121965
121993
  closeTypeRootsWatch();
121966
121994
  }
121967
121995
  }
121968
- function canWatchTypeRootPath(nodeTypesDirectory) {
121996
+ function canWatchTypeRootPath(typeRoot) {
121969
121997
  if (resolutionHost.getCompilationSettings().typeRoots)
121970
121998
  return true;
121971
- const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
121972
- const dirPath = resolutionHost.toPath(dir);
121973
- return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
121999
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
121974
122000
  }
121975
122001
  }
121976
122002
  function resolutionIsSymlink(resolution) {
@@ -123043,7 +123069,7 @@ ${lanes.join("\n")}
123043
123069
  }
123044
123070
  const pending = clearInvalidateResolutionsOfFailedLookupLocations();
123045
123071
  writeLog(`Scheduling invalidateFailedLookup${pending ? ", Cancelled earlier one" : ""}`);
123046
- timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250);
123072
+ timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250, "timerToInvalidateFailedLookupResolutions");
123047
123073
  }
123048
123074
  function invalidateResolutionsOfFailedLookup() {
123049
123075
  timerToInvalidateFailedLookupResolutions = void 0;
@@ -123059,7 +123085,7 @@ ${lanes.join("\n")}
123059
123085
  host.clearTimeout(timerToUpdateProgram);
123060
123086
  }
123061
123087
  writeLog("Scheduling update");
123062
- timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
123088
+ timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250, "timerToUpdateProgram");
123063
123089
  }
123064
123090
  function scheduleProgramReload() {
123065
123091
  Debug.assert(!!configFileName);
@@ -124969,9 +124995,9 @@ ${lanes.join("\n")}
124969
124995
  if (state.timerToBuildInvalidatedProject) {
124970
124996
  hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
124971
124997
  }
124972
- state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
124998
+ state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, "timerToBuildInvalidatedProject", state, changeDetected);
124973
124999
  }
124974
- function buildNextInvalidatedProject(state, changeDetected) {
125000
+ function buildNextInvalidatedProject(_timeoutType, state, changeDetected) {
124975
125001
  mark("SolutionBuilder::beforeBuild");
124976
125002
  const buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
124977
125003
  mark("SolutionBuilder::afterBuild");
@@ -129067,7 +129093,7 @@ ${lanes.join("\n")}
129067
129093
  // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list.
129068
129094
  typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || // Module agumentation and ambient module changes can add or remove exports available to be auto-imported.
129069
129095
  // Changes elsewhere in the file can change the *type* of an export in a module augmentation,
129070
- // but type info is gathered in getCompletionEntryDetails, which doesnt use the cache.
129096
+ // but type info is gathered in getCompletionEntryDetails, which doesn't use the cache.
129071
129097
  !arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) {
129072
129098
  cache.clear();
129073
129099
  return true;
@@ -137832,7 +137858,7 @@ ${lanes.join("\n")}
137832
137858
  function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) {
137833
137859
  const errorNode = isPropertyAccessExpression(reference.parent) ? reference.parent.name : isBinaryExpression(reference.parent) ? reference.parent : reference;
137834
137860
  const diagnostic = find(diagnostics, (diagnostic2) => diagnostic2.start === errorNode.getStart(sourceFile) && diagnostic2.start + diagnostic2.length === errorNode.getEnd());
137835
- return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (its not valid
137861
+ return diagnostic && contains(errorCodes3, diagnostic.code) || // A Promise is usually not correct in a binary expression (it's not valid
137836
137862
  // in an arithmetic expression and an equality comparison seems unusual),
137837
137863
  // but if the other side of the binary expression has an error, the side
137838
137864
  // is typed `any` which will squash the error that would identify this
@@ -140741,7 +140767,6 @@ ${lanes.join("\n")}
140741
140767
  importClauseOrBindingPattern,
140742
140768
  defaultImport,
140743
140769
  arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
140744
- compilerOptions,
140745
140770
  preferences
140746
140771
  );
140747
140772
  });
@@ -140939,7 +140964,19 @@ ${lanes.join("\n")}
140939
140964
  return 1 /* Allowed */;
140940
140965
  }
140941
140966
  function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) {
140942
- return firstDefined(existingImports, ({ declaration, importKind, symbol, targetFlags }) => {
140967
+ let best;
140968
+ for (const existingImport of existingImports) {
140969
+ const fix = getAddToExistingImportFix(existingImport);
140970
+ if (!fix)
140971
+ continue;
140972
+ const isTypeOnly = isTypeOnlyImportDeclaration(fix.importClauseOrBindingPattern);
140973
+ if (fix.addAsTypeOnly !== 4 /* NotAllowed */ && isTypeOnly || fix.addAsTypeOnly === 4 /* NotAllowed */ && !isTypeOnly) {
140974
+ return fix;
140975
+ }
140976
+ best != null ? best : best = fix;
140977
+ }
140978
+ return best;
140979
+ function getAddToExistingImportFix({ declaration, importKind, symbol, targetFlags }) {
140943
140980
  if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 269 /* ImportEqualsDeclaration */) {
140944
140981
  return void 0;
140945
140982
  }
@@ -140947,11 +140984,13 @@ ${lanes.join("\n")}
140947
140984
  return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 204 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } : void 0;
140948
140985
  }
140949
140986
  const { importClause } = declaration;
140950
- if (!importClause || !isStringLiteralLike(declaration.moduleSpecifier))
140987
+ if (!importClause || !isStringLiteralLike(declaration.moduleSpecifier)) {
140951
140988
  return void 0;
140989
+ }
140952
140990
  const { name, namedBindings } = importClause;
140953
- if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings))
140991
+ if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) {
140954
140992
  return void 0;
140993
+ }
140955
140994
  const addAsTypeOnly = getAddAsTypeOnly(
140956
140995
  isValidTypeOnlyUseSite,
140957
140996
  /*isForNewImportDeclaration*/
@@ -140962,10 +141001,12 @@ ${lanes.join("\n")}
140962
141001
  compilerOptions
140963
141002
  );
140964
141003
  if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one
140965
- addAsTypeOnly === 2 /* Required */ && namedBindings))
141004
+ addAsTypeOnly === 2 /* Required */ && namedBindings)) {
140966
141005
  return void 0;
140967
- if (importKind === 0 /* Named */ && (namedBindings == null ? void 0 : namedBindings.kind) === 272 /* NamespaceImport */)
141006
+ }
141007
+ if (importKind === 0 /* Named */ && (namedBindings == null ? void 0 : namedBindings.kind) === 272 /* NamespaceImport */) {
140968
141008
  return void 0;
141009
+ }
140969
141010
  return {
140970
141011
  kind: 2 /* AddToExisting */,
140971
141012
  importClauseOrBindingPattern: importClause,
@@ -140973,7 +141014,7 @@ ${lanes.join("\n")}
140973
141014
  moduleSpecifier: declaration.moduleSpecifier.text,
140974
141015
  addAsTypeOnly
140975
141016
  };
140976
- });
141017
+ }
140977
141018
  }
140978
141019
  function createExistingImportMap(checker, importingFile, compilerOptions) {
140979
141020
  let importMap;
@@ -141402,7 +141443,6 @@ ${lanes.join("\n")}
141402
141443
  importClauseOrBindingPattern,
141403
141444
  importKind === 1 /* Default */ ? { name: symbolName2, addAsTypeOnly } : void 0,
141404
141445
  importKind === 0 /* Named */ ? [{ name: symbolName2, addAsTypeOnly }] : emptyArray,
141405
- compilerOptions,
141406
141446
  preferences
141407
141447
  );
141408
141448
  const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier);
@@ -141504,7 +141544,7 @@ ${lanes.join("\n")}
141504
141544
  }
141505
141545
  }
141506
141546
  }
141507
- function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions, preferences) {
141547
+ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, preferences) {
141508
141548
  var _a2;
141509
141549
  if (clause.kind === 204 /* ObjectBindingPattern */) {
141510
141550
  if (defaultImport) {
@@ -141522,7 +141562,6 @@ ${lanes.join("\n")}
141522
141562
  }
141523
141563
  const promoteFromTypeOnly2 = clause.isTypeOnly && some([defaultImport, ...namedImports], (i) => (i == null ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */);
141524
141564
  const existingSpecifiers = clause.namedBindings && ((_a2 = tryCast(clause.namedBindings, isNamedImports)) == null ? void 0 : _a2.elements);
141525
- const convertExistingToTypeOnly = promoteFromTypeOnly2 && importNameElisionDisabled(compilerOptions);
141526
141565
  if (defaultImport) {
141527
141566
  Debug.assert(!clause.name, "Cannot add a default import to an import clause that already has one");
141528
141567
  changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), factory.createIdentifier(defaultImport.name), { suffix: ", " });
@@ -141553,7 +141592,7 @@ ${lanes.join("\n")}
141553
141592
  const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
141554
141593
  if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
141555
141594
  for (const spec of newSpecifiers) {
141556
- const insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
141595
+ const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
141557
141596
  changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
141558
141597
  }
141559
141598
  } else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
@@ -141573,7 +141612,7 @@ ${lanes.join("\n")}
141573
141612
  }
141574
141613
  if (promoteFromTypeOnly2) {
141575
141614
  changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(clause, sourceFile));
141576
- if (convertExistingToTypeOnly && existingSpecifiers) {
141615
+ if (existingSpecifiers) {
141577
141616
  for (const specifier of existingSpecifiers) {
141578
141617
  changes.insertModifierBefore(sourceFile, 155 /* TypeKeyword */, specifier);
141579
141618
  }
@@ -153776,7 +153815,7 @@ ${lanes.join("\n")}
153776
153815
  */
153777
153816
  this.markSeenReExportRHS = nodeSeenTracker();
153778
153817
  this.symbolIdToReferences = [];
153779
- // Source file ID symbol ID Whether the symbol has been searched for in the source file.
153818
+ // Source file ID -> symbol ID -> Whether the symbol has been searched for in the source file.
153780
153819
  this.sourceFileToSeenSymbols = [];
153781
153820
  }
153782
153821
  includesSourceFile(sourceFile) {
@@ -162920,7 +162959,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162920
162959
  if (start !== end) {
162921
162960
  const textSpan = createTextSpanFromBounds(start, end);
162922
162961
  if (!selectionRange || // Skip ranges that are identical to the parent
162923
- !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that dont contain the original position
162962
+ !textSpansEqual(textSpan, selectionRange.textSpan) && // Skip ranges that don't contain the original position
162924
162963
  textSpanIntersectsWithPosition(textSpan, pos)) {
162925
162964
  selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
162926
162965
  }
@@ -168289,6 +168328,8 @@ ${options.prefix}` : "\n" : options.prefix
168289
168328
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
168290
168329
  canProduceDiagnostics: () => canProduceDiagnostics,
168291
168330
  canUsePropertyAccess: () => canUsePropertyAccess,
168331
+ canWatchAffectingLocation: () => canWatchAffectingLocation,
168332
+ canWatchAtTypes: () => canWatchAtTypes,
168292
168333
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
168293
168334
  cartesianProduct: () => cartesianProduct,
168294
168335
  cast: () => cast,
@@ -168736,6 +168777,8 @@ ${options.prefix}` : "\n" : options.prefix
168736
168777
  getDiagnosticText: () => getDiagnosticText,
168737
168778
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
168738
168779
  getDirectoryPath: () => getDirectoryPath,
168780
+ getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
168781
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
168739
168782
  getDocumentPositionMapper: () => getDocumentPositionMapper,
168740
168783
  getESModuleInterop: () => getESModuleInterop,
168741
168784
  getEditsForFileRename: () => getEditsForFileRename,
@@ -169005,6 +169048,7 @@ ${options.prefix}` : "\n" : options.prefix
169005
169048
  getRestParameterElementType: () => getRestParameterElementType,
169006
169049
  getRightMostAssignedExpression: () => getRightMostAssignedExpression,
169007
169050
  getRootDeclaration: () => getRootDeclaration,
169051
+ getRootDirectoryOfResolutionCache: () => getRootDirectoryOfResolutionCache,
169008
169052
  getRootLength: () => getRootLength,
169009
169053
  getScriptKind: () => getScriptKind,
169010
169054
  getScriptKindFromFileName: () => getScriptKindFromFileName,
@@ -170102,6 +170146,7 @@ ${options.prefix}` : "\n" : options.prefix
170102
170146
  setValueDeclaration: () => setValueDeclaration,
170103
170147
  shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
170104
170148
  shouldPreserveConstEnums: () => shouldPreserveConstEnums,
170149
+ shouldResolveJsRequire: () => shouldResolveJsRequire,
170105
170150
  shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
170106
170151
  showModuleSpecifier: () => showModuleSpecifier,
170107
170152
  signatureHasLiteralTypes: () => signatureHasLiteralTypes,