typescript 5.6.0-dev.20240612 → 5.6.0-dev.20240614

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.6";
21
- var version = `${versionMajorMinor}.0-dev.20240612`;
21
+ var version = `${versionMajorMinor}.0-dev.20240614`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -2548,16 +2548,6 @@ function tryGetNativePerformanceHooks() {
2548
2548
  }
2549
2549
  var timestamp = nativePerformanceTime ? () => nativePerformanceTime.now() : Date.now;
2550
2550
 
2551
- // src/compiler/perfLogger.ts
2552
- var etwModule;
2553
- try {
2554
- const etwModulePath = process.env.TS_ETW_MODULE_PATH ?? "./node_modules/@microsoft/typescript-etw";
2555
- etwModule = require(etwModulePath);
2556
- } catch (e) {
2557
- etwModule = void 0;
2558
- }
2559
- var perfLogger = (etwModule == null ? void 0 : etwModule.logEvent) ? etwModule : void 0;
2560
-
2561
2551
  // src/compiler/performance.ts
2562
2552
  var perfHooks;
2563
2553
  var performanceImpl;
@@ -3564,6 +3554,7 @@ var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags3) => {
3564
3554
  NodeCheckFlags3[NodeCheckFlags3["ContainsClassWithPrivateIdentifiers"] = 1048576] = "ContainsClassWithPrivateIdentifiers";
3565
3555
  NodeCheckFlags3[NodeCheckFlags3["ContainsSuperPropertyInStaticInitializer"] = 2097152] = "ContainsSuperPropertyInStaticInitializer";
3566
3556
  NodeCheckFlags3[NodeCheckFlags3["InCheckIdentifier"] = 4194304] = "InCheckIdentifier";
3557
+ NodeCheckFlags3[NodeCheckFlags3["PartiallyTypeChecked"] = 8388608] = "PartiallyTypeChecked";
3567
3558
  NodeCheckFlags3[NodeCheckFlags3["LazyFlags"] = 539358128] = "LazyFlags";
3568
3559
  return NodeCheckFlags3;
3569
3560
  })(NodeCheckFlags || {});
@@ -5108,7 +5099,7 @@ var sys = (() => {
5108
5099
  callback
5109
5100
  );
5110
5101
  }
