typescript 5.7.0-dev.20240904 → 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/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.7";
21
- var version = `${versionMajorMinor}.0-dev.20240904`;
21
+ var version = `${versionMajorMinor}.0-dev.20240911`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -11118,29 +11118,33 @@ function isExternalModuleNameRelative(moduleName) {
11118
11118
  function sortAndDeduplicateDiagnostics(diagnostics) {
11119
11119
  return sortAndDeduplicate(diagnostics, compareDiagnostics, diagnosticsEqualityComparer);
11120
11120
  }
11121
+ var targetToLibMap = /* @__PURE__ */ new Map([
11122
+ [99 /* ESNext */, "lib.esnext.full.d.ts"],
11123
+ [10 /* ES2023 */, "lib.es2023.full.d.ts"],
11124
+ [9 /* ES2022 */, "lib.es2022.full.d.ts"],
11125
+ [8 /* ES2021 */, "lib.es2021.full.d.ts"],
11126
+ [7 /* ES2020 */, "lib.es2020.full.d.ts"],
11127
+ [6 /* ES2019 */, "lib.es2019.full.d.ts"],
11128
+ [5 /* ES2018 */, "lib.es2018.full.d.ts"],
11129
+ [4 /* ES2017 */, "lib.es2017.full.d.ts"],
11130
+ [3 /* ES2016 */, "lib.es2016.full.d.ts"],
11131
+ [2 /* ES2015 */, "lib.es6.d.ts"]
11132
+ // We don't use lib.es2015.full.d.ts due to breaking change.
11133
+ ]);
11121
11134
  function getDefaultLibFileName(options) {
11122
- switch (getEmitScriptTarget(options)) {
11135
+ const target = getEmitScriptTarget(options);
11136
+ switch (target) {
11123
11137
  case 99 /* ESNext */:
11124
- return "lib.esnext.full.d.ts";
11125
11138
  case 10 /* ES2023 */:
11126
- return "lib.es2023.full.d.ts";
11127
11139
  case 9 /* ES2022 */:
11128
- return "lib.es2022.full.d.ts";
11129
11140
  case 8 /* ES2021 */:
11130
- return "lib.es2021.full.d.ts";
11131
11141
  case 7 /* ES2020 */:
11132
- return "lib.es2020.full.d.ts";
11133
11142
  case 6 /* ES2019 */:
11134
- return "lib.es2019.full.d.ts";
11135
11143
  case 5 /* ES2018 */:
11136
- return "lib.es2018.full.d.ts";
11137
11144
  case 4 /* ES2017 */:
11138
- return "lib.es2017.full.d.ts";
11139
11145
  case 3 /* ES2016 */:
11140
- return "lib.es2016.full.d.ts";
11141
11146
  case 2 /* ES2015 */:
11142
- return "lib.es6.d.ts";
11143
- // We don't use lib.es2015.full.d.ts due to breaking change.
11147
+ return targetToLibMap.get(target);
11144
11148
  default:
11145
11149
  return "lib.d.ts";
11146
11150
  }
@@ -27020,23 +27024,21 @@ function hasRecordedExternalHelpers(sourceFile) {
27020
27024
  }
27021
27025
  function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
27022
27026
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
27023
- let namedBindings;
27024
27027
  const moduleKind = getEmitModuleKind(compilerOptions);
27025
- if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
27026
- const helpers = getEmitHelpers(sourceFile);
27028
+ const impliedModuleKind = getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions);
27029
+ const helpers = getImportedHelpers(sourceFile);
27030
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || impliedModuleKind === 99 /* ESNext */ || impliedModuleKind === void 0 && moduleKind === 200 /* Preserve */) {
27027
27031
  if (helpers) {
27028
27032
  const helperNames = [];
27029
27033
  for (const helper of helpers) {
27030
- if (!helper.scoped) {
27031
- const importName = helper.importName;
27032
- if (importName) {
27033
- pushIfUnique(helperNames, importName);
27034
- }
27034
+ const importName = helper.importName;
27035
+ if (importName) {
27036
+ pushIfUnique(helperNames, importName);
27035
27037
  }
27036
27038
  }
27037
27039
  if (some(helperNames)) {
27038
27040
  helperNames.sort(compareStringsCaseSensitive);
27039
- namedBindings = nodeFactory.createNamedImports(
27041
+ const namedBindings = nodeFactory.createNamedImports(
27040
27042
  map(helperNames, (name) => isFileLevelUniqueName(sourceFile, name) ? nodeFactory.createImportSpecifier(
27041
27043
  /*isTypeOnly*/
27042
27044
  false,
@@ -27053,57 +27055,54 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
27053
27055
  const parseNode = getOriginalNode(sourceFile, isSourceFile);
27054
27056
  const emitNode = getOrCreateEmitNode(parseNode);
27055
27057
  emitNode.externalHelpers = true;
27058
+ const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
27059
+ /*modifiers*/
27060
+ void 0,
27061
+ nodeFactory.createImportClause(
27062
+ /*isTypeOnly*/
27063
+ false,
27064
+ /*name*/
27065
+ void 0,
27066
+ namedBindings
27067
+ ),
27068
+ nodeFactory.createStringLiteral(externalHelpersModuleNameText),
27069
+ /*attributes*/
27070
+ void 0
27071
+ );
27072
+ addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
27073
+ return externalHelpersImportDeclaration;
27056
27074
  }
27057
27075
  }
27058
27076
  } else {
27059
- const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
27077
+ const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
27060
27078
  if (externalHelpersModuleName) {
27061
- namedBindings = nodeFactory.createNamespaceImport(externalHelpersModuleName);
27062
- }
27063
- }
27064
- if (namedBindings) {
27065
- const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
27066
- /*modifiers*/
27067
- void 0,
27068
- nodeFactory.createImportClause(
27079
+ const externalHelpersImportDeclaration = nodeFactory.createImportEqualsDeclaration(
27080
+ /*modifiers*/
27081
+ void 0,
27069
27082
  /*isTypeOnly*/
27070
27083
  false,
27071
- /*name*/
27072
- void 0,
27073
- namedBindings
27074
- ),
27075
- nodeFactory.createStringLiteral(externalHelpersModuleNameText),
27076
- /*attributes*/
27077
- void 0
27078
- );
27079
- addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
27080
- return externalHelpersImportDeclaration;
27084
+ externalHelpersModuleName,
27085
+ nodeFactory.createExternalModuleReference(nodeFactory.createStringLiteral(externalHelpersModuleNameText))
27086
+ );
27087
+ addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
27088
+ return externalHelpersImportDeclaration;
27089
+ }
27081
27090
  }
27082
27091
  }
27083
27092
  }
27084
- function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
27085
- if (compilerOptions.importHelpers && isEffectiveExternalModule(node, compilerOptions)) {
27086
- const externalHelpersModuleName = getExternalHelpersModuleName(node);
27087
- if (externalHelpersModuleName) {
27088
- return externalHelpersModuleName;
27089
- }
27090
- let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
27091
- if (!create) {
27092
- const helpers = getEmitHelpers(node);
27093
- if (helpers) {
27094
- for (const helper of helpers) {
27095
- if (!helper.scoped) {
27096
- create = true;
27097
- break;
27098
- }
27099
- }
27100
- }
27101
- }
27102
- if (create) {
27103
- const parseNode = getOriginalNode(node, isSourceFile);
27104
- const emitNode = getOrCreateEmitNode(parseNode);
27105
- return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory2.createUniqueName(externalHelpersModuleNameText));
27106
- }
27093
+ function getImportedHelpers(sourceFile) {
27094
+ return filter(getEmitHelpers(sourceFile), (helper) => !helper.scoped);
27095
+ }
27096
+ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
27097
+ const externalHelpersModuleName = getExternalHelpersModuleName(node);
27098
+ if (externalHelpersModuleName) {
27099
+ return externalHelpersModuleName;
27100
+ }
27101
+ const create = some(helpers) || (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
27102
+ if (create) {
27103
+ const parseNode = getOriginalNode(node, isSourceFile);
27104
+ const emitNode = getOrCreateEmitNode(parseNode);
27105
+ return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory2.createUniqueName(externalHelpersModuleNameText));
27107
27106
  }
27108
27107
  }
