typescript 5.7.0-dev.20240903 → 5.7.0-dev.20240911

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
@@ -259,6 +259,7 @@ __export(typescript_exports, {
259
259
  canWatchAffectingLocation: () => canWatchAffectingLocation,
260
260
  canWatchAtTypes: () => canWatchAtTypes,
261
261
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
262
+ canWatchDirectoryOrFilePath: () => canWatchDirectoryOrFilePath,
262
263
  cartesianProduct: () => cartesianProduct,
263
264
  cast: () => cast,
264
265
  chainBundle: () => chainBundle,
@@ -591,6 +592,7 @@ __export(typescript_exports, {
591
592
  forEach: () => forEach,
592
593
  forEachAncestor: () => forEachAncestor,
593
594
  forEachAncestorDirectory: () => forEachAncestorDirectory,
595
+ forEachAncestorDirectoryStoppingAtGlobalCache: () => forEachAncestorDirectoryStoppingAtGlobalCache,
594
596
  forEachChild: () => forEachChild,
595
597
  forEachChildRecursively: () => forEachChildRecursively,
596
598
  forEachEmittedFile: () => forEachEmittedFile,
@@ -1204,7 +1206,7 @@ __export(typescript_exports, {
1204
1206
  isBooleanLiteral: () => isBooleanLiteral,
1205
1207
  isBreakOrContinueStatement: () => isBreakOrContinueStatement,
1206
1208
  isBreakStatement: () => isBreakStatement,
1207
- isBuild: () => isBuild,
1209
+ isBuildCommand: () => isBuildCommand,
1208
1210
  isBuildInfoFile: () => isBuildInfoFile,
1209
1211
  isBuilderProgram: () => isBuilderProgram,
1210
1212
  isBundle: () => isBundle,
@@ -2119,6 +2121,7 @@ __export(typescript_exports, {
2119
2121
  tagNamesAreEquivalent: () => tagNamesAreEquivalent,
2120
2122
  takeWhile: () => takeWhile,
2121
2123
  targetOptionDeclaration: () => targetOptionDeclaration,
2124
+ targetToLibMap: () => targetToLibMap,
2122
2125
  testFormatSettings: () => testFormatSettings,
2123
2126
  textChangeRangeIsUnchanged: () => textChangeRangeIsUnchanged,
2124
2127
  textChangeRangeNewSpan: () => textChangeRangeNewSpan,
@@ -2212,6 +2215,7 @@ __export(typescript_exports, {
2212
2215
  tryRemoveExtension: () => tryRemoveExtension,
2213
2216
  tryRemovePrefix: () => tryRemovePrefix,
2214
2217
  tryRemoveSuffix: () => tryRemoveSuffix,
2218
+ tscBuildOption: () => tscBuildOption,
2215
2219
  typeAcquisitionDeclarations: () => typeAcquisitionDeclarations,
2216
2220
  typeAliasNamePart: () => typeAliasNamePart,
2217
2221
  typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
@@ -2265,7 +2269,7 @@ module.exports = __toCommonJS(typescript_exports);
2265
2269
 
2266
2270
  // src/compiler/corePublic.ts
2267
2271
  var versionMajorMinor = "5.7";
2268
- var version = `${versionMajorMinor}.0-dev.20240903`;
2272
+ var version = `${versionMajorMinor}.0-dev.20240911`;
2269
2273
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2270
2274
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2271
2275
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -14544,29 +14548,33 @@ function isExternalModuleNameRelative(moduleName) {
14544
14548
  function sortAndDeduplicateDiagnostics(diagnostics) {
14545
14549
  return sortAndDeduplicate(diagnostics, compareDiagnostics, diagnosticsEqualityComparer);
14546
14550
  }
14551
+ var targetToLibMap = /* @__PURE__ */ new Map([
14552
+ [99 /* ESNext */, "lib.esnext.full.d.ts"],
14553
+ [10 /* ES2023 */, "lib.es2023.full.d.ts"],
14554
+ [9 /* ES2022 */, "lib.es2022.full.d.ts"],
14555
+ [8 /* ES2021 */, "lib.es2021.full.d.ts"],
14556
+ [7 /* ES2020 */, "lib.es2020.full.d.ts"],
14557
+ [6 /* ES2019 */, "lib.es2019.full.d.ts"],
14558
+ [5 /* ES2018 */, "lib.es2018.full.d.ts"],
14559
+ [4 /* ES2017 */, "lib.es2017.full.d.ts"],
14560
+ [3 /* ES2016 */, "lib.es2016.full.d.ts"],
14561
+ [2 /* ES2015 */, "lib.es6.d.ts"]
14562
+ // We don't use lib.es2015.full.d.ts due to breaking change.
14563
+ ]);
14547
14564
  function getDefaultLibFileName(options) {
14548
- switch (getEmitScriptTarget(options)) {
14565
+ const target = getEmitScriptTarget(options);
14566
+ switch (target) {
14549
14567
  case 99 /* ESNext */:
14550
- return "lib.esnext.full.d.ts";
14551
14568
  case 10 /* ES2023 */:
14552
- return "lib.es2023.full.d.ts";
14553
14569
  case 9 /* ES2022 */:
14554
- return "lib.es2022.full.d.ts";
14555
14570
  case 8 /* ES2021 */:
14556
- return "lib.es2021.full.d.ts";
14557
14571
  case 7 /* ES2020 */:
14558
- return "lib.es2020.full.d.ts";
14559
14572
  case 6 /* ES2019 */:
14560
- return "lib.es2019.full.d.ts";
14561
14573
  case 5 /* ES2018 */:
14562
- return "lib.es2018.full.d.ts";
14563
14574
  case 4 /* ES2017 */:
14564
- return "lib.es2017.full.d.ts";
14565
14575
  case 3 /* ES2016 */:
14566
- return "lib.es2016.full.d.ts";
14567
14576
  case 2 /* ES2015 */:
14568
- return "lib.es6.d.ts";
14569
- // We don't use lib.es2015.full.d.ts due to breaking change.
14577
+ return targetToLibMap.get(target);
14570
14578
  default:
14571
14579
  return "lib.d.ts";
14572
14580
  }
@@ -31277,23 +31285,21 @@ function hasRecordedExternalHelpers(sourceFile) {
31277
31285
  }
31278
31286
  function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
31279
31287
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
31280
- let namedBindings;
31281
31288
  const moduleKind = getEmitModuleKind(compilerOptions);
31282
- if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
31283
- const helpers = getEmitHelpers(sourceFile);
31289
+ const impliedModuleKind = getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions);
31290
+ const helpers = getImportedHelpers(sourceFile);
31291
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || impliedModuleKind === 99 /* ESNext */ || impliedModuleKind === void 0 && moduleKind === 200 /* Preserve */) {
31284
31292
  if (helpers) {
31285
31293
  const helperNames = [];
31286
31294
  for (const helper of helpers) {
31287
- if (!helper.scoped) {
31288
- const importName = helper.importName;
31289
- if (importName) {
31290
- pushIfUnique(helperNames, importName);
31291
- }
31295
+ const importName = helper.importName;
31296
+ if (importName) {
31297
+ pushIfUnique(helperNames, importName);
31292
31298
  }
31293
31299
  }
31294
31300
  if (some(helperNames)) {
31295
31301
  helperNames.sort(compareStringsCaseSensitive);
31296
- namedBindings = nodeFactory.createNamedImports(
31302
+ const namedBindings = nodeFactory.createNamedImports(
31297
31303
  map(helperNames, (name) => isFileLevelUniqueName(sourceFile, name) ? nodeFactory.createImportSpecifier(
31298
31304
  /*isTypeOnly*/
31299
31305
  false,
@@ -31310,57 +31316,54 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
31310
31316
  const parseNode = getOriginalNode(sourceFile, isSourceFile);
31311
31317
  const emitNode = getOrCreateEmitNode(parseNode);
31312
31318
  emitNode.externalHelpers = true;
31319
+ const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
31320
+ /*modifiers*/
31321
+ void 0,
31322
+ nodeFactory.createImportClause(
31323
+ /*isTypeOnly*/
31324
+ false,
31325
+ /*name*/
31326
+ void 0,
31327
+ namedBindings
31328
+ ),
31329
+ nodeFactory.createStringLiteral(externalHelpersModuleNameText),
31330
+ /*attributes*/
31331
+ void 0
31332
+ );
31333
+ addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
31334
+ return externalHelpersImportDeclaration;
31313
31335
  }
31314
31336
  }
31315
31337
  } else {
31316
- const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
31338
+ const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
31317
31339
  if (externalHelpersModuleName) {
31318
- namedBindings = nodeFactory.createNamespaceImport(externalHelpersModuleName);
31319
- }
31320
- }
31321
- if (namedBindings) {
31322
- const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
31323
- /*modifiers*/
31324
- void 0,
31325
- nodeFactory.createImportClause(
31340
+ const externalHelpersImportDeclaration = nodeFactory.createImportEqualsDeclaration(
31341
+ /*modifiers*/
31342
+ void 0,
31326
31343
  /*isTypeOnly*/
31327
31344
  false,
31328
- /*name*/
31329
- void 0,
31330
- namedBindings
31331
- ),
31332
- nodeFactory.createStringLiteral(externalHelpersModuleNameText),
31333
- /*attributes*/
31334
- void 0
31335
- );
31336
- addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
31337
- return externalHelpersImportDeclaration;
31345
+ externalHelpersModuleName,
31346
+ nodeFactory.createExternalModuleReference(nodeFactory.createStringLiteral(externalHelpersModuleNameText))
31347
+ );
31348
+ addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
31349
+ return externalHelpersImportDeclaration;
31350
+ }
31338
31351
  }
31339
31352
  }
31340
31353
  }
31341
- function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
31342
- if (compilerOptions.importHelpers && isEffectiveExternalModule(node, compilerOptions)) {
31343
- const externalHelpersModuleName = getExternalHelpersModuleName(node);
31344
- if (externalHelpersModuleName) {
31345
- return externalHelpersModuleName;
31346
- }
31347
- let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
31348
- if (!create) {
31349
- const helpers = getEmitHelpers(node);
31350
- if (helpers) {
31351
- for (const helper of helpers) {
31352
- if (!helper.scoped) {
31353
- create = true;
31354
- break;
31355
- }
31356
- }
31357
- }
31358
- }
31359
- if (create) {
31360
- const parseNode = getOriginalNode(node, isSourceFile);
31361
- const emitNode = getOrCreateEmitNode(parseNode);
31362
- return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory2.createUniqueName(externalHelpersModuleNameText));
31363
- }
31354
+ function getImportedHelpers(sourceFile) {
31355
+ return filter(getEmitHelpers(sourceFile), (helper) => !helper.scoped);
31356
+ }
31357
+ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
31358
+ const externalHelpersModuleName = getExternalHelpersModuleName(node);
31359
+ if (externalHelpersModuleName) {
31360
+ return externalHelpersModuleName;
31361
+ }
31362
+ const create = some(helpers) || (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
31363
+ if (create) {
31364
+ const parseNode = getOriginalNode(node, isSourceFile);
31365
+ const emitNode = getOrCreateEmitNode(parseNode);
31366
+ return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory2.createUniqueName(externalHelpersModuleNameText));
31364
31367
  }
31365
31368
  }
31366
31369
  function getLocalNameForExternalImport(factory2, node, sourceFile) {
@@ -40537,15 +40540,6 @@ var commandOptionsWithoutBuild = [
40537
40540
  paramType: Diagnostics.FILE_OR_DIRECTORY,
40538
40541
  description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json
40539
40542
  },
40540
- {
40541
- name: "build",
40542
- type: "boolean",
40543
- shortName: "b",
40544
- showInSimplifiedHelpView: true,
40545
- category: Diagnostics.Command_line_Options,
40546
- description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
40547
- defaultValueDescription: false
40548
- },
40549
40543
  {
40550
40544
  name: "showConfig",
40551
40545
  type: "boolean",
@@ -41530,7 +41524,17 @@ var commandLineOptionOfCustomType = optionDeclarations.filter(isCommandLineOptio
41530
41524
  function isCommandLineOptionOfCustomType(option) {
41531
41525
  return !isString(option.type);
41532
41526
  }
41527
+ var tscBuildOption = {
41528
+ name: "build",
41529
+ type: "boolean",
41530
+ shortName: "b",
41531
+ showInSimplifiedHelpView: true,
41532
+ category: Diagnostics.Command_line_Options,
41533
+ description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
41534
+ defaultValueDescription: false
41535
+ };
41533
41536
  var optionsForBuild = [
41537
+ tscBuildOption,
41534
41538
  {
41535
41539
  name: "verbose",
41536
41540
  shortName: "v",
@@ -41669,8 +41673,14 @@ function getOptionName(option) {
41669
41673
  }
41670
41674
  function createUnknownOptionError(unknownOption, diagnostics, unknownOptionErrorText, node, sourceFile) {
41671
41675
  var _a;
41672
- if ((_a = diagnostics.alternateMode) == null ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) {
41673
- return createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.alternateMode.diagnostic, unknownOption);
41676
+ const otherOption = (_a = diagnostics.alternateMode) == null ? void 0 : _a.getOptionsNameMap().optionsNameMap.get(unknownOption.toLowerCase());
41677
+ if (otherOption) {
41678
+ return createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(
41679
+ sourceFile,
41680
+ node,
41681
+ otherOption !== tscBuildOption ? diagnostics.alternateMode.diagnostic : Diagnostics.Option_build_must_be_the_first_command_line_argument,
41682
+ unknownOption
41683
+ );
41674
41684
  }
41675
41685
  const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
41676
41686
  return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
@@ -41859,10 +41869,10 @@ var buildOptionsDidYouMeanDiagnostics = {
41859
41869
  unknownDidYouMeanDiagnostic: Diagnostics.Unknown_build_option_0_Did_you_mean_1,
41860
41870
  optionTypeMismatchDiagnostic: Diagnostics.Build_option_0_requires_a_value_of_type_1
41861
41871
  };
41862
- function parseBuildCommand(args) {
41872
+ function parseBuildCommand(commandLine) {
41863
41873
  const { options, watchOptions, fileNames: projects, errors } = parseCommandLineWorker(
41864
41874
  buildOptionsDidYouMeanDiagnostics,
41865
- args
41875
+ commandLine
41866
41876
  );
41867
41877
  const buildOptions = options;
41868
41878
  if (projects.length === 0) {
@@ -42805,7 +42815,7 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
42805
42815
  if (ownConfig.raw.compileOnSave === void 0 && result.compileOnSave) ownConfig.raw.compileOnSave = result.compileOnSave;
42806
42816
  if (sourceFile && result.extendedSourceFiles) sourceFile.extendedSourceFiles = arrayFrom(result.extendedSourceFiles.keys());
42807
42817
  ownConfig.options = assign(result.options, ownConfig.options);
42808
- ownConfig.watchOptions = ownConfig.watchOptions && result.watchOptions ? assign(result.watchOptions, ownConfig.watchOptions) : ownConfig.watchOptions || result.watchOptions;
42818
+ ownConfig.watchOptions = ownConfig.watchOptions && result.watchOptions ? assignWatchOptions(result, ownConfig.watchOptions) : ownConfig.watchOptions || result.watchOptions;
42809
42819
  }
42810
42820
  return ownConfig;
42811
42821
  function applyExtendedConfig(result, extendedConfigPath) {
@@ -42829,9 +42839,14 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
42829
42839
  result.compileOnSave = extendsRaw.compileOnSave;
42830
42840
  }
42831
42841
  assign(result.options, extendedConfig.options);
42832
- result.watchOptions = result.watchOptions && extendedConfig.watchOptions ? assign({}, result.watchOptions, extendedConfig.watchOptions) : result.watchOptions || extendedConfig.watchOptions;
42842
+ result.watchOptions = result.watchOptions && extendedConfig.watchOptions ? assignWatchOptions(result, extendedConfig.watchOptions) : result.watchOptions || extendedConfig.watchOptions;
42833
42843
  }
42834
42844
  }
42845
+ function assignWatchOptions(result, watchOptions) {
42846
+ if (result.watchOptionsCopied) return assign(result.watchOptions, watchOptions);
42847
+ result.watchOptionsCopied = true;
42848
+ return assign({}, result.watchOptions, watchOptions);
42849
+ }
42835
42850
  }
42836
42851
  function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
42837
42852
  if (hasProperty(json, "excludes")) {
@@ -43874,7 +43889,7 @@ function getConditions(options, resolutionMode) {
43874
43889
  }
43875
43890
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
43876
43891
  const moduleResolutionState = getTemporaryModuleResolutionState(cache == null ? void 0 : cache.getPackageJsonInfoCache(), host, options);
43877
- return forEachAncestorDirectory(containingDirectory, (ancestorDirectory) => {
43892
+ return forEachAncestorDirectoryStoppingAtGlobalCache(host, containingDirectory, (ancestorDirectory) => {
43878
43893
  if (getBaseFileName(ancestorDirectory) !== "node_modules") {
43879
43894
  const nodeModulesFolder = combinePaths(ancestorDirectory, "node_modules");
43880
43895
  const candidate = combinePaths(nodeModulesFolder, packageName);
@@ -45006,7 +45021,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
45006
45021
  };
45007
45022
  }
45008
45023
  function getPackageScopeForPath(directory, state) {
45009
- return forEachAncestorDirectory(
45024
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
45025
+ state.host,
45010
45026
  directory,
45011
45027
  (dir) => getPackageJsonInfo(
45012
45028
  dir,
@@ -45645,17 +45661,30 @@ function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName,
45645
45661
  return lookup(secondaryExtensions);
45646
45662
  }
45647
45663
  function lookup(extensions2) {
45648
- return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
45649
- if (getBaseFileName(ancestorDirectory) !== "node_modules") {
45650
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
45651
- if (resolutionFromCache) {
45652
- return resolutionFromCache;
45664
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
45665
+ state.host,
45666
+ normalizeSlashes(directory),
45667
+ (ancestorDirectory) => {
45668
+ if (getBaseFileName(ancestorDirectory) !== "node_modules") {
45669
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
45670
+ if (resolutionFromCache) {
45671
+ return resolutionFromCache;
45672
+ }
45673
+ return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions2, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
45653
45674
  }
45654
- return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions2, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
45655
45675
  }
45656
- });
45676
+ );
45657
45677
  }
45658
45678
  }
45679
+ function forEachAncestorDirectoryStoppingAtGlobalCache(host, directory, callback) {
45680
+ var _a;
45681
+ const globalCache = (_a = host == null ? void 0 : host.getGlobalTypingsCacheLocation) == null ? void 0 : _a.call(host);
45682
+ return forEachAncestorDirectory(directory, (ancestorDirectory) => {
45683
+ const result = callback(ancestorDirectory);
45684
+ if (result !== void 0) return result;
45685
+ if (ancestorDirectory === globalCache) return false;
45686
+ }) || void 0;
45687
+ }
45659
45688
  function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
45660
45689
  const nodeModulesFolder = combinePaths(directory, "node_modules");
45661
45690
  const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
@@ -45851,28 +45880,32 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
45851
45880
  return { value: resolvedUsingSettings };
45852
45881
  }
45853
45882
  if (!isExternalModuleNameRelative(moduleName)) {
45854
- const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
45855
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
45856
- cache,
45857
- moduleName,
45858
- /*mode*/
45859
- void 0,
45860
- directory,
45861
- redirectedReference,
45862
- state
45863
- );
45864
- if (resolutionFromCache) {
45865
- return resolutionFromCache;
45883
+ const resolved2 = forEachAncestorDirectoryStoppingAtGlobalCache(
45884
+ state.host,
45885
+ containingDirectory,
45886
+ (directory) => {
45887
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
45888
+ cache,
45889
+ moduleName,
45890
+ /*mode*/
45891
+ void 0,
45892
+ directory,
45893
+ redirectedReference,
45894
+ state
45895
+ );
45896
+ if (resolutionFromCache) {
45897
+ return resolutionFromCache;
45898
+ }
45899
+ const searchName = normalizePath(combinePaths(directory, moduleName));
45900
+ return toSearchResult(loadModuleFromFileNoPackageId(
45901
+ extensions,
45902
+ searchName,
45903
+ /*onlyRecordFailures*/
45904
+ false,
45905
+ state
45906
+ ));
45866
45907
  }
45867
- const searchName = normalizePath(combinePaths(directory, moduleName));
45868
- return toSearchResult(loadModuleFromFileNoPackageId(
45869
- extensions,
45870
- searchName,
45871
- /*onlyRecordFailures*/
45872
- false,
45873
- state
45874
- ));
45875
- });
45908
+ );
45876
45909
  if (resolved2) return resolved2;
45877
45910
  if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
45878
45911
  let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
@@ -49497,9 +49530,11 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
49497
49530
  if (host.getNearestAncestorDirectoryWithPackageJson) {
49498
49531
  return host.getNearestAncestorDirectoryWithPackageJson(fileName);
49499
49532
  }
49500
- return forEachAncestorDirectory(fileName, (directory) => {
49501
- return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
49502
- });
49533
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
49534
+ host,
49535
+ fileName,
49536
+ (directory) => host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0
49537
+ );
49503
49538
  }
49504
49539
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
49505
49540
  var _a;
@@ -49517,25 +49552,29 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
49517
49552
  }
49518
49553
  const symlinkedDirectories = (_a = host.getSymlinkCache) == null ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
49519
49554
  const fullImportedFileName = getNormalizedAbsolutePath(importedFileName, cwd);
49520
- const result = symlinkedDirectories && forEachAncestorDirectory(getDirectoryPath(fullImportedFileName), (realPathDirectory) => {
49521
- const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(toPath(realPathDirectory, cwd, getCanonicalFileName)));
49522
- if (!symlinkDirectories) return void 0;
49523
- if (startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
49524
- return false;
49525
- }
49526
- return forEach(targets, (target) => {
49527
- if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
49528
- return;
49529
- }
49530
- const relative = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
49531
- for (const symlinkDirectory of symlinkDirectories) {
49532
- const option = resolvePath(symlinkDirectory, relative);
49533
- const result2 = cb(option, target === referenceRedirect);
49534
- shouldFilterIgnoredPaths = true;
49535
- if (result2) return result2;
49555
+ const result = symlinkedDirectories && forEachAncestorDirectoryStoppingAtGlobalCache(
49556
+ host,
49557
+ getDirectoryPath(fullImportedFileName),
49558
+ (realPathDirectory) => {
49559
+ const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(toPath(realPathDirectory, cwd, getCanonicalFileName)));
49560
+ if (!symlinkDirectories) return void 0;
49561
+ if (startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
49562
+ return false;
49536
49563
  }
49537
- });
49538
- });
49564
+ return forEach(targets, (target) => {
49565
+ if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
49566
+ return;
49567
+ }
49568
+ const relative = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
49569
+ for (const symlinkDirectory of symlinkDirectories) {
49570
+ const option = resolvePath(symlinkDirectory, relative);
49571
+ const result2 = cb(option, target === referenceRedirect);
49572
+ shouldFilterIgnoredPaths = true;
49573
+ if (result2) return result2;
49574
+ }
49575
+ });
49576
+ }
49577
+ );
49539
49578
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
49540
49579
  }
49541
49580
  function getAllModulePaths(info, importedFileName, host, preferences, compilerOptions, options = {}) {
@@ -84180,7 +84219,7 @@ function createTypeChecker(host) {
84180
84219
  const modifiers = getTypeParameterModifiers(typeParameter) & (8192 /* In */ | 16384 /* Out */);
84181
84220
  if (modifiers) {
84182
84221
  const symbol = getSymbolOfDeclaration(node.parent);
84183
- if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */))) {
84222
+ if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
84184
84223
  error2(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
84185
84224
  } else if (modifiers === 8192 /* In */ || modifiers === 16384 /* Out */) {
84186
84225
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
@@ -93324,7 +93363,8 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
93324
93363
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
93325
93364
  readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
93326
93365
  getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
93327
- getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
93366
+ getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index),
93367
+ getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
93328
93368
  };
93329
93369
  }
93330
93370
  var SymbolTrackerImpl = class _SymbolTrackerImpl {
@@ -115915,6 +115955,7 @@ function transformECMAScriptModule(context) {
115915
115955
  context.onSubstituteNode = onSubstituteNode;
115916
115956
  context.enableEmitNotification(307 /* SourceFile */);
115917
115957
  context.enableSubstitution(80 /* Identifier */);
115958
+ const noSubstitution = /* @__PURE__ */ new Set();
115918
115959
  let helperNameSubstitutions;
115919
115960
  let currentSourceFile;
115920
115961
  let importRequireStatements;
@@ -115949,7 +115990,7 @@ function transformECMAScriptModule(context) {
115949
115990
  if (externalHelpersImportDeclaration) {
115950
115991
  const statements = [];
115951
115992
  const statementOffset = factory2.copyPrologue(node.statements, statements);
115952
- append(statements, externalHelpersImportDeclaration);
115993
+ addRange(statements, visitArray([externalHelpersImportDeclaration], visitor, isStatement));
115953
115994
  addRange(statements, visitNodes2(node.statements, visitor, isStatement, statementOffset));
115954
115995
  return factory2.updateSourceFile(
115955
115996
  node,
@@ -116164,7 +116205,9 @@ function transformECMAScriptModule(context) {
116164
116205
  if ((isExternalModule(node) || getIsolatedModules(compilerOptions)) && compilerOptions.importHelpers) {
116165
116206
  helperNameSubstitutions = /* @__PURE__ */ new Map();
116166
116207
  }
116208
+ currentSourceFile = node;
116167
116209
  previousOnEmitNode(hint, node, emitCallback);
116210
+ currentSourceFile = void 0;
116168
116211
  helperNameSubstitutions = void 0;
116169
116212
  } else {
116170
116213
  previousOnEmitNode(hint, node, emitCallback);
@@ -116172,18 +116215,29 @@ function transformECMAScriptModule(context) {
116172
116215
  }
116173
116216
  function onSubstituteNode(hint, node) {
116174
116217
  node = previousOnSubstituteNode(hint, node);
116175
- if (helperNameSubstitutions && isIdentifier(node) && getEmitFlags(node) & 8192 /* HelperName */) {
116218
+ if (node.id && noSubstitution.has(node.id)) {
116219
+ return node;
116220
+ }
116221
+ if (isIdentifier(node) && getEmitFlags(node) & 8192 /* HelperName */) {
116176
116222
  return substituteHelperName(node);
116177
116223
  }
116178
116224
  return node;
116179
116225
  }
116180
116226
  function substituteHelperName(node) {
116181
- const name = idText(node);
116182
- let substitution = helperNameSubstitutions.get(name);
116183
- if (!substitution) {
116184
- helperNameSubstitutions.set(name, substitution = factory2.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */));
116227
+ const externalHelpersModuleName = currentSourceFile && getExternalHelpersModuleName(currentSourceFile);
116228
+ if (externalHelpersModuleName) {
116229
+ noSubstitution.add(getNodeId(node));
116230
+ return factory2.createPropertyAccessExpression(externalHelpersModuleName, node);
116231
+ }
116232
+ if (helperNameSubstitutions) {
116233
+ const name = idText(node);
116234
+ let substitution = helperNameSubstitutions.get(name);
116235
+ if (!substitution) {
116236
+ helperNameSubstitutions.set(name, substitution = factory2.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */));
116237
+ }
116238
+ return substitution;
116185
116239
  }
116186
- return substitution;
116240
+ return node;
116187
116241
  }
116188
116242
  }
116189
116243
 
@@ -125503,7 +125557,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125503
125557
  getCanonicalFileName,
125504
125558
  getFileIncludeReasons: () => fileReasons,
125505
125559
  structureIsReused,
125506
- writeFile: writeFile2
125560
+ writeFile: writeFile2,
125561
+ getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
125507
125562
  };
125508
125563
  onProgramCreateComplete();
125509
125564
  verifyCompilerOptions();
@@ -126069,7 +126124,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126069
126124
  getFileIncludeReasons: program.getFileIncludeReasons,
126070
126125
  createHash: maybeBind(host, host.createHash),
126071
126126
  getModuleResolutionCache: () => program.getModuleResolutionCache(),
126072
- trace: maybeBind(host, host.trace)
126127
+ trace: maybeBind(host, host.trace),
126128
+ getGlobalTypingsCacheLocation: program.getGlobalTypingsCacheLocation
126073
126129
  };
126074
126130
  }
126075
126131
  function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -130436,6 +130492,9 @@ function canWatchDirectoryOrFile(pathComponents2, length2) {
130436
130492
  const perceivedOsRootLength = perceivedOsRootLengthForWatching(pathComponents2, length2);
130437
130493
  return length2 > perceivedOsRootLength + 1;
130438
130494
  }
130495
+ function canWatchDirectoryOrFilePath(path) {
130496
+ return canWatchDirectoryOrFile(getPathComponents(path));
130497
+ }
130439
130498
  function canWatchAtTypes(atTypes) {
130440
130499
  return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(getDirectoryPath(atTypes));
130441
130500
  }
@@ -130447,12 +130506,12 @@ function isInDirectoryPath(dirComponents, fileOrDirComponents) {
130447
130506
  return true;
130448
130507
  }
130449
130508
  function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
130450
- return canWatchDirectoryOrFile(getPathComponents(fileOrDirPath));
130509
+ return canWatchDirectoryOrFilePath(fileOrDirPath);
130451
130510
  }
130452
130511
  function canWatchAffectingLocation(filePath) {
130453
130512
  return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
130454
130513
  }
130455
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch) {
130514
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch) {
130456
130515
  const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
130457
130516
  failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
130458
130517
  const failedLookupComponents = getPathComponents(failedLookupLocation);
@@ -130461,7 +130520,7 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
130461
130520
  const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
130462
130521
  if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1) return void 0;
130463
130522
  const lastNodeModulesIndex = failedLookupPathComponents.lastIndexOf("node_modules");
130464
- if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
130523
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
130465
130524
  if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
130466
130525
  return getDirectoryOfFailedLookupWatch(
130467
130526
  failedLookupComponents,
@@ -130533,9 +130592,9 @@ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, lengt
130533
130592
  packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
130534
130593
  };
130535
130594
  }
130536
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
130595
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
130537
130596
  const typeRootPathComponents = getPathComponents(typeRootPath);
130538
- if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
130597
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
130539
130598
  return rootPath;
130540
130599
  }
130541
130600
  typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
@@ -130576,10 +130635,10 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected
130576
130635
  function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) {
130577
130636
  const host = getModuleResolutionHost(resolutionHost);
130578
130637
  const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
130579
- if (!resolutionHost.getGlobalCache) {
130638
+ if (!resolutionHost.getGlobalTypingsCacheLocation) {
130580
130639
  return primaryResult;
130581
130640
  }
130582
- const globalCache = resolutionHost.getGlobalCache();
130641
+ const globalCache = resolutionHost.getGlobalTypingsCacheLocation();
130583
130642
  if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
130584
130643
  const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
130585
130644
  Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
@@ -130643,6 +130702,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130643
130702
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
130644
130703
  const rootPath = resolutionHost.toPath(rootDir);
130645
130704
  const rootPathComponents = getPathComponents(rootPath);
130705
+ const isRootWatchable = canWatchDirectoryOrFile(rootPathComponents);
130646
130706
  const isSymlinkCache = /* @__PURE__ */ new Map();
130647
130707
  const packageDirWatchers = /* @__PURE__ */ new Map();
130648
130708
  const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
@@ -131054,6 +131114,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
131054
131114
  rootDir,
131055
131115
  rootPath,
131056
131116
  rootPathComponents,
131117
+ isRootWatchable,
131057
131118
  getCurrentDirectory,
131058
131119
  resolutionHost.preferNonRecursiveWatch
131059
131120
  );
@@ -131242,6 +131303,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
131242
131303
  rootDir,
131243
131304
  rootPath,
131244
131305
  rootPathComponents,
131306
+ isRootWatchable,
131245
131307
  getCurrentDirectory,
131246
131308
  resolutionHost.preferNonRecursiveWatch
131247
131309
  );
@@ -131385,6 +131447,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
131385
131447
  return false;
131386
131448
  }
131387
131449
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
131450
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
131388
131451
  const packagePath = parseNodeModuleFromPath(
131389
131452
  fileOrDirectoryPath,
131390
131453
  /*isFolder*/
@@ -131466,6 +131529,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
131466
131529
  resolutionHost.toPath(typeRoot),
131467
131530
  rootPath,
131468
131531
  rootPathComponents,
131532
+ isRootWatchable,
131469
131533
  getCurrentDirectory,
131470
131534
  resolutionHost.preferNonRecursiveWatch,
131471
131535
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
@@ -132223,6 +132287,7 @@ function createWatchProgram(host) {
132223
132287
  let updateLevel;
132224
132288
  let missingFilesMap;
132225
132289
  let watchedWildcardDirectories;
132290
+ let staleWatches = /* @__PURE__ */ new Map([[void 0, void 0]]);
132226
132291
  let timerToUpdateProgram;
132227
132292
  let timerToInvalidateFailedLookupResolutions;
132228
132293
  let parsedConfigs;
@@ -132311,8 +132376,6 @@ function createWatchProgram(host) {
132311
132376
  const customHasInvalidLibResolutions = host.resolveLibrary ? maybeBind(host, host.hasInvalidatedLibResolutions) || returnTrue : returnFalse;
132312
132377
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
132313
132378
  synchronizeProgram();
132314
- watchConfigFileWildCardDirectories();
132315
- if (configFileName) updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
132316
132379
  return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close, getResolutionCache } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames, close, getResolutionCache };
132317
132380
  function close() {
132318
132381
  clearInvalidateResolutionsOfFailedLookupLocations();
@@ -132415,6 +132478,16 @@ function createWatchProgram(host) {
132415
132478
  compilerHost.directoryExists = originalDirectoryExists;
132416
132479
  compilerHost.createDirectory = originalCreateDirectory;
132417
132480
  compilerHost.writeFile = originalWriteFile;
132481
+ staleWatches == null ? void 0 : staleWatches.forEach((configFile, configPath) => {
132482
+ if (!configPath) {
132483
+ watchConfigFileWildCardDirectories();
132484
+ if (configFileName) updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
132485
+ } else {
132486
+ const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
132487
+ if (config) watchReferencedProject(configFile, configPath, config);
132488
+ }
132489
+ });
132490
+ staleWatches = void 0;
132418
132491
  return builderProgram;
132419
132492
  }
132420
132493
  function createNewProgram(hasInvalidatedResolutions, hasInvalidatedLibResolutions) {
@@ -132621,9 +132694,8 @@ function createWatchProgram(host) {
132621
132694
  }
132622
132695
  parseConfigFile2();
132623
132696
  hasChangedCompilerOptions = true;
132697
+ (staleWatches ?? (staleWatches = /* @__PURE__ */ new Map())).set(void 0, void 0);
132624
132698
  synchronizeProgram();
132625
- watchConfigFileWildCardDirectories();
132626
- updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
132627
132699
  }
132628
132700
  function parseConfigFile2() {
132629
132701
  Debug.assert(configFileName);
@@ -132675,7 +132747,7 @@ function createWatchProgram(host) {
132675
132747
  } else {
132676
132748
  (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine });
132677
132749
  }
132678
- watchReferencedProject(configFileName2, configPath, config);
132750
+ (staleWatches ?? (staleWatches = /* @__PURE__ */ new Map())).set(configPath, configFileName2);
132679
132751
  return parsedCommandLine;
132680
132752
  }
132681
132753
  function getParsedCommandLineFromConfigFileHost(configFileName2) {
@@ -134692,7 +134764,7 @@ function shouldBePretty(sys2, options) {
134692
134764
  return options.pretty;
134693
134765
  }
134694
134766
  function getOptionsForHelp(commandLine) {
134695
- return !!commandLine.options.all ? toSorted(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) : filter(optionDeclarations.slice(), (v) => !!v.showInSimplifiedHelpView);
134767
+ return !!commandLine.options.all ? toSorted(optionDeclarations.concat(tscBuildOption), (a, b) => compareStringsCaseInsensitive(a.name, b.name)) : filter(optionDeclarations.concat(tscBuildOption), (v) => !!v.showInSimplifiedHelpView);
134696
134768
  }
134697
134769
  function printVersion(sys2) {
134698
134770
  sys2.write(getDiagnosticText(Diagnostics.Version_0, version) + sys2.newLine);
@@ -135016,7 +135088,7 @@ function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
135016
135088
  output = [...output, ...generateSectionOptionsOutput(
135017
135089
  sys2,
135018
135090
  getDiagnosticText(Diagnostics.BUILD_OPTIONS),
135019
- buildOptions,
135091
+ filter(buildOptions, (option) => option !== tscBuildOption),
135020
135092
  /*subCategory*/
135021
135093
  false,
135022
135094
  formatMessage(Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")
@@ -135030,7 +135102,7 @@ function printBuildHelp(sys2, buildOptions) {
135030
135102
  output = [...output, ...generateSectionOptionsOutput(
135031
135103
  sys2,
135032
135104
  getDiagnosticText(Diagnostics.BUILD_OPTIONS),
135033
- buildOptions,
135105
+ filter(buildOptions, (option) => option !== tscBuildOption),
135034
135106
  /*subCategory*/
135035
135107
  false,
135036
135108
  formatMessage(Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")
@@ -135067,10 +135139,6 @@ function printHelp(sys2, commandLine) {
135067
135139
  }
135068
135140
  function executeCommandLineWorker(sys2, cb, commandLine) {
135069
135141
  let reportDiagnostic = createDiagnosticReporter(sys2);
135070
- if (commandLine.options.build) {
135071
- reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_build_must_be_the_first_command_line_argument));
135072
- return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
135073
- }
135074
135142
  let configFileName;
135075
135143
  if (commandLine.options.locale) {
135076
135144
  validateLocaleAndSetLanguage(commandLine.options.locale, sys2, commandLine.errors);
@@ -135216,16 +135284,16 @@ function executeCommandLineWorker(sys2, cb, commandLine) {
135216
135284
  }
135217
135285
  }
135218
135286
  }
135219
- function isBuild(commandLineArgs) {
135287
+ function isBuildCommand(commandLineArgs) {
135220
135288
  if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45 /* minus */) {
135221
135289
  const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase();
135222
- return firstOption === "build" || firstOption === "b";
135290
+ return firstOption === tscBuildOption.name || firstOption === tscBuildOption.shortName;
135223
135291
  }
135224
135292
  return false;
135225
135293
  }
135226
135294
  function executeCommandLine(system, cb, commandLineArgs) {
135227
- if (isBuild(commandLineArgs)) {
135228
- const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs.slice(1));
135295
+ if (isBuildCommand(commandLineArgs)) {
135296
+ const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs);
135229
135297
  if (buildOptions.generateCpuProfile && system.enableCPUProfiler) {
135230
135298
  system.enableCPUProfiler(buildOptions.generateCpuProfile, () => performBuild(
135231
135299
  system,
@@ -139062,28 +139130,33 @@ function tryAndIgnoreErrors(cb) {
139062
139130
  function tryIOAndConsumeErrors(host, toApply, ...args) {
139063
139131
  return tryAndIgnoreErrors(() => toApply && toApply.apply(host, args));
139064
139132
  }
139065
- function findPackageJsons(startDirectory, host, stopDirectory) {
139133
+ function findPackageJsons(startDirectory, host) {
139066
139134
  const paths = [];
139067
- forEachAncestorDirectory(startDirectory, (ancestor) => {
139068
- if (ancestor === stopDirectory) {
139069
- return true;
139070
- }
139071
- const currentConfigPath = combinePaths(ancestor, "package.json");
139072
- if (tryFileExists(host, currentConfigPath)) {
139073
- paths.push(currentConfigPath);
139135
+ forEachAncestorDirectoryStoppingAtGlobalCache(
139136
+ host,
139137
+ startDirectory,
139138
+ (ancestor) => {
139139
+ const currentConfigPath = combinePaths(ancestor, "package.json");
139140
+ if (tryFileExists(host, currentConfigPath)) {
139141
+ paths.push(currentConfigPath);
139142
+ }
139074
139143
  }
139075
- });
139144
+ );
139076
139145
  return paths;
139077
139146
  }
139078
139147
  function findPackageJson(directory, host) {
139079
139148
  let packageJson;
139080
- forEachAncestorDirectory(directory, (ancestor) => {
139081
- if (ancestor === "node_modules") return true;
139082
- packageJson = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json");
139083
- if (packageJson) {
139084
- return true;
139149
+ forEachAncestorDirectoryStoppingAtGlobalCache(
139150
+ host,
139151
+ directory,
139152
+ (ancestor) => {
139153
+ if (ancestor === "node_modules") return true;
139154
+ packageJson = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json");
139155
+ if (packageJson) {
139156
+ return true;
139157
+ }
139085
139158
  }
139086
- });
139159
+ );
139087
139160
  return packageJson;
139088
139161
  }
139089
139162
  function getPackageJsonsVisibleToFile(fileName, host) {
@@ -139091,15 +139164,19 @@ function getPackageJsonsVisibleToFile(fileName, host) {
139091
139164
  return [];
139092
139165
  }
139093
139166
  const packageJsons = [];
139094
- forEachAncestorDirectory(getDirectoryPath(fileName), (ancestor) => {
139095
- const packageJsonFileName = combinePaths(ancestor, "package.json");
139096
- if (host.fileExists(packageJsonFileName)) {
139097
- const info = createPackageJsonInfo(packageJsonFileName, host);
139098
- if (info) {
139099
- packageJsons.push(info);
139167
+ forEachAncestorDirectoryStoppingAtGlobalCache(
139168
+ host,
139169
+ getDirectoryPath(fileName),
139170
+ (ancestor) => {
139171
+ const packageJsonFileName = combinePaths(ancestor, "package.json");
139172
+ if (host.fileExists(packageJsonFileName)) {
139173
+ const info = createPackageJsonInfo(packageJsonFileName, host);
139174
+ if (info) {
139175
+ packageJsons.push(info);
139176
+ }
139100
139177
  }
139101
139178
  }
139102
- });
139179
+ );
139103
139180
  return packageJsons;
139104
139181
  }
139105
139182
  function createPackageJsonInfo(fileName, host) {
@@ -139786,7 +139863,13 @@ function isImportable(program, fromFile, toFile, toModule, preferences, packageJ
139786
139863
  false,
139787
139864
  (toPath3) => {
139788
139865
  const file = program.getSourceFile(toPath3);
139789
- return (file === toFile || !file) && isImportablePath(fromFile.fileName, toPath3, getCanonicalFileName, globalTypingsCache);
139866
+ return (file === toFile || !file) && isImportablePath(
139867
+ fromFile.fileName,
139868
+ toPath3,
139869
+ getCanonicalFileName,
139870
+ globalTypingsCache,
139871
+ moduleSpecifierResolutionHost
139872
+ );
139790
139873
  }
139791
139874
  );
139792
139875
  if (packageJsonFilter) {
@@ -139799,8 +139882,12 @@ function isImportable(program, fromFile, toFile, toModule, preferences, packageJ
139799
139882
  function fileContainsPackageImport(sourceFile, packageName) {
139800
139883
  return sourceFile.imports && sourceFile.imports.some((i) => i.text === packageName || i.text.startsWith(packageName + "/"));
139801
139884
  }
139802
- function isImportablePath(fromPath, toPath3, getCanonicalFileName, globalCachePath) {
139803
- const toNodeModules = forEachAncestorDirectory(toPath3, (ancestor) => getBaseFileName(ancestor) === "node_modules" ? ancestor : void 0);
139885
+ function isImportablePath(fromPath, toPath3, getCanonicalFileName, globalCachePath, host) {
139886
+ const toNodeModules = forEachAncestorDirectoryStoppingAtGlobalCache(
139887
+ host,
139888
+ toPath3,
139889
+ (ancestor) => getBaseFileName(ancestor) === "node_modules" ? ancestor : void 0
139890
+ );
139804
139891
  const toNodeModulesParent = toNodeModules && getDirectoryPath(getCanonicalFileName(toNodeModules));
139805
139892
  return toNodeModulesParent === void 0 || startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) || !!globalCachePath && startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent);
139806
139893
  }
@@ -139871,13 +139958,17 @@ function getIsExcluded(excludePatterns, host) {
139871
139958
  if (excludePatterns.some((p) => p.test(fileName))) return true;
139872
139959
  if ((realpathsWithSymlinks == null ? void 0 : realpathsWithSymlinks.size) && pathContainsNodeModules(fileName)) {
139873
139960
  let dir = getDirectoryPath(fileName);
139874
- return forEachAncestorDirectory(getDirectoryPath(path), (dirPath) => {
139875
- const symlinks = realpathsWithSymlinks.get(ensureTrailingDirectorySeparator(dirPath));
139876
- if (symlinks) {
139877
- return symlinks.some((s) => excludePatterns.some((p) => p.test(fileName.replace(dir, s))));
139961
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
139962
+ host,
139963
+ getDirectoryPath(path),
139964
+ (dirPath) => {
139965
+ const symlinks = realpathsWithSymlinks.get(ensureTrailingDirectorySeparator(dirPath));
139966
+ if (symlinks) {
139967
+ return symlinks.some((s) => excludePatterns.some((p) => p.test(fileName.replace(dir, s))));
139968
+ }
139969
+ dir = getDirectoryPath(dir);
139878
139970
  }
139879
- dir = getDirectoryPath(dir);
139880
- }) ?? false;
139971
+ ) ?? false;
139881
139972
  }
139882
139973
  return false;
139883
139974
  };
@@ -150252,7 +150343,8 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
150252
150343
  resolveLibrary: maybeBind(host, host.resolveLibrary),
150253
150344
  useSourceOfProjectReferenceRedirect: maybeBind(host, host.useSourceOfProjectReferenceRedirect),
150254
150345
  getParsedCommandLine,
150255
- jsDocParsingMode: host.jsDocParsingMode
150346
+ jsDocParsingMode: host.jsDocParsingMode,
150347
+ getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
150256
150348
  };
150257
150349
  const originalGetSourceFile = compilerHost.getSourceFile;
150258
150350
  const { getSourceFileWithCache } = changeCompilerHostLikeToUseCache(
@@ -155756,9 +155848,19 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
155756
155848
  );
155757
155849
  if (fix) {
155758
155850
  const localName = ((_b = tryCast(referenceImport == null ? void 0 : referenceImport.name, isIdentifier)) == null ? void 0 : _b.text) ?? symbolName2;
155851
+ let addAsTypeOnly;
155852
+ let propertyName;
155759
155853
  if (referenceImport && isTypeOnlyImportDeclaration(referenceImport) && (fix.kind === 3 /* AddNew */ || fix.kind === 2 /* AddToExisting */) && fix.addAsTypeOnly === 1 /* Allowed */) {
155760
- fix = { ...fix, addAsTypeOnly: 2 /* Required */ };
155854
+ addAsTypeOnly = 2 /* Required */;
155761
155855
  }
155856
+ if (exportedSymbol.name !== localName) {
155857
+ propertyName = exportedSymbol.name;
155858
+ }
155859
+ fix = {
155860
+ ...fix,
155861
+ ...addAsTypeOnly === void 0 ? {} : { addAsTypeOnly },
155862
+ ...propertyName === void 0 ? {} : { propertyName }
155863
+ };
155762
155864
  addImport({ fix, symbolName: localName ?? symbolName2, errorIdentifierText: void 0 });
155763
155865
  }
155764
155866
  }
@@ -155824,7 +155926,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
155824
155926
  removeExisting.add(declaration);
155825
155927
  }
155826
155928
  function addImport(info) {
155827
- var _a, _b;
155929
+ var _a, _b, _c;
155828
155930
  const { fix, symbolName: symbolName2 } = info;
155829
155931
  switch (fix.kind) {
155830
155932
  case 0 /* UseNamespace */:
@@ -155834,40 +155936,40 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
155834
155936
  importType.push(fix);
155835
155937
  break;
155836
155938
  case 2 /* AddToExisting */: {
155837
- const { importClauseOrBindingPattern, importKind, addAsTypeOnly } = fix;
155939
+ const { importClauseOrBindingPattern, importKind, addAsTypeOnly, propertyName } = fix;
155838
155940
  let entry = addToExisting.get(importClauseOrBindingPattern);
155839
155941
  if (!entry) {
155840
155942
  addToExisting.set(importClauseOrBindingPattern, entry = { importClauseOrBindingPattern, defaultImport: void 0, namedImports: /* @__PURE__ */ new Map() });
155841
155943
  }
155842
155944
  if (importKind === 0 /* Named */) {
155843
- const prevValue = entry == null ? void 0 : entry.namedImports.get(symbolName2);
155844
- entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
155945
+ const prevTypeOnly = (_a = entry == null ? void 0 : entry.namedImports.get(symbolName2)) == null ? void 0 : _a.addAsTypeOnly;
155946
+ entry.namedImports.set(symbolName2, { addAsTypeOnly: reduceAddAsTypeOnlyValues(prevTypeOnly, addAsTypeOnly), propertyName });
155845
155947
  } else {
155846
155948
  Debug.assert(entry.defaultImport === void 0 || entry.defaultImport.name === symbolName2, "(Add to Existing) Default import should be missing or match symbolName");
155847
155949
  entry.defaultImport = {
155848
155950
  name: symbolName2,
155849
- addAsTypeOnly: reduceAddAsTypeOnlyValues((_a = entry.defaultImport) == null ? void 0 : _a.addAsTypeOnly, addAsTypeOnly)
155951
+ addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) == null ? void 0 : _b.addAsTypeOnly, addAsTypeOnly)
155850
155952
  };
155851
155953
  }
155852
155954
  break;
155853
155955
  }
155854
155956
  case 3 /* AddNew */: {
155855
- const { moduleSpecifier, importKind, useRequire, addAsTypeOnly } = fix;
155957
+ const { moduleSpecifier, importKind, useRequire, addAsTypeOnly, propertyName } = fix;
155856
155958
  const entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly);
155857
155959
  Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module");
155858
155960
  switch (importKind) {
155859
155961
  case 1 /* Default */:
155860
155962
  Debug.assert(entry.defaultImport === void 0 || entry.defaultImport.name === symbolName2, "(Add new) Default import should be missing or match symbolName");
155861
- entry.defaultImport = { name: symbolName2, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) == null ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) };
155963
+ entry.defaultImport = { name: symbolName2, addAsTypeOnly: reduceAddAsTypeOnlyValues((_c = entry.defaultImport) == null ? void 0 : _c.addAsTypeOnly, addAsTypeOnly) };
155862
155964
  break;
155863
155965
  case 0 /* Named */:
155864
155966
  const prevValue = (entry.namedImports || (entry.namedImports = /* @__PURE__ */ new Map())).get(symbolName2);
155865
- entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
155967
+ entry.namedImports.set(symbolName2, [reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly), propertyName]);
155866
155968
  break;
155867
155969
  case 3 /* CommonJS */:
155868
155970
  if (compilerOptions.verbatimModuleSyntax) {
155869
155971
  const prevValue2 = (entry.namedImports || (entry.namedImports = /* @__PURE__ */ new Map())).get(symbolName2);
155870
- entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue2, addAsTypeOnly));
155972
+ entry.namedImports.set(symbolName2, [reduceAddAsTypeOnlyValues(prevValue2, addAsTypeOnly), propertyName]);
155871
155973
  } else {
155872
155974
  Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
155873
155975
  entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
@@ -156021,7 +156123,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
156021
156123
  sourceFile,
156022
156124
  importClauseOrBindingPattern,
156023
156125
  defaultImport,
156024
- arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
156126
+ arrayFrom(namedImports.entries(), ([name, { addAsTypeOnly, propertyName }]) => ({ addAsTypeOnly, propertyName, name })),
156025
156127
  importSpecifiersToRemoveWhileAdding,
156026
156128
  preferences
156027
156129
  );
@@ -156034,7 +156136,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
156034
156136
  moduleSpecifier,
156035
156137
  quotePreference,
156036
156138
  defaultImport,
156037
- namedImports && arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
156139
+ namedImports && arrayFrom(namedImports.entries(), ([name, [addAsTypeOnly, propertyName]]) => ({ addAsTypeOnly, propertyName, name })),
156038
156140
  namespaceLikeImport,
156039
156141
  compilerOptions,
156040
156142
  preferences
@@ -156934,8 +157036,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
156934
157036
  ...namedImports.map((i) => factory.createBindingElement(
156935
157037
  /*dotDotDotToken*/
156936
157038
  void 0,
156937
- /*propertyName*/
156938
- void 0,
157039
+ i.propertyName,
156939
157040
  i.name
156940
157041
  ))
156941
157042
  ])
@@ -156946,12 +157047,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
156946
157047
  addElementToBindingPattern(clause, defaultImport.name, "default");
156947
157048
  }
156948
157049
  for (const specifier of namedImports) {
156949
- addElementToBindingPattern(
156950
- clause,
156951
- specifier.name,
156952
- /*propertyName*/
156953
- void 0
156954
- );
157050
+ addElementToBindingPattern(clause, specifier.name, specifier.propertyName);
156955
157051
  }
156956
157052
  return;
156957
157053
  }
@@ -156967,8 +157063,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
156967
157063
  namedImports.map(
156968
157064
  (namedImport) => factory.createImportSpecifier(
156969
157065
  (!clause.isTypeOnly || promoteFromTypeOnly2) && shouldUseTypeOnly(namedImport, preferences),
156970
- /*propertyName*/
156971
- void 0,
157066
+ namedImport.propertyName === void 0 ? void 0 : factory.createIdentifier(namedImport.propertyName),
156972
157067
  factory.createIdentifier(namedImport.name)
156973
157068
  )
156974
157069
  ),
@@ -157063,8 +157158,7 @@ function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImp
157063
157158
  namedImports == null ? void 0 : namedImports.map(
157064
157159
  (namedImport) => factory.createImportSpecifier(
157065
157160
  !topLevelTypeOnly && shouldUseTypeOnly(namedImport, preferences),
157066
- /*propertyName*/
157067
- void 0,
157161
+ namedImport.propertyName === void 0 ? void 0 : factory.createIdentifier(namedImport.propertyName),
157068
157162
  factory.createIdentifier(namedImport.name)
157069
157163
  )
157070
157164
  ),
@@ -157102,11 +157196,10 @@ function getNewRequires(moduleSpecifier, quotePreference, defaultImport, namedIm
157102
157196
  const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
157103
157197
  let statements;
157104
157198
  if (defaultImport || (namedImports == null ? void 0 : namedImports.length)) {
157105
- const bindingElements = (namedImports == null ? void 0 : namedImports.map(({ name }) => factory.createBindingElement(
157199
+ const bindingElements = (namedImports == null ? void 0 : namedImports.map(({ name, propertyName }) => factory.createBindingElement(
157106
157200
  /*dotDotDotToken*/
157107
157201
  void 0,
157108
- /*propertyName*/
157109
- void 0,
157202
+ propertyName,
157110
157203
  name
157111
157204
  ))) || [];
157112
157205
  if (defaultImport) {
@@ -165650,7 +165743,7 @@ function getSourceFromOrigin(origin) {
165650
165743
  }
165651
165744
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
165652
165745
  const start = timestamp();
165653
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
165746
+ const closestSymbolDeclaration = getClosestSymbolDeclaration(contextToken, location);
165654
165747
  const useSemicolons = probablyUsesSemicolons(sourceFile);
165655
165748
  const typeChecker = program.getTypeChecker();
165656
165749
  const uniques = /* @__PURE__ */ new Map();
@@ -165720,15 +165813,26 @@ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, con
165720
165813
  if (isExportAssignment(location.parent)) {
165721
165814
  return true;
165722
165815
  }
165723
- if (tryCast(variableOrParameterDeclaration, isVariableDeclaration) && symbol.valueDeclaration === variableOrParameterDeclaration) {
165816
+ if (tryCast(closestSymbolDeclaration, isVariableDeclaration) && symbol.valueDeclaration === closestSymbolDeclaration) {
165724
165817
  return false;
165725
165818
  }
165726
165819
  const symbolDeclaration = symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
165727
- if (variableOrParameterDeclaration && symbolDeclaration && (isTypeParameterDeclaration(variableOrParameterDeclaration) && isTypeParameterDeclaration(symbolDeclaration) || isParameter(variableOrParameterDeclaration) && isParameter(symbolDeclaration))) {
165728
- const symbolDeclarationPos = symbolDeclaration.pos;
165729
- const parameters = isParameter(variableOrParameterDeclaration) ? variableOrParameterDeclaration.parent.parameters : isInferTypeNode(variableOrParameterDeclaration.parent) ? void 0 : variableOrParameterDeclaration.parent.typeParameters;
165730
- if (symbolDeclarationPos >= variableOrParameterDeclaration.pos && parameters && symbolDeclarationPos < parameters.end) {
165731
- return false;
165820
+ if (closestSymbolDeclaration && symbolDeclaration) {
165821
+ if (isParameter(closestSymbolDeclaration) && isParameter(symbolDeclaration)) {
165822
+ const parameters = closestSymbolDeclaration.parent.parameters;
165823
+ if (symbolDeclaration.pos >= closestSymbolDeclaration.pos && symbolDeclaration.pos < parameters.end) {
165824
+ return false;
165825
+ }
165826
+ } else if (isTypeParameterDeclaration(closestSymbolDeclaration) && isTypeParameterDeclaration(symbolDeclaration)) {
165827
+ if (closestSymbolDeclaration === symbolDeclaration && (contextToken == null ? void 0 : contextToken.kind) === 96 /* ExtendsKeyword */) {
165828
+ return false;
165829
+ }
165830
+ if (isInTypeParameterDefault(contextToken) && !isInferTypeNode(closestSymbolDeclaration.parent)) {
165831
+ const typeParameters = closestSymbolDeclaration.parent.typeParameters;
165832
+ if (typeParameters && symbolDeclaration.pos >= closestSymbolDeclaration.pos && symbolDeclaration.pos < typeParameters.end) {
165833
+ return false;
165834
+ }
165835
+ }
165732
165836
  }
165733
165837
  }
165734
165838
  const symbolOrigin = skipAlias(symbol, typeChecker);
@@ -168011,11 +168115,28 @@ function isModuleSpecifierMissingOrEmpty(specifier) {
168011
168115
  if (nodeIsMissing(specifier)) return true;
168012
168116
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
168013
168117
  }
168014
- function getVariableOrParameterDeclaration(contextToken, location) {
168118
+ function getClosestSymbolDeclaration(contextToken, location) {
168015
168119
  if (!contextToken) return;
168016
- const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
168017
- const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
168018
- return possiblyParameterDeclaration || possiblyVariableDeclaration;
168120
+ let closestDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
168121
+ if (!closestDeclaration) {
168122
+ closestDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
168123
+ }
168124
+ return closestDeclaration;
168125
+ }
168126
+ function isInTypeParameterDefault(contextToken) {
168127
+ if (!contextToken) {
168128
+ return false;
168129
+ }
168130
+ let node = contextToken;
168131
+ let parent2 = contextToken.parent;
168132
+ while (parent2) {
168133
+ if (isTypeParameterDeclaration(parent2)) {
168134
+ return parent2.default === node || node.kind === 64 /* EqualsToken */;
168135
+ }
168136
+ node = parent2;
168137
+ parent2 = parent2.parent;
168138
+ }
168139
+ return false;
168019
168140
  }
168020
168141
  function isArrowFunctionBody(node) {
168021
168142
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -168781,7 +168902,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
168781
168902
  return nodeModulesDirectoryLookup(ancestor);
168782
168903
  };
168783
168904
  }
168784
- forEachAncestorDirectory(scriptPath, ancestorLookup);
168905
+ forEachAncestorDirectoryStoppingAtGlobalCache(host, scriptPath, ancestorLookup);
168785
168906
  }
168786
168907
  }
168787
168908
  return arrayFrom(result.values());
@@ -180399,6 +180520,7 @@ __export(ts_exports2, {
180399
180520
  canWatchAffectingLocation: () => canWatchAffectingLocation,
180400
180521
  canWatchAtTypes: () => canWatchAtTypes,
180401
180522
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
180523
+ canWatchDirectoryOrFilePath: () => canWatchDirectoryOrFilePath,
180402
180524
  cartesianProduct: () => cartesianProduct,
180403
180525
  cast: () => cast,
180404
180526
  chainBundle: () => chainBundle,
@@ -180731,6 +180853,7 @@ __export(ts_exports2, {
180731
180853
  forEach: () => forEach,
180732
180854
  forEachAncestor: () => forEachAncestor,
180733
180855
  forEachAncestorDirectory: () => forEachAncestorDirectory,
180856
+ forEachAncestorDirectoryStoppingAtGlobalCache: () => forEachAncestorDirectoryStoppingAtGlobalCache,
180734
180857
  forEachChild: () => forEachChild,
180735
180858
  forEachChildRecursively: () => forEachChildRecursively,
180736
180859
  forEachEmittedFile: () => forEachEmittedFile,
@@ -181344,7 +181467,7 @@ __export(ts_exports2, {
181344
181467
  isBooleanLiteral: () => isBooleanLiteral,
181345
181468
  isBreakOrContinueStatement: () => isBreakOrContinueStatement,
181346
181469
  isBreakStatement: () => isBreakStatement,
181347
- isBuild: () => isBuild,
181470
+ isBuildCommand: () => isBuildCommand,
181348
181471
  isBuildInfoFile: () => isBuildInfoFile,
181349
181472
  isBuilderProgram: () => isBuilderProgram,
181350
181473
  isBundle: () => isBundle,
@@ -182259,6 +182382,7 @@ __export(ts_exports2, {
182259
182382
  tagNamesAreEquivalent: () => tagNamesAreEquivalent,
182260
182383
  takeWhile: () => takeWhile,
182261
182384
  targetOptionDeclaration: () => targetOptionDeclaration,
182385
+ targetToLibMap: () => targetToLibMap,
182262
182386
  testFormatSettings: () => testFormatSettings,
182263
182387
  textChangeRangeIsUnchanged: () => textChangeRangeIsUnchanged,
182264
182388
  textChangeRangeNewSpan: () => textChangeRangeNewSpan,
@@ -182352,6 +182476,7 @@ __export(ts_exports2, {
182352
182476
  tryRemoveExtension: () => tryRemoveExtension,
182353
182477
  tryRemovePrefix: () => tryRemovePrefix,
182354
182478
  tryRemoveSuffix: () => tryRemoveSuffix,
182479
+ tscBuildOption: () => tscBuildOption,
182355
182480
  typeAcquisitionDeclarations: () => typeAcquisitionDeclarations,
182356
182481
  typeAliasNamePart: () => typeAliasNamePart,
182357
182482
  typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
@@ -182577,6 +182702,7 @@ __export(ts_server_exports3, {
182577
182702
  formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
182578
182703
  formatMessage: () => formatMessage2,
182579
182704
  getBaseConfigFileName: () => getBaseConfigFileName,
182705
+ getDetailWatchInfo: () => getDetailWatchInfo,
182580
182706
  getLocationInNewDocument: () => getLocationInNewDocument,
182581
182707
  hasArgument: () => hasArgument,
182582
182708
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
@@ -183995,10 +184121,9 @@ function unresolvedImportsChanged(imports1, imports2) {
183995
184121
  }
183996
184122
  var Project2 = class _Project {
183997
184123
  /** @internal */
183998
- constructor(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, watchOptions, directoryStructureHost, currentDirectory) {
184124
+ constructor(projectName, projectKind, projectService, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, watchOptions, directoryStructureHost, currentDirectory) {
183999
184125
  this.projectKind = projectKind;
184000
184126
  this.projectService = projectService;
184001
- this.documentRegistry = documentRegistry;
184002
184127
  this.compilerOptions = compilerOptions;
184003
184128
  this.compileOnSaveEnabled = compileOnSaveEnabled;
184004
184129
  this.watchOptions = watchOptions;
@@ -184045,6 +184170,7 @@ var Project2 = class _Project {
184045
184170
  this.globalCacheResolutionModuleName = ts_JsTyping_exports.nonRelativeModuleNameForTypingCache;
184046
184171
  /** @internal */
184047
184172
  this.updateFromProjectInProgress = false;
184173
+ projectService.logger.info(`Creating ${ProjectKind[projectKind]}Project: ${projectName}, currentDirectory: ${currentDirectory}`);
184048
184174
  this.projectName = projectName;
184049
184175
  this.directoryStructureHost = directoryStructureHost;
184050
184176
  this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory);
@@ -184090,7 +184216,11 @@ var Project2 = class _Project {
184090
184216
  /*logChangesWhenResolvingModule*/
184091
184217
  true
184092
184218
  );
184093
- this.languageService = createLanguageService(this, this.documentRegistry, this.projectService.serverMode);
184219
+ this.languageService = createLanguageService(
184220
+ this,
184221
+ this.projectService.documentRegistry,
184222
+ this.projectService.serverMode
184223
+ );
184094
184224
  if (lastFileExceededProgramSize) {
184095
184225
  this.disableLanguageService(lastFileExceededProgramSize);
184096
184226
  }
@@ -184164,7 +184294,7 @@ var Project2 = class _Project {
184164
184294
  }
184165
184295
  /** @internal */
184166
184296
  getGlobalTypingsCacheLocation() {
184167
- return this.getGlobalCache();
184297
+ return this.getTypeAcquisition().enable ? this.projectService.typingsInstaller.globalTypingsCacheLocation : void 0;
184168
184298
  }
184169
184299
  /** @internal */
184170
184300
  getSymlinkCache() {
@@ -184379,10 +184509,6 @@ var Project2 = class _Project {
184379
184509
  this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this);
184380
184510
  }
184381
184511
  /** @internal */
184382
- getGlobalCache() {
184383
- return this.getTypeAcquisition().enable ? this.projectService.typingsInstaller.globalTypingsCacheLocation : void 0;
184384
- }
184385
- /** @internal */
184386
184512
  fileIsOpen(filePath) {
184387
184513
  return this.projectService.openFiles.has(filePath);
184388
184514
  }
@@ -184912,14 +185038,15 @@ var Project2 = class _Project {
184912
185038
  const canonicalPath = this.toPath(path);
184913
185039
  toRemove.delete(canonicalPath);
184914
185040
  if (!this.typingWatchers.has(canonicalPath)) {
185041
+ const watchType = typingsWatcherType === "FileWatcher" /* FileWatcher */ ? WatchType.TypingInstallerLocationFile : WatchType.TypingInstallerLocationDirectory;
184915
185042
  this.typingWatchers.set(
184916
185043
  canonicalPath,
184917
- typingsWatcherType === "FileWatcher" /* FileWatcher */ ? this.projectService.watchFactory.watchFile(
185044
+ canWatchDirectoryOrFilePath(canonicalPath) ? typingsWatcherType === "FileWatcher" /* FileWatcher */ ? this.projectService.watchFactory.watchFile(
184918
185045
  path,
184919
185046
  () => !this.typingWatchers.isInvoked ? this.onTypingInstallerWatchInvoke() : this.writeLog(`TypingWatchers already invoked`),
184920
185047
  2e3 /* High */,
184921
185048
  this.projectService.getWatchOptions(this),
184922
- WatchType.TypingInstallerLocationFile,
185049
+ watchType,
184923
185050
  this
184924
185051
  ) : this.projectService.watchFactory.watchDirectory(
184925
185052
  path,
@@ -184931,9 +185058,9 @@ var Project2 = class _Project {
184931
185058
  },
184932
185059
  1 /* Recursive */,
184933
185060
  this.projectService.getWatchOptions(this),
184934
- WatchType.TypingInstallerLocationDirectory,
185061
+ watchType,
184935
185062
  this
184936
- )
185063
+ ) : (this.writeLog(`Skipping watcher creation at ${path}:: ${getDetailWatchInfo(watchType, this)}`), noopFileWatcher)
184937
185064
  );
184938
185065
  }
184939
185066
  };
@@ -184969,7 +185096,7 @@ var Project2 = class _Project {
184969
185096
  }
184970
185097
  removeExistingTypings(include) {
184971
185098
  if (!include.length) return include;
184972
- const existing = getAutomaticTypeDirectiveNames(this.getCompilerOptions(), this.directoryStructureHost);
185099
+ const existing = getAutomaticTypeDirectiveNames(this.getCompilerOptions(), this);
184973
185100
  return filter(include, (i) => !existing.includes(i));
184974
185101
  }
184975
185102
  updateGraphWorker() {
@@ -185475,7 +185602,7 @@ var Project2 = class _Project {
185475
185602
  }
185476
185603
  /** @internal */
185477
185604
  getNearestAncestorDirectoryWithPackageJson(fileName) {
185478
- return this.projectService.getNearestAncestorDirectoryWithPackageJson(fileName);
185605
+ return this.projectService.getNearestAncestorDirectoryWithPackageJson(fileName, this);
185479
185606
  }
185480
185607
  /** @internal */
185481
185608
  getPackageJsonsForAutoImport(rootDir) {
@@ -185546,7 +185673,11 @@ var Project2 = class _Project {
185546
185673
  if (dependencySelection) {
185547
185674
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "getPackageJsonAutoImportProvider");
185548
185675
  const start = timestamp();
185549
- this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getHostForAutoImportProvider(), this.documentRegistry) ?? false;
185676
+ this.autoImportProviderHost = AutoImportProviderProject.create(
185677
+ dependencySelection,
185678
+ this,
185679
+ this.getHostForAutoImportProvider()
185680
+ ) ?? false;
185550
185681
  if (this.autoImportProviderHost) {
185551
185682
  updateProjectIfDirty(this.autoImportProviderHost);
185552
185683
  this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", timestamp() - start);
@@ -185573,11 +185704,12 @@ var Project2 = class _Project {
185573
185704
  /** @internal */
185574
185705
  getNoDtsResolutionProject(rootFile) {
185575
185706
  Debug.assert(this.projectService.serverMode === 0 /* Semantic */);
185576
- if (!this.noDtsResolutionProject) {
185577
- this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject(), this.currentDirectory);
185578
- }
185707
+ this.noDtsResolutionProject ?? (this.noDtsResolutionProject = new AuxiliaryProject(this));
185579
185708
  if (this.noDtsResolutionProject.rootFile !== rootFile) {
185580
- this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this.noDtsResolutionProject, [rootFile]);
185709
+ this.projectService.setFileNamesOfAutoImportProviderOrAuxillaryProject(
185710
+ this.noDtsResolutionProject,
185711
+ [rootFile]
185712
+ );
185581
185713
  this.noDtsResolutionProject.rootFile = rootFile;
185582
185714
  }
185583
185715
  return this.noDtsResolutionProject;
@@ -185596,6 +185728,7 @@ var Project2 = class _Project {
185596
185728
  (_d = this.getScriptInfo(rootFile)) == null ? void 0 : _d.editContent(0, updatedText.length, originalText);
185597
185729
  }
185598
185730
  }
185731
+ /** @internal */
185599
185732
  getCompilerOptionsForNoDtsResolutionProject() {
185600
185733
  return {
185601
185734
  ...this.getCompilerOptions(),
@@ -185638,15 +185771,13 @@ function extractUnresolvedImportsFromSourceFile(program, file, ambientModules, c
185638
185771
  }
185639
185772
  var InferredProject2 = class extends Project2 {
185640
185773
  /** @internal */
185641
- constructor(projectService, documentRegistry, compilerOptions, watchOptions, projectRootPath, currentDirectory, typeAcquisition) {
185774
+ constructor(projectService, compilerOptions, watchOptions, projectRootPath, currentDirectory, typeAcquisition) {
185642
185775
  super(
185643
185776
  projectService.newInferredProjectName(),
185644
185777
  0 /* Inferred */,
185645
185778
  projectService,
185646
- documentRegistry,
185647
- // TODO: GH#18217
185648
- /*files*/
185649
- void 0,
185779
+ /*hasExplicitListOfFiles*/
185780
+ false,
185650
185781
  /*lastFileExceededProgramSize*/
185651
185782
  void 0,
185652
185783
  compilerOptions,
@@ -185731,23 +185862,22 @@ var InferredProject2 = class extends Project2 {
185731
185862
  }
185732
185863
  };
185733
185864
  var AuxiliaryProject = class extends Project2 {
185734
- constructor(projectService, documentRegistry, compilerOptions, currentDirectory) {
185865
+ constructor(hostProject) {
185735
185866
  super(
185736
- projectService.newAuxiliaryProjectName(),
185867
+ hostProject.projectService.newAuxiliaryProjectName(),
185737
185868
  4 /* Auxiliary */,
185738
- projectService,
185739
- documentRegistry,
185869
+ hostProject.projectService,
185740
185870
  /*hasExplicitListOfFiles*/
185741
185871
  false,
185742
185872
  /*lastFileExceededProgramSize*/
185743
185873
  void 0,
185744
- compilerOptions,
185874
+ hostProject.getCompilerOptionsForNoDtsResolutionProject(),
185745
185875
  /*compileOnSaveEnabled*/
185746
185876
  false,
185747
185877
  /*watchOptions*/
185748
185878
  void 0,
185749
- projectService.host,
185750
- currentDirectory
185879
+ hostProject.projectService.host,
185880
+ hostProject.currentDirectory
185751
185881
  );
185752
185882
  }
185753
185883
  isOrphan() {
@@ -185759,12 +185889,11 @@ var AuxiliaryProject = class extends Project2 {
185759
185889
  };
185760
185890
  var _AutoImportProviderProject = class _AutoImportProviderProject extends Project2 {
185761
185891
  /** @internal */
185762
- constructor(hostProject, initialRootNames, documentRegistry, compilerOptions) {
185892
+ constructor(hostProject, initialRootNames, compilerOptions) {
185763
185893
  super(
185764
185894
  hostProject.projectService.newAutoImportProviderProjectName(),
185765
185895
  3 /* AutoImportProvider */,
185766
185896
  hostProject.projectService,
185767
- documentRegistry,
185768
185897
  /*hasExplicitListOfFiles*/
185769
185898
  false,
185770
185899
  /*lastFileExceededProgramSize*/
@@ -185925,7 +186054,7 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
185925
186054
  }
185926
186055
  }
185927
186056
  /** @internal */
185928
- static create(dependencySelection, hostProject, host, documentRegistry) {
186057
+ static create(dependencySelection, hostProject, host) {
185929
186058
  if (dependencySelection === 0 /* Off */) {
185930
186059
  return void 0;
185931
186060
  }
@@ -185937,7 +186066,7 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
185937
186066
  if (!rootNames.length) {
185938
186067
  return void 0;
185939
186068
  }
185940
- return new _AutoImportProviderProject(hostProject, rootNames, documentRegistry, compilerOptions);
186069
+ return new _AutoImportProviderProject(hostProject, rootNames, compilerOptions);
185941
186070
  }
185942
186071
  /** @internal */
185943
186072
  isEmpty() {
@@ -185957,7 +186086,7 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
185957
186086
  this.getCompilationSettings()
185958
186087
  );
185959
186088
  }
185960
- this.projectService.setFileNamesOfAutpImportProviderOrAuxillaryProject(this, rootFileNames);
186089
+ this.projectService.setFileNamesOfAutoImportProviderOrAuxillaryProject(this, rootFileNames);
185961
186090
  this.rootFileNames = rootFileNames;
185962
186091
  const oldProgram = this.getCurrentProgram();
185963
186092
  const hasSameSetOfFiles = super.updateGraph();
@@ -186026,12 +186155,11 @@ _AutoImportProviderProject.compilerOptionsOverrides = {
186026
186155
  var AutoImportProviderProject = _AutoImportProviderProject;
186027
186156
  var ConfiguredProject2 = class extends Project2 {
186028
186157
  /** @internal */
186029
- constructor(configFileName, canonicalConfigFilePath, projectService, documentRegistry, cachedDirectoryStructureHost, pendingUpdateReason) {
186158
+ constructor(configFileName, canonicalConfigFilePath, projectService, cachedDirectoryStructureHost, pendingUpdateReason) {
186030
186159
  super(
186031
186160
  configFileName,
186032
186161
  1 /* Configured */,
186033
186162
  projectService,
186034
- documentRegistry,
186035
186163
  /*hasExplicitListOfFiles*/
186036
186164
  false,
186037
186165
  /*lastFileExceededProgramSize*/
@@ -186231,12 +186359,11 @@ var ConfiguredProject2 = class extends Project2 {
186231
186359
  };
186232
186360
  var ExternalProject = class extends Project2 {
186233
186361
  /** @internal */
186234
- constructor(externalProjectName, projectService, documentRegistry, compilerOptions, lastFileExceededProgramSize, compileOnSaveEnabled, projectFilePath, watchOptions) {
186362
+ constructor(externalProjectName, projectService, compilerOptions, lastFileExceededProgramSize, compileOnSaveEnabled, projectFilePath, watchOptions) {
186235
186363
  super(
186236
186364
  externalProjectName,
186237
186365
  2 /* External */,
186238
186366
  projectService,
186239
- documentRegistry,
186240
186367
  /*hasExplicitListOfFiles*/
186241
186368
  true,
186242
186369
  lastFileExceededProgramSize,
@@ -186844,6 +186971,9 @@ var _ProjectService = class _ProjectService {
186844
186971
  this.toCanonicalFileName = createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
186845
186972
  this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation ? ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation)) : void 0;
186846
186973
  this.throttledOperations = new ThrottledOperations(this.host, this.logger);
186974
+ this.logger.info(`currentDirectory:: ${this.host.getCurrentDirectory()} useCaseSensitiveFileNames:: ${this.host.useCaseSensitiveFileNames}`);
186975
+ this.logger.info(`libs Location:: ${getDirectoryPath(this.host.getExecutingFilePath())}`);
186976
+ this.logger.info(`globalTypingsCacheLocation:: ${this.typingsInstaller.globalTypingsCacheLocation}`);
186847
186977
  if (this.typesMapLocation) {
186848
186978
  this.loadTypesMap();
186849
186979
  } else {
@@ -186856,7 +186986,12 @@ var _ProjectService = class _ProjectService {
186856
186986
  hostInfo: "Unknown host",
186857
186987
  extraFileExtensions: []
186858
186988
  };
186859
- this.documentRegistry = createDocumentRegistryInternal(this.host.useCaseSensitiveFileNames, this.currentDirectory, this.jsDocParsingMode, this);
186989
+ this.documentRegistry = createDocumentRegistryInternal(
186990
+ this.host.useCaseSensitiveFileNames,
186991
+ this.currentDirectory,
186992
+ this.jsDocParsingMode,
186993
+ this
186994
+ );
186860
186995
  const watchLogLevel = this.logger.hasLevel(3 /* verbose */) ? 2 /* Verbose */ : this.logger.loggingEnabled() ? 1 /* TriggerOnly */ : 0 /* None */;
186861
186996
  const log = watchLogLevel !== 0 /* None */ ? (s) => this.logger.info(s) : noop;
186862
186997
  this.packageJsonCache = createPackageJsonCache(this);
@@ -187628,7 +187763,7 @@ var _ProjectService = class _ProjectService {
187628
187763
  Debug.checkDefined(configFileExistenceInfo.watcher);
187629
187764
  if ((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) == null ? void 0 : _c.size) {
187630
187765
  if (configFileExistenceInfo.inferredProjectRoots) {
187631
- if (!canWatchDirectoryOrFile(getPathComponents(getDirectoryPath(canonicalConfigFilePath)))) {
187766
+ if (!canWatchDirectoryOrFilePath(getDirectoryPath(canonicalConfigFilePath))) {
187632
187767
  configFileExistenceInfo.watcher.close();
187633
187768
  configFileExistenceInfo.watcher = noopConfigFileWatcher;
187634
187769
  }
@@ -187691,7 +187826,7 @@ var _ProjectService = class _ProjectService {
187691
187826
  configFileExistenceInfo.inferredProjectRoots = (configFileExistenceInfo.inferredProjectRoots ?? 0) + 1;
187692
187827
  }
187693
187828
  (configFileExistenceInfo.openFilesImpactedByConfigFile ?? (configFileExistenceInfo.openFilesImpactedByConfigFile = /* @__PURE__ */ new Set())).add(info.path);
187694
- configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = canWatchDirectoryOrFile(getPathComponents(getDirectoryPath(canonicalConfigFilePath))) ? this.watchFactory.watchFile(
187829
+ configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = canWatchDirectoryOrFilePath(getDirectoryPath(canonicalConfigFilePath)) ? this.watchFactory.watchFile(
187695
187830
  configFileName,
187696
187831
  (_filename, eventKind) => this.onConfigFileChanged(configFileName, canonicalConfigFilePath, eventKind),
187697
187832
  2e3 /* High */,
@@ -187840,7 +187975,6 @@ var _ProjectService = class _ProjectService {
187840
187975
  const project = new ExternalProject(
187841
187976
  projectFileName,
187842
187977
  this,
187843
- this.documentRegistry,
187844
187978
  compilerOptions,
187845
187979
  /*lastFileExceededProgramSize*/
187846
187980
  this.getFilenameForExceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader),
@@ -187911,7 +188045,6 @@ var _ProjectService = class _ProjectService {
187911
188045
  createConfiguredProject(configFileName, reason) {
187912
188046
  var _a;
187913
188047
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.Session, "createConfiguredProject", { configFilePath: configFileName });
187914
- this.logger.info(`Creating configuration project ${configFileName}`);
187915
188048
  const canonicalConfigFilePath = asNormalizedPath(this.toCanonicalFileName(configFileName));
187916
188049
  let configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
187917
188050
  if (!configFileExistenceInfo) {
@@ -187930,7 +188063,6 @@ var _ProjectService = class _ProjectService {
187930
188063
  configFileName,
187931
188064
  canonicalConfigFilePath,
187932
188065
  this,
187933
- this.documentRegistry,
187934
188066
  configFileExistenceInfo.config.cachedDirectoryStructureHost,
187935
188067
  reason
187936
188068
  );
@@ -188207,7 +188339,7 @@ var _ProjectService = class _ProjectService {
188207
188339
  return fileNames;
188208
188340
  }
188209
188341
  /** @internal */
188210
- setFileNamesOfAutpImportProviderOrAuxillaryProject(project, fileNames) {
188342
+ setFileNamesOfAutoImportProviderOrAuxillaryProject(project, fileNames) {
188211
188343
  this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader);
188212
188344
  }
188213
188345
  /** @internal */
@@ -188297,9 +188429,11 @@ var _ProjectService = class _ProjectService {
188297
188429
  return this.inferredProjects[0];
188298
188430
  }
188299
188431
  return this.createInferredProject(
188300
- "",
188432
+ this.currentDirectory,
188301
188433
  /*isSingleInferredProject*/
188302
- true
188434
+ true,
188435
+ /*projectRootPath*/
188436
+ void 0
188303
188437
  );
188304
188438
  }
188305
188439
  getOrCreateSingleInferredWithoutProjectRoot(currentDirectory) {
@@ -188310,7 +188444,13 @@ var _ProjectService = class _ProjectService {
188310
188444
  return inferredProject;
188311
188445
  }
188312
188446
  }
188313
- return this.createInferredProject(currentDirectory);
188447
+ return this.createInferredProject(
188448
+ currentDirectory,
188449
+ /*isSingleInferredProject*/
188450
+ false,
188451
+ /*projectRootPath*/
188452
+ void 0
188453
+ );
188314
188454
  }
188315
188455
  createInferredProject(currentDirectory, isSingleInferredProject, projectRootPath) {
188316
188456
  const compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects;
@@ -188327,7 +188467,14 @@ var _ProjectService = class _ProjectService {
188327
188467
  typeAcquisition = this.typeAcquisitionForInferredProjects;
188328
188468
  }
188329
188469
  watchOptionsAndErrors = watchOptionsAndErrors || void 0;
188330
- const project = new InferredProject2(this, this.documentRegistry, compilerOptions, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions, projectRootPath, currentDirectory, typeAcquisition);
188470
+ const project = new InferredProject2(
188471
+ this,
188472
+ compilerOptions,
188473
+ watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions,
188474
+ projectRootPath,
188475
+ currentDirectory,
188476
+ typeAcquisition
188477
+ );
188331
188478
  project.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
188332
188479
  if (isSingleInferredProject) {
188333
188480
  this.inferredProjects.unshift(project);
@@ -189832,7 +189979,7 @@ Dynamic files must always be opened with service's current directory or service
189832
189979
  switch (packageJsonCache.directoryHasPackageJson(directory)) {
189833
189980
  // Sync and check same directory again
189834
189981
  case 3 /* Maybe */:
189835
- packageJsonCache.searchDirectoryAndAncestors(directory);
189982
+ packageJsonCache.searchDirectoryAndAncestors(directory, project);
189836
189983
  return processDirectory(directory);
189837
189984
  // Check package.json
189838
189985
  case -1 /* True */:
@@ -189845,21 +189992,29 @@ Dynamic files must always be opened with service's current directory or service
189845
189992
  return true;
189846
189993
  }
189847
189994
  };
189848
- forEachAncestorDirectory(getDirectoryPath(fileName), processDirectory);
189995
+ forEachAncestorDirectoryStoppingAtGlobalCache(
189996
+ project,
189997
+ getDirectoryPath(fileName),
189998
+ processDirectory
189999
+ );
189849
190000
  return result;
189850
190001
  }
189851
190002
  /** @internal */
189852
- getNearestAncestorDirectoryWithPackageJson(fileName) {
189853
- return forEachAncestorDirectory(fileName, (directory) => {
189854
- switch (this.packageJsonCache.directoryHasPackageJson(directory)) {
189855
- case -1 /* True */:
189856
- return directory;
189857
- case 0 /* False */:
189858
- return void 0;
189859
- case 3 /* Maybe */:
189860
- return this.host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
190003
+ getNearestAncestorDirectoryWithPackageJson(fileName, project) {
190004
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
190005
+ project,
190006
+ fileName,
190007
+ (directory) => {
190008
+ switch (this.packageJsonCache.directoryHasPackageJson(directory)) {
190009
+ case -1 /* True */:
190010
+ return directory;
190011
+ case 0 /* False */:
190012
+ return void 0;
190013
+ case 3 /* Maybe */:
190014
+ return this.host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
190015
+ }
189861
190016
  }
189862
- });
190017
+ );
189863
190018
  }
189864
190019
  watchPackageJsonFile(file, path, project) {
189865
190020
  Debug.assert(project !== void 0);
@@ -190072,19 +190227,23 @@ function createPackageJsonCache(host) {
190072
190227
  return packageJsons.get(host.toPath(combinePaths(directory, "package.json"))) || void 0;
190073
190228
  },
190074
190229
  directoryHasPackageJson: (directory) => directoryHasPackageJson(host.toPath(directory)),
190075
- searchDirectoryAndAncestors: (directory) => {
190076
- forEachAncestorDirectory(directory, (ancestor) => {
190077
- const ancestorPath = host.toPath(ancestor);
190078
- if (directoryHasPackageJson(ancestorPath) !== 3 /* Maybe */) {
190079
- return true;
190080
- }
190081
- const packageJsonFileName = combinePaths(ancestor, "package.json");
190082
- if (tryFileExists(host, packageJsonFileName)) {
190083
- addOrUpdate(packageJsonFileName, combinePaths(ancestorPath, "package.json"));
190084
- } else {
190085
- directoriesWithoutPackageJson.set(ancestorPath, true);
190230
+ searchDirectoryAndAncestors: (directory, project) => {
190231
+ forEachAncestorDirectoryStoppingAtGlobalCache(
190232
+ project,
190233
+ directory,
190234
+ (ancestor) => {
190235
+ const ancestorPath = host.toPath(ancestor);
190236
+ if (directoryHasPackageJson(ancestorPath) !== 3 /* Maybe */) {
190237
+ return true;
190238
+ }
190239
+ const packageJsonFileName = combinePaths(ancestor, "package.json");
190240
+ if (tryFileExists(host, packageJsonFileName)) {
190241
+ addOrUpdate(packageJsonFileName, combinePaths(ancestorPath, "package.json"));
190242
+ } else {
190243
+ directoriesWithoutPackageJson.set(ancestorPath, true);
190244
+ }
190086
190245
  }
190087
- });
190246
+ );
190088
190247
  }
190089
190248
  };
190090
190249
  function addOrUpdate(fileName, path) {
@@ -194487,6 +194646,7 @@ __export(ts_server_exports4, {
194487
194646
  formatDiagnosticToProtocol: () => formatDiagnosticToProtocol,
194488
194647
  formatMessage: () => formatMessage2,
194489
194648
  getBaseConfigFileName: () => getBaseConfigFileName,
194649
+ getDetailWatchInfo: () => getDetailWatchInfo,
194490
194650
  getLocationInNewDocument: () => getLocationInNewDocument,
194491
194651
  hasArgument: () => hasArgument,
194492
194652
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
@@ -194759,6 +194919,7 @@ if (typeof console !== "undefined") {
194759
194919
  canWatchAffectingLocation,
194760
194920
  canWatchAtTypes,
194761
194921
  canWatchDirectoryOrFile,
194922
+ canWatchDirectoryOrFilePath,
194762
194923
  cartesianProduct,
194763
194924
  cast,
194764
194925
  chainBundle,
@@ -195091,6 +195252,7 @@ if (typeof console !== "undefined") {
195091
195252
  forEach,
195092
195253
  forEachAncestor,
195093
195254
  forEachAncestorDirectory,
195255
+ forEachAncestorDirectoryStoppingAtGlobalCache,
195094
195256
  forEachChild,
195095
195257
  forEachChildRecursively,
195096
195258
  forEachEmittedFile,
@@ -195704,7 +195866,7 @@ if (typeof console !== "undefined") {
195704
195866
  isBooleanLiteral,
195705
195867
  isBreakOrContinueStatement,
195706
195868
  isBreakStatement,
195707
- isBuild,
195869
+ isBuildCommand,
195708
195870
  isBuildInfoFile,
195709
195871
  isBuilderProgram,
195710
195872
  isBundle,
@@ -196619,6 +196781,7 @@ if (typeof console !== "undefined") {
196619
196781
  tagNamesAreEquivalent,
196620
196782
  takeWhile,
196621
196783
  targetOptionDeclaration,
196784
+ targetToLibMap,
196622
196785
  testFormatSettings,
196623
196786
  textChangeRangeIsUnchanged,
196624
196787
  textChangeRangeNewSpan,
@@ -196712,6 +196875,7 @@ if (typeof console !== "undefined") {
196712
196875
  tryRemoveExtension,
196713
196876
  tryRemovePrefix,
196714
196877
  tryRemoveSuffix,
196878
+ tscBuildOption,
196715
196879
  typeAcquisitionDeclarations,
196716
196880
  typeAliasNamePart,
196717
196881
  typeDirectiveIsEqualTo,