5111
- function readFileWorker(fileName, _encoding) {
5102
+ function readFile(fileName, _encoding) {
5112
5103
  let buffer;
5113
5104
  try {
5114
5105
  buffer = _fs.readFileSync(fileName);
@@ -5133,16 +5124,7 @@ var sys = (() => {
5133
5124
  }
5134
5125
  return buffer.toString("utf8");
5135
5126
  }
5136
- function readFile(fileName, _encoding) {
5137
- var _a, _b;
5138
- (_a = perfLogger) == null ? void 0 : _a.logStartReadFile(fileName);
5139
- const file = readFileWorker(fileName, _encoding);
5140
- (_b = perfLogger) == null ? void 0 : _b.logStopReadFile();
5141
- return file;
5142
- }
5143
5127
  function writeFile2(fileName, data, writeByteOrderMark) {
5144
- var _a;
5145
- (_a = perfLogger) == null ? void 0 : _a.logEvent("WriteFile: " + fileName);
5146
5128
  if (writeByteOrderMark) {
5147
5129
  data = byteOrderMarkIndicator + data;
5148
5130
  }
@@ -5163,8 +5145,6 @@ var sys = (() => {
5163
5145
  }
5164
5146
  }
5165
5147
  function getAccessibleFileSystemEntries(path) {
5166
- var _a;
5167
- (_a = perfLogger) == null ? void 0 : _a.logEvent("ReadDir: " + (path || "."));
5168
5148
  try {
5169
5149
  const entries = _fs.readdirSync(path || ".", { withFileTypes: true });
5170
5150
  const files = [];
@@ -5923,7 +5903,6 @@ var Diagnostics = {
5923
5903
  _0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5924
5904
  _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5925
5905
  _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5926
- ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve: diag(1293, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve_1293", "ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'."),
5927
5906
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5928
5907
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5929
5908
  The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
@@ -6812,7 +6791,6 @@ var Diagnostics = {
6812
6791
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, 1 /* Error */, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
6813
6792
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, 1 /* Error */, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
6814
6793
  Cannot_read_file_0_Colon_1: diag(5012, 1 /* Error */, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
6815
- Failed_to_parse_file_0_Colon_1: diag(5014, 1 /* Error */, "Failed_to_parse_file_0_Colon_1_5014", "Failed to parse file '{0}': {1}."),
6816
6794
  Unknown_compiler_option_0: diag(5023, 1 /* Error */, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
6817
6795
  Compiler_option_0_requires_a_value_of_type_1: diag(5024, 1 /* Error */, "Compiler_option_0_requires_a_value_of_type_1_5024", "Compiler option '{0}' requires a value of type {1}."),
6818
6796
  Unknown_compiler_option_0_Did_you_mean_1: diag(5025, 1 /* Error */, "Unknown_compiler_option_0_Did_you_mean_1_5025", "Unknown compiler option '{0}'. Did you mean '{1}'?"),
@@ -6875,6 +6853,7 @@ var Diagnostics = {
6875
6853
  Option_0_1_has_been_removed_Please_remove_it_from_your_configuration: diag(5108, 1 /* Error */, "Option_0_1_has_been_removed_Please_remove_it_from_your_configuration_5108", "Option '{0}={1}' has been removed. Please remove it from your configuration."),
6876
6854
  Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1: diag(5109, 1 /* Error */, "Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1_5109", "Option 'moduleResolution' must be set to '{0}' (or left unspecified) when option 'module' is set to '{1}'."),
6877
6855
  Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1: diag(5110, 1 /* Error */, "Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1_5110", "Option 'module' must be set to '{0}' when option 'moduleResolution' is set to '{1}'."),
6856
+ Option_tsBuildInfoFile_cannot_be_specified_without_specifying_option_incremental_or_composite_or_if_not_running_tsc_b: diag(5111, 1 /* Error */, "Option_tsBuildInfoFile_cannot_be_specified_without_specifying_option_incremental_or_composite_or_if__5111", "Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or 'composite' or if not running 'tsc -b'."),
6878
6857
  Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6e3, 3 /* Message */, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."),
6879
6858
  Concatenate_and_emit_output_to_single_file: diag(6001, 3 /* Message */, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."),
6880
6859
  Generates_corresponding_d_ts_file: diag(6002, 3 /* Message */, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
@@ -7255,6 +7234,8 @@ var Diagnostics = {
7255
7234
  Exiting_conditional_exports: diag(6416, 3 /* Message */, "Exiting_conditional_exports_6416", "Exiting conditional exports."),
7256
7235
  Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0: diag(6417, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0_6417", "Searching all ancestor node_modules directories for preferred extensions: {0}."),
7257
7236
  Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0: diag(6418, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0_6418", "Searching all ancestor node_modules directories for fallback extensions: {0}."),
7237
+ Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors: diag(6419, 3 /* Message */, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors_6419", "Project '{0}' is out of date because buildinfo file '{1}' indicates that program needs to report errors."),
7238
+ Project_0_is_out_of_date_because_1: diag(6420, 3 /* Message */, "Project_0_is_out_of_date_because_1_6420", "Project '{0}' is out of date because {1}."),
7258
7239
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, 3 /* Message */, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
7259
7240
  The_expected_type_comes_from_this_index_signature: diag(6501, 3 /* Message */, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
7260
7241
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, 3 /* Message */, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -11102,8 +11083,8 @@ function textSpanIsEmpty(span) {
11102
11083
  function textSpanContainsPosition(span, position) {
11103
11084
  return position >= span.start && position < textSpanEnd(span);
11104
11085
  }
11105
- function textRangeContainsPositionInclusive(span, position) {
11106
- return position >= span.pos && position <= span.end;
11086
+ function textRangeContainsPositionInclusive(range, position) {
11087
+ return position >= range.pos && position <= range.end;
11107
11088
  }
11108
11089
  function createTextSpan(start, length2) {
11109
11090
  if (start < 0) {
@@ -14754,23 +14735,6 @@ function isFunctionSymbol(symbol) {
14754
14735
  const decl = symbol.valueDeclaration;
14755
14736
  return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
14756
14737
  }
14757
- function canHaveModuleSpecifier(node) {
14758
- switch (node == null ? void 0 : node.kind) {
14759
- case 260 /* VariableDeclaration */:
14760
- case 208 /* BindingElement */:
14761
- case 272 /* ImportDeclaration */:
14762
- case 278 /* ExportDeclaration */:
14763
- case 271 /* ImportEqualsDeclaration */:
14764
- case 273 /* ImportClause */:
14765
- case 280 /* NamespaceExport */:
14766
- case 274 /* NamespaceImport */:
14767
- case 281 /* ExportSpecifier */:
14768
- case 276 /* ImportSpecifier */:
14769
- case 205 /* ImportType */:
14770
- return true;
14771
- }
14772
- return false;
14773
- }
14774
14738
  function tryGetModuleSpecifierFromDeclaration(node) {
14775
14739
  var _a, _b;
14776
14740
  switch (node.kind) {
@@ -17488,8 +17452,8 @@ function walkTreeForJSXTags(node) {
17488
17452
  function isFileModuleFromUsingJSXTag(file) {
17489
17453
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
17490
17454
  }
17491
- function isFileForcedToBeModuleByFormat(file, options) {
17492
- return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
17455
+ function isFileForcedToBeModuleByFormat(file) {
17456
+ return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
17493
17457
  }
17494
17458
  function getSetExternalModuleIndicator(options) {
17495
17459
  switch (getEmitModuleDetectionKind(options)) {
@@ -17508,14 +17472,10 @@ function getSetExternalModuleIndicator(options) {
17508
17472
  }
17509
17473
  checks.push(isFileForcedToBeModuleByFormat);
17510
17474
  const combined = or(...checks);
17511
- const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
17475
+ const callback = (file) => void (file.externalModuleIndicator = combined(file));
17512
17476
  return callback;
17513
17477
  }
17514
17478
  }
17515
- function importSyntaxAffectsModuleResolution(options) {
17516
- const moduleResolution = getEmitModuleResolutionKind(options);
17517
- return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
17518
- }
17519
17479
  function createComputedCompilerOptions(options) {
17520
17480
  return options;
17521
17481
  }
@@ -18336,9 +18296,9 @@ function rangeOfTypeParameters(sourceFile, typeParameters) {
18336
18296
  return { pos, end };
18337
18297
  }
18338
18298
  function skipTypeChecking(sourceFile, options, host) {
18339
- return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || options.noCheck || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName) || !canIncludeBindAndCheckDiagnsotics(sourceFile, options);
18299
+ return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || options.noCheck || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName) || !canIncludeBindAndCheckDiagnostics(sourceFile, options);
18340
18300
  }
18341
- function canIncludeBindAndCheckDiagnsotics(sourceFile, options) {
18301
+ function canIncludeBindAndCheckDiagnostics(sourceFile, options) {
18342
18302
  if (!!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false) return false;
18343
18303
  if (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || sourceFile.scriptKind === 5 /* External */) return true;
18344
18304
  const isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
@@ -19189,7 +19149,7 @@ function createNameResolver({
19189
19149
  }
19190
19150
  break;
19191
19151
  }
19192
- if (isSelfReferenceLocation(location)) {
19152
+ if (isSelfReferenceLocation(location, lastLocation)) {
19193
19153
  lastSelfReferenceLocation = location;
19194
19154
  }
19195
19155
  lastLocation = location;
@@ -19290,8 +19250,10 @@ function createNameResolver({
19290
19250
  }
19291
19251
  return !getImmediatelyInvokedFunctionExpression(location);
19292
19252
  }
19293
- function isSelfReferenceLocation(node) {
19253
+ function isSelfReferenceLocation(node, lastLocation) {
19294
19254
  switch (node.kind) {
19255
+ case 169 /* Parameter */:
19256
+ return !!lastLocation && lastLocation === node.name;
19295
19257
  case 262 /* FunctionDeclaration */:
19296
19258
  case 263 /* ClassDeclaration */:
19297
19259
  case 264 /* InterfaceDeclaration */:
@@ -26676,7 +26638,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
26676
26638
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
26677
26639
  let namedBindings;
26678
26640
  const moduleKind = getEmitModuleKind(compilerOptions);
26679
- if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
26641
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
26680
26642
  const helpers = getEmitHelpers(sourceFile);
26681
26643
  if (helpers) {
26682
26644
  const helperNames = [];
@@ -26741,7 +26703,8 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
26741
26703
  if (externalHelpersModuleName) {
26742
26704
  return externalHelpersModuleName;
26743
26705
  }
26744
- let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
26706
+ const moduleKind = getEmitModuleKind(compilerOptions);
26707
+ let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
26745
26708
  if (!create) {
26746
26709
  const helpers = getEmitHelpers(node);
26747
26710
  if (helpers) {
@@ -27915,7 +27878,7 @@ function setExternalModuleIndicator(sourceFile) {
27915
27878
  sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
27916
27879
  }
27917
27880
  function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes = false, scriptKind) {
27918
- var _a, _b, _c, _d;
27881
+ var _a, _b;
27919
27882
  (_a = tracing) == null ? void 0 : _a.push(
27920
27883
  tracing.Phase.Parse,
27921
27884
  "createSourceFile",
@@ -27925,7 +27888,6 @@ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setPar
27925
27888
  );
27926
27889
  mark("beforeParse");
27927
27890
  let result;
27928
- (_b = perfLogger) == null ? void 0 : _b.logStartParseSourceFile(fileName);
27929
27891
  const {
27930
27892
  languageVersion,
27931
27893
  setExternalModuleIndicator: overrideSetExternalModuleIndicator,
@@ -27961,10 +27923,9 @@ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setPar
27961
27923
  jsDocParsingMode
27962
27924
  );
27963
27925
  }
27964
- (_c = perfLogger) == null ? void 0 : _c.logStopParseSourceFile();
27965
27926
  mark("afterParse");
27966
27927
  measure("Parse", "beforeParse", "afterParse");
27967
- (_d = tracing) == null ? void 0 : _d.pop();
27928
+ (_b = tracing) == null ? void 0 : _b.pop();
27968
27929
  return result;
27969
27930
  }
27970
27931
  function parseIsolatedEntityName(text, languageVersion) {
@@ -39449,7 +39410,6 @@ function resolveLibrary(libraryName, resolveFrom, compilerOptions, host, cache)
39449
39410
  return resolveModuleName(libraryName, resolveFrom, getOptionsForLibraryResolution(compilerOptions), host, cache);
39450
39411
  }
39451
39412
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
39452
- var _a, _b, _c;
39453
39413
  const traceEnabled = isTraceEnabled(compilerOptions, host);
39454
39414
  if (redirectedReference) {
39455
39415
  compilerOptions = redirectedReference.commandLine.options;
@@ -39478,7 +39438,6 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
39478
39438
  trace(host, Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ModuleResolutionKind[moduleResolution]);
39479
39439
  }
39480
39440
  }
39481
- (_a = perfLogger) == null ? void 0 : _a.logStartResolveModule(moduleName);
39482
39441
  switch (moduleResolution) {
39483
39442
  case 3 /* Node16 */:
39484
39443
  result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
@@ -39498,8 +39457,6 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
39498
39457
  default:
39499
39458
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
39500
39459
  }
39501
- if (result && result.resolvedModule) (_b = perfLogger) == null ? void 0 : _b.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
39502
- (_c = perfLogger) == null ? void 0 : _c.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
39503
39460
  if (cache && !cache.isReadonly) {
39504
39461
  cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
39505
39462
  if (!isExternalModuleNameRelative(moduleName)) {
@@ -41202,11 +41159,8 @@ function createFlowNode(flags, node, antecedent) {
41202
41159
  }
41203
41160
  var binder = /* @__PURE__ */ createBinder();
41204
41161
  function bindSourceFile(file, options) {
41205
- var _a, _b;
41206
41162
  mark("beforeBind");
41207
- (_a = perfLogger) == null ? void 0 : _a.logStartBindFile("" + file.fileName);
41208
41163
  binder(file, options);
41209
- (_b = perfLogger) == null ? void 0 : _b.logStopBindFile();
41210
41164
  mark("afterBind");
41211
41165
  measure("Bind", "beforeBind", "afterBind");
41212
41166
  }
@@ -44174,15 +44128,13 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
44174
44128
  }
44175
44129
 
44176
44130
  // src/compiler/moduleSpecifiers.ts
44177
- function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, host, compilerOptions, importingSourceFile, oldImportSpecifier) {
44131
+ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
44178
44132
  const filePreferredEnding = getPreferredEnding();
44179
44133
  return {
44180
44134
  relativePreference: oldImportSpecifier !== void 0 ? isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */ : importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */,
44181
44135
  getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
44182
- const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
44183
- const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
44184
- const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
44185
- if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
44136
+ const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
44137
+ if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
44186
44138
  if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
44187
44139
  return [3 /* TsExtension */, 2 /* JsExtension */];
44188
44140
  }
@@ -44213,7 +44165,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
44213
44165
  }
44214
44166
  return getModuleSpecifierEndingPreference(
44215
44167
  importModuleSpecifierEnding,
44216
- resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
44168
+ resolutionMode ?? importingSourceFile.impliedNodeFormat,
44217
44169
  compilerOptions,
44218
44170
  isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
44219
44171
  );
@@ -44271,16 +44223,12 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
44271
44223
  }
44272
44224
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
44273
44225
  const info = getInfo(importingSourceFile.fileName, host);
44274
- const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
44226
+ const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
44275
44227
  const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
44276
44228
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
44277
44229
  (reason) => {
44278
44230
  if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
44279
- const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
44280
- const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
44281
- if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
44282
- return void 0;
44283
- }
44231
+ if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
44284
44232
  const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
44285
44233
  return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
44286
44234
  }
@@ -44795,7 +44743,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
44795
44743
  if (!parts) {
44796
44744
  return void 0;
44797
44745
  }
44798
- const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
44746
+ const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
44799
44747
  const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
44800
44748
  let moduleSpecifier = path;
44801
44749
  let isPackageRootPath = false;
@@ -44845,7 +44793,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
44845
44793
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
44846
44794
  if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
44847
44795
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
44848
- const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
44796
+ const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
44849
44797
  if (getResolvePackageJsonExports(options)) {
44850
44798
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
44851
44799
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
@@ -44995,9 +44943,6 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
44995
44943
  function isPathRelativeToParent(path) {
44996
44944
  return startsWith(path, "..");
44997
44945
  }
44998
- function getDefaultResolutionModeForFile(file, host, compilerOptions) {
44999
- return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
45000
- }
45001
44946
 
45002
44947
  // src/compiler/checker.ts
45003
44948
  var ambientModuleSymbolRegex = /^".+"$/;
@@ -47220,28 +47165,22 @@ function createTypeChecker(host) {
47220
47165
  function isSyntacticDefault(node) {
47221
47166
  return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
47222
47167
  }
47223
- function getEmitSyntaxForModuleSpecifierExpression(usage) {
47224
- return isStringLiteralLike(usage) ? host.getEmitSyntaxForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
47168
+ function getUsageModeForExpression(usage) {
47169
+ return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
47225
47170
  }
47226
47171
  function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
47227
47172
  return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
47228
47173
  }
47229
- function isOnlyImportableAsDefault(usage) {
47230
- if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47231
- const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
47232
- return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
47233
- }
47234
- return false;
47174
+ function isOnlyImportedAsDefault(usage) {
47175
+ const usageMode = getUsageModeForExpression(usage);
47176
+ return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
47235
47177
  }
47236
47178
  function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
47237
- const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
47238
- if (file && usageMode !== void 0) {
47239
- const targetMode = host.getImpliedNodeFormatForEmit(file);
47240
- if (usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */ && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47241
- return true;
47242
- }
47243
- if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
47244
- return false;
47179
+ const usageMode = file && getUsageModeForExpression(usage);
47180
+ if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47181
+ const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
47182
+ if (usageMode === 99 /* ESNext */ || result) {
47183
+ return result;
47245
47184
  }
47246
47185
  }
47247
47186
  if (!allowSyntheticDefaultImports) {
@@ -47300,7 +47239,7 @@ function createTypeChecker(host) {
47300
47239
  if (!specifier) {
47301
47240
  return exportDefaultSymbol;
47302
47241
  }
47303
- const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
47242
+ const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
47304
47243
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
47305
47244
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
47306
47245
  if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
@@ -47502,7 +47441,7 @@ function createTypeChecker(host) {
47502
47441
  let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
47503
47442
  if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
47504
47443
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
47505
- if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47444
+ if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47506
47445
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
47507
47446
  }
47508
47447
  }
@@ -48106,7 +48045,7 @@ function createTypeChecker(host) {
48106
48045
  /*requireStringLiteralLikeArgument*/
48107
48046
  true
48108
48047
  ) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, isImportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression) || ((_f = findAncestor(location, isExportDeclaration)) == null ? void 0 : _f.moduleSpecifier);
48109
- const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
48048
+ const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
48110
48049
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
48111
48050
  const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
48112
48051
  const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
@@ -48350,7 +48289,7 @@ function createTypeChecker(host) {
48350
48289
  return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
48351
48290
  }
48352
48291
  const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
48353
- const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), host.getImpliedNodeFormatForEmit(targetFile));
48292
+ const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
48354
48293
  if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
48355
48294
  let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
48356
48295
  if (!sigs || !sigs.length) {
@@ -50956,10 +50895,8 @@ function createTypeChecker(host) {
50956
50895
  }
50957
50896
  return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
50958
50897
  }
50959
- const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
50960
- const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
50961
50898
  const contextFile = context.enclosingFile;
50962
- const resolutionMode = overrideImportMode || originalModuleSpecifier && host.getModeForUsageLocation(contextFile, originalModuleSpecifier) || contextFile && host.getDefaultResolutionModeForFile(contextFile);
50899
+ const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
50963
50900
  const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
50964
50901
  const links = getSymbolLinks(symbol);
50965
50902
  let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
@@ -51928,8 +51865,28 @@ function createTypeChecker(host) {
51928
51865
  } else {
51929
51866
  const type = getWidenedType(getRegularTypeOfExpression(node.expression));
51930
51867
  const computedPropertyNameType = typeToTypeNodeHelper(type, context);
51931
- Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
51932
- const literal = computedPropertyNameType.literal;
51868
+ let literal;
51869
+ if (isLiteralTypeNode(computedPropertyNameType)) {
51870
+ literal = computedPropertyNameType.literal;
51871
+ } else {
51872
+ const evaluated = evaluateEntityNameExpression(node.expression);
51873
+ const literalNode = typeof evaluated.value === "string" ? factory.createStringLiteral(
51874
+ evaluated.value,
51875
+ /*isSingleQuote*/
51876
+ void 0
51877
+ ) : typeof evaluated.value === "number" ? factory.createNumericLiteral(
51878
+ evaluated.value,
51879
+ /*numericLiteralFlags*/
51880
+ 0
51881
+ ) : void 0;
51882
+ if (!literalNode) {
51883
+ if (isImportTypeNode(computedPropertyNameType)) {
51884
+ trackComputedName(node.expression, context.enclosingDeclaration, context);
51885
+ }
51886
+ return node;
51887
+ }
51888
+ literal = literalNode;
51889
+ }
51933
51890
  if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
51934
51891
  return factory.createIdentifier(literal.text);
51935
51892
  }
@@ -75431,7 +75388,7 @@ function createTypeChecker(host) {
75431
75388
  return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
75432
75389
  }
75433
75390
  function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
75434
- const hasDefaultOnly = isOnlyImportableAsDefault(moduleSpecifier);
75391
+ const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
75435
75392
  if (hasDefaultOnly && type && !isErrorType(type)) {
75436
75393
  const synthType = type;
75437
75394
  if (!synthType.defaultOnlyType) {
@@ -80658,7 +80615,7 @@ function createTypeChecker(host) {
80658
80615
  });
80659
80616
  }
80660
80617
  function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
80661
- if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) >= 5 /* ES2015 */) {
80618
+ if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
80662
80619
  return;
80663
80620
  }
80664
80621
  if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
@@ -82079,7 +82036,7 @@ function createTypeChecker(host) {
82079
82036
  }
82080
82037
  }
82081
82038
  function checkClassNameCollisionWithObject(name) {
82082
- if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < 5 /* ES2015 */) {
82039
+ if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
82083
82040
  error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
82084
82041
  }
82085
82042
  }
@@ -82458,23 +82415,22 @@ function createTypeChecker(host) {
82458
82415
  hasAbstractModifier(member),
82459
82416
  isStatic(member),
82460
82417
  memberIsParameterProperty,
82461
- symbolName(declaredProp),
82418
+ declaredProp,
82462
82419
  reportErrors2 ? member : void 0
82463
82420
  );
82464
82421
  }
82465
- function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
82422
+ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, member, errorNode) {
82466
82423
  const isJs = isInJSFile(node);
82467
82424
  const nodeInAmbientContext = !!(node.flags & 33554432 /* Ambient */);
82468
82425
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
82469
- const memberEscapedName = escapeLeadingUnderscores(memberName);
82470
82426
  const thisType = memberIsStatic ? staticType : typeWithThis;
82471
82427
  const baseType = memberIsStatic ? baseStaticType : baseWithThis;
82472
- const prop = getPropertyOfType(thisType, memberEscapedName);
82473
- const baseProp = getPropertyOfType(baseType, memberEscapedName);
82428
+ const prop = getPropertyOfType(thisType, member.escapedName);
82429
+ const baseProp = getPropertyOfType(baseType, member.escapedName);
82474
82430
  const baseClassName = typeToString(baseWithThis);
82475
82431
  if (prop && !baseProp && memberHasOverrideModifier) {
82476
82432
  if (errorNode) {
82477
- const suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType);
82433
+ const suggestion = getSuggestedSymbolForNonexistentClassMember(symbolName(member), baseType);
82478
82434
  suggestion ? error(
82479
82435
  errorNode,
82480
82436
  isJs ? Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 : Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1,
@@ -82591,7 +82547,7 @@ function createTypeChecker(host) {
82591
82547
  isStatic(member),
82592
82548
  /*memberIsParameterProperty*/
82593
82549
  false,
82594
- symbolName(memberSymbol)
82550
+ memberSymbol
82595
82551
  );
82596
82552
  }
82597
82553
  function getTargetSymbol(s) {
@@ -83160,7 +83116,7 @@ function createTypeChecker(host) {
83160
83116
  getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
83161
83117
  }
83162
83118
  }
83163
- if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(node.parent) === 1 /* CommonJS */) {
83119
+ if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
83164
83120
  const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
83165
83121
  if (exportModifier) {
83166
83122
  error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
@@ -83380,10 +83336,8 @@ function createTypeChecker(host) {
83380
83336
  }
83381
83337
  }
83382
83338
  }
83383
- if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
83339
+ if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83384
83340
  error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
83385
- } else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
83386
- error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
83387
83341
  }
83388
83342
  }
83389
83343
  if (isImportSpecifier(node)) {
@@ -83424,7 +83378,7 @@ function createTypeChecker(host) {
83424
83378
  checkAliasSymbol(node);
83425
83379
  if (node.kind === 276 /* ImportSpecifier */) {
83426
83380
  checkModuleExportName(node.propertyName);
83427
- if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83381
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83428
83382
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83429
83383
  }
83430
83384
  }
@@ -83446,7 +83400,7 @@ function createTypeChecker(host) {
83446
83400
  if (validForTypeAttributes && override) {
83447
83401
  return;
83448
83402
  }
83449
- const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
83403
+ const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
83450
83404
  if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
83451
83405
  const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
83452
83406
  return grammarErrorOnNode(node, message);
@@ -83479,7 +83433,7 @@ function createTypeChecker(host) {
83479
83433
  if (importClause.namedBindings) {
83480
83434
  if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
83481
83435
  checkImportBinding(importClause.namedBindings);
83482
- if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && getESModuleInterop(compilerOptions)) {
83436
+ if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
83483
83437
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
83484
83438
  }
83485
83439
  } else {
@@ -83519,7 +83473,7 @@ function createTypeChecker(host) {
83519
83473
  grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
83520
83474
  }
83521
83475
  } else {
83522
- if (5 /* ES2015 */ <= moduleKind && moduleKind <= 99 /* ESNext */ && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
83476
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
83523
83477
  grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
83524
83478
  }
83525
83479
  }
@@ -83549,7 +83503,7 @@ function createTypeChecker(host) {
83549
83503
  checkAliasSymbol(node.exportClause);
83550
83504
  checkModuleExportName(node.exportClause.name);
83551
83505
  }
83552
- if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83506
+ if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83553
83507
  if (node.exportClause) {
83554
83508
  if (getESModuleInterop(compilerOptions)) {
83555
83509
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
@@ -83608,7 +83562,7 @@ function createTypeChecker(host) {
83608
83562
  markLinkedReferences(node, 7 /* ExportSpecifier */);
83609
83563
  }
83610
83564
  } else {
83611
- if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
83565
+ if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleExportNameIsDefault(node.propertyName || node.name)) {
83612
83566
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83613
83567
  }
83614
83568
  }
@@ -83634,7 +83588,7 @@ function createTypeChecker(host) {
83634
83588
  if (typeAnnotationNode) {
83635
83589
  checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
83636
83590
  }
83637
- const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */;
83591
+ const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
83638
83592
  if (node.expression.kind === 80 /* Identifier */) {
83639
83593
  const id = node.expression;
83640
83594
  const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
@@ -83714,7 +83668,7 @@ function createTypeChecker(host) {
83714
83668
  grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
83715
83669
  }
83716
83670
  if (node.isExportEquals) {
83717
- if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) !== 1 /* CommonJS */)) {
83671
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
83718
83672
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
83719
83673
  } else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
83720
83674
  grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
@@ -83775,6 +83729,9 @@ function createTypeChecker(host) {
83775
83729
  }
83776
83730
  }
83777
83731
  function checkSourceElementWorker(node) {
83732
+ if (getNodeCheckFlags(node) & 8388608 /* PartiallyTypeChecked */) {
83733
+ return;
83734
+ }
83778
83735
  if (canHaveJSDoc(node)) {
83779
83736
  forEach(node.jsDoc, ({ comment, tags }) => {
83780
83737
  checkJSDocCommentWorker(comment);
@@ -84118,19 +84075,21 @@ function createTypeChecker(host) {
84118
84075
  currentNode = saveCurrentNode;
84119
84076
  (_b = tracing) == null ? void 0 : _b.pop();
84120
84077
  }
84121
- function checkSourceFile(node) {
84078
+ function checkSourceFile(node, nodesToCheck) {
84122
84079
  var _a, _b;
84123
84080
  (_a = tracing) == null ? void 0 : _a.push(
84124
84081
  tracing.Phase.Check,
84125
- "checkSourceFile",
84082
+ nodesToCheck ? "checkSourceFileNodes" : "checkSourceFile",
84126
84083
  { path: node.path },
84127
84084
  /*separateBeginAndEnd*/
84128
84085
  true
84129
84086
  );
84130
- mark("beforeCheck");
84131
- checkSourceFileWorker(node);
84132
- mark("afterCheck");
84133
- measure("Check", "beforeCheck", "afterCheck");
84087
+ const beforeMark = nodesToCheck ? "beforeCheckNodes" : "beforeCheck";
84088
+ const afterMark = nodesToCheck ? "afterCheckNodes" : "afterCheck";
84089
+ mark(beforeMark);
84090
+ nodesToCheck ? checkSourceFileNodesWorker(node, nodesToCheck) : checkSourceFileWorker(node);
84091
+ mark(afterMark);
84092
+ measure("Check", beforeMark, afterMark);
84134
84093
  (_b = tracing) == null ? void 0 : _b.pop();
84135
84094
  }
84136
84095
  function unusedIsError(kind, isAmbient) {
@@ -84161,6 +84120,13 @@ function createTypeChecker(host) {
84161
84120
  clear(potentialWeakMapSetCollisions);
84162
84121
  clear(potentialReflectCollisions);
84163
84122
  clear(potentialUnusedRenamedBindingElementsInTypes);
84123
+ if (links.flags & 8388608 /* PartiallyTypeChecked */) {
84124
+ potentialThisCollisions = links.potentialThisCollisions;
84125
+ potentialNewTargetCollisions = links.potentialNewTargetCollisions;
84126
+ potentialWeakMapSetCollisions = links.potentialWeakMapSetCollisions;
84127
+ potentialReflectCollisions = links.potentialReflectCollisions;
84128
+ potentialUnusedRenamedBindingElementsInTypes = links.potentialUnusedRenamedBindingElementsInTypes;
84129
+ }
84164
84130
  forEach(node.statements, checkSourceElement);
84165
84131
  checkSourceElement(node.endOfFileToken);
84166
84132
  checkDeferredNodes(node);
@@ -84201,10 +84167,38 @@ function createTypeChecker(host) {
84201
84167
  links.flags |= 1 /* TypeChecked */;
84202
84168
  }
84203
84169
  }
84204
- function getDiagnostics(sourceFile, ct) {
84170
+ function checkSourceFileNodesWorker(file, nodes) {
84171
+ const links = getNodeLinks(file);
84172
+ if (!(links.flags & 1 /* TypeChecked */)) {
84173
+ if (skipTypeChecking(file, compilerOptions, host)) {
84174
+ return;
84175
+ }
84176
+ checkGrammarSourceFile(file);
84177
+ clear(potentialThisCollisions);
84178
+ clear(potentialNewTargetCollisions);
84179
+ clear(potentialWeakMapSetCollisions);
84180
+ clear(potentialReflectCollisions);
84181
+ clear(potentialUnusedRenamedBindingElementsInTypes);
84182
+ forEach(nodes, checkSourceElement);
84183
+ checkDeferredNodes(file);
84184
+ (links.potentialThisCollisions || (links.potentialThisCollisions = [])).push(...potentialThisCollisions);
84185
+ (links.potentialNewTargetCollisions || (links.potentialNewTargetCollisions = [])).push(...potentialNewTargetCollisions);
84186
+ (links.potentialWeakMapSetCollisions || (links.potentialWeakMapSetCollisions = [])).push(...potentialWeakMapSetCollisions);
84187
+ (links.potentialReflectCollisions || (links.potentialReflectCollisions = [])).push(...potentialReflectCollisions);
84188
+ (links.potentialUnusedRenamedBindingElementsInTypes || (links.potentialUnusedRenamedBindingElementsInTypes = [])).push(
84189
+ ...potentialUnusedRenamedBindingElementsInTypes
84190
+ );
84191
+ links.flags |= 8388608 /* PartiallyTypeChecked */;
84192
+ for (const node of nodes) {
84193
+ const nodeLinks2 = getNodeLinks(node);
84194
+ nodeLinks2.flags |= 8388608 /* PartiallyTypeChecked */;
84195
+ }
84196
+ }
84197
+ }
84198
+ function getDiagnostics(sourceFile, ct, nodesToCheck) {
84205
84199
  try {
84206
84200
  cancellationToken = ct;
84207
- return getDiagnosticsWorker(sourceFile);
84201
+ return getDiagnosticsWorker(sourceFile, nodesToCheck);
84208
84202
  } finally {
84209
84203
  cancellationToken = void 0;
84210
84204
  }
@@ -84215,20 +84209,23 @@ function createTypeChecker(host) {
84215
84209
  }
84216
84210
  deferredDiagnosticsCallbacks = [];
84217
84211
  }
84218
- function checkSourceFileWithEagerDiagnostics(sourceFile) {
84212
+ function checkSourceFileWithEagerDiagnostics(sourceFile, nodesToCheck) {
84219
84213
  ensurePendingDiagnosticWorkComplete();
84220
84214
  const oldAddLazyDiagnostics = addLazyDiagnostic;
84221
84215
  addLazyDiagnostic = (cb) => cb();
84222
- checkSourceFile(sourceFile);
84216
+ checkSourceFile(sourceFile, nodesToCheck);
84223
84217
  addLazyDiagnostic = oldAddLazyDiagnostics;
84224
84218
  }
84225
- function getDiagnosticsWorker(sourceFile) {
84219
+ function getDiagnosticsWorker(sourceFile, nodesToCheck) {
84226
84220
  if (sourceFile) {
84227
84221
  ensurePendingDiagnosticWorkComplete();
84228
84222
  const previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
84229
84223
  const previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
84230
- checkSourceFileWithEagerDiagnostics(sourceFile);
84224
+ checkSourceFileWithEagerDiagnostics(sourceFile, nodesToCheck);
84231
84225
  const semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
84226
+ if (nodesToCheck) {
84227
+ return semanticDiagnostics;
84228
+ }
84232
84229
  const currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
84233
84230
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
84234
84231
  const deferredGlobalDiagnostics = relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, compareDiagnostics);
@@ -84238,7 +84235,7 @@ function createTypeChecker(host) {
84238
84235
  }
84239
84236
  return semanticDiagnostics;
84240
84237
  }
84241
- forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
84238
+ forEach(host.getSourceFiles(), (file) => checkSourceFileWithEagerDiagnostics(file));
84242
84239
  return diagnostics.getDiagnostics();
84243
84240
  }
84244
84241
  function getGlobalDiagnostics() {
@@ -85200,7 +85197,7 @@ function createTypeChecker(host) {
85200
85197
  return !!(getNodeCheckFlags(node) & flag);
85201
85198
  }
85202
85199
  function calculateNodeCheckFlagWorker(node, flag) {
85203
- if (!compilerOptions.noCheck && canIncludeBindAndCheckDiagnsotics(getSourceFileOfNode(node), compilerOptions)) {
85200
+ if (!compilerOptions.noCheck && canIncludeBindAndCheckDiagnostics(getSourceFileOfNode(node), compilerOptions)) {
85204
85201
  return;
85205
85202
  }
85206
85203
  const links = getNodeLinks(node);
@@ -86217,7 +86214,7 @@ function createTypeChecker(host) {
86217
86214
  break;
86218
86215
  case 95 /* ExportKeyword */:
86219
86216
  if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later
86220
- node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
86217
+ node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
86221
86218
  return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
86222
86219
  }
86223
86220
  if (flags & 32 /* Export */) {
@@ -87126,7 +87123,7 @@ function createTypeChecker(host) {
87126
87123
  const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
87127
87124
  return grammarErrorOnNode(node.exclamationToken, message);
87128
87125
  }
87129
- if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
87126
+ if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
87130
87127
  checkESModuleMarker(node.name);
87131
87128
  }
87132
87129
  return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
@@ -87627,9 +87624,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
87627
87624
  isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
87628
87625
  fileExists: (fileName) => host.fileExists(fileName),
87629
87626
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
87630
- readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
87631
- getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
87632
- getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
87627
+ readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
87633
87628
  };
87634
87629
  }
87635
87630
  var SymbolTrackerImpl = class _SymbolTrackerImpl {
@@ -107302,7 +107297,7 @@ function transformModule(context) {
107302
107297
  case 354 /* PartiallyEmittedExpression */:
107303
107298
  return visitPartiallyEmittedExpression(node, valueIsDiscarded);
107304
107299
  case 213 /* CallExpression */:
107305
- if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
107300
+ if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
107306
107301
  return visitImportCallExpression(node);
107307
107302
  }
107308
107303
  break;
@@ -110298,8 +110293,8 @@ function transformECMAScriptModule(context) {
110298
110293
  }
110299
110294
  }
110300
110295
 
110301
- // src/compiler/transformers/module/impliedNodeFormatDependent.ts
110302
- function transformImpliedNodeFormatDependentModule(context) {
110296
+ // src/compiler/transformers/module/node.ts
110297
+ function transformNodeModule(context) {
110303
110298
  const previousOnSubstituteNode = context.onSubstituteNode;
110304
110299
  const previousOnEmitNode = context.onEmitNode;
110305
110300
  const esmTransform = transformECMAScriptModule(context);
@@ -110310,7 +110305,6 @@ function transformImpliedNodeFormatDependentModule(context) {
110310
110305
  const cjsTransform = transformModule(context);
110311
110306
  const cjsOnSubstituteNode = context.onSubstituteNode;
110312
110307
  const cjsOnEmitNode = context.onEmitNode;
110313
- const getEmitModuleFormatOfFile = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
110314
110308
  context.onSubstituteNode = onSubstituteNode;
110315
110309
  context.onEmitNode = onEmitNode;
110316
110310
  context.enableSubstitution(307 /* SourceFile */);
@@ -110325,7 +110319,7 @@ function transformImpliedNodeFormatDependentModule(context) {
110325
110319
  if (!currentSourceFile) {
110326
110320
  return previousOnSubstituteNode(hint, node);
110327
110321
  }
110328
- if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
110322
+ if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
110329
110323
  return esmOnSubstituteNode(hint, node);
110330
110324
  }
110331
110325
  return cjsOnSubstituteNode(hint, node);
@@ -110338,13 +110332,13 @@ function transformImpliedNodeFormatDependentModule(context) {
110338
110332
  if (!currentSourceFile) {
110339
110333
  return previousOnEmitNode(hint, node, emitCallback);
110340
110334
  }
110341
- if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
110335
+ if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
110342
110336
  return esmOnEmitNode(hint, node, emitCallback);
110343
110337
  }
110344
110338
  return cjsOnEmitNode(hint, node, emitCallback);
110345
110339
  }
110346
110340
  function getModuleTransformForFile(file) {
110347
- return getEmitModuleFormatOfFile(file) >= 5 /* ES2015 */ ? esmTransform : cjsTransform;
110341
+ return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
110348
110342
  }
110349
110343
  function transformSourceFile(node) {
110350
110344
  if (node.isDeclarationFile) {
@@ -112466,18 +112460,17 @@ function isProcessedComponent(node) {
112466
112460
  // src/compiler/transformer.ts
112467
112461
  function getModuleTransformer(moduleKind) {
112468
112462
  switch (moduleKind) {
112469
- case 200 /* Preserve */:
112470
- return transformECMAScriptModule;
112471
112463
  case 99 /* ESNext */:
112472
112464
  case 7 /* ES2022 */:
112473
112465
  case 6 /* ES2020 */:
112474
112466
  case 5 /* ES2015 */:
112475
- case 100 /* Node16 */:
112476
- case 199 /* NodeNext */:
112477
- case 1 /* CommonJS */:
112478
- return transformImpliedNodeFormatDependentModule;
112467
+ case 200 /* Preserve */:
112468
+ return transformECMAScriptModule;
112479
112469
  case 4 /* System */:
112480
112470
  return transformSystemModule;
112471
+ case 100 /* Node16 */:
112472
+ case 199 /* NodeNext */:
112473
+ return transformNodeModule;
112481
112474
  default:
112482
112475
  return transformModule;
112483
112476
  }
@@ -112930,7 +112923,7 @@ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDt
112930
112923
  }
112931
112924
  function getTsBuildInfoEmitOutputFilePath(options) {
112932
112925
  const configFile = options.configFilePath;
112933
- if (!isIncrementalCompilation(options)) return void 0;
112926
+ if (!canEmitTsBuildInfo(options)) return void 0;
112934
112927
  if (options.tsBuildInfoFile) return options.tsBuildInfoFile;
112935
112928
  const outPath = options.outFile;
112936
112929
  let buildInfoExtensionLess;
@@ -112948,6 +112941,9 @@ function getTsBuildInfoEmitOutputFilePath(options) {
112948
112941
  }
112949
112942
  return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */;
112950
112943
  }
112944
+ function canEmitTsBuildInfo(options) {
112945
+ return isIncrementalCompilation(options) || !!options.tscBuild;
112946
+ }
112951
112947
  function getOutputPathsForBundle(options, forceDtsPaths) {
112952
112948
  const outPath = options.outFile;
112953
112949
  const jsFilePath = options.emitDeclarationOnly ? void 0 : outPath;
@@ -113173,7 +113169,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113173
113169
  }
113174
113170
  (isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : filter(sourceFileOrBundle.sourceFiles, isSourceFileNotJson)).forEach(
113175
113171
  (sourceFile) => {
113176
- if (compilerOptions.noCheck || !canIncludeBindAndCheckDiagnsotics(sourceFile, compilerOptions)) markLinkedReferences(sourceFile);
113172
+ if (compilerOptions.noCheck || !canIncludeBindAndCheckDiagnostics(sourceFile, compilerOptions)) markLinkedReferences(sourceFile);
113177
113173
  }
113178
113174
  );
113179
113175
  const transform = transformNodes(
@@ -113191,7 +113187,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113191
113187
  newLine: compilerOptions.newLine,
113192
113188
  noEmitHelpers: compilerOptions.noEmitHelpers,
113193
113189
  module: getEmitModuleKind(compilerOptions),
113194
- moduleResolution: getEmitModuleResolutionKind(compilerOptions),
113195
113190
  target: getEmitScriptTarget(compilerOptions),
113196
113191
  sourceMap: compilerOptions.sourceMap,
113197
113192
  inlineSourceMap: compilerOptions.inlineSourceMap,
@@ -113226,7 +113221,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113226
113221
  const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson);
113227
113222
  const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit;
113228
113223
  filesForEmit.forEach((sourceFile) => {
113229
- if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck || emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) || !canIncludeBindAndCheckDiagnsotics(sourceFile, compilerOptions)) {
113224
+ if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck || emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) || !canIncludeBindAndCheckDiagnostics(sourceFile, compilerOptions)) {
113230
113225
  collectLinkedAliases(sourceFile);
113231
113226
  }
113232
113227
  });
@@ -113254,7 +113249,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113254
113249
  newLine: compilerOptions.newLine,
113255
113250
  noEmitHelpers: true,
113256
113251
  module: compilerOptions.module,
113257
- moduleResolution: compilerOptions.moduleResolution,
113258
113252
  target: compilerOptions.target,
113259
113253
  sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
113260
113254
  inlineSourceMap: compilerOptions.inlineSourceMap,
@@ -113270,7 +113264,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113270
113264
  isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
113271
113265
  substituteNode: declarationTransform.substituteNode
113272
113266
  });
113273
- printSourceFileOrBundle(
113267
+ const dtsWritten = printSourceFileOrBundle(
113274
113268
  declarationFilePath,
113275
113269
  declarationMapPath,
113276
113270
  declarationTransform,
@@ -113284,7 +113278,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113284
113278
  }
113285
113279
  );
113286
113280
  if (emittedFilesList) {
113287
- emittedFilesList.push(declarationFilePath);
113281
+ if (dtsWritten) emittedFilesList.push(declarationFilePath);
113288
113282
  if (declarationMapPath) {
113289
113283
  emittedFilesList.push(declarationMapPath);
113290
113284
  }
@@ -113375,8 +113369,10 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113375
113369
  writer.writeLine();
113376
113370
  }
113377
113371
  const text = writer.getText();
113378
- writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
113372
+ const data = { sourceMapUrlPos, diagnostics: transform.diagnostics };
113373
+ writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
113379
113374
  writer.clear();
113375
+ return !data.skippedDtsWrite;
113380
113376
  }
113381
113377
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
113382
113378
  return (mapOptions.sourceMap || mapOptions.inlineSourceMap) && (sourceFileOrBundle.kind !== 307 /* SourceFile */ || !fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */));
@@ -118707,6 +118703,9 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
118707
118703
  function getModeForFileReference(ref, containingFileMode) {
118708
118704
  return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
118709
118705
  }
118706
+ function getModeForResolutionAtIndex(file, index, compilerOptions) {
118707
+ return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
118708
+ }
118710
118709
  function isExclusivelyTypeOnlyImportOrExport(decl) {
118711
118710
  var _a;
118712
118711
  if (isExportDeclaration(decl)) {
@@ -118721,6 +118720,7 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
118721
118720
  return getModeForUsageLocationWorker(file, usage, compilerOptions);
118722
118721
  }
118723
118722
  function getModeForUsageLocationWorker(file, usage, compilerOptions) {
118723
+ var _a;
118724
118724
  if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
118725
118725
  const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
118726
118726
  if (isTypeOnly) {
@@ -118736,28 +118736,19 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
118736
118736
  return override;
118737
118737
  }
118738
118738
  }
118739
- if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
118740
- return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
118739
+ if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
118740
+ return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
118741
+ usage.parent,
118742
+ /*requireStringLiteralLikeArgument*/
118743
+ false
118744
+ ) ? 1 /* CommonJS */ : 99 /* ESNext */;
118741
118745
  }
118742
- }
118743
- function getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions) {
118744
- var _a;
118745
- if (!compilerOptions) {
118746
- return void 0;
118746
+ if (file.impliedNodeFormat === void 0) return void 0;
118747
+ if (file.impliedNodeFormat !== 99 /* ESNext */) {
118748
+ return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
118747
118749
  }
118748
118750
  const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
118749
- if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(
118750
- usage.parent,
118751
- /*requireStringLiteralLikeArgument*/
118752
- false
118753
- )) {
118754
- return 1 /* CommonJS */;
118755
- }
118756
- if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
118757
- return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
118758
- }
118759
- const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
118760
- return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
118751
+ return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
118761
118752
  }
118762
118753
  function getResolutionModeOverride(node, grammarErrorOnNode) {
118763
118754
  if (!node) return void 0;
@@ -118814,7 +118805,7 @@ function getTypeReferenceResolutionName(entry) {
118814
118805
  }
118815
118806
  var typeReferenceResolutionNameAndModeGetter = {
118816
118807
  getName: getTypeReferenceResolutionName,
118817
- getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions))
118808
+ getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
118818
118809
  };
118819
118810
  function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
118820
118811
  return {
@@ -118984,7 +118975,13 @@ function getConfigFileParsingDiagnostics(configFileParseResult) {
118984
118975
  return configFileParseResult.options.configFile ? [...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] : configFileParseResult.errors;
118985
118976
  }
118986
118977
  function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
118987
- return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
118978
+ switch (getEmitModuleResolutionKind(options)) {
118979
+ case 3 /* Node16 */:
118980
+ case 99 /* NodeNext */:
118981
+ return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
118982
+ default:
118983
+ return void 0;
118984
+ }
118988
118985
  function lookupFromPackageJson() {
118989
118986
  const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
118990
118987
  const packageJsonLocations = [];
@@ -119443,8 +119440,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119443
119440
  isSourceFileFromExternalLibrary,
119444
119441
  isSourceFileDefaultLibrary,
119445
119442
  getModeForUsageLocation: getModeForUsageLocation2,
119446
- getEmitSyntaxForUsageLocation,
119447
- getModeForResolutionAtIndex,
119443
+ getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
119448
119444
  getSourceFileFromReference,
119449
119445
  getLibFileFromReference,
119450
119446
  sourceFileToPackageName,
@@ -119472,11 +119468,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119472
119468
  forEachResolvedProjectReference: forEachResolvedProjectReference2,
119473
119469
  isSourceOfProjectReferenceRedirect,
119474
119470
  getRedirectReferenceForResolutionFromSourceOfProject,
119475
- getCompilerOptionsForFile,
119476
- getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
119477
- getEmitModuleFormatOfFile,
119478
- getImpliedNodeFormatForEmit,
119479
- shouldTransformImportCall,
119480
119471
  emitBuildInfo,
119481
119472
  fileExists,
119482
119473
  readFile,
@@ -120059,10 +120050,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120059
120050
  getSymlinkCache,
120060
120051
  writeFile: writeFileCallback || writeFile2,
120061
120052
  isEmitBlocked,
120062
- shouldTransformImportCall,
120063
- getEmitModuleFormatOfFile,
120064
- getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
120065
- getModeForResolutionAtIndex,
120066
120053
  readFile: (f) => host.readFile(f),
120067
120054
  fileExists: (f) => {
120068
120055
  const path = toPath3(f);
@@ -120220,15 +120207,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120220
120207
  function getSyntacticDiagnostics(sourceFile, cancellationToken) {
120221
120208
  return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
120222
120209
  }
120223
- function getSemanticDiagnostics(sourceFile, cancellationToken) {
120224
- return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
120210
+ function getSemanticDiagnostics(sourceFile, cancellationToken, nodesToCheck) {
120211
+ return getDiagnosticsHelper(
120212
+ sourceFile,
120213
+ (sourceFile2, cancellationToken2) => getSemanticDiagnosticsForFile(sourceFile2, cancellationToken2, nodesToCheck),
120214
+ cancellationToken
120215
+ );
120225
120216
  }
120226
120217
  function getCachedSemanticDiagnostics(sourceFile) {
120227
120218
  var _a2;
120228
120219
  return sourceFile ? (_a2 = cachedBindAndCheckDiagnosticsForFile.perFile) == null ? void 0 : _a2.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
120229
120220
  }
120230
120221
  function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
120231
- return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
120222
+ return getBindAndCheckDiagnosticsForFile(
120223
+ sourceFile,
120224
+ cancellationToken,
120225
+ /*nodesToCheck*/
120226
+ void 0
120227
+ );
120232
120228
  }
120233
120229
  function getProgramDiagnostics(sourceFile) {
120234
120230
  var _a2;
@@ -120268,16 +120264,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120268
120264
  throw e;
120269
120265
  }
120270
120266
  }
120271
- function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
120267
+ function getSemanticDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck) {
120272
120268
  return concatenate(
120273
- filterSemanticDiagnostics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options),
120269
+ filterSemanticDiagnostics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck), options),
120274
120270
  getProgramDiagnostics(sourceFile)
120275
120271
  );
120276
120272
  }
120277
- function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
120273
+ function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck) {
120274
+ if (nodesToCheck) {
120275
+ return getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck);
120276
+ }
120278
120277
  return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
120279
120278
  }
120280
- function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
120279
+ function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck) {
120281
120280
  return runWithCancellationToken(() => {
120282
120281
  if (skipTypeChecking(sourceFile, options, program)) {
120283
120282
  return emptyArray;
@@ -120285,24 +120284,34 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120285
120284
  const typeChecker2 = getTypeChecker();
120286
120285
  Debug.assert(!!sourceFile.bindDiagnostics);
120287
120286
  const isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
120288
- const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
120289
120287
  const isPlainJs = isPlainJsFile(sourceFile, options.checkJs);
120288
+ const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
120290
120289
  let bindDiagnostics = sourceFile.bindDiagnostics;
120291
- let checkDiagnostics = typeChecker2.getDiagnostics(sourceFile, cancellationToken);
120290
+ let checkDiagnostics = typeChecker2.getDiagnostics(sourceFile, cancellationToken, nodesToCheck);
120292
120291
  if (isPlainJs) {
120293
120292
  bindDiagnostics = filter(bindDiagnostics, (d) => plainJSErrors.has(d.code));
120294
120293
  checkDiagnostics = filter(checkDiagnostics, (d) => plainJSErrors.has(d.code));
120295
120294
  }
120296
- return getMergedBindAndCheckDiagnostics(sourceFile, !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : void 0);
120295
+ return getMergedBindAndCheckDiagnostics(
120296
+ sourceFile,
120297
+ !isPlainJs,
120298
+ !!nodesToCheck,
120299
+ bindDiagnostics,
120300
+ checkDiagnostics,
120301
+ isCheckJs ? sourceFile.jsDocDiagnostics : void 0
120302
+ );
120297
120303
  });
120298
120304
  }
120299
- function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, ...allDiagnostics) {
120305
+ function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, partialCheck, ...allDiagnostics) {
120300
120306
  var _a2;
120301
120307
  const flatDiagnostics = flatten(allDiagnostics);
120302
120308
  if (!includeBindAndCheckDiagnostics || !((_a2 = sourceFile.commentDirectives) == null ? void 0 : _a2.length)) {
120303
120309
  return flatDiagnostics;
120304
120310
  }
120305
120311
  const { diagnostics, directives } = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics);
120312
+ if (partialCheck) {
120313
+ return diagnostics;
120314
+ }
120306
120315
  for (const errorExpectation of directives.getUnusedExpectations()) {
120307
120316
  diagnostics.push(createDiagnosticForRange(sourceFile, errorExpectation.range, Diagnostics.Unused_ts_expect_error_directive));
120308
120317
  }
@@ -121123,14 +121132,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121123
121132
  const resolvedTypeReferenceDirective = resolutions[index];
121124
121133
  const fileName = ref.fileName;
121125
121134
  resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
121126
- const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
121135
+ const mode = ref.resolutionMode || file.impliedNodeFormat;
121127
121136
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
121128
121137
  }
121129
121138
  }
121130
- function getCompilerOptionsForFile(file) {
121131
- var _a2;
121132
- return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
121133
- }
121134
121139
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
121135
121140
  var _a2, _b2;
121136
121141
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
@@ -121231,12 +121236,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121231
121236
  return host.getCanonicalFileName(fileName);
121232
121237
  }
121233
121238
  function processImportedModules(file) {
121239
+ var _a2;
121234
121240
  collectExternalModuleReferences(file);
121235
121241
  if (file.imports.length || file.moduleAugmentations.length) {
121236
121242
  const moduleNames = getModuleNames(file);
121237
121243
  const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
121238
121244
  Debug.assert(resolutions.length === moduleNames.length);
121239
- const optionsForFile = getCompilerOptionsForFile(file);
121245
+ const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
121240
121246
  const resolutionsInFile = createModeAwareCache();
121241
121247
  (resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
121242
121248
  for (let index = 0; index < moduleNames.length; index++) {
@@ -121401,8 +121407,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121401
121407
  }
121402
121408
  const outputFile = options.outFile;
121403
121409
  if (options.tsBuildInfoFile) {
121404
- if (!isIncrementalCompilation(options)) {
121405
- createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
121410
+ if (!canEmitTsBuildInfo(options)) {
121411
+ createDiagnosticForOptionName(Diagnostics.Option_tsBuildInfoFile_cannot_be_specified_without_specifying_option_incremental_or_composite_or_if_not_running_tsc_b, "tsBuildInfoFile");
121406
121412
  }
121407
121413
  } else if (options.incremental && !outputFile && !options.configFilePath) {
121408
121414
  programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
@@ -121792,7 +121798,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121792
121798
  redirectInfo = cachedChain.redirectInfo;
121793
121799
  } else {
121794
121800
  reasons == null ? void 0 : reasons.forEach(processReason);
121795
- redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
121801
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
121796
121802
  }
121797
121803
  if (fileProcessingReason) processReason(fileProcessingReason);
121798
121804
  const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
@@ -122150,53 +122156,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122150
122156
  return symlinks;
122151
122157
  }
122152
122158
  function getModeForUsageLocation2(file, usage) {
122153
- return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
122154
- }
122155
- function getEmitSyntaxForUsageLocation(file, usage) {
122156
- return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
122159
+ var _a2;
122160
+ const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
122161
+ return getModeForUsageLocationWorker(file, usage, optionsForFile);
122157
122162
  }
122158
- function getModeForResolutionAtIndex(file, index) {
122163
+ function getModeForResolutionAtIndex2(file, index) {
122159
122164
  return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
122160
122165
  }
122161
- function getDefaultResolutionModeForFile2(sourceFile) {
122162
- return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122163
- }
122164
- function getImpliedNodeFormatForEmit(sourceFile) {
122165
- return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122166
- }
122167
- function getEmitModuleFormatOfFile(sourceFile) {
122168
- return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122169
- }
122170
- function shouldTransformImportCall(sourceFile) {
122171
- return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122172
- }
122173
- }
122174
- function shouldTransformImportCallWorker(sourceFile, options) {
122175
- const moduleKind = getEmitModuleKind(options);
122176
- if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
122177
- return false;
122178
- }
122179
- return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
122180
- }
122181
- function getEmitModuleFormatOfFileWorker(sourceFile, options) {
122182
- return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
122183
- }
122184
- function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
122185
- var _a, _b;
122186
- const moduleKind = getEmitModuleKind(options);
122187
- if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
122188
- return sourceFile.impliedNodeFormat;
122189
- }
122190
- if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
122191
- return 1 /* CommonJS */;
122192
- }
122193
- if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
122194
- return 99 /* ESNext */;
122195
- }
122196
- return void 0;
122197
- }
122198
- function getDefaultResolutionModeForFileWorker(sourceFile, options) {
122199
- return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
122200
122166
  }
122201
122167
  function updateHostForUseSourceOfProjectReferenceRedirect(host) {
122202
122168
  let setOfDeclarationDirectories;
@@ -122854,8 +122820,9 @@ function createBuilderProgramState(newProgram, oldState) {
122854
122820
  canCopySemanticDiagnostics = false;
122855
122821
  canCopyEmitDiagnostics = false;
122856
122822
  }
122823
+ state.hasErrorsFromOldState = oldState.hasErrors;
122857
122824
  } else {
122858
- state.buildInfoEmitPending = true;
122825
+ state.buildInfoEmitPending = isIncrementalCompilation(compilerOptions);
122859
122826
  }
122860
122827
  const referencedMap = state.referencedMap;
122861
122828
  const oldReferencedMap = useOldState ? oldState.referencedMap : void 0;
@@ -123013,40 +122980,6 @@ function releaseCache(state) {
123013
122980
  BuilderState.releaseCache(state);
123014
122981
  state.program = void 0;
123015
122982
  }
123016
- function backupBuilderProgramEmitState(state) {
123017
- const outFilePath = state.compilerOptions.outFile;
123018
- Debug.assert(!state.changedFilesSet.size || outFilePath);
123019
- return {
123020
- affectedFilesPendingEmit: state.affectedFilesPendingEmit && new Map(state.affectedFilesPendingEmit),
123021
- seenEmittedFiles: state.seenEmittedFiles && new Map(state.seenEmittedFiles),
123022
- seenProgramEmit: state.seenProgramEmit,
123023
- programEmitPending: state.programEmitPending,
123024
- emitSignatures: state.emitSignatures && new Map(state.emitSignatures),
123025
- outSignature: state.outSignature,
123026
- latestChangedDtsFile: state.latestChangedDtsFile,
123027
- hasChangedEmitSignature: state.hasChangedEmitSignature,
123028
- changedFilesSet: outFilePath ? new Set(state.changedFilesSet) : void 0,
123029
- buildInfoEmitPending: state.buildInfoEmitPending,
123030
- emitDiagnosticsPerFile: state.emitDiagnosticsPerFile && new Map(state.emitDiagnosticsPerFile)
123031
- };
123032
- }
123033
- function restoreBuilderProgramEmitState(state, savedEmitState) {
123034
- state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit;
123035
- state.seenEmittedFiles = savedEmitState.seenEmittedFiles;
123036
- state.seenProgramEmit = savedEmitState.seenProgramEmit;
123037
- state.programEmitPending = savedEmitState.programEmitPending;
123038
- state.emitSignatures = savedEmitState.emitSignatures;
123039
- state.outSignature = savedEmitState.outSignature;
123040
- state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile;
123041
- state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
123042
- state.buildInfoEmitPending = savedEmitState.buildInfoEmitPending;
123043
- state.emitDiagnosticsPerFile = savedEmitState.emitDiagnosticsPerFile;
123044
- if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet;
123045
- if (state.compilerOptions.outFile && state.changedFilesSet.size) {
123046
- state.semanticDiagnosticsPerFile.clear();
123047
- state.emitDiagnosticsPerFile = void 0;
123048
- }
123049
- }
123050
122983
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
123051
122984
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
123052
122985
  }
@@ -123328,6 +123261,7 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
123328
123261
  }
123329
123262
  const diagnostics = state.program.getBindAndCheckDiagnostics(sourceFile, cancellationToken);
123330
123263
  semanticDiagnosticsPerFile.set(path, diagnostics);
123264
+ state.buildInfoEmitPending = true;
123331
123265
  return filterSemanticDiagnostics(diagnostics, state.compilerOptions);
123332
123266
  }
123333
123267
  function isIncrementalBundleEmitBuildInfo(info) {
@@ -123337,6 +123271,35 @@ function isIncrementalBundleEmitBuildInfo(info) {
123337
123271
  function isIncrementalBuildInfo(info) {
123338
123272
  return !!info.fileNames;
123339
123273
  }
123274
+ function isNonIncrementalBuildInfo(info) {
123275
+ return !isIncrementalBuildInfo(info) && !!info.root;
123276
+ }
123277
+ function ensureHasErrorsForState(state) {
123278
+ if (state.hasErrors !== void 0) return;
123279
+ if (isIncrementalCompilation(state.compilerOptions)) {
123280
+ state.hasErrors = !some(state.program.getSourceFiles(), (f) => {
123281
+ var _a, _b;
123282
+ const bindAndCheckDiagnostics = state.semanticDiagnosticsPerFile.get(f.resolvedPath);
123283
+ return bindAndCheckDiagnostics === void 0 || // Missing semantic diagnostics in cache will be encoded in buildInfo
123284
+ !!bindAndCheckDiagnostics.length || // cached semantic diagnostics will be encoded in buildInfo
123285
+ !!((_b = (_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.get(f.resolvedPath)) == null ? void 0 : _b.length);
123286
+ }) && (hasSyntaxOrGlobalErrors(state) || some(state.program.getSourceFiles(), (f) => !!state.program.getProgramDiagnostics(f).length));
123287
+ } else {
123288
+ state.hasErrors = some(state.program.getSourceFiles(), (f) => {
123289
+ var _a, _b;
123290
+ const bindAndCheckDiagnostics = state.semanticDiagnosticsPerFile.get(f.resolvedPath);
123291
+ return !!(bindAndCheckDiagnostics == null ? void 0 : bindAndCheckDiagnostics.length) || // If has semantic diagnostics
123292
+ !!((_b = (_a = state.emitDiagnosticsPerFile) == null ? void 0 : _a.get(f.resolvedPath)) == null ? void 0 : _b.length);
123293
+ }) || hasSyntaxOrGlobalErrors(state);
123294
+ }
123295
+ }
123296
+ function hasSyntaxOrGlobalErrors(state) {
123297
+ return !!state.program.getConfigFileParsingDiagnostics().length || !!state.program.getSyntacticDiagnostics().length || !!state.program.getOptionsDiagnostics().length || !!state.program.getGlobalDiagnostics().length;
123298
+ }
123299
+ function getBuildInfoEmitPending(state) {
123300
+ ensureHasErrorsForState(state);
123301
+ return state.buildInfoEmitPending ?? (state.buildInfoEmitPending = !!state.hasErrorsFromOldState !== !!state.hasErrors);
123302
+ }
123340
123303
  function getBuildInfo2(state) {
123341
123304
  var _a, _b;
123342
123305
  const currentDirectory = state.program.getCurrentDirectory();
@@ -123345,6 +123308,15 @@ function getBuildInfo2(state) {
123345
123308
  const fileNames = [];
123346
123309
  const fileNameToFileId = /* @__PURE__ */ new Map();
123347
123310
  const rootFileNames = new Set(state.program.getRootFileNames().map((f) => toPath(f, currentDirectory, state.program.getCanonicalFileName)));
123311
+ ensureHasErrorsForState(state);
123312
+ if (!isIncrementalCompilation(state.compilerOptions)) {
123313
+ const buildInfo2 = {
123314
+ root: arrayFrom(rootFileNames, (r) => relativeToBuildInfo(r)),
123315
+ errors: state.hasErrors ? true : void 0,
123316
+ version
123317
+ };
123318
+ return buildInfo2;
123319
+ }
123348
123320
  const root = [];
123349
123321
  if (state.compilerOptions.outFile) {
123350
123322
  const fileInfos2 = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
@@ -123352,7 +123324,7 @@ function getBuildInfo2(state) {
123352
123324
  tryAddRoot(key, fileId);
123353
123325
  return value.impliedFormat ? { version: value.version, impliedFormat: value.impliedFormat, signature: void 0, affectsGlobalScope: void 0 } : value.version;
123354
123326
  });
123355
- return {
123327
+ const buildInfo2 = {
123356
123328
  fileNames,
123357
123329
  fileInfos: fileInfos2,
123358
123330
  root,
@@ -123360,7 +123332,6 @@ function getBuildInfo2(state) {
123360
123332
  options: toIncrementalBuildInfoCompilerOptions(state.compilerOptions),
123361
123333
  semanticDiagnosticsPerFile: toIncrementalBuildInfoDiagnostics(),
123362
123334
  emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123363
- changeFileSet: toChangeFileSet(),
123364
123335
  outSignature: state.outSignature,
123365
123336
  latestChangedDtsFile,
123366
123337
  pendingEmit: !state.programEmitPending ? void 0 : (
@@ -123371,8 +123342,10 @@ function getBuildInfo2(state) {
123371
123342
  )
123372
123343
  ),
123373
123344
  // Actual value
123345
+ errors: state.hasErrors ? true : void 0,
123374
123346
  version
123375
123347
  };
123348
+ return buildInfo2;
123376
123349
  }
123377
123350
  let fileIdsList;
123378
123351
  let fileNamesToFileIdListId;
@@ -123451,7 +123424,7 @@ function getBuildInfo2(state) {
123451
123424
  }
123452
123425
  }
123453
123426
  }
123454
- return {
123427
+ const buildInfo = {
123455
123428
  fileNames,
123456
123429
  fileIdsList,
123457
123430
  fileInfos,
@@ -123462,11 +123435,12 @@ function getBuildInfo2(state) {
123462
123435
  semanticDiagnosticsPerFile,
123463
123436
  emitDiagnosticsPerFile: toIncrementalBuildInfoEmitDiagnostics(),
123464
123437
  affectedFilesPendingEmit,
123465
- changeFileSet: toChangeFileSet(),
123466
123438
  emitSignatures,
123467
123439
  latestChangedDtsFile,
123440
+ errors: state.hasErrors ? true : void 0,
123468
123441
  version
123469
123442
  };
123443
+ return buildInfo;
123470
123444
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
123471
123445
  return relativeToBuildInfo(getNormalizedAbsolutePath(path, currentDirectory));
123472
123446
  }
@@ -123547,7 +123521,7 @@ function getBuildInfo2(state) {
123547
123521
  state.fileInfos.forEach((_value, key) => {
123548
123522
  const value = state.semanticDiagnosticsPerFile.get(key);
123549
123523
  if (!value) {
123550
- if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
123524
+ result = append(result, toFileId(key));
123551
123525
  } else if (value.length) {
123552
123526
  result = append(result, [
123553
123527
  toFileId(key),
@@ -123614,15 +123588,6 @@ function getBuildInfo2(state) {
123614
123588
  return result;
123615
123589
  }) || array;
123616
123590
  }
123617
- function toChangeFileSet() {
123618
- let changeFileSet;
123619
- if (state.changedFilesSet.size) {
123620
- for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
123621
- changeFileSet = append(changeFileSet, toFileId(path));
123622
- }
123623
- }
123624
- return changeFileSet;
123625
- }
123626
123591
  }
123627
123592
  function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
123628
123593
  let host;
@@ -123694,8 +123659,6 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123694
123659
  oldState = void 0;
123695
123660
  const builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
123696
123661
  builderProgram.state = state;
123697
- builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
123698
- builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
123699
123662
  builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
123700
123663
  builderProgram.getAllDependencies = (sourceFile) => BuilderState.getAllDependencies(
123701
123664
  state,
@@ -123717,7 +123680,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123717
123680
  return builderProgram;
123718
123681
  function emitBuildInfo(writeFile2, cancellationToken) {
123719
123682
  Debug.assert(isBuilderProgramStateWithDefinedProgram(state));
123720
- if (state.buildInfoEmitPending) {
123683
+ if (getBuildInfoEmitPending(state)) {
123721
123684
  const result = state.program.emitBuildInfo(
123722
123685
  writeFile2 || maybeBind(host, host.writeFile),
123723
123686
  cancellationToken
@@ -123768,7 +123731,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123768
123731
  }
123769
123732
  }
123770
123733
  if (!affected) {
123771
- if (!state.buildInfoEmitPending) return void 0;
123734
+ if (!getBuildInfoEmitPending(state)) return void 0;
123772
123735
  const affected2 = state.program;
123773
123736
  const result2 = affected2.emitBuildInfo(
123774
123737
  writeFile2 || maybeBind(host, host.writeFile),
@@ -123856,7 +123819,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123856
123819
  if (state.compilerOptions.composite) {
123857
123820
  const filePath = sourceFiles[0].resolvedPath;
123858
123821
  emitSignature = handleNewSignature((_c = state.emitSignatures) == null ? void 0 : _c.get(filePath), emitSignature);
123859
- if (!emitSignature) return;
123822
+ if (!emitSignature) return data.skippedDtsWrite = true;
123860
123823
  (state.emitSignatures ?? (state.emitSignatures = /* @__PURE__ */ new Map())).set(filePath, emitSignature);
123861
123824
  }
123862
123825
  } else if (state.compilerOptions.composite) {
@@ -123865,7 +123828,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
123865
123828
  /*newSignature*/
123866
123829
  void 0
123867
123830
  );
123868
- if (!newSignature) return;
123831
+ if (!newSignature) return data.skippedDtsWrite = true;
123869
123832
  state.outSignature = newSignature;
123870
123833
  }
123871
123834
  }
@@ -124010,7 +123973,6 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124010
123973
  let filePathsSetList;
124011
123974
  const latestChangedDtsFile = buildInfo.latestChangedDtsFile ? toAbsolutePath(buildInfo.latestChangedDtsFile) : void 0;
124012
123975
  const fileInfos = /* @__PURE__ */ new Map();
124013
- const changedFilesSet = new Set(map(buildInfo.changeFileSet, toFilePath));
124014
123976
  if (isIncrementalBundleEmitBuildInfo(buildInfo)) {
124015
123977
  buildInfo.fileInfos.forEach((fileInfo, index) => {
124016
123978
  const path = toFilePath(index + 1);
@@ -124022,10 +123984,10 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124022
123984
  semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(buildInfo.semanticDiagnosticsPerFile),
124023
123985
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
124024
123986
  hasReusableDiagnostic: true,
124025
- changedFilesSet,
124026
123987
  latestChangedDtsFile,
124027
123988
  outSignature: buildInfo.outSignature,
124028
- programEmitPending: buildInfo.pendingEmit === void 0 ? void 0 : toProgramEmitPending(buildInfo.pendingEmit, buildInfo.options)
123989
+ programEmitPending: buildInfo.pendingEmit === void 0 ? void 0 : toProgramEmitPending(buildInfo.pendingEmit, buildInfo.options),
123990
+ hasErrors: buildInfo.errors
124029
123991
  };
124030
123992
  } else {
124031
123993
  filePathsSetList = (_b = buildInfo.fileIdsList) == null ? void 0 : _b.map((fileIds) => new Set(fileIds.map(toFilePath)));
@@ -124058,15 +124020,13 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124058
124020
  emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
124059
124021
  hasReusableDiagnostic: true,
124060
124022
  affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
124061
- changedFilesSet,
124062
124023
  latestChangedDtsFile,
124063
- emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
124024
+ emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0,
124025
+ hasErrors: buildInfo.errors
124064
124026
  };
124065
124027
  }
124066
124028
  return {
124067
124029
  state,
124068
- saveEmitState: noop,
124069
- restoreEmitState: noop,
124070
124030
  getProgram: notImplemented,
124071
124031
  getProgramOrUndefined: returnUndefined,
124072
124032
  releaseProgram: noop,
@@ -124110,7 +124070,7 @@ function createBuilderProgramUsingIncrementalBuildInfo(buildInfo, buildInfoPath,
124110
124070
  const semanticDiagnostics = new Map(
124111
124071
  mapDefinedIterator(
124112
124072
  fileInfos.keys(),
124113
- (key) => !changedFilesSet.has(key) ? [key, emptyArray] : void 0
124073
+ (key) => [key, emptyArray]
124114
124074
  )
124115
124075
  );
124116
124076
  diagnostics == null ? void 0 : diagnostics.forEach((value) => {
@@ -124158,11 +124118,15 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
124158
124118
  }
124159
124119
  }
124160
124120
  }
124121
+ function getNonIncrementalBuildInfoRoots(buildInfo, buildInfoPath, host) {
124122
+ if (!isNonIncrementalBuildInfo(buildInfo)) return void 0;
124123
+ const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
124124
+ const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
124125
+ return buildInfo.root.map((r) => toPath(r, buildInfoDirectory, getCanonicalFileName));
124126
+ }
124161
124127
  function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
124162
124128
  return {
124163
124129
  state: void 0,
124164
- saveEmitState: noop,
124165
- restoreEmitState: noop,
124166
124130
  getProgram,
124167
124131
  getProgramOrUndefined: () => state.program,
124168
124132
  releaseProgram: () => state.program = void 0,
@@ -125490,10 +125454,10 @@ function explainFiles(program, write) {
125490
125454
  for (const file of program.getSourceFiles()) {
125491
125455
  write(`${toFileName(file, relativeFileName)}`);
125492
125456
  (_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
125493
- (_b = explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
125457
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
125494
125458
  }
125495
125459
  }
125496
- function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConvertor) {
125460
+ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
125497
125461
  var _a;
125498
125462
  let result;
125499
125463
  if (file.path !== file.resolvedPath) {
@@ -125513,7 +125477,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConverto
125513
125477
  ));
125514
125478
  }
125515
125479
  if (isExternalOrCommonJsModule(file)) {
125516
- switch (getImpliedNodeFormatForEmitWorker(file, options)) {
125480
+ switch (file.impliedNodeFormat) {
125517
125481
  case 99 /* ESNext */:
125518
125482
  if (file.packageJsonScope) {
125519
125483
  (result ?? (result = [])).push(chainDiagnosticMessages(
@@ -125710,13 +125674,12 @@ function emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummar
125710
125674
  emitOnlyDtsFiles,
125711
125675
  customTransformers
125712
125676
  );
125713
- const { emittedFiles, diagnostics: emitDiagnostics } = emitResult;
125714
- addRange(allDiagnostics, emitDiagnostics);
125677
+ addRange(allDiagnostics, emitResult.diagnostics);
125715
125678
  const diagnostics = sortAndDeduplicateDiagnostics(allDiagnostics);
125716
125679
  diagnostics.forEach(reportDiagnostic);
125717
125680
  if (write) {
125718
125681
  const currentDir = program.getCurrentDirectory();
125719
- forEach(emittedFiles, (file) => {
125682
+ forEach(emitResult.emittedFiles, (file) => {
125720
125683
  const filepath = getNormalizedAbsolutePath(file, currentDir);
125721
125684
  write(`TSFILE: ${filepath}`);
125722
125685
  });
@@ -126374,22 +126337,17 @@ function createWatchProgram(host) {
126374
126337
  updateProgram();
126375
126338
  }
126376
126339
  function updateProgram() {
126377
- var _a, _b, _c, _d;
126378
126340
  switch (updateLevel) {
126379
126341
  case 1 /* RootNamesAndUpdate */:
126380
- (_a = perfLogger) == null ? void 0 : _a.logStartUpdateProgram("PartialConfigReload");
126381
126342
  reloadFileNamesFromConfigFile();
126382
126343
  break;
126383
126344
  case 2 /* Full */:
126384
- (_b = perfLogger) == null ? void 0 : _b.logStartUpdateProgram("FullConfigReload");
126385
126345
  reloadConfigFile();
126386
126346
  break;
126387
126347
  default:
126388
- (_c = perfLogger) == null ? void 0 : _c.logStartUpdateProgram("SynchronizeProgram");
126389
126348
  synchronizeProgram();
126390
126349
  break;
126391
126350
  }
126392
- (_d = perfLogger) == null ? void 0 : _d.logStopUpdateProgram("Done");
126393
126351
  return getCurrentBuilderProgram();
126394
126352
  }
126395
126353
  function reloadFileNamesFromConfigFile() {
@@ -126672,7 +126630,6 @@ function resolveConfigFileProjectName(project) {
126672
126630
 
126673
126631
  // src/compiler/tsbuildPublic.ts
126674
126632
  var minimumDate = /* @__PURE__ */ new Date(-864e13);
126675
- var maximumDate = /* @__PURE__ */ new Date(864e13);
126676
126633
  function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
126677
126634
  const existingValue = configFileMap.get(resolved);
126678
126635
  let newValue;
@@ -126727,6 +126684,7 @@ function getCompilerOptionsOfBuildOptions(buildOptions) {
126727
126684
  commonOptionsWithBuild.forEach((option) => {
126728
126685
  if (hasProperty(buildOptions, option.name)) result[option.name] = buildOptions[option.name];
126729
126686
  });
126687
+ result.tscBuild = true;
126730
126688
  return result;
126731
126689
  }
126732
126690
  function createSolutionBuilder(host, rootNames, defaultOptions) {
@@ -127125,7 +127083,7 @@ function createUpdateOutputFileStampsProject(state, project, projectPath, config
127125
127083
  }
127126
127084
  };
127127
127085
  }
127128
- function createBuildOrUpdateInvalidedProject(state, project, projectPath, projectIndex, config, buildOrder) {
127086
+ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projectIndex, config, status, buildOrder) {
127129
127087
  let step = 0 /* CreateProgram */;
127130
127088
  let program;
127131
127089
  let buildResult;
@@ -127176,17 +127134,13 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127176
127134
  }
127177
127135
  );
127178
127136
  }
127179
- executeSteps(2 /* SemanticDiagnostics */, cancellationToken);
127180
- if (step === 4 /* EmitBuildInfo */) {
127181
- return emitBuildInfo(writeFile2, cancellationToken);
127182
- }
127183
- if (step !== 3 /* Emit */) return void 0;
127137
+ executeSteps(0 /* CreateProgram */, cancellationToken);
127184
127138
  return emit(writeFile2, cancellationToken, customTransformers);
127185
127139
  },
127186
127140
  done
127187
127141
  };
127188
127142
  function done(cancellationToken, writeFile2, customTransformers) {
127189
- executeSteps(6 /* Done */, cancellationToken, writeFile2, customTransformers);
127143
+ executeSteps(3 /* Done */, cancellationToken, writeFile2, customTransformers);
127190
127144
  mark("SolutionBuilder::Projects built");
127191
127145
  return doneInvalidatedProject(state, projectPath);
127192
127146
  }
@@ -127203,14 +127157,14 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127203
127157
  if (state.options.dry) {
127204
127158
  reportStatus(state, Diagnostics.A_non_dry_build_would_build_project_0, project);
127205
127159
  buildResult = 1 /* Success */;
127206
- step = 5 /* QueueReferencingProjects */;
127160
+ step = 2 /* QueueReferencingProjects */;
127207
127161
  return;
127208
127162
  }
127209
127163
  if (state.options.verbose) reportStatus(state, Diagnostics.Building_project_0, project);
127210
127164
  if (config.fileNames.length === 0) {
127211
127165
  reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
127212
127166
  buildResult = 0 /* None */;
127213
- step = 5 /* QueueReferencingProjects */;
127167
+ step = 2 /* QueueReferencingProjects */;
127214
127168
  return;
127215
127169
  }
127216
127170
  const { host, compilerHost } = state;
@@ -127238,179 +127192,97 @@ function createBuildOrUpdateInvalidedProject(state, project, projectPath, projec
127238
127192
  }
127239
127193
  step++;
127240
127194
  }
127241
- function handleDiagnostics(diagnostics, errorFlags, errorType) {
127242
- if (diagnostics.length) {
127243
- ({ buildResult, step } = buildErrors(
127244
- state,
127245
- projectPath,
127246
- diagnostics,
127247
- errorFlags,
127248
- errorType
127249
- ));
127250
- } else {
127251
- step++;
127252
- }
127253
- }
127254
- function getSyntaxDiagnostics(cancellationToken) {
127255
- Debug.assertIsDefined(program);
127256
- handleDiagnostics(
127257
- [
127258
- ...program.getConfigFileParsingDiagnostics(),
127259
- ...program.getOptionsDiagnostics(cancellationToken),
127260
- ...program.getGlobalDiagnostics(cancellationToken),
127261
- ...program.getSyntacticDiagnostics(
127262
- /*sourceFile*/
127263
- void 0,
127264
- cancellationToken
127265
- )
127266
- ],
127267
- 8 /* SyntaxErrors */,
127268
- "Syntactic"
127269
- );
127270
- }
127271
- function getSemanticDiagnostics(cancellationToken) {
127272
- handleDiagnostics(
127273
- Debug.checkDefined(program).getSemanticDiagnostics(
127274
- /*sourceFile*/
127275
- void 0,
127276
- cancellationToken
127277
- ),
127278
- 16 /* TypeErrors */,
127279
- "Semantic"
127280
- );
127281
- }
127282
127195
  function emit(writeFileCallback, cancellationToken, customTransformers) {
127283
127196
  var _a, _b, _c;
127284
127197
  Debug.assertIsDefined(program);
127285
- Debug.assert(step === 3 /* Emit */);
127286
- const saved = program.saveEmitState();
127287
- let declDiagnostics;
127288
- const reportDeclarationDiagnostics = (d) => (declDiagnostics || (declDiagnostics = [])).push(d);
127289
- const outputFiles = [];
127290
- const { emitResult } = emitFilesAndReportErrors(
127198
+ Debug.assert(step === 1 /* Emit */);
127199
+ const { host, compilerHost } = state;
127200
+ const emittedOutputs = /* @__PURE__ */ new Map();
127201
+ const options = program.getCompilerOptions();
127202
+ const isIncremental = isIncrementalCompilation(options);
127203
+ let outputTimeStampMap;
127204
+ let now;
127205
+ const { emitResult, diagnostics } = emitFilesAndReportErrors(
127291
127206
  program,
127292
- reportDeclarationDiagnostics,
127293
- /*write*/
127294
- void 0,
127207
+ (d) => host.reportDiagnostic(d),
127208
+ state.write,
127295
127209
  /*reportSummary*/
127296
127210
  void 0,
127297
- (name, text, writeByteOrderMark, _onError, _sourceFiles, data) => outputFiles.push({ name, text, writeByteOrderMark, data }),
127211
+ (name, text, writeByteOrderMark, onError, sourceFiles, data) => {
127212
+ var _a2;
127213
+ const path = toPath2(state, name);
127214
+ emittedOutputs.set(toPath2(state, name), name);
127215
+ if (data == null ? void 0 : data.buildInfo) {
127216
+ now || (now = getCurrentTime(state.host));
127217
+ const isChangedSignature2 = (_a2 = program.hasChangedEmitSignature) == null ? void 0 : _a2.call(program);
127218
+ const existing = getBuildInfoCacheEntry(state, name, projectPath);
127219
+ if (existing) {
127220
+ existing.buildInfo = data.buildInfo;
127221
+ existing.modifiedTime = now;
127222
+ if (isChangedSignature2) existing.latestChangedDtsTime = now;
127223
+ } else {
127224
+ state.buildInfoCache.set(projectPath, {
127225
+ path: toPath2(state, name),
127226
+ buildInfo: data.buildInfo,
127227
+ modifiedTime: now,
127228
+ latestChangedDtsTime: isChangedSignature2 ? now : void 0
127229
+ });
127230
+ }
127231
+ }
127232
+ const modifiedTime = (data == null ? void 0 : data.differsOnlyInMap) ? getModifiedTime(state.host, name) : void 0;
127233
+ (writeFileCallback || compilerHost.writeFile)(
127234
+ name,
127235
+ text,
127236
+ writeByteOrderMark,
127237
+ onError,
127238
+ sourceFiles,
127239
+ data
127240
+ );
127241
+ if (data == null ? void 0 : data.differsOnlyInMap) state.host.setModifiedTime(name, modifiedTime);
127242
+ else if (!isIncremental && state.watch) {
127243
+ (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
127244
+ }
127245
+ },
127298
127246
  cancellationToken,
127299
127247
  /*emitOnlyDtsFiles*/
127300
- false,
127248
+ void 0,
127301
127249
  customTransformers || ((_b = (_a = state.host).getCustomTransformers) == null ? void 0 : _b.call(_a, project))
127302
127250
  );
127303
- if (declDiagnostics) {
127304
- program.restoreEmitState(saved);
127305
- ({ buildResult, step } = buildErrors(
127306
- state,
127307
- projectPath,
127308
- declDiagnostics,
127309
- 32 /* DeclarationEmitErrors */,
127310
- "Declaration file"
127311
- ));
127312
- return {
127313
- emitSkipped: true,
127314
- diagnostics: emitResult.diagnostics
127315
- };
127251
+ if ((!options.noEmitOnError || !diagnostics.length) && (emittedOutputs.size || status.type !== 8 /* OutOfDateBuildInfoWithErrors */)) {
127252
+ updateOutputTimestampsWorker(state, config, projectPath, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
127316
127253
  }
127317
- const { host, compilerHost } = state;
127318
- const resultFlags = ((_c = program.hasChangedEmitSignature) == null ? void 0 : _c.call(program)) ? 0 /* None */ : 2 /* DeclarationOutputUnchanged */;
127319
- const emitterDiagnostics = createDiagnosticCollection();
127320
- const emittedOutputs = /* @__PURE__ */ new Map();
127321
- const options = program.getCompilerOptions();
127322
- const isIncremental = isIncrementalCompilation(options);
127323
- let outputTimeStampMap;
127324
- let now;
127325
- outputFiles.forEach(({ name, text, writeByteOrderMark, data }) => {
127326
- const path = toPath2(state, name);
127327
- emittedOutputs.set(toPath2(state, name), name);
127328
- if (data == null ? void 0 : data.buildInfo) setBuildInfo(state, data.buildInfo, projectPath, options, resultFlags);
127329
- const modifiedTime = (data == null ? void 0 : data.differsOnlyInMap) ? getModifiedTime(state.host, name) : void 0;
127330
- writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
127331
- if (data == null ? void 0 : data.differsOnlyInMap) state.host.setModifiedTime(name, modifiedTime);
127332
- else if (!isIncremental && state.watch) {
127333
- (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host)));
127334
- }
127335
- });
127336
- finishEmit(
127337
- emitterDiagnostics,
127338
- emittedOutputs,
127339
- outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()),
127340
- resultFlags
127341
- );
127342
- return emitResult;
127343
- }
127344
- function emitBuildInfo(writeFileCallback, cancellationToken) {
127345
- Debug.assertIsDefined(program);
127346
- Debug.assert(step === 4 /* EmitBuildInfo */);
127347
- const emitResult = program.emitBuildInfo((name, text, writeByteOrderMark, onError, sourceFiles, data) => {
127348
- if (data == null ? void 0 : data.buildInfo) setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), 2 /* DeclarationOutputUnchanged */);
127349
- if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
127350
- else state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
127351
- }, cancellationToken);
127352
- if (emitResult.diagnostics.length) {
127353
- reportErrors(state, emitResult.diagnostics);
127354
- state.diagnostics.set(projectPath, [...state.diagnostics.get(projectPath), ...emitResult.diagnostics]);
127355
- buildResult = 64 /* EmitErrors */ & buildResult;
127356
- }
127357
- if (emitResult.emittedFiles && state.write) {
127358
- emitResult.emittedFiles.forEach((name) => listEmittedFile(state, config, name));
127254
+ state.projectErrorsReported.set(projectPath, true);
127255
+ if (!diagnostics.length) {
127256
+ state.diagnostics.delete(projectPath);
127257
+ state.projectStatus.set(projectPath, {
127258
+ type: 1 /* UpToDate */,
127259
+ oldestOutputFileName: firstOrUndefinedIterator(emittedOutputs.values()) ?? getFirstProjectOutput(config, !host.useCaseSensitiveFileNames())
127260
+ });
127261
+ buildResult = ((_c = program.hasChangedEmitSignature) == null ? void 0 : _c.call(program)) ? 0 /* None */ : 2 /* DeclarationOutputUnchanged */;
127262
+ } else {
127263
+ state.diagnostics.set(projectPath, diagnostics);
127264
+ state.projectStatus.set(projectPath, { type: 0 /* Unbuildable */, reason: `it had errors` });
127265
+ buildResult = 4 /* AnyErrors */;
127359
127266
  }
127360
127267
  afterProgramDone(state, program);
127361
- step = 5 /* QueueReferencingProjects */;
127268
+ step = 2 /* QueueReferencingProjects */;
127362
127269
  return emitResult;
127363
127270
  }
127364
- function finishEmit(emitterDiagnostics, emittedOutputs, oldestOutputFileName, resultFlags) {
127365
- const emitDiagnostics = emitterDiagnostics.getDiagnostics();
127366
- if (emitDiagnostics.length) {
127367
- ({ buildResult, step } = buildErrors(
127368
- state,
127369
- projectPath,
127370
- emitDiagnostics,
127371
- 64 /* EmitErrors */,
127372
- "Emit"
127373
- ));
127374
- return emitDiagnostics;
127375
- }
127376
- if (state.write) {
127377
- emittedOutputs.forEach((name) => listEmittedFile(state, config, name));
127378
- }
127379
- updateOutputTimestampsWorker(state, config, projectPath, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
127380
- state.diagnostics.delete(projectPath);
127381
- state.projectStatus.set(projectPath, {
127382
- type: 1 /* UpToDate */,
127383
- oldestOutputFileName
127384
- });
127385
- afterProgramDone(state, program);
127386
- step = 5 /* QueueReferencingProjects */;
127387
- buildResult = resultFlags;
127388
- return emitDiagnostics;
127389
- }
127390
127271
  function executeSteps(till, cancellationToken, writeFile2, customTransformers) {
127391
- while (step <= till && step < 6 /* Done */) {
127272
+ while (step <= till && step < 3 /* Done */) {
127392
127273
  const currentStep = step;
127393
127274
  switch (step) {
127394
127275
  case 0 /* CreateProgram */:
127395
127276
  createProgram2();
127396
127277
  break;
127397
- case 1 /* SyntaxDiagnostics */:
127398
- getSyntaxDiagnostics(cancellationToken);
127399
- break;
127400
- case 2 /* SemanticDiagnostics */:
127401
- getSemanticDiagnostics(cancellationToken);
127402
- break;
127403
- case 3 /* Emit */:
127278
+ case 1 /* Emit */:
127404
127279
  emit(writeFile2, cancellationToken, customTransformers);
127405
127280
  break;
127406
- case 4 /* EmitBuildInfo */:
127407
- emitBuildInfo(writeFile2, cancellationToken);
127408
- break;
127409
- case 5 /* QueueReferencingProjects */:
127281
+ case 2 /* QueueReferencingProjects */:
127410
127282
  queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, Debug.checkDefined(buildResult));
127411
127283
  step++;
127412
127284
  break;
127413
- case 6 /* Done */:
127285
+ case 3 /* Done */:
127414
127286
  default:
127415
127287
  assertType(step);
127416
127288
  }
@@ -127460,7 +127332,7 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
127460
127332
  }
127461
127333
  continue;
127462
127334
  }
127463
- if (status.type === 2 /* UpToDateWithUpstreamTypes */ || status.type === 14 /* UpToDateWithInputFileText */) {
127335
+ if (status.type === 2 /* UpToDateWithUpstreamTypes */ || status.type === 15 /* UpToDateWithInputFileText */) {
127464
127336
  reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
127465
127337
  return {
127466
127338
  kind: 1 /* UpdateOutputFileStamps */,
@@ -127472,7 +127344,7 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
127472
127344
  };
127473
127345
  }
127474
127346
  }
127475
- if (status.type === 11 /* UpstreamBlocked */) {
127347
+ if (status.type === 12 /* UpstreamBlocked */) {
127476
127348
  verboseReportProjectStatus(state, project, status);
127477
127349
  reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
127478
127350
  projectPendingBuild.delete(projectPath);
@@ -127486,7 +127358,7 @@ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
127486
127358
  }
127487
127359
  continue;
127488
127360
  }
127489
- if (status.type === 15 /* ContainerOnly */) {
127361
+ if (status.type === 16 /* ContainerOnly */) {
127490
127362
  verboseReportProjectStatus(state, project, status);
127491
127363
  reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
127492
127364
  projectPendingBuild.delete(projectPath);
@@ -127511,6 +127383,7 @@ function createInvalidatedProjectWithInfo(state, info, buildOrder) {
127511
127383
  info.projectPath,
127512
127384
  info.projectIndex,
127513
127385
  info.config,
127386
+ info.status,
127514
127387
  buildOrder
127515
127388
  ) : createUpdateOutputFileStampsProject(
127516
127389
  state,
@@ -127525,11 +127398,6 @@ function getNextInvalidatedProject(state, buildOrder, reportQueue) {
127525
127398
  if (!info) return info;
127526
127399
  return createInvalidatedProjectWithInfo(state, info, buildOrder);
127527
127400
  }
127528
- function listEmittedFile({ write }, proj, file) {
127529
- if (write && proj.options.listEmittedFiles) {
127530
- write(`TSFILE: ${file}`);
127531
- }
127532
- }
127533
127401
  function getOldProgram({ options, builderPrograms, compilerHost }, proj, parsed) {
127534
127402
  if (options.force) return void 0;
127535
127403
  const value = builderPrograms.get(proj);
@@ -127538,7 +127406,6 @@ function getOldProgram({ options, builderPrograms, compilerHost }, proj, parsed)
127538
127406
  }
127539
127407
  function afterProgramDone(state, program) {
127540
127408
  if (program) {
127541
- if (state.write) listFiles(program, state.write);
127542
127409
  if (state.host.afterProgramEmitAndDiagnostics) {
127543
127410
  state.host.afterProgramEmitAndDiagnostics(program);
127544
127411
  }
@@ -127546,11 +127413,6 @@ function afterProgramDone(state, program) {
127546
127413
  }
127547
127414
  state.projectCompilerOptions = state.baseCompilerOptions;
127548
127415
  }
127549
- function buildErrors(state, resolvedPath, diagnostics, buildResult, errorType) {
127550
- reportAndStoreErrors(state, resolvedPath, diagnostics);
127551
- state.projectStatus.set(resolvedPath, { type: 0 /* Unbuildable */, reason: `${errorType} errors` });
127552
- return { buildResult, step: 4 /* EmitBuildInfo */ };
127553
- }
127554
127416
  function isFileWatcherWithModifiedTime(value) {
127555
127417
  return !!value.watcher;
127556
127418
  }
@@ -127608,23 +127470,6 @@ function getOutputTimeStampMap(state, resolvedConfigFilePath) {
127608
127470
  if (!result) state.outputTimeStamps.set(resolvedConfigFilePath, result = /* @__PURE__ */ new Map());
127609
127471
  return result;
127610
127472
  }
127611
- function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) {
127612
- const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
127613
- const existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
127614
- const modifiedTime = getCurrentTime(state.host);
127615
- if (existing) {
127616
- existing.buildInfo = buildInfo;
127617
- existing.modifiedTime = modifiedTime;
127618
- if (!(resultFlags & 2 /* DeclarationOutputUnchanged */)) existing.latestChangedDtsTime = modifiedTime;
127619
- } else {
127620
- state.buildInfoCache.set(resolvedConfigPath, {
127621
- path: toPath2(state, buildInfoPath),
127622
- buildInfo,
127623
- modifiedTime,
127624
- latestChangedDtsTime: resultFlags & 2 /* DeclarationOutputUnchanged */ ? void 0 : modifiedTime
127625
- });
127626
- }
127627
- }
127628
127473
  function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) {
127629
127474
  const path = toPath2(state, buildInfoPath);
127630
127475
  const existing = state.buildInfoCache.get(resolvedConfigPath);
@@ -127652,99 +127497,106 @@ function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime,
127652
127497
  }
127653
127498
  }
127654
127499
  function getUpToDateStatusWorker(state, project, resolvedPath) {
127655
- var _a, _b, _c, _d;
127500
+ var _a, _b, _c;
127656
127501
  if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
127657
127502
  return {
127658
- type: 15 /* ContainerOnly */
127503
+ type: 16 /* ContainerOnly */
127659
127504
  };
127660
127505
  }
127661
127506
  let referenceStatuses;
127662
127507
  const force = !!state.options.force;
127663
127508
  if (project.projectReferences) {
127664
- state.projectStatus.set(resolvedPath, { type: 12 /* ComputingUpstream */ });
127509
+ state.projectStatus.set(resolvedPath, { type: 13 /* ComputingUpstream */ });
127665
127510
  for (const ref of project.projectReferences) {
127666
127511
  const resolvedRef = resolveProjectReferencePath(ref);
127667
127512
  const resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
127668
127513
  const resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath);
127669
127514
  const refStatus = getUpToDateStatus(state, resolvedConfig, resolvedRefPath);
127670
- if (refStatus.type === 12 /* ComputingUpstream */ || refStatus.type === 15 /* ContainerOnly */) {
127515
+ if (refStatus.type === 13 /* ComputingUpstream */ || refStatus.type === 16 /* ContainerOnly */) {
127671
127516
  continue;
127672
127517
  }
127673
- if (refStatus.type === 0 /* Unbuildable */ || refStatus.type === 11 /* UpstreamBlocked */) {
127518
+ if (refStatus.type === 0 /* Unbuildable */ || refStatus.type === 12 /* UpstreamBlocked */) {
127674
127519
  return {
127675
- type: 11 /* UpstreamBlocked */,
127520
+ type: 12 /* UpstreamBlocked */,
127676
127521
  upstreamProjectName: ref.path,
127677
- upstreamProjectBlocked: refStatus.type === 11 /* UpstreamBlocked */
127522
+ upstreamProjectBlocked: refStatus.type === 12 /* UpstreamBlocked */
127678
127523
  };
127679
127524
  }
127680
127525
  if (refStatus.type !== 1 /* UpToDate */) {
127681
127526
  return {
127682
- type: 10 /* UpstreamOutOfDate */,
127527
+ type: 11 /* UpstreamOutOfDate */,
127683
127528
  upstreamProjectName: ref.path
127684
127529
  };
127685
127530
  }
127686
127531
  if (!force) (referenceStatuses || (referenceStatuses = [])).push({ ref, refStatus, resolvedRefPath, resolvedConfig });
127687
127532
  }
127688
127533
  }
127689
- if (force) return { type: 16 /* ForceBuild */ };
127534
+ if (force) return { type: 17 /* ForceBuild */ };
127690
127535
  const { host } = state;
127691
127536
  const buildInfoPath = getTsBuildInfoEmitOutputFilePath(project.options);
127692
- let oldestOutputFileName;
127693
- let oldestOutputFileTime = maximumDate;
127694
- let buildInfoTime;
127695
- let incrementalBuildInfo;
127696
- let buildInfoVersionMap;
127697
- if (buildInfoPath) {
127698
- const buildInfoCacheEntry2 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
127699
- buildInfoTime = (buildInfoCacheEntry2 == null ? void 0 : buildInfoCacheEntry2.modifiedTime) || getModifiedTime(host, buildInfoPath);
127700
- if (buildInfoTime === missingFileModifiedTime) {
127701
- if (!buildInfoCacheEntry2) {
127702
- state.buildInfoCache.set(resolvedPath, {
127703
- path: toPath2(state, buildInfoPath),
127704
- buildInfo: false,
127705
- modifiedTime: buildInfoTime
127706
- });
127707
- }
127537
+ const isIncremental = isIncrementalCompilation(project.options);
127538
+ let buildInfoCacheEntry = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
127539
+ const buildInfoTime = (buildInfoCacheEntry == null ? void 0 : buildInfoCacheEntry.modifiedTime) || getModifiedTime(host, buildInfoPath);
127540
+ if (buildInfoTime === missingFileModifiedTime) {
127541
+ if (!buildInfoCacheEntry) {
127542
+ state.buildInfoCache.set(resolvedPath, {
127543
+ path: toPath2(state, buildInfoPath),
127544
+ buildInfo: false,
127545
+ modifiedTime: buildInfoTime
127546
+ });
127547
+ }
127548
+ return {
127549
+ type: 3 /* OutputMissing */,
127550
+ missingOutputFileName: buildInfoPath
127551
+ };
127552
+ }
127553
+ const buildInfo = getBuildInfo3(state, buildInfoPath, resolvedPath, buildInfoTime);
127554
+ if (!buildInfo) {
127555
+ return {
127556
+ type: 4 /* ErrorReadingFile */,
127557
+ fileName: buildInfoPath
127558
+ };
127559
+ }
127560
+ const incrementalBuildInfo = isIncremental && isIncrementalBuildInfo(buildInfo) ? buildInfo : void 0;
127561
+ if ((incrementalBuildInfo || !isIncremental) && buildInfo.version !== version) {
127562
+ return {
127563
+ type: 14 /* TsVersionOutputOfDate */,
127564
+ version: buildInfo.version
127565
+ };
127566
+ }
127567
+ if (buildInfo.errors) {
127568
+ return {
127569
+ type: 8 /* OutOfDateBuildInfoWithErrors */,
127570
+ buildInfoFile: buildInfoPath
127571
+ };
127572
+ }
127573
+ if (incrementalBuildInfo) {
127574
+ if (((_a = incrementalBuildInfo.semanticDiagnosticsPerFile) == null ? void 0 : _a.length) || !project.options.noEmit && getEmitDeclarations(project.options) && ((_b = incrementalBuildInfo.emitDiagnosticsPerFile) == null ? void 0 : _b.length)) {
127708
127575
  return {
127709
- type: 3 /* OutputMissing */,
127710
- missingOutputFileName: buildInfoPath
127576
+ type: 8 /* OutOfDateBuildInfoWithErrors */,
127577
+ buildInfoFile: buildInfoPath
127711
127578
  };
127712
127579
  }
127713
- const buildInfo = getBuildInfo3(state, buildInfoPath, resolvedPath, buildInfoTime);
127714
- if (!buildInfo) {
127580
+ if (!project.options.noEmit && (((_c = incrementalBuildInfo.affectedFilesPendingEmit) == null ? void 0 : _c.length) || incrementalBuildInfo.pendingEmit !== void 0)) {
127715
127581
  return {
127716
- type: 4 /* ErrorReadingFile */,
127717
- fileName: buildInfoPath
127582
+ type: 7 /* OutOfDateBuildInfoWithPendingEmit */,
127583
+ buildInfoFile: buildInfoPath
127718
127584
  };
127719
127585
  }
127720
- if (isIncrementalBuildInfo(buildInfo) && buildInfo.version !== version) {
127586
+ if (!project.options.noEmit && getPendingEmitKind(project.options, incrementalBuildInfo.options || {})) {
127721
127587
  return {
127722
- type: 13 /* TsVersionOutputOfDate */,
127723
- version: buildInfo.version
127588
+ type: 9 /* OutOfDateOptions */,
127589
+ buildInfoFile: buildInfoPath
127724
127590
  };
127725
127591
  }
127726
- if (isIncrementalBuildInfo(buildInfo)) {
127727
- if (((_a = buildInfo.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.emitDiagnosticsPerFile) == null ? void 0 : _c.length) || buildInfo.pendingEmit !== void 0 : (_d = buildInfo.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
127728
- return {
127729
- type: 7 /* OutOfDateBuildInfo */,
127730
- buildInfoFile: buildInfoPath
127731
- };
127732
- }
127733
- if (!project.options.noEmit && getPendingEmitKind(project.options, buildInfo.options || {})) {
127734
- return {
127735
- type: 8 /* OutOfDateOptions */,
127736
- buildInfoFile: buildInfoPath
127737
- };
127738
- }
127739
- incrementalBuildInfo = buildInfo;
127740
- }
127741
- oldestOutputFileTime = buildInfoTime;
127742
- oldestOutputFileName = buildInfoPath;
127743
127592
  }
127593
+ let oldestOutputFileTime = buildInfoTime;
127594
+ let oldestOutputFileName = buildInfoPath;
127744
127595
  let newestInputFileName = void 0;
127745
127596
  let newestInputFileTime = minimumDate;
127746
127597
  let pseudoInputUpToDate = false;
127747
127598
  const seenRoots = /* @__PURE__ */ new Set();
127599
+ let buildInfoVersionMap;
127748
127600
  for (const inputFile of project.fileNames) {
127749
127601
  const inputTime = getModifiedTime2(state, inputFile);
127750
127602
  if (inputTime === missingFileModifiedTime) {
@@ -127753,8 +127605,8 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127753
127605
  reason: `${inputFile} does not exist`
127754
127606
  };
127755
127607
  }
127756
- const inputPath = incrementalBuildInfo ? toPath2(state, inputFile) : void 0;
127757
- if (buildInfoTime && buildInfoTime < inputTime) {
127608
+ const inputPath = toPath2(state, inputFile);
127609
+ if (buildInfoTime < inputTime) {
127758
127610
  let version2;
127759
127611
  let currentVersion;
127760
127612
  if (incrementalBuildInfo) {
@@ -127777,27 +127629,34 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127777
127629
  newestInputFileName = inputFile;
127778
127630
  newestInputFileTime = inputTime;
127779
127631
  }
127780
- if (incrementalBuildInfo) seenRoots.add(inputPath);
127632
+ seenRoots.add(inputPath);
127781
127633
  }
127634
+ let existingRoot;
127782
127635
  if (incrementalBuildInfo) {
127783
127636
  if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host);
127784
- const existingRoot = forEachEntry(
127637
+ existingRoot = forEachEntry(
127785
127638
  buildInfoVersionMap.roots,
127786
127639
  // File was root file when project was built but its not any more
127787
127640
  (_resolved, existingRoot2) => !seenRoots.has(existingRoot2) ? existingRoot2 : void 0
127788
127641
  );
127789
- if (existingRoot) {
127790
- return {
127791
- type: 9 /* OutOfDateRoots */,
127792
- buildInfoFile: buildInfoPath,
127793
- inputFile: existingRoot
127794
- };
127795
- }
127642
+ } else {
127643
+ existingRoot = forEach(
127644
+ getNonIncrementalBuildInfoRoots(buildInfo, buildInfoPath, host),
127645
+ (root) => !seenRoots.has(root) ? root : void 0
127646
+ );
127796
127647
  }
127797
- if (!buildInfoPath) {
127648
+ if (existingRoot) {
127649
+ return {
127650
+ type: 10 /* OutOfDateRoots */,
127651
+ buildInfoFile: buildInfoPath,
127652
+ inputFile: existingRoot
127653
+ };
127654
+ }
127655
+ if (!isIncremental) {
127798
127656
  const outputs = getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
127799
127657
  const outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
127800
127658
  for (const output of outputs) {
127659
+ if (output === buildInfoPath) continue;
127801
127660
  const path = toPath2(state, output);
127802
127661
  let outputTime = outputTimeStampMap == null ? void 0 : outputTimeStampMap.get(path);
127803
127662
  if (!outputTime) {
@@ -127823,14 +127682,13 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127823
127682
  }
127824
127683
  }
127825
127684
  }
127826
- const buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath);
127827
127685
  let pseudoUpToDate = false;
127828
127686
  if (referenceStatuses) {
127829
127687
  for (const { ref, refStatus, resolvedConfig, resolvedRefPath } of referenceStatuses) {
127830
127688
  if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
127831
127689
  continue;
127832
127690
  }
127833
- if (buildInfoCacheEntry && hasSameBuildInfo(state, buildInfoCacheEntry, resolvedRefPath)) {
127691
+ if (hasSameBuildInfo(state, buildInfoCacheEntry ?? (buildInfoCacheEntry = state.buildInfoCache.get(resolvedPath)), resolvedRefPath)) {
127834
127692
  return {
127835
127693
  type: 6 /* OutOfDateWithUpstream */,
127836
127694
  outOfDateOutputFileName: buildInfoPath,
@@ -127861,7 +127719,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
127861
127719
  );
127862
127720
  if (dependentPackageFileStatus) return dependentPackageFileStatus;
127863
127721
  return {
127864
- type: pseudoUpToDate ? 2 /* UpToDateWithUpstreamTypes */ : pseudoInputUpToDate ? 14 /* UpToDateWithInputFileText */ : 1 /* UpToDate */,
127722
+ type: pseudoUpToDate ? 2 /* UpToDateWithUpstreamTypes */ : pseudoInputUpToDate ? 15 /* UpToDateWithInputFileText */ : 1 /* UpToDate */,
127865
127723
  newestInputFileTime,
127866
127724
  newestInputFileName,
127867
127725
  oldestOutputFileName
@@ -127873,7 +127731,7 @@ function hasSameBuildInfo(state, buildInfoCacheEntry, resolvedRefPath) {
127873
127731
  }
127874
127732
  function getUpToDateStatus(state, project, resolvedPath) {
127875
127733
  if (project === void 0) {
127876
- return { type: 0 /* Unbuildable */, reason: "File deleted mid-build" };
127734
+ return { type: 0 /* Unbuildable */, reason: "config file deleted mid-build" };
127877
127735
  }
127878
127736
  const prior = state.projectStatus.get(resolvedPath);
127879
127737
  if (prior !== void 0) {
@@ -127890,7 +127748,8 @@ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage,
127890
127748
  if (proj.options.noEmit) return;
127891
127749
  let now;
127892
127750
  const buildInfoPath = getTsBuildInfoEmitOutputFilePath(proj.options);
127893
- if (buildInfoPath) {
127751
+ const isIncremental = isIncrementalCompilation(proj.options);
127752
+ if (buildInfoPath && isIncremental) {
127894
127753
  if (!(skipOutputs == null ? void 0 : skipOutputs.has(toPath2(state, buildInfoPath)))) {
127895
127754
  if (!!state.options.verbose) reportStatus(state, verboseMessage, proj.options.configFilePath);
127896
127755
  state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
@@ -127913,7 +127772,8 @@ function updateOutputTimestampsWorker(state, proj, projectPath, verboseMessage,
127913
127772
  reportStatus(state, verboseMessage, proj.options.configFilePath);
127914
127773
  }
127915
127774
  host.setModifiedTime(file, now || (now = getCurrentTime(state.host)));
127916
- if (outputTimeStampMap) {
127775
+ if (file === buildInfoPath) getBuildInfoCacheEntry(state, buildInfoPath, projectPath).modifiedTime = now;
127776
+ else if (outputTimeStampMap) {
127917
127777
  outputTimeStampMap.set(path, now);
127918
127778
  modifiedOutputs.add(path);
127919
127779
  }
@@ -127942,7 +127802,7 @@ function updateOutputTimestamps(state, proj, resolvedPath) {
127942
127802
  });
127943
127803
  }
127944
127804
  function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
127945
- if (buildResult & 124 /* AnyErrors */) return;
127805
+ if (buildResult & 4 /* AnyErrors */) return;
127946
127806
  if (!config.options.composite) return;
127947
127807
  for (let index = projectIndex + 1; index < buildOrder.length; index++) {
127948
127808
  const nextProject = buildOrder[index];
@@ -127961,7 +127821,7 @@ function queueReferencingProjects(state, project, projectPath, projectIndex, con
127961
127821
  status.type = 2 /* UpToDateWithUpstreamTypes */;
127962
127822
  break;
127963
127823
  }
127964
- case 14 /* UpToDateWithInputFileText */:
127824
+ case 15 /* UpToDateWithInputFileText */:
127965
127825
  case 2 /* UpToDateWithUpstreamTypes */:
127966
127826
  if (!(buildResult & 2 /* DeclarationOutputUnchanged */)) {
127967
127827
  state.projectStatus.set(nextProjectPath, {
@@ -127971,7 +127831,7 @@ function queueReferencingProjects(state, project, projectPath, projectIndex, con
127971
127831
  });
127972
127832
  }
127973
127833
  break;
127974
- case 11 /* UpstreamBlocked */:
127834
+ case 12 /* UpstreamBlocked */:
127975
127835
  if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
127976
127836
  clearProjectStatus(state, nextProjectPath);
127977
127837
  }
@@ -128390,21 +128250,28 @@ function reportUpToDateStatus(state, configFileName, status) {
128390
128250
  relName(state, configFileName),
128391
128251
  relName(state, status.fileName)
128392
128252
  );
128393
- case 7 /* OutOfDateBuildInfo */:
128253
+ case 7 /* OutOfDateBuildInfoWithPendingEmit */:
128394
128254
  return reportStatus(
128395
128255
  state,
128396
128256
  Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted,
128397
128257
  relName(state, configFileName),
128398
128258
  relName(state, status.buildInfoFile)
128399
128259
  );
128400
- case 8 /* OutOfDateOptions */:
128260
+ case 8 /* OutOfDateBuildInfoWithErrors */:
128261
+ return reportStatus(
128262
+ state,
128263
+ Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors,
128264
+ relName(state, configFileName),
128265
+ relName(state, status.buildInfoFile)
128266
+ );
128267
+ case 9 /* OutOfDateOptions */:
128401
128268
  return reportStatus(
128402
128269
  state,
128403
128270
  Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions,
128404
128271
  relName(state, configFileName),
128405
128272
  relName(state, status.buildInfoFile)
128406
128273
  );
128407
- case 9 /* OutOfDateRoots */:
128274
+ case 10 /* OutOfDateRoots */:
128408
128275
  return reportStatus(
128409
128276
  state,
128410
128277
  Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_file_2_was_root_file_of_compilation_but_not_any_more,
@@ -128429,20 +128296,20 @@ function reportUpToDateStatus(state, configFileName, status) {
128429
128296
  Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies,
128430
128297
  relName(state, configFileName)
128431
128298
  );
128432
- case 14 /* UpToDateWithInputFileText */:
128299
+ case 15 /* UpToDateWithInputFileText */:
128433
128300
  return reportStatus(
128434
128301
  state,
128435
128302
  Diagnostics.Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files,
128436
128303
  relName(state, configFileName)
128437
128304
  );
128438
- case 10 /* UpstreamOutOfDate */:
128305
+ case 11 /* UpstreamOutOfDate */:
128439
128306
  return reportStatus(
128440
128307
  state,
128441
128308
  Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date,
128442
128309
  relName(state, configFileName),
128443
128310
  relName(state, status.upstreamProjectName)
128444
128311
  );
128445
- case 11 /* UpstreamBlocked */:
128312
+ case 12 /* UpstreamBlocked */:
128446
128313
  return reportStatus(
128447
128314
  state,
128448
128315
  status.upstreamProjectBlocked ? Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors,
@@ -128452,11 +128319,11 @@ function reportUpToDateStatus(state, configFileName, status) {
128452
128319
  case 0 /* Unbuildable */:
128453
128320
  return reportStatus(
128454
128321
  state,
128455
- Diagnostics.Failed_to_parse_file_0_Colon_1,
128322
+ Diagnostics.Project_0_is_out_of_date_because_1,
128456
128323
  relName(state, configFileName),
128457
128324
  status.reason
128458
128325
  );
128459
- case 13 /* TsVersionOutputOfDate */:
128326
+ case 14 /* TsVersionOutputOfDate */:
128460
128327
  return reportStatus(
128461
128328
  state,
128462
128329
  Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2,
@@ -128464,14 +128331,14 @@ function reportUpToDateStatus(state, configFileName, status) {
128464
128331
  status.version,
128465
128332
  version
128466
128333
  );
128467
- case 16 /* ForceBuild */:
128334
+ case 17 /* ForceBuild */:
128468
128335
  return reportStatus(
128469
128336
  state,
128470
128337
  Diagnostics.Project_0_is_being_forcibly_rebuilt,
128471
128338
  relName(state, configFileName)
128472
128339
  );
128473
- case 15 /* ContainerOnly */:
128474
- case 12 /* ComputingUpstream */:
128340
+ case 16 /* ContainerOnly */:
128341
+ case 13 /* ComputingUpstream */:
128475
128342
  break;
128476
128343
  default:
128477
128344
  assertType(status);