27109
27108
  function getLocalNameForExternalImport(factory2, node, sourceFile) {
@@ -36261,15 +36260,6 @@ var commandOptionsWithoutBuild = [
36261
36260
  paramType: Diagnostics.FILE_OR_DIRECTORY,
36262
36261
  description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json
36263
36262
  },
36264
- {
36265
- name: "build",
36266
- type: "boolean",
36267
- shortName: "b",
36268
- showInSimplifiedHelpView: true,
36269
- category: Diagnostics.Command_line_Options,
36270
- description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
36271
- defaultValueDescription: false
36272
- },
36273
36263
  {
36274
36264
  name: "showConfig",
36275
36265
  type: "boolean",
@@ -37254,7 +37244,17 @@ var commandLineOptionOfCustomType = optionDeclarations.filter(isCommandLineOptio
37254
37244
  function isCommandLineOptionOfCustomType(option) {
37255
37245
  return !isString(option.type);
37256
37246
  }
37247
+ var tscBuildOption = {
37248
+ name: "build",
37249
+ type: "boolean",
37250
+ shortName: "b",
37251
+ showInSimplifiedHelpView: true,
37252
+ category: Diagnostics.Command_line_Options,
37253
+ description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
37254
+ defaultValueDescription: false
37255
+ };
37257
37256
  var optionsForBuild = [
37257
+ tscBuildOption,
37258
37258
  {
37259
37259
  name: "verbose",
37260
37260
  shortName: "v",
@@ -37390,8 +37390,14 @@ function getOptionName(option) {
37390
37390
  }
37391
37391
  function createUnknownOptionError(unknownOption, diagnostics, unknownOptionErrorText, node, sourceFile) {
37392
37392
  var _a;
37393
- if ((_a = diagnostics.alternateMode) == null ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) {
37394
- return createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.alternateMode.diagnostic, unknownOption);
37393
+ const otherOption = (_a = diagnostics.alternateMode) == null ? void 0 : _a.getOptionsNameMap().optionsNameMap.get(unknownOption.toLowerCase());
37394
+ if (otherOption) {
37395
+ return createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(
37396
+ sourceFile,
37397
+ node,
37398
+ otherOption !== tscBuildOption ? diagnostics.alternateMode.diagnostic : Diagnostics.Option_build_must_be_the_first_command_line_argument,
37399
+ unknownOption
37400
+ );
37395
37401
  }
37396
37402
  const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
37397
37403
  return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
@@ -37577,10 +37583,10 @@ var buildOptionsDidYouMeanDiagnostics = {
37577
37583
  unknownDidYouMeanDiagnostic: Diagnostics.Unknown_build_option_0_Did_you_mean_1,
37578
37584
  optionTypeMismatchDiagnostic: Diagnostics.Build_option_0_requires_a_value_of_type_1
37579
37585
  };
37580
- function parseBuildCommand(args) {
37586
+ function parseBuildCommand(commandLine) {
37581
37587
  const { options, watchOptions, fileNames: projects, errors } = parseCommandLineWorker(
37582
37588
  buildOptionsDidYouMeanDiagnostics,
37583
- args
37589
+ commandLine
37584
37590
  );
37585
37591
  const buildOptions = options;
37586
37592
  if (projects.length === 0) {
@@ -38504,7 +38510,7 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
38504
38510
  if (ownConfig.raw.compileOnSave === void 0 && result.compileOnSave) ownConfig.raw.compileOnSave = result.compileOnSave;
38505
38511
  if (sourceFile && result.extendedSourceFiles) sourceFile.extendedSourceFiles = arrayFrom(result.extendedSourceFiles.keys());
38506
38512
  ownConfig.options = assign(result.options, ownConfig.options);
38507
- ownConfig.watchOptions = ownConfig.watchOptions && result.watchOptions ? assign(result.watchOptions, ownConfig.watchOptions) : ownConfig.watchOptions || result.watchOptions;
38513
+ ownConfig.watchOptions = ownConfig.watchOptions && result.watchOptions ? assignWatchOptions(result, ownConfig.watchOptions) : ownConfig.watchOptions || result.watchOptions;
38508
38514
  }
38509
38515
  return ownConfig;
38510
38516
  function applyExtendedConfig(result, extendedConfigPath) {
@@ -38528,9 +38534,14 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
38528
38534
  result.compileOnSave = extendsRaw.compileOnSave;
38529
38535
  }
38530
38536
  assign(result.options, extendedConfig.options);
38531
- result.watchOptions = result.watchOptions && extendedConfig.watchOptions ? assign({}, result.watchOptions, extendedConfig.watchOptions) : result.watchOptions || extendedConfig.watchOptions;
38537
+ result.watchOptions = result.watchOptions && extendedConfig.watchOptions ? assignWatchOptions(result, extendedConfig.watchOptions) : result.watchOptions || extendedConfig.watchOptions;
38532
38538
  }
38533
38539
  }
38540
+ function assignWatchOptions(result, watchOptions) {
38541
+ if (result.watchOptionsCopied) return assign(result.watchOptions, watchOptions);
38542
+ result.watchOptionsCopied = true;
38543
+ return assign({}, result.watchOptions, watchOptions);
38544
+ }
38534
38545
  }
38535
38546
  function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
38536
38547
  if (hasProperty(json, "excludes")) {
@@ -40498,7 +40509,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
40498
40509
  };
40499
40510
  }
40500
40511
  function getPackageScopeForPath(directory, state) {
40501
- return forEachAncestorDirectory(
40512
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
40513
+ state.host,
40502
40514
  directory,
40503
40515
  (dir) => getPackageJsonInfo(
40504
40516
  dir,
@@ -41137,17 +41149,30 @@ function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName,
41137
41149
  return lookup(secondaryExtensions);
41138
41150
  }
41139
41151
  function lookup(extensions2) {
41140
- return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
41141
- if (getBaseFileName(ancestorDirectory) !== "node_modules") {
41142
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
41143
- if (resolutionFromCache) {
41144
- return resolutionFromCache;
41152
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
41153
+ state.host,
41154
+ normalizeSlashes(directory),
41155
+ (ancestorDirectory) => {
41156
+ if (getBaseFileName(ancestorDirectory) !== "node_modules") {
41157
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
41158
+ if (resolutionFromCache) {
41159
+ return resolutionFromCache;
41160
+ }
41161
+ return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions2, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
41145
41162
  }
41146
- return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions2, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
41147
41163
  }
41148
- });
41164
+ );
41149
41165
  }
41150
41166
  }
41167
+ function forEachAncestorDirectoryStoppingAtGlobalCache(host, directory, callback) {
41168
+ var _a;
41169
+ const globalCache = (_a = host == null ? void 0 : host.getGlobalTypingsCacheLocation) == null ? void 0 : _a.call(host);
41170
+ return forEachAncestorDirectory(directory, (ancestorDirectory) => {
41171
+ const result = callback(ancestorDirectory);
41172
+ if (result !== void 0) return result;
41173
+ if (ancestorDirectory === globalCache) return false;
41174
+ }) || void 0;
41175
+ }
41151
41176
  function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
41152
41177
  const nodeModulesFolder = combinePaths(directory, "node_modules");
41153
41178
  const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
@@ -41343,28 +41368,32 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
41343
41368
  return { value: resolvedUsingSettings };
41344
41369
  }
41345
41370
  if (!isExternalModuleNameRelative(moduleName)) {
41346
- const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
41347
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
41348
- cache,
41349
- moduleName,
41350
- /*mode*/
41351
- void 0,
41352
- directory,
41353
- redirectedReference,
41354
- state
41355
- );
41356
- if (resolutionFromCache) {
41357
- return resolutionFromCache;
41358
- }
41359
- const searchName = normalizePath(combinePaths(directory, moduleName));
41360
- return toSearchResult(loadModuleFromFileNoPackageId(
41361
- extensions,
41362
- searchName,
41363
- /*onlyRecordFailures*/
41364
- false,
41365
- state
41366
- ));
41367
- });
41371
+ const resolved2 = forEachAncestorDirectoryStoppingAtGlobalCache(
41372
+ state.host,
41373
+ containingDirectory,
41374
+ (directory) => {
41375
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
41376
+ cache,
41377
+ moduleName,
41378
+ /*mode*/
41379
+ void 0,
41380
+ directory,
41381
+ redirectedReference,
41382
+ state
41383
+ );
41384
+ if (resolutionFromCache) {
41385
+ return resolutionFromCache;
41386
+ }
41387
+ const searchName = normalizePath(combinePaths(directory, moduleName));
41388
+ return toSearchResult(loadModuleFromFileNoPackageId(
41389
+ extensions,
41390
+ searchName,
41391
+ /*onlyRecordFailures*/
41392
+ false,
41393
+ state
41394
+ ));
41395
+ }
41396
+ );
41368
41397
  if (resolved2) return resolved2;
