typescript 5.6.0-dev.20240717 → 5.6.0-dev.20240719

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.20240717`;
21
+ var version = `${versionMajorMinor}.0-dev.20240719`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -5914,6 +5914,7 @@ var Diagnostics = {
5914
5914
  _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 }'."),
5915
5915
  _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."),
5916
5916
  _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 }'."),
5917
+ 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'."),
5917
5918
  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."),
5918
5919
  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."),
5919
5920
  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."),
@@ -6122,6 +6123,7 @@ var Diagnostics = {
6122
6123
  This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
6123
6124
  Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead: diag(1536, 1 /* Error */, "Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended__1536", "Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '{0}' instead."),
6124
6125
  Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class: diag(1537, 1 /* Error */, "Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_1537", "Decimal escape sequences and backreferences are not allowed in a character class."),
6126
+ Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1538, 1 /* Error */, "Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_se_1538", "Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
6125
6127
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
6126
6128
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
6127
6129
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -8969,9 +8971,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8969
8971
  case 34 /* doubleQuote */:
8970
8972
  return '"';
8971
8973
  case 117 /* u */:
8972
- if (flags & 17 /* ScanExtendedUnicodeEscape */ && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
8974
+ if (pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
8973
8975
  pos -= 2;
8974
- return scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
8976
+ const result = scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
8977
+ if (!(flags & 17 /* AllowExtendedUnicodeEscape */)) {
8978
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
8979
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
8980
+ error(Diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
8981
+ }
8982
+ }
8983
+ return result;
8975
8984
  }
8976
8985
  for (; pos < start2 + 6; pos++) {
8977
8986
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
@@ -8989,7 +8998,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8989
8998
  const nextStart = pos;
8990
8999
  let nextPos = pos + 2;
8991
9000
  for (; nextPos < nextStart + 6; nextPos++) {
8992
- if (!isHexDigit(charCodeUnchecked(pos))) {
9001
+ if (!isHexDigit(charCodeUnchecked(nextPos))) {
8993
9002
  return escapedValueString;
8994
9003
  }
8995
9004
  }
@@ -10617,7 +10626,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10617
10626
  return value;
10618
10627
  }
10619
10628
  function scanSourceCharacter() {
10620
- const size = anyUnicodeMode ? charSize(charCodeChecked(pos)) : 1;
10629
+ const size = anyUnicodeMode ? charSize(codePointChecked(pos)) : 1;
10621
10630
  pos += size;
10622
10631
  return size > 0 ? text.substring(pos - size, pos) : "";
10623
10632
  }
@@ -14826,6 +14835,23 @@ function isFunctionSymbol(symbol) {
14826
14835
  const decl = symbol.valueDeclaration;
14827
14836
  return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
14828
14837
  }
14838
+ function canHaveModuleSpecifier(node) {
14839
+ switch (node == null ? void 0 : node.kind) {
14840
+ case 260 /* VariableDeclaration */:
14841
+ case 208 /* BindingElement */:
14842
+ case 272 /* ImportDeclaration */:
14843
+ case 278 /* ExportDeclaration */:
14844
+ case 271 /* ImportEqualsDeclaration */:
14845
+ case 273 /* ImportClause */:
14846
+ case 280 /* NamespaceExport */:
14847
+ case 274 /* NamespaceImport */:
14848
+ case 281 /* ExportSpecifier */:
14849
+ case 276 /* ImportSpecifier */:
14850
+ case 205 /* ImportType */:
14851
+ return true;
14852
+ }
14853
+ return false;
14854
+ }
14829
14855
  function tryGetModuleSpecifierFromDeclaration(node) {
14830
14856
  var _a, _b;
14831
14857
  switch (node.kind) {
@@ -17543,8 +17569,8 @@ function walkTreeForJSXTags(node) {
17543
17569
  function isFileModuleFromUsingJSXTag(file) {
17544
17570
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
17545
17571
  }
17546
- function isFileForcedToBeModuleByFormat(file) {
17547
- return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
17572
+ function isFileForcedToBeModuleByFormat(file, options) {
17573
+ return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
17548
17574
  }
17549
17575
  function getSetExternalModuleIndicator(options) {
17550
17576
  switch (getEmitModuleDetectionKind(options)) {
@@ -17563,10 +17589,14 @@ function getSetExternalModuleIndicator(options) {
17563
17589
  }
17564
17590
  checks.push(isFileForcedToBeModuleByFormat);
17565
17591
  const combined = or(...checks);
17566
- const callback = (file) => void (file.externalModuleIndicator = combined(file));
17592
+ const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
17567
17593
  return callback;
17568
17594
  }
17569
17595
  }
17596
+ function importSyntaxAffectsModuleResolution(options) {
17597
+ const moduleResolution = getEmitModuleResolutionKind(options);
17598
+ return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
17599
+ }
17570
17600
  function createComputedCompilerOptions(options) {
17571
17601
  return options;
17572
17602
  }
@@ -26766,7 +26796,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
26766
26796
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
26767
26797
  let namedBindings;
26768
26798
  const moduleKind = getEmitModuleKind(compilerOptions);
26769
- if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
26799
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
26770
26800
  const helpers = getEmitHelpers(sourceFile);
26771
26801
  if (helpers) {
26772
26802
  const helperNames = [];
@@ -26831,8 +26861,7 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
26831
26861
  if (externalHelpersModuleName) {
26832
26862
  return externalHelpersModuleName;
26833
26863
  }
26834
- const moduleKind = getEmitModuleKind(compilerOptions);
26835
- let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
26864
+ let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
26836
26865
  if (!create) {
26837
26866
  const helpers = getEmitHelpers(node);
26838
26867
  if (helpers) {
@@ -35786,7 +35815,6 @@ var commonOptionsWithBuild = [
35786
35815
  affectsBuildInfo: true,
35787
35816
  showInSimplifiedHelpView: true,
35788
35817
  category: Diagnostics.Emit,
35789
- transpileOptionValue: void 0,
35790
35818
  defaultValueDescription: false,
35791
35819
  description: Diagnostics.Create_sourcemaps_for_d_ts_files
35792
35820
  },
@@ -44249,13 +44277,15 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
44249
44277
  }
44250
44278
 
44251
44279
  // src/compiler/moduleSpecifiers.ts
44252
- function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
44280
+ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, host, compilerOptions, importingSourceFile, oldImportSpecifier) {
44253
44281
  const filePreferredEnding = getPreferredEnding();
44254
44282
  return {
44255
44283
  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 */,
44256
44284
  getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
44257
- const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
44258
- if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
44285
+ const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
44286
+ const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
44287
+ const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
44288
+ if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
44259
44289
  if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
44260
44290
  return [3 /* TsExtension */, 2 /* JsExtension */];
44261
44291
  }
@@ -44286,7 +44316,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
44286
44316
  }
44287
44317
  return getModuleSpecifierEndingPreference(
44288
44318
  importModuleSpecifierEnding,
44289
- resolutionMode ?? importingSourceFile.impliedNodeFormat,
44319
+ resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
44290
44320
  compilerOptions,
44291
44321
  isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
44292
44322
  );
@@ -44344,12 +44374,16 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
44344
44374
  }
44345
44375
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
44346
44376
  const info = getInfo(importingSourceFile.fileName, host);
44347
- const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
44377
+ const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
44348
44378
  const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
44349
44379
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
44350
44380
  (reason) => {
44351
44381
  if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
44352
- if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
44382
+ const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
44383
+ const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
44384
+ if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
44385
+ return void 0;
44386
+ }
44353
44387
  const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
44354
44388
  return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
44355
44389
  }
@@ -44864,7 +44898,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
44864
44898
  if (!parts) {
44865
44899
  return void 0;
44866
44900
  }
44867
- const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
44901
+ const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
44868
44902
  const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
44869
44903
  let moduleSpecifier = path;
44870
44904
  let isPackageRootPath = false;
@@ -44914,7 +44948,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
44914
44948
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
44915
44949
  if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
44916
44950
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
44917
- const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
44951
+ const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
44918
44952
  if (getResolvePackageJsonExports(options)) {
44919
44953
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
44920
44954
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
@@ -45064,6 +45098,9 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
45064
45098
  function isPathRelativeToParent(path) {
45065
45099
  return startsWith(path, "..");
45066
45100
  }
45101
+ function getDefaultResolutionModeForFile(file, host, compilerOptions) {
45102
+ return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
45103
+ }
45067
45104
 
45068
45105
  // src/compiler/checker.ts
45069
45106
  var ambientModuleSymbolRegex = /^".+"$/;
@@ -47284,22 +47321,28 @@ function createTypeChecker(host) {
47284
47321
  function isSyntacticDefault(node) {
47285
47322
  return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
47286
47323
  }
47287
- function getUsageModeForExpression(usage) {
47288
- return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
47324
+ function getEmitSyntaxForModuleSpecifierExpression(usage) {
47325
+ return isStringLiteralLike(usage) ? host.getEmitSyntaxForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
47289
47326
  }
47290
47327
  function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
47291
47328
  return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
47292
47329
  }
47293
- function isOnlyImportedAsDefault(usage) {
47294
- const usageMode = getUsageModeForExpression(usage);
47295
- return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
47330
+ function isOnlyImportableAsDefault(usage) {
47331
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47332
+ const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
47333
+ return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
47334
+ }
47335
+ return false;
47296
47336
  }
47297
47337
  function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
47298
- const usageMode = file && getUsageModeForExpression(usage);
47299
- if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47300
- const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
47301
- if (usageMode === 99 /* ESNext */ || result) {
47302
- return result;
47338
+ const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
47339
+ if (file && usageMode !== void 0) {
47340
+ const targetMode = host.getImpliedNodeFormatForEmit(file);
47341
+ if (usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */ && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47342
+ return true;
47343
+ }
47344
+ if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
47345
+ return false;
47303
47346
  }
47304
47347
  }
47305
47348
  if (!allowSyntheticDefaultImports) {
@@ -47358,7 +47401,7 @@ function createTypeChecker(host) {
47358
47401
  if (!specifier) {
47359
47402
  return exportDefaultSymbol;
47360
47403
  }
47361
- const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
47404
+ const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
47362
47405
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
47363
47406
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
47364
47407
  if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
@@ -47560,7 +47603,7 @@ function createTypeChecker(host) {
47560
47603
  let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
47561
47604
  if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
47562
47605
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
47563
- if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47606
+ if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
47564
47607
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
47565
47608
  }
47566
47609
  }
@@ -48164,7 +48207,7 @@ function createTypeChecker(host) {
48164
48207
  /*requireStringLiteralLikeArgument*/
48165
48208
  true
48166
48209
  ) ? 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);
48167
- const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
48210
+ const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
48168
48211
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
48169
48212
  const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
48170
48213
  const resolutionDiagnostic = errorNode && resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
@@ -48377,7 +48420,7 @@ function createTypeChecker(host) {
48377
48420
  return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
48378
48421
  }
48379
48422
  const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
48380
- const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
48423
+ const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), host.getImpliedNodeFormatForEmit(targetFile));
48381
48424
  if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
48382
48425
  let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
48383
48426
  if (!sigs || !sigs.length) {
@@ -50997,8 +51040,10 @@ function createTypeChecker(host) {
50997
51040
  }
50998
51041
  return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
50999
51042
  }
51043
+ const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
51044
+ const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
51000
51045
  const contextFile = context.enclosingFile;
51001
- const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
51046
+ const resolutionMode = overrideImportMode || originalModuleSpecifier && host.getModeForUsageLocation(contextFile, originalModuleSpecifier) || contextFile && host.getDefaultResolutionModeForFile(contextFile);
51002
51047
  const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
51003
51048
  const links = getSymbolLinks(symbol);
51004
51049
  let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
@@ -56047,18 +56092,18 @@ function createTypeChecker(host) {
56047
56092
  function getExpandedParameters(sig, skipUnionExpanding) {
56048
56093
  if (signatureHasRestParameter(sig)) {
56049
56094
  const restIndex = sig.parameters.length - 1;
56050
- const restName = sig.parameters[restIndex].escapedName;
56051
- const restType = getTypeOfSymbol(sig.parameters[restIndex]);
56095
+ const restSymbol = sig.parameters[restIndex];
56096
+ const restType = getTypeOfSymbol(restSymbol);
56052
56097
  if (isTupleType(restType)) {
56053
- return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
56098
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex, restSymbol)];
56054
56099
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
56055
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
56100
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restSymbol));
56056
56101
  }
56057
56102
  }
56058
56103
  return [sig.parameters];
56059
- function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
56104
+ function expandSignatureParametersWithTupleMembers(restType, restIndex, restSymbol) {
56060
56105
  const elementTypes = getTypeArguments(restType);
56061
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
56106
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restSymbol);
56062
56107
  const restParams = map(elementTypes, (t, i) => {
56063
56108
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
56064
56109
  const flags = restType.target.elementFlags[i];
@@ -56069,19 +56114,29 @@ function createTypeChecker(host) {
56069
56114
  });
56070
56115
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
56071
56116
  }
56072
- function getUniqAssociatedNamesFromTupleType(type, restName) {
56073
- const associatedNamesMap = /* @__PURE__ */ new Map();
56074
- return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
56075
- const name = getTupleElementLabel(labeledElement, i, restName);
56076
- const prevCounter = associatedNamesMap.get(name);
56077
- if (prevCounter === void 0) {
56078
- associatedNamesMap.set(name, 1);
56079
- return name;
56080
- } else {
56081
- associatedNamesMap.set(name, prevCounter + 1);
56082
- return `${name}_${prevCounter}`;
56117
+ function getUniqAssociatedNamesFromTupleType(type, restSymbol) {
56118
+ const names = map(type.target.labeledElementDeclarations, (labeledElement, i) => getTupleElementLabel(labeledElement, i, type.target.elementFlags[i], restSymbol));
56119
+ if (names) {
56120
+ const duplicates = [];
56121
+ const uniqueNames = /* @__PURE__ */ new Set();
56122
+ for (let i = 0; i < names.length; i++) {
56123
+ const name = names[i];
56124
+ if (!tryAddToSet(uniqueNames, name)) {
56125
+ duplicates.push(i);
56126
+ }
56083
56127
  }
56084
- });
56128
+ const counters = /* @__PURE__ */ new Map();
56129
+ for (const i of duplicates) {
56130
+ let counter = counters.get(names[i]) ?? 1;
56131
+ let name;
56132
+ while (!tryAddToSet(uniqueNames, name = `${names[i]}_${counter}`)) {
56133
+ counter++;
56134
+ }
56135
+ names[i] = name;
56136
+ counters.set(names[i], counter + 1);
56137
+ }
56138
+ }
56139
+ return names;
56085
56140
  }
56086
56141
  }
56087
56142
  function getDefaultConstructSignatures(classType) {
@@ -69573,7 +69628,7 @@ function createTypeChecker(host) {
69573
69628
  if (!canCollectSymbolAliasAccessabilityData) {
69574
69629
  return;
69575
69630
  }
69576
- if (location.flags & 33554432 /* Ambient */) {
69631
+ if (location.flags & 33554432 /* Ambient */ && !isPropertySignature(location) && !isPropertyDeclaration(location)) {
69577
69632
  return;
69578
69633
  }
69579
69634
  switch (hint) {
@@ -75495,7 +75550,7 @@ function createTypeChecker(host) {
75495
75550
  return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
75496
75551
  }
75497
75552
  function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
75498
- const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
75553
+ const hasDefaultOnly = isOnlyImportableAsDefault(moduleSpecifier);
75499
75554
  if (hasDefaultOnly && type && !isErrorType(type)) {
75500
75555
  const synthType = type;
75501
75556
  if (!synthType.defaultOnlyType) {
@@ -75821,14 +75876,45 @@ function createTypeChecker(host) {
75821
75876
  !!declaration && (hasInitializer(declaration) || isOptionalDeclaration(declaration))
75822
75877
  );
75823
75878
  }
75824
- function getTupleElementLabel(d, index, restParameterName = "arg") {
75879
+ function getTupleElementLabelFromBindingElement(node, index, elementFlags) {
75880
+ switch (node.name.kind) {
75881
+ case 80 /* Identifier */: {
75882
+ const name = node.name.escapedText;
75883
+ if (node.dotDotDotToken) {
75884
+ return elementFlags & 12 /* Variable */ ? name : `${name}_${index}`;
75885
+ } else {
75886
+ return elementFlags & 3 /* Fixed */ ? name : `${name}_n`;
75887
+ }
75888
+ }
75889
+ case 207 /* ArrayBindingPattern */: {
75890
+ if (node.dotDotDotToken) {
75891
+ const elements = node.name.elements;
75892
+ const lastElement = tryCast(lastOrUndefined(elements), isBindingElement);
75893
+ const elementCount = elements.length - ((lastElement == null ? void 0 : lastElement.dotDotDotToken) ? 1 : 0);
75894
+ if (index < elementCount) {
75895
+ const element = elements[index];
75896
+ if (isBindingElement(element)) {
75897
+ return getTupleElementLabelFromBindingElement(element, index, elementFlags);
75898
+ }
75899
+ } else if (lastElement == null ? void 0 : lastElement.dotDotDotToken) {
75900
+ return getTupleElementLabelFromBindingElement(lastElement, index - elementCount, elementFlags);
75901
+ }
75902
+ }
75903
+ break;
75904
+ }
75905
+ }
75906
+ return `arg_${index}`;
75907
+ }
75908
+ function getTupleElementLabel(d, index = 0, elementFlags = 3 /* Fixed */, restSymbol) {
75825
75909
  if (!d) {
75826
- return `${restParameterName}_${index}`;
75910
+ const restParameter = tryCast(restSymbol == null ? void 0 : restSymbol.valueDeclaration, isParameter);
75911
+ return restParameter ? getTupleElementLabelFromBindingElement(restParameter, index, elementFlags) : `${(restSymbol == null ? void 0 : restSymbol.escapedName) ?? "arg"}_${index}`;
75827
75912
  }
75828
75913
  Debug.assert(isIdentifier(d.name));
75829
75914
  return d.name.escapedText;
75830
75915
  }
75831
75916
  function getParameterNameAtPosition(signature, pos, overrideRestType) {
75917
+ var _a;
75832
75918
  const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75833
75919
  if (pos < paramCount) {
75834
75920
  return signature.parameters[pos].escapedName;
@@ -75836,9 +75922,11 @@ function createTypeChecker(host) {
75836
75922
  const restParameter = signature.parameters[paramCount] || unknownSymbol;
75837
75923
  const restType = overrideRestType || getTypeOfSymbol(restParameter);
75838
75924
  if (isTupleType(restType)) {
75839
- const associatedNames = restType.target.labeledElementDeclarations;
75925
+ const tupleType = restType.target;
75840
75926
  const index = pos - paramCount;
75841
- return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
75927
+ const associatedName = (_a = tupleType.labeledElementDeclarations) == null ? void 0 : _a[index];
75928
+ const elementFlags = tupleType.elementFlags[index];
75929
+ return getTupleElementLabel(associatedName, index, elementFlags, restParameter);
75842
75930
  }
75843
75931
  return restParameter.escapedName;
75844
75932
  }
@@ -80769,7 +80857,7 @@ function createTypeChecker(host) {
80769
80857
  });
80770
80858
  }
80771
80859
  function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
80772
- if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
80860
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) >= 5 /* ES2015 */) {
80773
80861
  return;
80774
80862
  }
80775
80863
  if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
@@ -82190,7 +82278,7 @@ function createTypeChecker(host) {
82190
82278
  }
82191
82279
  }
82192
82280
  function checkClassNameCollisionWithObject(name) {
82193
- if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
82281
+ if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < 5 /* ES2015 */) {
82194
82282
  error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
82195
82283
  }
82196
82284
  }
@@ -83270,7 +83358,7 @@ function createTypeChecker(host) {
83270
83358
  getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
83271
83359
  }
83272
83360
  }
83273
- if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
83361
+ if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(node.parent) === 1 /* CommonJS */) {
83274
83362
  const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
83275
83363
  if (exportModifier) {
83276
83364
  error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
@@ -83490,8 +83578,10 @@ function createTypeChecker(host) {
83490
83578
  }
83491
83579
  }
83492
83580
  }
83493
- if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83581
+ if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
83494
83582
  error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
83583
+ } else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
83584
+ error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
83495
83585
  }
83496
83586
  }
83497
83587
  if (isImportSpecifier(node)) {
@@ -83532,7 +83622,7 @@ function createTypeChecker(host) {
83532
83622
  checkAliasSymbol(node);
83533
83623
  if (node.kind === 276 /* ImportSpecifier */) {
83534
83624
  checkModuleExportName(node.propertyName);
83535
- if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83625
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83536
83626
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83537
83627
  }
83538
83628
  }
@@ -83554,7 +83644,7 @@ function createTypeChecker(host) {
83554
83644
  if (validForTypeAttributes && override) {
83555
83645
  return;
83556
83646
  }
83557
- const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
83647
+ const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
83558
83648
  if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
83559
83649
  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;
83560
83650
  return grammarErrorOnNode(node, message);
@@ -83587,7 +83677,7 @@ function createTypeChecker(host) {
83587
83677
  if (importClause.namedBindings) {
83588
83678
  if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
83589
83679
  checkImportBinding(importClause.namedBindings);
83590
- if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
83680
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && getESModuleInterop(compilerOptions)) {
83591
83681
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
83592
83682
  }
83593
83683
  } else {
@@ -83627,7 +83717,7 @@ function createTypeChecker(host) {
83627
83717
  grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
83628
83718
  }
83629
83719
  } else {
83630
- if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
83720
+ if (5 /* ES2015 */ <= moduleKind && moduleKind <= 99 /* ESNext */ && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
83631
83721
  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);
83632
83722
  }
83633
83723
  }
@@ -83657,7 +83747,7 @@ function createTypeChecker(host) {
83657
83747
  checkAliasSymbol(node.exportClause);
83658
83748
  checkModuleExportName(node.exportClause.name);
83659
83749
  }
83660
- if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
83750
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
83661
83751
  if (node.exportClause) {
83662
83752
  if (getESModuleInterop(compilerOptions)) {
83663
83753
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
@@ -83716,7 +83806,7 @@ function createTypeChecker(host) {
83716
83806
  markLinkedReferences(node, 7 /* ExportSpecifier */);
83717
83807
  }
83718
83808
  } else {
83719
- if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleExportNameIsDefault(node.propertyName || node.name)) {
83809
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
83720
83810
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
83721
83811
  }
83722
83812
  }
@@ -83742,7 +83832,7 @@ function createTypeChecker(host) {
83742
83832
  if (typeAnnotationNode) {
83743
83833
  checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
83744
83834
  }
83745
- const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
83835
+ const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */;
83746
83836
  if (node.expression.kind === 80 /* Identifier */) {
83747
83837
  const id = node.expression;
83748
83838
  const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
@@ -83822,7 +83912,7 @@ function createTypeChecker(host) {
83822
83912
  grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
83823
83913
  }
83824
83914
  if (node.isExportEquals) {
83825
- 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 */)) {
83915
+ 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 */)) {
83826
83916
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
83827
83917
  } else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
83828
83918
  grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
@@ -86367,7 +86457,7 @@ function createTypeChecker(host) {
86367
86457
  break;
86368
86458
  case 95 /* ExportKeyword */:
86369
86459
  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
86370
- node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
86460
+ node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
86371
86461
  return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
86372
86462
  }
86373
86463
  if (flags & 32 /* Export */) {
@@ -87277,7 +87367,7 @@ function createTypeChecker(host) {
87277
87367
  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;
87278
87368
  return grammarErrorOnNode(node.exclamationToken, message);
87279
87369
  }
87280
- if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
87370
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
87281
87371
  checkESModuleMarker(node.name);
87282
87372
  }
87283
87373
  return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
@@ -87778,7 +87868,9 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
87778
87868
  isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
87779
87869
  fileExists: (fileName) => host.fileExists(fileName),
87780
87870
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
87781
- readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
87871
+ readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
87872
+ getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
87873
+ getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
87782
87874
  };
87783
87875
  }
87784
87876
  var SymbolTrackerImpl = class _SymbolTrackerImpl {
@@ -107449,7 +107541,7 @@ function transformModule(context) {
107449
107541
  case 354 /* PartiallyEmittedExpression */:
107450
107542
  return visitPartiallyEmittedExpression(node, valueIsDiscarded);
107451
107543
  case 213 /* CallExpression */:
107452
- if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
107544
+ if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
107453
107545
  return visitImportCallExpression(node);
107454
107546
  }
107455
107547
  break;
@@ -110445,8 +110537,8 @@ function transformECMAScriptModule(context) {
110445
110537
  }
110446
110538
  }
110447
110539
 
110448
- // src/compiler/transformers/module/node.ts
110449
- function transformNodeModule(context) {
110540
+ // src/compiler/transformers/module/impliedNodeFormatDependent.ts
110541
+ function transformImpliedNodeFormatDependentModule(context) {
110450
110542
  const previousOnSubstituteNode = context.onSubstituteNode;
110451
110543
  const previousOnEmitNode = context.onEmitNode;
110452
110544
  const esmTransform = transformECMAScriptModule(context);
@@ -110457,6 +110549,7 @@ function transformNodeModule(context) {
110457
110549
  const cjsTransform = transformModule(context);
110458
110550
  const cjsOnSubstituteNode = context.onSubstituteNode;
110459
110551
  const cjsOnEmitNode = context.onEmitNode;
110552
+ const getEmitModuleFormatOfFile = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
110460
110553
  context.onSubstituteNode = onSubstituteNode;
110461
110554
  context.onEmitNode = onEmitNode;
110462
110555
  context.enableSubstitution(307 /* SourceFile */);
@@ -110471,7 +110564,7 @@ function transformNodeModule(context) {
110471
110564
  if (!currentSourceFile) {
110472
110565
  return previousOnSubstituteNode(hint, node);
110473
110566
  }
110474
- if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
110567
+ if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
110475
110568
  return esmOnSubstituteNode(hint, node);
110476
110569
  }
110477
110570
  return cjsOnSubstituteNode(hint, node);
@@ -110484,13 +110577,13 @@ function transformNodeModule(context) {
110484
110577
  if (!currentSourceFile) {
110485
110578
  return previousOnEmitNode(hint, node, emitCallback);
110486
110579
  }
110487
- if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
110580
+ if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
110488
110581
  return esmOnEmitNode(hint, node, emitCallback);
110489
110582
  }
110490
110583
  return cjsOnEmitNode(hint, node, emitCallback);
110491
110584
  }
110492
110585
  function getModuleTransformForFile(file) {
110493
- return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
110586
+ return getEmitModuleFormatOfFile(file) >= 5 /* ES2015 */ ? esmTransform : cjsTransform;
110494
110587
  }
110495
110588
  function transformSourceFile(node) {
110496
110589
  if (node.isDeclarationFile) {
@@ -112615,17 +112708,18 @@ function isProcessedComponent(node) {
112615
112708
  // src/compiler/transformer.ts
112616
112709
  function getModuleTransformer(moduleKind) {
112617
112710
  switch (moduleKind) {
112711
+ case 200 /* Preserve */:
112712
+ return transformECMAScriptModule;
112618
112713
  case 99 /* ESNext */:
112619
112714
  case 7 /* ES2022 */:
112620
112715
  case 6 /* ES2020 */:
112621
112716
  case 5 /* ES2015 */:
112622
- case 200 /* Preserve */:
112623
- return transformECMAScriptModule;
112624
- case 4 /* System */:
112625
- return transformSystemModule;
112626
112717
  case 100 /* Node16 */:
112627
112718
  case 199 /* NodeNext */:
112628
- return transformNodeModule;
112719
+ case 1 /* CommonJS */:
112720
+ return transformImpliedNodeFormatDependentModule;
112721
+ case 4 /* System */:
112722
+ return transformSystemModule;
112629
112723
  default:
112630
112724
  return transformModule;
112631
112725
  }
@@ -113342,6 +113436,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113342
113436
  newLine: compilerOptions.newLine,
113343
113437
  noEmitHelpers: compilerOptions.noEmitHelpers,
113344
113438
  module: getEmitModuleKind(compilerOptions),
113439
+ moduleResolution: getEmitModuleResolutionKind(compilerOptions),
113345
113440
  target: getEmitScriptTarget(compilerOptions),
113346
113441
  sourceMap: compilerOptions.sourceMap,
113347
113442
  inlineSourceMap: compilerOptions.inlineSourceMap,
@@ -113404,8 +113499,9 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
113404
113499
  newLine: compilerOptions.newLine,
113405
113500
  noEmitHelpers: true,
113406
113501
  module: compilerOptions.module,
113502
+ moduleResolution: compilerOptions.moduleResolution,
113407
113503
  target: compilerOptions.target,
113408
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
113504
+ sourceMap: emitOnly !== 2 /* BuilderSignature */ && compilerOptions.declarationMap,
113409
113505
  inlineSourceMap: compilerOptions.inlineSourceMap,
113410
113506
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
113411
113507
  onlyPrintJsDocStyle: true,
@@ -118866,9 +118962,6 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
118866
118962
  function getModeForFileReference(ref, containingFileMode) {
118867
118963
  return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
118868
118964
  }
118869
- function getModeForResolutionAtIndex(file, index, compilerOptions) {
118870
- return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
118871
- }
118872
118965
  function isExclusivelyTypeOnlyImportOrExport(decl) {
118873
118966
  var _a;
118874
118967
  if (isExportDeclaration(decl)) {
@@ -118883,7 +118976,6 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
118883
118976
  return getModeForUsageLocationWorker(file, usage, compilerOptions);
118884
118977
  }
118885
118978
  function getModeForUsageLocationWorker(file, usage, compilerOptions) {
118886
- var _a;
118887
118979
  if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent) || isJSDocImportTag(usage.parent)) {
118888
118980
  const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
118889
118981
  if (isTypeOnly) {
@@ -118899,19 +118991,28 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
118899
118991
  return override;
118900
118992
  }
118901
118993
  }
118902
- if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
118903
- return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
118904
- usage.parent,
118905
- /*requireStringLiteralLikeArgument*/
118906
- false
118907
- ) ? 1 /* CommonJS */ : 99 /* ESNext */;
118994
+ if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
118995
+ return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
118908
118996
  }
118909
- if (file.impliedNodeFormat === void 0) return void 0;
118910
- if (file.impliedNodeFormat !== 99 /* ESNext */) {
118911
- return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
118997
+ }
118998
+ function getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions) {
118999
+ var _a;
119000
+ if (!compilerOptions) {
119001
+ return void 0;
118912
119002
  }
118913
119003
  const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
118914
- return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
119004
+ if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(
119005
+ usage.parent,
119006
+ /*requireStringLiteralLikeArgument*/
119007
+ false
119008
+ )) {
119009
+ return 1 /* CommonJS */;
119010
+ }
119011
+ if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
119012
+ return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
119013
+ }
119014
+ const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
119015
+ return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
118915
119016
  }
118916
119017
  function getResolutionModeOverride(node, grammarErrorOnNode) {
118917
119018
  if (!node) return void 0;
@@ -118968,7 +119069,7 @@ function getTypeReferenceResolutionName(entry) {
118968
119069
  }
118969
119070
  var typeReferenceResolutionNameAndModeGetter = {
118970
119071
  getName: getTypeReferenceResolutionName,
118971
- getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
119072
+ getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions))
118972
119073
  };
118973
119074
  function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
118974
119075
  return {
@@ -119604,7 +119705,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119604
119705
  isSourceFileFromExternalLibrary,
119605
119706
  isSourceFileDefaultLibrary,
119606
119707
  getModeForUsageLocation: getModeForUsageLocation2,
119607
- getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
119708
+ getEmitSyntaxForUsageLocation,
119709
+ getModeForResolutionAtIndex,
119608
119710
  getSourceFileFromReference,
119609
119711
  getLibFileFromReference,
119610
119712
  sourceFileToPackageName,
@@ -119632,6 +119734,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119632
119734
  forEachResolvedProjectReference: forEachResolvedProjectReference2,
119633
119735
  isSourceOfProjectReferenceRedirect,
119634
119736
  getRedirectReferenceForResolutionFromSourceOfProject,
119737
+ getCompilerOptionsForFile,
119738
+ getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
119739
+ getEmitModuleFormatOfFile,
119740
+ getImpliedNodeFormatForEmit,
119741
+ shouldTransformImportCall,
119635
119742
  emitBuildInfo,
119636
119743
  fileExists,
119637
119744
  readFile,
@@ -120186,6 +120293,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120186
120293
  getSymlinkCache,
120187
120294
  writeFile: writeFileCallback || writeFile2,
120188
120295
  isEmitBlocked,
120296
+ shouldTransformImportCall,
120297
+ getEmitModuleFormatOfFile,
120298
+ getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
120299
+ getModeForResolutionAtIndex,
120189
120300
  readFile: (f) => host.readFile(f),
120190
120301
  fileExists: (f) => {
120191
120302
  const path = toPath3(f);
@@ -121265,10 +121376,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121265
121376
  const resolvedTypeReferenceDirective = resolutions[index];
121266
121377
  const fileName = ref.fileName;
121267
121378
  resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
121268
- const mode = ref.resolutionMode || file.impliedNodeFormat;
121379
+ const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
121269
121380
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
121270
121381
  }
121271
121382
  }
121383
+ function getCompilerOptionsForFile(file) {
121384
+ var _a2;
121385
+ return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
121386
+ }
121272
121387
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
121273
121388
  var _a2, _b2;
121274
121389
  (_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 });
@@ -121369,13 +121484,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121369
121484
  return host.getCanonicalFileName(fileName);
121370
121485
  }
121371
121486
  function processImportedModules(file) {
121372
- var _a2;
121373
121487
  collectExternalModuleReferences(file);
121374
121488
  if (file.imports.length || file.moduleAugmentations.length) {
121375
121489
  const moduleNames = getModuleNames(file);
121376
121490
  const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
121377
121491
  Debug.assert(resolutions.length === moduleNames.length);
121378
- const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
121492
+ const optionsForFile = getCompilerOptionsForFile(file);
121379
121493
  const resolutionsInFile = createModeAwareCache();
121380
121494
  (resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
121381
121495
  for (let index = 0; index < moduleNames.length; index++) {
@@ -121924,7 +122038,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121924
122038
  redirectInfo = cachedChain.redirectInfo;
121925
122039
  } else {
121926
122040
  reasons == null ? void 0 : reasons.forEach(processReason);
121927
- redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
122041
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
121928
122042
  }
121929
122043
  if (fileProcessingReason) processReason(fileProcessingReason);
121930
122044
  const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
@@ -122282,13 +122396,53 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122282
122396
  return symlinks;
122283
122397
  }
122284
122398
  function getModeForUsageLocation2(file, usage) {
122285
- var _a2;
122286
- const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
122287
- return getModeForUsageLocationWorker(file, usage, optionsForFile);
122399
+ return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
122288
122400
  }
122289
- function getModeForResolutionAtIndex2(file, index) {
122401
+ function getEmitSyntaxForUsageLocation(file, usage) {
122402
+ return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
122403
+ }
122404
+ function getModeForResolutionAtIndex(file, index) {
122290
122405
  return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
122291
122406
  }
122407
+ function getDefaultResolutionModeForFile2(sourceFile) {
122408
+ return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122409
+ }
122410
+ function getImpliedNodeFormatForEmit(sourceFile) {
122411
+ return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122412
+ }
122413
+ function getEmitModuleFormatOfFile(sourceFile) {
122414
+ return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122415
+ }
122416
+ function shouldTransformImportCall(sourceFile) {
122417
+ return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
122418
+ }
122419
+ }
122420
+ function shouldTransformImportCallWorker(sourceFile, options) {
122421
+ const moduleKind = getEmitModuleKind(options);
122422
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
122423
+ return false;
122424
+ }
122425
+ return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
122426
+ }
122427
+ function getEmitModuleFormatOfFileWorker(sourceFile, options) {
122428
+ return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
122429
+ }
122430
+ function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
122431
+ var _a, _b;
122432
+ const moduleKind = getEmitModuleKind(options);
122433
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
122434
+ return sourceFile.impliedNodeFormat;
122435
+ }
122436
+ if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
122437
+ return 1 /* CommonJS */;
122438
+ }
122439
+ if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
122440
+ return 99 /* ESNext */;
122441
+ }
122442
+ return void 0;
122443
+ }
122444
+ function getDefaultResolutionModeForFileWorker(sourceFile, options) {
122445
+ return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
122292
122446
  }
122293
122447
  function updateHostForUseSourceOfProjectReferenceRedirect(host) {
122294
122448
  let setOfDeclarationDirectories;
@@ -122743,8 +122897,7 @@ var BuilderState;
122743
122897
  );
122744
122898
  },
122745
122899
  cancellationToken,
122746
- /*emitOnly*/
122747
- true,
122900
+ 2 /* BuilderSignature */,
122748
122901
  /*customTransformers*/
122749
122902
  void 0,
122750
122903
  /*forceDtsEmit*/
@@ -125693,10 +125846,10 @@ function explainFiles(program, write) {
125693
125846
  for (const file of program.getSourceFiles()) {
125694
125847
  write(`${toFileName(file, relativeFileName)}`);
125695
125848
  (_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
125696
- (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
125849
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
125697
125850
  }
125698
125851
  }
125699
- function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
125852
+ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConvertor) {
125700
125853
  var _a;
125701
125854
  let result;
125702
125855
  if (file.path !== file.resolvedPath) {
@@ -125716,7 +125869,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
125716
125869
  ));
125717
125870
  }
125718
125871
  if (isExternalOrCommonJsModule(file)) {
125719
- switch (file.impliedNodeFormat) {
125872
+ switch (getImpliedNodeFormatForEmitWorker(file, options)) {
125720
125873
  case 99 /* ESNext */:
125721
125874
  if (file.packageJsonScope) {
125722
125875
  (result ?? (result = [])).push(chainDiagnosticMessages(