41369
41398
  if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
41370
41399
  let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
@@ -44886,9 +44915,11 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
44886
44915
  if (host.getNearestAncestorDirectoryWithPackageJson) {
44887
44916
  return host.getNearestAncestorDirectoryWithPackageJson(fileName);
44888
44917
  }
44889
- return forEachAncestorDirectory(fileName, (directory) => {
44890
- return host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0;
44891
- });
44918
+ return forEachAncestorDirectoryStoppingAtGlobalCache(
44919
+ host,
44920
+ fileName,
44921
+ (directory) => host.fileExists(combinePaths(directory, "package.json")) ? directory : void 0
44922
+ );
44892
44923
  }
44893
44924
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
44894
44925
  var _a;
@@ -44906,25 +44937,29 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
44906
44937
  }
44907
44938
  const symlinkedDirectories = (_a = host.getSymlinkCache) == null ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
44908
44939
  const fullImportedFileName = getNormalizedAbsolutePath(importedFileName, cwd);
44909
- const result = symlinkedDirectories && forEachAncestorDirectory(getDirectoryPath(fullImportedFileName), (realPathDirectory) => {
44910
- const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(toPath(realPathDirectory, cwd, getCanonicalFileName)));
44911
- if (!symlinkDirectories) return void 0;
44912
- if (startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
44913
- return false;
44914
- }
44915
- return forEach(targets, (target) => {
44916
- if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
44917
- return;
44918
- }
44919
- const relative = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
44920
- for (const symlinkDirectory of symlinkDirectories) {
44921
- const option = resolvePath(symlinkDirectory, relative);
44922
- const result2 = cb(option, target === referenceRedirect);
44923
- shouldFilterIgnoredPaths = true;
44924
- if (result2) return result2;
44940
+ const result = symlinkedDirectories && forEachAncestorDirectoryStoppingAtGlobalCache(
44941
+ host,
44942
+ getDirectoryPath(fullImportedFileName),
44943
+ (realPathDirectory) => {
44944
+ const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(toPath(realPathDirectory, cwd, getCanonicalFileName)));
44945
+ if (!symlinkDirectories) return void 0;
44946
+ if (startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
44947
+ return false;
44925
44948
  }
44926
- });
44927
- });
44949
+ return forEach(targets, (target) => {
44950
+ if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
44951
+ return;
44952
+ }
44953
+ const relative = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
44954
+ for (const symlinkDirectory of symlinkDirectories) {
44955
+ const option = resolvePath(symlinkDirectory, relative);
44956
+ const result2 = cb(option, target === referenceRedirect);
44957
+ shouldFilterIgnoredPaths = true;
44958
+ if (result2) return result2;
44959
+ }
44960
+ });
44961
+ }
44962
+ );
44928
44963
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
44929
44964
  }
44930
44965
  var runtimeDependencyFields = ["dependencies", "peerDependencies", "optionalDependencies"];
@@ -88698,7 +88733,8 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
88698
88733
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
88699
88734
  readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
88700
88735
  getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
88701
- getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
88736
+ getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index),
88737
+ getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
88702
88738
  };
88703
88739
  }
88704
88740
  var SymbolTrackerImpl = class _SymbolTrackerImpl {
@@ -111107,6 +111143,7 @@ function transformECMAScriptModule(context) {
111107
111143
  context.onSubstituteNode = onSubstituteNode;
111108
111144
  context.enableEmitNotification(307 /* SourceFile */);
111109
111145
  context.enableSubstitution(80 /* Identifier */);
111146
+ const noSubstitution = /* @__PURE__ */ new Set();
111110
111147
  let helperNameSubstitutions;
111111
111148
  let currentSourceFile;
111112
111149
  let importRequireStatements;
@@ -111141,7 +111178,7 @@ function transformECMAScriptModule(context) {
111141
111178
  if (externalHelpersImportDeclaration) {
111142
111179
  const statements = [];
111143
111180
  const statementOffset = factory2.copyPrologue(node.statements, statements);
111144
- append(statements, externalHelpersImportDeclaration);
111181
+ addRange(statements, visitArray([externalHelpersImportDeclaration], visitor, isStatement));
111145
111182
  addRange(statements, visitNodes2(node.statements, visitor, isStatement, statementOffset));
111146
111183
  return factory2.updateSourceFile(
111147
111184
  node,
@@ -111356,7 +111393,9 @@ function transformECMAScriptModule(context) {
111356
111393
  if ((isExternalModule(node) || getIsolatedModules(compilerOptions)) && compilerOptions.importHelpers) {
111357
111394
  helperNameSubstitutions = /* @__PURE__ */ new Map();
111358
111395
  }
111396
+ currentSourceFile = node;
111359
111397
  previousOnEmitNode(hint, node, emitCallback);
111398
+ currentSourceFile = void 0;
111360
111399
  helperNameSubstitutions = void 0;
111361
111400
  } else {
111362
111401
  previousOnEmitNode(hint, node, emitCallback);
@@ -111364,18 +111403,29 @@ function transformECMAScriptModule(context) {
111364
111403
  }
111365
111404
  function onSubstituteNode(hint, node) {
111366
111405
  node = previousOnSubstituteNode(hint, node);
111367
- if (helperNameSubstitutions && isIdentifier(node) && getEmitFlags(node) & 8192 /* HelperName */) {
111406
+ if (node.id && noSubstitution.has(node.id)) {
111407
+ return node;
111408
+ }
111409
+ if (isIdentifier(node) && getEmitFlags(node) & 8192 /* HelperName */) {
111368
111410
  return substituteHelperName(node);
111369
111411
  }
111370
111412
  return node;
111371
111413
  }
111372
111414
  function substituteHelperName(node) {
111373
- const name = idText(node);
111374
- let substitution = helperNameSubstitutions.get(name);
111375
- if (!substitution) {
111376
- helperNameSubstitutions.set(name, substitution = factory2.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */));
111415
+ const externalHelpersModuleName = currentSourceFile && getExternalHelpersModuleName(currentSourceFile);
111416
+ if (externalHelpersModuleName) {
111417
+ noSubstitution.add(getNodeId(node));
111418
+ return factory2.createPropertyAccessExpression(externalHelpersModuleName, node);
111419
+ }
111420
+ if (helperNameSubstitutions) {
111421
+ const name = idText(node);
111422
+ let substitution = helperNameSubstitutions.get(name);
111423
+ if (!substitution) {
111424
+ helperNameSubstitutions.set(name, substitution = factory2.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */));
111425
+ }
111426
+ return substitution;
111377
111427
  }
111378
- return substitution;
111428
+ return node;
111379
111429
  }
111380
111430
  }
111381
111431
 
@@ -120638,7 +120688,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120638
120688
  getCanonicalFileName,
120639
120689
  getFileIncludeReasons: () => fileReasons,
120640
120690
  structureIsReused,
120641
- writeFile: writeFile2
120691
+ writeFile: writeFile2,
120692
+ getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
120642
120693
  };
120643
120694
  onProgramCreateComplete();
120644
120695
  verifyCompilerOptions();
@@ -121204,7 +121255,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121204
121255
  getFileIncludeReasons: program.getFileIncludeReasons,
121205
121256
  createHash: maybeBind(host, host.createHash),
121206
121257
  getModuleResolutionCache: () => program.getModuleResolutionCache(),
121207
- trace: maybeBind(host, host.trace)
121258
+ trace: maybeBind(host, host.trace),
121259
+ getGlobalTypingsCacheLocation: program.getGlobalTypingsCacheLocation
121208
121260
  };
121209
121261
  }
121210
121262
  function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
@@ -125510,6 +125562,9 @@ function canWatchDirectoryOrFile(pathComponents2, length2) {
125510
125562
  const perceivedOsRootLength = perceivedOsRootLengthForWatching(pathComponents2, length2);
125511
125563
  return length2 > perceivedOsRootLength + 1;
125512
125564
  }
125565
+ function canWatchDirectoryOrFilePath(path) {
125566
+ return canWatchDirectoryOrFile(getPathComponents(path));
125567
+ }
125513
125568
  function canWatchAtTypes(atTypes) {
125514
125569
  return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(getDirectoryPath(atTypes));
125515
125570
  }
@@ -125521,12 +125576,12 @@ function isInDirectoryPath(dirComponents, fileOrDirComponents) {
125521
125576
  return true;
125522
125577
  }
125523
125578
  function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
125524
- return canWatchDirectoryOrFile(getPathComponents(fileOrDirPath));
125579
+ return canWatchDirectoryOrFilePath(fileOrDirPath);
125525
125580
  }
125526
125581
  function canWatchAffectingLocation(filePath) {
125527
125582
  return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
125528
125583
  }
125529
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch) {
125584
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch) {
125530
125585
  const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
125531
125586
  failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
125532
125587
  const failedLookupComponents = getPathComponents(failedLookupLocation);
@@ -125535,7 +125590,7 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
125535
125590
  const nodeModulesIndex = failedLookupPathComponents.indexOf("node_modules");
125536
125591
  if (nodeModulesIndex !== -1 && nodeModulesIndex + 1 <= perceivedOsRootLength + 1) return void 0;
125537
125592
  const lastNodeModulesIndex = failedLookupPathComponents.lastIndexOf("node_modules");
125538
- if (isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
125593
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, failedLookupPathComponents)) {
125539
125594
  if (failedLookupPathComponents.length > rootPathComponents.length + 1) {
125540
125595
  return getDirectoryOfFailedLookupWatch(
125541
125596
  failedLookupComponents,
@@ -125607,9 +125662,9 @@ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, lengt
125607
125662
  packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
125608
125663
  };
125609
125664
  }
125610
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
125665
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
125611
125666
  const typeRootPathComponents = getPathComponents(typeRootPath);
125612
- if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
125667
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
125613
125668
  return rootPath;
125614
125669
  }
125615
125670
  typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
@@ -125650,10 +125705,10 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected
125650
125705
  function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) {
125651
125706
  const host = getModuleResolutionHost(resolutionHost);
125652
125707
  const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
125653
- if (!resolutionHost.getGlobalCache) {
125708
+ if (!resolutionHost.getGlobalTypingsCacheLocation) {
125654
125709
  return primaryResult;
125655
125710
  }
125656
- const globalCache = resolutionHost.getGlobalCache();
125711
+ const globalCache = resolutionHost.getGlobalTypingsCacheLocation();
125657
125712
  if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
125658
125713
  const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
125659
125714
  Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
@@ -125717,6 +125772,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125717
125772
  const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
125718
125773
  const rootPath = resolutionHost.toPath(rootDir);
125719
125774
  const rootPathComponents = getPathComponents(rootPath);
125775
+ const isRootWatchable = canWatchDirectoryOrFile(rootPathComponents);
125720
125776
  const isSymlinkCache = /* @__PURE__ */ new Map();
125721
125777
  const packageDirWatchers = /* @__PURE__ */ new Map();
125722
125778
  const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
@@ -126128,6 +126184,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
126128
126184
  rootDir,
126129
126185
  rootPath,
126130
126186
  rootPathComponents,
126187
+ isRootWatchable,
126131
126188
  getCurrentDirectory,
126132
126189
  resolutionHost.preferNonRecursiveWatch
126133
126190
  );
@@ -126316,6 +126373,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
126316
126373
  rootDir,
126317
126374
  rootPath,
126318
126375
  rootPathComponents,
126376
+ isRootWatchable,
126319
126377
  getCurrentDirectory,
126320
126378
  resolutionHost.preferNonRecursiveWatch
126321
126379
  );
@@ -126459,6 +126517,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
126459
126517
  return false;
126460
126518
  }
126461
126519
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
126520
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
126462
126521
  const packagePath = parseNodeModuleFromPath(
126463
126522
  fileOrDirectoryPath,
126464
126523
  /*isFolder*/
@@ -126540,6 +126599,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
126540
126599
  resolutionHost.toPath(typeRoot),
126541
126600
  rootPath,
126542
126601
  rootPathComponents,
126602
+ isRootWatchable,
126543
126603
  getCurrentDirectory,
126544
126604
  resolutionHost.preferNonRecursiveWatch,
126545
126605
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
@@ -127272,6 +127332,7 @@ function createWatchProgram(host) {
127272
127332
  let updateLevel;
127273
127333
  let missingFilesMap;
127274
127334
  let watchedWildcardDirectories;
127335
+ let staleWatches = /* @__PURE__ */ new Map([[void 0, void 0]]);
127275
127336
  let timerToUpdateProgram;
127276
127337
  let timerToInvalidateFailedLookupResolutions;
127277
127338
  let parsedConfigs;
@@ -127360,8 +127421,6 @@ function createWatchProgram(host) {
127360
127421
  const customHasInvalidLibResolutions = host.resolveLibrary ? maybeBind(host, host.hasInvalidatedLibResolutions) || returnTrue : returnFalse;
127361
127422
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
127362
127423
  synchronizeProgram();
127363
- watchConfigFileWildCardDirectories();
127364
- if (configFileName) updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
127365
127424
  return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close, getResolutionCache } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames, close, getResolutionCache };
127366
127425
  function close() {
127367
127426
  clearInvalidateResolutionsOfFailedLookupLocations();
@@ -127464,6 +127523,16 @@ function createWatchProgram(host) {
127464
127523
  compilerHost.directoryExists = originalDirectoryExists;
127465
127524
  compilerHost.createDirectory = originalCreateDirectory;
127466
127525
  compilerHost.writeFile = originalWriteFile;
127526
+ staleWatches == null ? void 0 : staleWatches.forEach((configFile, configPath) => {
127527
+ if (!configPath) {
127528
+ watchConfigFileWildCardDirectories();
127529
+ if (configFileName) updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
127530
+ } else {
127531
+ const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
127532
+ if (config) watchReferencedProject(configFile, configPath, config);
127533
+ }
127534
+ });
127535
+ staleWatches = void 0;
127467
127536
  return builderProgram;
127468
127537
  }
127469
127538
  function createNewProgram(hasInvalidatedResolutions, hasInvalidatedLibResolutions) {
@@ -127670,9 +127739,8 @@ function createWatchProgram(host) {
127670
127739
  }
127671
127740
  parseConfigFile2();
127672
127741
  hasChangedCompilerOptions = true;
127742
+ (staleWatches ?? (staleWatches = /* @__PURE__ */ new Map())).set(void 0, void 0);
127673
127743
  synchronizeProgram();
127674
- watchConfigFileWildCardDirectories();
127675
- updateExtendedConfigFilesWatches(toPath3(configFileName), compilerOptions, watchOptions, WatchType.ExtendedConfigFile);
127676
127744
  }
127677
127745
  function parseConfigFile2() {
127678
127746
  Debug.assert(configFileName);
@@ -127724,7 +127792,7 @@ function createWatchProgram(host) {
127724
127792
  } else {
127725
127793
  (parsedConfigs || (parsedConfigs = /* @__PURE__ */ new Map())).set(configPath, config = { parsedCommandLine });
127726
127794
  }
127727
- watchReferencedProject(configFileName2, configPath, config);
127795
+ (staleWatches ?? (staleWatches = /* @__PURE__ */ new Map())).set(configPath, configFileName2);
127728
127796
  return parsedCommandLine;
127729
127797
  }
127730
127798
  function getParsedCommandLineFromConfigFileHost(configFileName2) {
@@ -129709,7 +129777,7 @@ function shouldBePretty(sys2, options) {
129709
129777
  return options.pretty;
129710
129778
  }
129711
129779
  function getOptionsForHelp(commandLine) {
129712
- return !!commandLine.options.all ? toSorted(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) : filter(optionDeclarations.slice(), (v) => !!v.showInSimplifiedHelpView);
129780
+ return !!commandLine.options.all ? toSorted(optionDeclarations.concat(tscBuildOption), (a, b) => compareStringsCaseInsensitive(a.name, b.name)) : filter(optionDeclarations.concat(tscBuildOption), (v) => !!v.showInSimplifiedHelpView);
129713
129781
  }
129714
129782
  function printVersion(sys2) {
129715
129783
  sys2.write(getDiagnosticText(Diagnostics.Version_0, version) + sys2.newLine);
@@ -130033,7 +130101,7 @@ function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
130033
130101
  output = [...output, ...generateSectionOptionsOutput(
130034
130102
  sys2,
130035
130103
  getDiagnosticText(Diagnostics.BUILD_OPTIONS),
130036
- buildOptions,
130104
+ filter(buildOptions, (option) => option !== tscBuildOption),
130037
130105
  /*subCategory*/
130038
130106
  false,
130039
130107
  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")
@@ -130047,7 +130115,7 @@ function printBuildHelp(sys2, buildOptions) {
130047
130115
  output = [...output, ...generateSectionOptionsOutput(
130048
130116
  sys2,
130049
130117
  getDiagnosticText(Diagnostics.BUILD_OPTIONS),
130050
- buildOptions,
130118
+ filter(buildOptions, (option) => option !== tscBuildOption),
130051
130119
  /*subCategory*/
130052
130120
  false,
130053
130121
  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")
@@ -130084,10 +130152,6 @@ function printHelp(sys2, commandLine) {
130084
130152
  }
130085
130153
  function executeCommandLineWorker(sys2, cb, commandLine) {
130086
130154
  let reportDiagnostic = createDiagnosticReporter(sys2);
130087
- if (commandLine.options.build) {
130088
- reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_build_must_be_the_first_command_line_argument));
130089
- return sys2.exit(1 /* DiagnosticsPresent_OutputsSkipped */);
130090
- }
130091
130155
  let configFileName;
130092
130156
  if (commandLine.options.locale) {
130093
130157
  validateLocaleAndSetLanguage(commandLine.options.locale, sys2, commandLine.errors);
@@ -130233,16 +130297,16 @@ function executeCommandLineWorker(sys2, cb, commandLine) {
130233
130297
  }
130234
130298
  }
130235
130299
  }
130236
- function isBuild(commandLineArgs) {
130300
+ function isBuildCommand(commandLineArgs) {
130237
130301
  if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45 /* minus */) {
130238
130302
  const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase();
130239
- return firstOption === "build" || firstOption === "b";
130303
+ return firstOption === tscBuildOption.name || firstOption === tscBuildOption.shortName;
130240
130304
  }
130241
130305
  return false;
130242
130306
  }
130243
130307
  function executeCommandLine(system, cb, commandLineArgs) {
130244
- if (isBuild(commandLineArgs)) {
130245
- const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs.slice(1));
130308
+ if (isBuildCommand(commandLineArgs)) {
130309
+ const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs);
130246
130310
  if (buildOptions.generateCpuProfile && system.enableCPUProfiler) {
130247
130311
  system.enableCPUProfiler(buildOptions.generateCpuProfile, () => performBuild(
130248
130312
  system,