typescript 5.6.0-dev.20240716 → 5.6.0-dev.20240718

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -248,6 +248,7 @@ __export(typescript_exports, {
248
248
  canHaveJSDoc: () => canHaveJSDoc,
249
249
  canHaveLocals: () => canHaveLocals,
250
250
  canHaveModifiers: () => canHaveModifiers,
251
+ canHaveModuleSpecifier: () => canHaveModuleSpecifier,
251
252
  canHaveSymbol: () => canHaveSymbol,
252
253
  canIncludeBindAndCheckDiagnostics: () => canIncludeBindAndCheckDiagnostics,
253
254
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
@@ -410,6 +411,7 @@ __export(typescript_exports, {
410
411
  createMemberAccessForPropertyName: () => createMemberAccessForPropertyName,
411
412
  createModeAwareCache: () => createModeAwareCache,
412
413
  createModeAwareCacheKey: () => createModeAwareCacheKey,
414
+ createModeMismatchDetails: () => createModeMismatchDetails,
413
415
  createModuleNotFoundChain: () => createModuleNotFoundChain,
414
416
  createModuleResolutionCache: () => createModuleResolutionCache,
415
417
  createModuleResolutionLoader: () => createModuleResolutionLoader,
@@ -691,6 +693,7 @@ __export(typescript_exports, {
691
693
  getDefaultLibFilePath: () => getDefaultLibFilePath,
692
694
  getDefaultLikeExportInfo: () => getDefaultLikeExportInfo,
693
695
  getDefaultLikeExportNameFromDeclaration: () => getDefaultLikeExportNameFromDeclaration,
696
+ getDefaultResolutionModeForFileWorker: () => getDefaultResolutionModeForFileWorker,
694
697
  getDiagnosticText: () => getDiagnosticText,
695
698
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
696
699
  getDirectoryPath: () => getDirectoryPath,
@@ -721,6 +724,7 @@ __export(typescript_exports, {
721
724
  getEmitFlags: () => getEmitFlags,
722
725
  getEmitHelpers: () => getEmitHelpers,
723
726
  getEmitModuleDetectionKind: () => getEmitModuleDetectionKind,
727
+ getEmitModuleFormatOfFileWorker: () => getEmitModuleFormatOfFileWorker,
724
728
  getEmitModuleKind: () => getEmitModuleKind,
725
729
  getEmitModuleResolutionKind: () => getEmitModuleResolutionKind,
726
730
  getEmitScriptTarget: () => getEmitScriptTarget,
@@ -771,6 +775,7 @@ __export(typescript_exports, {
771
775
  getIdentifierGeneratedImportReference: () => getIdentifierGeneratedImportReference,
772
776
  getIdentifierTypeArguments: () => getIdentifierTypeArguments,
773
777
  getImmediatelyInvokedFunctionExpression: () => getImmediatelyInvokedFunctionExpression,
778
+ getImpliedNodeFormatForEmitWorker: () => getImpliedNodeFormatForEmitWorker,
774
779
  getImpliedNodeFormatForFile: () => getImpliedNodeFormatForFile,
775
780
  getImpliedNodeFormatForFileWorker: () => getImpliedNodeFormatForFileWorker,
776
781
  getImportNeedsImportDefaultHelper: () => getImportNeedsImportDefaultHelper,
@@ -876,7 +881,6 @@ __export(typescript_exports, {
876
881
  getNameOfScriptTarget: () => getNameOfScriptTarget,
877
882
  getNameOrArgument: () => getNameOrArgument,
878
883
  getNameTable: () => getNameTable,
879
- getNamesForExportedSymbol: () => getNamesForExportedSymbol,
880
884
  getNamespaceDeclarationNode: () => getNamespaceDeclarationNode,
881
885
  getNewLineCharacter: () => getNewLineCharacter,
882
886
  getNewLineKind: () => getNewLineKind,
@@ -1113,6 +1117,7 @@ __export(typescript_exports, {
1113
1117
  ignoreSourceNewlines: () => ignoreSourceNewlines,
1114
1118
  ignoredPaths: () => ignoredPaths,
1115
1119
  importFromModuleSpecifier: () => importFromModuleSpecifier,
1120
+ importSyntaxAffectsModuleResolution: () => importSyntaxAffectsModuleResolution,
1116
1121
  indexOfAnyCharCode: () => indexOfAnyCharCode,
1117
1122
  indexOfNode: () => indexOfNode,
1118
1123
  indicesOf: () => indicesOf,
@@ -2158,11 +2163,11 @@ __export(typescript_exports, {
2158
2163
  transformESDecorators: () => transformESDecorators,
2159
2164
  transformESNext: () => transformESNext,
2160
2165
  transformGenerators: () => transformGenerators,
2166
+ transformImpliedNodeFormatDependentModule: () => transformImpliedNodeFormatDependentModule,
2161
2167
  transformJsx: () => transformJsx,
2162
2168
  transformLegacyDecorators: () => transformLegacyDecorators,
2163
2169
  transformModule: () => transformModule,
2164
2170
  transformNamedEvaluation: () => transformNamedEvaluation,
2165
- transformNodeModule: () => transformNodeModule,
2166
2171
  transformNodes: () => transformNodes,
2167
2172
  transformSystemModule: () => transformSystemModule,
2168
2173
  transformTypeScript: () => transformTypeScript,
@@ -2251,7 +2256,7 @@ module.exports = __toCommonJS(typescript_exports);
2251
2256
 
2252
2257
  // src/compiler/corePublic.ts
2253
2258
  var versionMajorMinor = "5.6";
2254
- var version = `${versionMajorMinor}.0-dev.20240716`;
2259
+ var version = `${versionMajorMinor}.0-dev.20240718`;
2255
2260
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2256
2261
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2257
2262
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5051,10 +5056,12 @@ function tryGetPerformance() {
5051
5056
  if (isNodeLikeSystem()) {
5052
5057
  try {
5053
5058
  const { performance: performance2 } = require("perf_hooks");
5054
- return {
5055
- shouldWriteNativeEvents: false,
5056
- performance: performance2
5057
- };
5059
+ if (performance2) {
5060
+ return {
5061
+ shouldWriteNativeEvents: false,
5062
+ performance: performance2
5063
+ };
5064
+ }
5058
5065
  } catch {
5059
5066
  }
5060
5067
  }
@@ -6085,6 +6092,7 @@ var FilePreprocessingDiagnosticsKind = /* @__PURE__ */ ((FilePreprocessingDiagno
6085
6092
  var EmitOnly = /* @__PURE__ */ ((EmitOnly4) => {
6086
6093
  EmitOnly4[EmitOnly4["Js"] = 0] = "Js";
6087
6094
  EmitOnly4[EmitOnly4["Dts"] = 1] = "Dts";
6095
+ EmitOnly4[EmitOnly4["BuilderSignature"] = 2] = "BuilderSignature";
6088
6096
  return EmitOnly4;
6089
6097
  })(EmitOnly || {});
6090
6098
  var StructureIsReused = /* @__PURE__ */ ((StructureIsReused2) => {
@@ -6722,22 +6730,22 @@ var ScriptKind = /* @__PURE__ */ ((ScriptKind7) => {
6722
6730
  ScriptKind7[ScriptKind7["Deferred"] = 7] = "Deferred";
6723
6731
  return ScriptKind7;
6724
6732
  })(ScriptKind || {});
6725
- var ScriptTarget = /* @__PURE__ */ ((ScriptTarget11) => {
6726
- ScriptTarget11[ScriptTarget11["ES3"] = 0] = "ES3";
6727
- ScriptTarget11[ScriptTarget11["ES5"] = 1] = "ES5";
6728
- ScriptTarget11[ScriptTarget11["ES2015"] = 2] = "ES2015";
6729
- ScriptTarget11[ScriptTarget11["ES2016"] = 3] = "ES2016";
6730
- ScriptTarget11[ScriptTarget11["ES2017"] = 4] = "ES2017";
6731
- ScriptTarget11[ScriptTarget11["ES2018"] = 5] = "ES2018";
6732
- ScriptTarget11[ScriptTarget11["ES2019"] = 6] = "ES2019";
6733
- ScriptTarget11[ScriptTarget11["ES2020"] = 7] = "ES2020";
6734
- ScriptTarget11[ScriptTarget11["ES2021"] = 8] = "ES2021";
6735
- ScriptTarget11[ScriptTarget11["ES2022"] = 9] = "ES2022";
6736
- ScriptTarget11[ScriptTarget11["ES2023"] = 10] = "ES2023";
6737
- ScriptTarget11[ScriptTarget11["ESNext"] = 99] = "ESNext";
6738
- ScriptTarget11[ScriptTarget11["JSON"] = 100] = "JSON";
6739
- ScriptTarget11[ScriptTarget11["Latest"] = 99 /* ESNext */] = "Latest";
6740
- return ScriptTarget11;
6733
+ var ScriptTarget = /* @__PURE__ */ ((ScriptTarget12) => {
6734
+ ScriptTarget12[ScriptTarget12["ES3"] = 0] = "ES3";
6735
+ ScriptTarget12[ScriptTarget12["ES5"] = 1] = "ES5";
6736
+ ScriptTarget12[ScriptTarget12["ES2015"] = 2] = "ES2015";
6737
+ ScriptTarget12[ScriptTarget12["ES2016"] = 3] = "ES2016";
6738
+ ScriptTarget12[ScriptTarget12["ES2017"] = 4] = "ES2017";
6739
+ ScriptTarget12[ScriptTarget12["ES2018"] = 5] = "ES2018";
6740
+ ScriptTarget12[ScriptTarget12["ES2019"] = 6] = "ES2019";
6741
+ ScriptTarget12[ScriptTarget12["ES2020"] = 7] = "ES2020";
6742
+ ScriptTarget12[ScriptTarget12["ES2021"] = 8] = "ES2021";
6743
+ ScriptTarget12[ScriptTarget12["ES2022"] = 9] = "ES2022";
6744
+ ScriptTarget12[ScriptTarget12["ES2023"] = 10] = "ES2023";
6745
+ ScriptTarget12[ScriptTarget12["ESNext"] = 99] = "ESNext";
6746
+ ScriptTarget12[ScriptTarget12["JSON"] = 100] = "JSON";
6747
+ ScriptTarget12[ScriptTarget12["Latest"] = 99 /* ESNext */] = "Latest";
6748
+ return ScriptTarget12;
6741
6749
  })(ScriptTarget || {});
6742
6750
  var LanguageVariant = /* @__PURE__ */ ((LanguageVariant4) => {
6743
6751
  LanguageVariant4[LanguageVariant4["Standard"] = 0] = "Standard";
@@ -9292,6 +9300,7 @@ var Diagnostics = {
9292
9300
  _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 }'."),
9293
9301
  _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."),
9294
9302
  _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 }'."),
9303
+ 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'."),
9295
9304
  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."),
9296
9305
  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."),
9297
9306
  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."),
@@ -9500,6 +9509,7 @@ var Diagnostics = {
9500
9509
  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."),
9501
9510
  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."),
9502
9511
  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."),
9512
+ 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."),
9503
9513
  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."),
9504
9514
  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."),
9505
9515
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -12371,9 +12381,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12371
12381
  case 34 /* doubleQuote */:
12372
12382
  return '"';
12373
12383
  case 117 /* u */:
12374
- if (flags & 17 /* ScanExtendedUnicodeEscape */ && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
12384
+ if (pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
12375
12385
  pos -= 2;
12376
- return scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
12386
+ const result = scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
12387
+ if (!(flags & 17 /* AllowExtendedUnicodeEscape */)) {
12388
+ tokenFlags |= 2048 /* ContainsInvalidEscape */;
12389
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
12390
+ error2(Diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
12391
+ }
12392
+ }
12393
+ return result;
12377
12394
  }
12378
12395
  for (; pos < start2 + 6; pos++) {
12379
12396
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
@@ -12391,7 +12408,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12391
12408
  const nextStart = pos;
12392
12409
  let nextPos = pos + 2;
12393
12410
  for (; nextPos < nextStart + 6; nextPos++) {
12394
- if (!isHexDigit(charCodeUnchecked(pos))) {
12411
+ if (!isHexDigit(charCodeUnchecked(nextPos))) {
12395
12412
  return escapedValueString;
12396
12413
  }
12397
12414
  }
@@ -14019,7 +14036,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14019
14036
  return value;
14020
14037
  }
14021
14038
  function scanSourceCharacter() {
14022
- const size = anyUnicodeMode ? charSize(charCodeChecked(pos)) : 1;
14039
+ const size = anyUnicodeMode ? charSize(codePointChecked(pos)) : 1;
14023
14040
  pos += size;
14024
14041
  return size > 0 ? text.substring(pos - size, pos) : "";
14025
14042
  }
@@ -16169,6 +16186,34 @@ function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, pack
16169
16186
  if (result) result.repopulateInfo = () => ({ moduleReference, mode, packageName: packageName === moduleReference ? void 0 : packageName });
16170
16187
  return result;
16171
16188
  }
16189
+ function createModeMismatchDetails(currentSourceFile) {
16190
+ const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
16191
+ const scope = currentSourceFile.packageJsonScope;
16192
+ const targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : void 0;
16193
+ const result = scope && !scope.contents.packageJsonContent.type ? targetExt ? chainDiagnosticMessages(
16194
+ /*details*/
16195
+ void 0,
16196
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
16197
+ targetExt,
16198
+ combinePaths(scope.packageDirectory, "package.json")
16199
+ ) : chainDiagnosticMessages(
16200
+ /*details*/
16201
+ void 0,
16202
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
16203
+ combinePaths(scope.packageDirectory, "package.json")
16204
+ ) : targetExt ? chainDiagnosticMessages(
16205
+ /*details*/
16206
+ void 0,
16207
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
16208
+ targetExt
16209
+ ) : chainDiagnosticMessages(
16210
+ /*details*/
16211
+ void 0,
16212
+ Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module
16213
+ );
16214
+ result.repopulateInfo = () => true;
16215
+ return result;
16216
+ }
16172
16217
  function packageIdIsEqual(a, b) {
16173
16218
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version && a.peerDependencies === b.peerDependencies;
16174
16219
  }
@@ -18477,6 +18522,23 @@ function isFunctionSymbol(symbol) {
18477
18522
  const decl = symbol.valueDeclaration;
18478
18523
  return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
18479
18524
  }
18525
+ function canHaveModuleSpecifier(node) {
18526
+ switch (node == null ? void 0 : node.kind) {
18527
+ case 260 /* VariableDeclaration */:
18528
+ case 208 /* BindingElement */:
18529
+ case 272 /* ImportDeclaration */:
18530
+ case 278 /* ExportDeclaration */:
18531
+ case 271 /* ImportEqualsDeclaration */:
18532
+ case 273 /* ImportClause */:
18533
+ case 280 /* NamespaceExport */:
18534
+ case 274 /* NamespaceImport */:
18535
+ case 281 /* ExportSpecifier */:
18536
+ case 276 /* ImportSpecifier */:
18537
+ case 205 /* ImportType */:
18538
+ return true;
18539
+ }
18540
+ return false;
18541
+ }
18480
18542
  function tryGetModuleSpecifierFromDeclaration(node) {
18481
18543
  var _a, _b;
18482
18544
  switch (node.kind) {
@@ -21460,8 +21522,8 @@ function walkTreeForJSXTags(node) {
21460
21522
  function isFileModuleFromUsingJSXTag(file) {
21461
21523
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
21462
21524
  }
21463
- function isFileForcedToBeModuleByFormat(file) {
21464
- return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
21525
+ function isFileForcedToBeModuleByFormat(file, options) {
21526
+ return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
21465
21527
  }
21466
21528
  function getSetExternalModuleIndicator(options) {
21467
21529
  switch (getEmitModuleDetectionKind(options)) {
@@ -21480,10 +21542,14 @@ function getSetExternalModuleIndicator(options) {
21480
21542
  }
21481
21543
  checks.push(isFileForcedToBeModuleByFormat);
21482
21544
  const combined = or(...checks);
21483
- const callback = (file) => void (file.externalModuleIndicator = combined(file));
21545
+ const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
21484
21546
  return callback;
21485
21547
  }
21486
21548
  }
21549
+ function importSyntaxAffectsModuleResolution(options) {
21550
+ const moduleResolution = getEmitModuleResolutionKind(options);
21551
+ return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
21552
+ }
21487
21553
  function createComputedCompilerOptions(options) {
21488
21554
  return options;
21489
21555
  }
@@ -30970,7 +31036,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
30970
31036
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
30971
31037
  let namedBindings;
30972
31038
  const moduleKind = getEmitModuleKind(compilerOptions);
30973
- if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
31039
+ if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
30974
31040
  const helpers = getEmitHelpers(sourceFile);
30975
31041
  if (helpers) {
30976
31042
  const helperNames = [];
@@ -31035,8 +31101,7 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
31035
31101
  if (externalHelpersModuleName) {
31036
31102
  return externalHelpersModuleName;
31037
31103
  }
31038
- const moduleKind = getEmitModuleKind(compilerOptions);
31039
- let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
31104
+ let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
31040
31105
  if (!create) {
31041
31106
  const helpers = getEmitHelpers(node);
31042
31107
  if (helpers) {
@@ -40009,7 +40074,6 @@ var commonOptionsWithBuild = [
40009
40074
  affectsBuildInfo: true,
40010
40075
  showInSimplifiedHelpView: true,
40011
40076
  category: Diagnostics.Emit,
40012
- transpileOptionValue: void 0,
40013
40077
  defaultValueDescription: false,
40014
40078
  description: Diagnostics.Create_sourcemaps_for_d_ts_files
40015
40079
  },
@@ -44617,22 +44681,16 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
44617
44681
  resolvedPackageDirectory: false
44618
44682
  };
44619
44683
  }
44620
- function getPackageScopeForPath(fileName, state) {
44621
- const parts = getPathComponents(fileName);
44622
- parts.pop();
44623
- while (parts.length > 0) {
44624
- const pkg = getPackageJsonInfo(
44625
- getPathFromPathComponents(parts),
44684
+ function getPackageScopeForPath(directory, state) {
44685
+ return forEachAncestorDirectory(
44686
+ directory,
44687
+ (dir) => getPackageJsonInfo(
44688
+ dir,
44626
44689
  /*onlyRecordFailures*/
44627
44690
  false,
44628
44691
  state
44629
- );
44630
- if (pkg) {
44631
- return pkg;
44632
- }
44633
- parts.pop();
44634
- }
44635
- return void 0;
44692
+ )
44693
+ );
44636
44694
  }
44637
44695
  function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
44638
44696
  if (packageJsonInfo.contents.versionPaths === void 0) {
@@ -44795,7 +44853,7 @@ function noKeyStartsWithDot(obj) {
44795
44853
  }
44796
44854
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
44797
44855
  var _a, _b;
44798
- const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
44856
+ const directoryPath = getNormalizedAbsolutePath(directory, (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
44799
44857
  const scope = getPackageScopeForPath(directoryPath, state);
44800
44858
  if (!scope || !scope.contents.packageJsonContent.exports) {
44801
44859
  return void 0;
@@ -44891,7 +44949,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
44891
44949
  void 0
44892
44950
  );
44893
44951
  }
44894
- const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
44952
+ const directoryPath = getNormalizedAbsolutePath(directory, (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
44895
44953
  const scope = getPackageScopeForPath(directoryPath, state);
44896
44954
  if (!scope) {
44897
44955
  if (state.traceEnabled) {
@@ -48752,13 +48810,15 @@ var RelativePreference = /* @__PURE__ */ ((RelativePreference2) => {
48752
48810
  RelativePreference2[RelativePreference2["ExternalNonRelative"] = 3] = "ExternalNonRelative";
48753
48811
  return RelativePreference2;
48754
48812
  })(RelativePreference || {});
48755
- function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
48813
+ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, host, compilerOptions, importingSourceFile, oldImportSpecifier) {
48756
48814
  const filePreferredEnding = getPreferredEnding();
48757
48815
  return {
48758
48816
  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 */,
48759
48817
  getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
48760
- const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
48761
- if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
48818
+ const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
48819
+ const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
48820
+ const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
48821
+ if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
48762
48822
  if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
48763
48823
  return [3 /* TsExtension */, 2 /* JsExtension */];
48764
48824
  }
@@ -48789,19 +48849,19 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
48789
48849
  }
48790
48850
  return getModuleSpecifierEndingPreference(
48791
48851
  importModuleSpecifierEnding,
48792
- resolutionMode ?? importingSourceFile.impliedNodeFormat,
48852
+ resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
48793
48853
  compilerOptions,
48794
48854
  isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
48795
48855
  );
48796
48856
  }
48797
48857
  }
48798
48858
  function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, oldImportSpecifier, options = {}) {
48799
- const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options);
48859
+ const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, host, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options);
48800
48860
  if (res === oldImportSpecifier) return void 0;
48801
48861
  return res;
48802
48862
  }
48803
48863
  function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, options = {}) {
48804
- return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile), {}, options);
48864
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, host, compilerOptions, importingSourceFile), {}, options);
48805
48865
  }
48806
48866
  function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences, options = {}) {
48807
48867
  const info = getInfo(importingSourceFile.fileName, host);
@@ -48831,7 +48891,7 @@ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importin
48831
48891
  /*packageNameOnly*/
48832
48892
  void 0,
48833
48893
  options.overrideImportMode
48834
- )) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
48894
+ )) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode || getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions), preferences);
48835
48895
  }
48836
48896
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options = {}) {
48837
48897
  const result = tryGetModuleSpecifiersFromCacheWorker(
@@ -48902,17 +48962,21 @@ function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName,
48902
48962
  compilerOptions,
48903
48963
  host,
48904
48964
  importMode,
48905
- getModuleSpecifierPreferences({}, compilerOptions, importingFile)
48965
+ getModuleSpecifierPreferences({}, host, compilerOptions, importingFile)
48906
48966
  );
48907
48967
  }
48908
48968
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
48909
48969
  const info = getInfo(importingSourceFile.fileName, host);
48910
- const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
48970
+ const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
48911
48971
  const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
48912
48972
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
48913
48973
  (reason) => {
48914
48974
  if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
48915
- if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
48975
+ const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
48976
+ const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
48977
+ if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
48978
+ return void 0;
48979
+ }
48916
48980
  const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
48917
48981
  return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
48918
48982
  }
@@ -49120,7 +49184,7 @@ function getAllModulePathsWorker(info, importedFileName, host, compilerOptions,
49120
49184
  if (cache && links && host.readFile && !pathContainsNodeModules(info.importingSourceFileName)) {
49121
49185
  Debug.type(host);
49122
49186
  const state = getTemporaryModuleResolutionState(cache.getPackageJsonInfoCache(), host, {});
49123
- const packageJson = getPackageScopeForPath(info.importingSourceFileName, state);
49187
+ const packageJson = getPackageScopeForPath(getDirectoryPath(info.importingSourceFileName), state);
49124
49188
  if (packageJson) {
49125
49189
  const toResolve = getAllRuntimeDependencies(packageJson.contents.packageJsonContent);
49126
49190
  for (const depName of toResolve || emptyArray) {
@@ -49442,7 +49506,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
49442
49506
  if (!parts) {
49443
49507
  return void 0;
49444
49508
  }
49445
- const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
49509
+ const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
49446
49510
  const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
49447
49511
  let moduleSpecifier = path;
49448
49512
  let isPackageRootPath = false;
@@ -49492,7 +49556,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
49492
49556
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
49493
49557
  if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
49494
49558
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
49495
- const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
49559
+ const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
49496
49560
  if (getResolvePackageJsonExports(options)) {
49497
49561
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
49498
49562
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
@@ -49642,6 +49706,9 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
49642
49706
  function isPathRelativeToParent(path) {
49643
49707
  return startsWith(path, "..");
49644
49708
  }
49709
+ function getDefaultResolutionModeForFile(file, host, compilerOptions) {
49710
+ return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
49711
+ }
49645
49712
 
49646
49713
  // src/compiler/checker.ts
49647
49714
  var ambientModuleSymbolRegex = /^".+"$/;
@@ -51862,22 +51929,28 @@ function createTypeChecker(host) {
51862
51929
  function isSyntacticDefault(node) {
51863
51930
  return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
51864
51931
  }
51865
- function getUsageModeForExpression(usage) {
51866
- return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
51932
+ function getEmitSyntaxForModuleSpecifierExpression(usage) {
51933
+ return isStringLiteralLike(usage) ? host.getEmitSyntaxForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
51867
51934
  }
51868
51935
  function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
51869
51936
  return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
51870
51937
  }
51871
- function isOnlyImportedAsDefault(usage) {
51872
- const usageMode = getUsageModeForExpression(usage);
51873
- return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
51938
+ function isOnlyImportableAsDefault(usage) {
51939
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
51940
+ const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
51941
+ return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
51942
+ }
51943
+ return false;
51874
51944
  }
51875
51945
  function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
51876
- const usageMode = file && getUsageModeForExpression(usage);
51877
- if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
51878
- const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
51879
- if (usageMode === 99 /* ESNext */ || result) {
51880
- return result;
51946
+ const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
51947
+ if (file && usageMode !== void 0) {
51948
+ const targetMode = host.getImpliedNodeFormatForEmit(file);
51949
+ if (usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */ && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
51950
+ return true;
51951
+ }
51952
+ if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
51953
+ return false;
51881
51954
  }
51882
51955
  }
51883
51956
  if (!allowSyntheticDefaultImports) {
@@ -51936,7 +52009,7 @@ function createTypeChecker(host) {
51936
52009
  if (!specifier) {
51937
52010
  return exportDefaultSymbol;
51938
52011
  }
51939
- const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
52012
+ const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
51940
52013
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
51941
52014
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
51942
52015
  if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
@@ -52138,7 +52211,7 @@ function createTypeChecker(host) {
52138
52211
  let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
52139
52212
  if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
52140
52213
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
52141
- if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
52214
+ if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
52142
52215
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
52143
52216
  }
52144
52217
  }
@@ -52742,7 +52815,7 @@ function createTypeChecker(host) {
52742
52815
  /*requireStringLiteralLikeArgument*/
52743
52816
  true
52744
52817
  ) ? 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);
52745
- const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
52818
+ const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
52746
52819
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
52747
52820
  const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
52748
52821
  const resolutionDiagnostic = errorNode && resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
@@ -52789,41 +52862,7 @@ function createTypeChecker(host) {
52789
52862
  let diagnosticDetails;
52790
52863
  const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
52791
52864
  if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
52792
- const scope = currentSourceFile.packageJsonScope;
52793
- const targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : void 0;
52794
- if (scope && !scope.contents.packageJsonContent.type) {
52795
- if (targetExt) {
52796
- diagnosticDetails = chainDiagnosticMessages(
52797
- /*details*/
52798
- void 0,
52799
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
52800
- targetExt,
52801
- combinePaths(scope.packageDirectory, "package.json")
52802
- );
52803
- } else {
52804
- diagnosticDetails = chainDiagnosticMessages(
52805
- /*details*/
52806
- void 0,
52807
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
52808
- combinePaths(scope.packageDirectory, "package.json")
52809
- );
52810
- }
52811
- } else {
52812
- if (targetExt) {
52813
- diagnosticDetails = chainDiagnosticMessages(
52814
- /*details*/
52815
- void 0,
52816
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
52817
- targetExt
52818
- );
52819
- } else {
52820
- diagnosticDetails = chainDiagnosticMessages(
52821
- /*details*/
52822
- void 0,
52823
- Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module
52824
- );
52825
- }
52826
- }
52865
+ diagnosticDetails = createModeMismatchDetails(currentSourceFile);
52827
52866
  }
52828
52867
  diagnostics.add(createDiagnosticForNodeFromMessageChain(
52829
52868
  getSourceFileOfNode(errorNode),
@@ -52989,7 +53028,7 @@ function createTypeChecker(host) {
52989
53028
  return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
52990
53029
  }
52991
53030
  const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
52992
- const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
53031
+ const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), host.getImpliedNodeFormatForEmit(targetFile));
52993
53032
  if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
52994
53033
  let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
52995
53034
  if (!sigs || !sigs.length) {
@@ -55609,8 +55648,10 @@ function createTypeChecker(host) {
55609
55648
  }
55610
55649
  return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
55611
55650
  }
55651
+ const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
55652
+ const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
55612
55653
  const contextFile = context.enclosingFile;
55613
- const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
55654
+ const resolutionMode = overrideImportMode || originalModuleSpecifier && host.getModeForUsageLocation(contextFile, originalModuleSpecifier) || contextFile && host.getDefaultResolutionModeForFile(contextFile);
55614
55655
  const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
55615
55656
  const links = getSymbolLinks(symbol);
55616
55657
  let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
@@ -56683,7 +56724,7 @@ function createTypeChecker(host) {
56683
56724
  if (result) {
56684
56725
  if (result.pos !== -1 || result.end !== -1) {
56685
56726
  if (result === nodes) {
56686
- result = factory.createNodeArray(nodes, nodes.hasTrailingComma);
56727
+ result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma);
56687
56728
  }
56688
56729
  setTextRangePosEnd(result, -1, -1);
56689
56730
  }
@@ -60659,18 +60700,18 @@ function createTypeChecker(host) {
60659
60700
  function getExpandedParameters(sig, skipUnionExpanding) {
60660
60701
  if (signatureHasRestParameter(sig)) {
60661
60702
  const restIndex = sig.parameters.length - 1;
60662
- const restName = sig.parameters[restIndex].escapedName;
60663
- const restType = getTypeOfSymbol(sig.parameters[restIndex]);
60703
+ const restSymbol = sig.parameters[restIndex];
60704
+ const restType = getTypeOfSymbol(restSymbol);
60664
60705
  if (isTupleType(restType)) {
60665
- return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
60706
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex, restSymbol)];
60666
60707
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
60667
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
60708
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restSymbol));
60668
60709
  }
60669
60710
  }
60670
60711
  return [sig.parameters];
60671
- function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
60712
+ function expandSignatureParametersWithTupleMembers(restType, restIndex, restSymbol) {
60672
60713
  const elementTypes = getTypeArguments(restType);
60673
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
60714
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restSymbol);
60674
60715
  const restParams = map(elementTypes, (t, i) => {
60675
60716
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
60676
60717
  const flags = restType.target.elementFlags[i];
@@ -60681,19 +60722,29 @@ function createTypeChecker(host) {
60681
60722
  });
60682
60723
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
60683
60724
  }
60684
- function getUniqAssociatedNamesFromTupleType(type, restName) {
60685
- const associatedNamesMap = /* @__PURE__ */ new Map();
60686
- return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
60687
- const name = getTupleElementLabel(labeledElement, i, restName);
60688
- const prevCounter = associatedNamesMap.get(name);
60689
- if (prevCounter === void 0) {
60690
- associatedNamesMap.set(name, 1);
60691
- return name;
60692
- } else {
60693
- associatedNamesMap.set(name, prevCounter + 1);
60694
- return `${name}_${prevCounter}`;
60725
+ function getUniqAssociatedNamesFromTupleType(type, restSymbol) {
60726
+ const names = map(type.target.labeledElementDeclarations, (labeledElement, i) => getTupleElementLabel(labeledElement, i, type.target.elementFlags[i], restSymbol));
60727
+ if (names) {
60728
+ const duplicates = [];
60729
+ const uniqueNames = /* @__PURE__ */ new Set();
60730
+ for (let i = 0; i < names.length; i++) {
60731
+ const name = names[i];
60732
+ if (!tryAddToSet(uniqueNames, name)) {
60733
+ duplicates.push(i);
60734
+ }
60695
60735
  }
60696
- });
60736
+ const counters = /* @__PURE__ */ new Map();
60737
+ for (const i of duplicates) {
60738
+ let counter = counters.get(names[i]) ?? 1;
60739
+ let name;
60740
+ while (!tryAddToSet(uniqueNames, name = `${names[i]}_${counter}`)) {
60741
+ counter++;
60742
+ }
60743
+ names[i] = name;
60744
+ counters.set(names[i], counter + 1);
60745
+ }
60746
+ }
60747
+ return names;
60697
60748
  }
60698
60749
  }
60699
60750
  function getDefaultConstructSignatures(classType) {
@@ -74185,7 +74236,7 @@ function createTypeChecker(host) {
74185
74236
  if (!canCollectSymbolAliasAccessabilityData) {
74186
74237
  return;
74187
74238
  }
74188
- if (location.flags & 33554432 /* Ambient */) {
74239
+ if (location.flags & 33554432 /* Ambient */ && !isPropertySignature(location) && !isPropertyDeclaration(location)) {
74189
74240
  return;
74190
74241
  }
74191
74242
  switch (hint) {
@@ -77176,7 +77227,7 @@ function createTypeChecker(host) {
77176
77227
  checkGrammarJsxElement(node);
77177
77228
  }
77178
77229
  checkJsxPreconditions(node);
77179
- markLinkedReferences(node, 4 /* Jsx */);
77230
+ markJsxAliasReferenced(node);
77180
77231
  if (isNodeOpeningLikeElement) {
77181
77232
  const jsxOpeningLikeNode = node;
77182
77233
  const sig = getResolvedSignature(jsxOpeningLikeNode);
@@ -80107,7 +80158,7 @@ function createTypeChecker(host) {
80107
80158
  return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
80108
80159
  }
80109
80160
  function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
80110
- const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
80161
+ const hasDefaultOnly = isOnlyImportableAsDefault(moduleSpecifier);
80111
80162
  if (hasDefaultOnly && type && !isErrorType(type)) {
80112
80163
  const synthType = type;
80113
80164
  if (!synthType.defaultOnlyType) {
@@ -80433,14 +80484,45 @@ function createTypeChecker(host) {
80433
80484
  !!declaration && (hasInitializer(declaration) || isOptionalDeclaration(declaration))
80434
80485
  );
80435
80486
  }
80436
- function getTupleElementLabel(d, index, restParameterName = "arg") {
80487
+ function getTupleElementLabelFromBindingElement(node, index, elementFlags) {
80488
+ switch (node.name.kind) {
80489
+ case 80 /* Identifier */: {
80490
+ const name = node.name.escapedText;
80491
+ if (node.dotDotDotToken) {
80492
+ return elementFlags & 12 /* Variable */ ? name : `${name}_${index}`;
80493
+ } else {
80494
+ return elementFlags & 3 /* Fixed */ ? name : `${name}_n`;
80495
+ }
80496
+ }
80497
+ case 207 /* ArrayBindingPattern */: {
80498
+ if (node.dotDotDotToken) {
80499
+ const elements = node.name.elements;
80500
+ const lastElement = tryCast(lastOrUndefined(elements), isBindingElement);
80501
+ const elementCount = elements.length - ((lastElement == null ? void 0 : lastElement.dotDotDotToken) ? 1 : 0);
80502
+ if (index < elementCount) {
80503
+ const element = elements[index];
80504
+ if (isBindingElement(element)) {
80505
+ return getTupleElementLabelFromBindingElement(element, index, elementFlags);
80506
+ }
80507
+ } else if (lastElement == null ? void 0 : lastElement.dotDotDotToken) {
80508
+ return getTupleElementLabelFromBindingElement(lastElement, index - elementCount, elementFlags);
80509
+ }
80510
+ }
80511
+ break;
80512
+ }
80513
+ }
80514
+ return `arg_${index}`;
80515
+ }
80516
+ function getTupleElementLabel(d, index = 0, elementFlags = 3 /* Fixed */, restSymbol) {
80437
80517
  if (!d) {
80438
- return `${restParameterName}_${index}`;
80518
+ const restParameter = tryCast(restSymbol == null ? void 0 : restSymbol.valueDeclaration, isParameter);
80519
+ return restParameter ? getTupleElementLabelFromBindingElement(restParameter, index, elementFlags) : `${(restSymbol == null ? void 0 : restSymbol.escapedName) ?? "arg"}_${index}`;
80439
80520
  }
80440
80521
  Debug.assert(isIdentifier(d.name));
80441
80522
  return d.name.escapedText;
80442
80523
  }
80443
80524
  function getParameterNameAtPosition(signature, pos, overrideRestType) {
80525
+ var _a;
80444
80526
  const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
80445
80527
  if (pos < paramCount) {
80446
80528
  return signature.parameters[pos].escapedName;
@@ -80448,9 +80530,11 @@ function createTypeChecker(host) {
80448
80530
  const restParameter = signature.parameters[paramCount] || unknownSymbol;
80449
80531
  const restType = overrideRestType || getTypeOfSymbol(restParameter);
80450
80532
  if (isTupleType(restType)) {
80451
- const associatedNames = restType.target.labeledElementDeclarations;
80533
+ const tupleType = restType.target;
80452
80534
  const index = pos - paramCount;
80453
- return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
80535
+ const associatedName = (_a = tupleType.labeledElementDeclarations) == null ? void 0 : _a[index];
80536
+ const elementFlags = tupleType.elementFlags[index];
80537
+ return getTupleElementLabel(associatedName, index, elementFlags, restParameter);
80454
80538
  }
80455
80539
  return restParameter.escapedName;
80456
80540
  }
@@ -85381,7 +85465,7 @@ function createTypeChecker(host) {
85381
85465
  });
85382
85466
  }
85383
85467
  function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
85384
- if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
85468
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) >= 5 /* ES2015 */) {
85385
85469
  return;
85386
85470
  }
85387
85471
  if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
@@ -86802,7 +86886,7 @@ function createTypeChecker(host) {
86802
86886
  }
86803
86887
  }
86804
86888
  function checkClassNameCollisionWithObject(name) {
86805
- if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
86889
+ if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < 5 /* ES2015 */) {
86806
86890
  error2(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
86807
86891
  }
86808
86892
  }
@@ -87882,7 +87966,7 @@ function createTypeChecker(host) {
87882
87966
  getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
87883
87967
  }
87884
87968
  }
87885
- if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
87969
+ if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(node.parent) === 1 /* CommonJS */) {
87886
87970
  const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
87887
87971
  if (exportModifier) {
87888
87972
  error2(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
@@ -88102,8 +88186,10 @@ function createTypeChecker(host) {
88102
88186
  }
88103
88187
  }
88104
88188
  }
88105
- if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
88189
+ if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
88106
88190
  error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
88191
+ } else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
88192
+ error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
88107
88193
  }
88108
88194
  }
88109
88195
  if (isImportSpecifier(node)) {
@@ -88144,7 +88230,7 @@ function createTypeChecker(host) {
88144
88230
  checkAliasSymbol(node);
88145
88231
  if (node.kind === 276 /* ImportSpecifier */) {
88146
88232
  checkModuleExportName(node.propertyName);
88147
- if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
88233
+ if (moduleExportNameIsDefault(node.propertyName || node.name) && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
88148
88234
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
88149
88235
  }
88150
88236
  }
@@ -88166,7 +88252,7 @@ function createTypeChecker(host) {
88166
88252
  if (validForTypeAttributes && override) {
88167
88253
  return;
88168
88254
  }
88169
- const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
88255
+ const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
88170
88256
  if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
88171
88257
  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;
88172
88258
  return grammarErrorOnNode(node, message);
@@ -88199,7 +88285,7 @@ function createTypeChecker(host) {
88199
88285
  if (importClause.namedBindings) {
88200
88286
  if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
88201
88287
  checkImportBinding(importClause.namedBindings);
88202
- if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
88288
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && getESModuleInterop(compilerOptions)) {
88203
88289
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
88204
88290
  }
88205
88291
  } else {
@@ -88239,7 +88325,7 @@ function createTypeChecker(host) {
88239
88325
  grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
88240
88326
  }
88241
88327
  } else {
88242
- if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
88328
+ if (5 /* ES2015 */ <= moduleKind && moduleKind <= 99 /* ESNext */ && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
88243
88329
  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);
88244
88330
  }
88245
88331
  }
@@ -88269,7 +88355,7 @@ function createTypeChecker(host) {
88269
88355
  checkAliasSymbol(node.exportClause);
88270
88356
  checkModuleExportName(node.exportClause.name);
88271
88357
  }
88272
- if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
88358
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
88273
88359
  if (node.exportClause) {
88274
88360
  if (getESModuleInterop(compilerOptions)) {
88275
88361
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
@@ -88328,7 +88414,7 @@ function createTypeChecker(host) {
88328
88414
  markLinkedReferences(node, 7 /* ExportSpecifier */);
88329
88415
  }
88330
88416
  } else {
88331
- if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleExportNameIsDefault(node.propertyName || node.name)) {
88417
+ if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && moduleExportNameIsDefault(node.propertyName || node.name)) {
88332
88418
  checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
88333
88419
  }
88334
88420
  }
@@ -88354,7 +88440,7 @@ function createTypeChecker(host) {
88354
88440
  if (typeAnnotationNode) {
88355
88441
  checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
88356
88442
  }
88357
- const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
88443
+ const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */;
88358
88444
  if (node.expression.kind === 80 /* Identifier */) {
88359
88445
  const id = node.expression;
88360
88446
  const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
@@ -88434,7 +88520,7 @@ function createTypeChecker(host) {
88434
88520
  grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
88435
88521
  }
88436
88522
  if (node.isExportEquals) {
88437
- 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 */)) {
88523
+ 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 */)) {
88438
88524
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
88439
88525
  } else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
88440
88526
  grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
@@ -90025,15 +90111,14 @@ function createTypeChecker(host) {
90025
90111
  function checkChildIdentifiers(node2) {
90026
90112
  forEachNodeRecursively(node2, checkIdentifiers);
90027
90113
  }
90114
+ function isExpressionNodeOrShorthandPropertyAssignmentName(node2) {
90115
+ return isExpressionNode(node2) || isShorthandPropertyAssignment(node2.parent) && (node2.parent.objectAssignmentInitializer ?? node2.parent.name) === node2;
90116
+ }
90028
90117
  function checkSingleIdentifier(node2) {
90029
90118
  const nodeLinks2 = getNodeLinks(node2);
90030
90119
  nodeLinks2.calculatedFlags |= 536870912 /* ConstructorReference */ | 16384 /* CapturedBlockScopedBinding */ | 32768 /* BlockScopedBindingInLoop */;
90031
- if (isIdentifier(node2) && isExpressionNode(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
90032
- const s = getSymbolAtLocation(
90033
- node2,
90034
- /*ignoreErrors*/
90035
- true
90036
- );
90120
+ if (isIdentifier(node2) && isExpressionNodeOrShorthandPropertyAssignmentName(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
90121
+ const s = getResolvedSymbol(node2);
90037
90122
  if (s && s !== unknownSymbol) {
90038
90123
  checkIdentifierCalculateNodeCheckFlags(node2, s);
90039
90124
  }
@@ -90980,7 +91065,7 @@ function createTypeChecker(host) {
90980
91065
  break;
90981
91066
  case 95 /* ExportKeyword */:
90982
91067
  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
90983
- node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
91068
+ node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
90984
91069
  return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
90985
91070
  }
90986
91071
  if (flags & 32 /* Export */) {
@@ -91890,7 +91975,7 @@ function createTypeChecker(host) {
91890
91975
  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;
91891
91976
  return grammarErrorOnNode(node.exclamationToken, message);
91892
91977
  }
91893
- if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
91978
+ if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
91894
91979
  checkESModuleMarker(node.name);
91895
91980
  }
91896
91981
  return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
@@ -92391,7 +92476,9 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
92391
92476
  isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
92392
92477
  fileExists: (fileName) => host.fileExists(fileName),
92393
92478
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
92394
- readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
92479
+ readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
92480
+ getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
92481
+ getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
92395
92482
  };
92396
92483
  }
92397
92484
  var SymbolTrackerImpl = class _SymbolTrackerImpl {
@@ -112244,7 +112331,7 @@ function transformModule(context) {
112244
112331
  case 354 /* PartiallyEmittedExpression */:
112245
112332
  return visitPartiallyEmittedExpression(node, valueIsDiscarded);
112246
112333
  case 213 /* CallExpression */:
112247
- if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
112334
+ if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
112248
112335
  return visitImportCallExpression(node);
112249
112336
  }
112250
112337
  break;
@@ -115240,8 +115327,8 @@ function transformECMAScriptModule(context) {
115240
115327
  }
115241
115328
  }
115242
115329
 
115243
- // src/compiler/transformers/module/node.ts
115244
- function transformNodeModule(context) {
115330
+ // src/compiler/transformers/module/impliedNodeFormatDependent.ts
115331
+ function transformImpliedNodeFormatDependentModule(context) {
115245
115332
  const previousOnSubstituteNode = context.onSubstituteNode;
115246
115333
  const previousOnEmitNode = context.onEmitNode;
115247
115334
  const esmTransform = transformECMAScriptModule(context);
@@ -115252,6 +115339,7 @@ function transformNodeModule(context) {
115252
115339
  const cjsTransform = transformModule(context);
115253
115340
  const cjsOnSubstituteNode = context.onSubstituteNode;
115254
115341
  const cjsOnEmitNode = context.onEmitNode;
115342
+ const getEmitModuleFormatOfFile2 = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
115255
115343
  context.onSubstituteNode = onSubstituteNode;
115256
115344
  context.onEmitNode = onEmitNode;
115257
115345
  context.enableSubstitution(307 /* SourceFile */);
@@ -115266,7 +115354,7 @@ function transformNodeModule(context) {
115266
115354
  if (!currentSourceFile) {
115267
115355
  return previousOnSubstituteNode(hint, node);
115268
115356
  }
115269
- if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
115357
+ if (getEmitModuleFormatOfFile2(currentSourceFile) >= 5 /* ES2015 */) {
115270
115358
  return esmOnSubstituteNode(hint, node);
115271
115359
  }
115272
115360
  return cjsOnSubstituteNode(hint, node);
@@ -115279,13 +115367,13 @@ function transformNodeModule(context) {
115279
115367
  if (!currentSourceFile) {
115280
115368
  return previousOnEmitNode(hint, node, emitCallback);
115281
115369
  }
115282
- if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
115370
+ if (getEmitModuleFormatOfFile2(currentSourceFile) >= 5 /* ES2015 */) {
115283
115371
  return esmOnEmitNode(hint, node, emitCallback);
115284
115372
  }
115285
115373
  return cjsOnEmitNode(hint, node, emitCallback);
115286
115374
  }
115287
115375
  function getModuleTransformForFile(file) {
115288
- return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
115376
+ return getEmitModuleFormatOfFile2(file) >= 5 /* ES2015 */ ? esmTransform : cjsTransform;
115289
115377
  }
115290
115378
  function transformSourceFile(node) {
115291
115379
  if (node.isDeclarationFile) {
@@ -117410,17 +117498,18 @@ function isProcessedComponent(node) {
117410
117498
  // src/compiler/transformer.ts
117411
117499
  function getModuleTransformer(moduleKind) {
117412
117500
  switch (moduleKind) {
117501
+ case 200 /* Preserve */:
117502
+ return transformECMAScriptModule;
117413
117503
  case 99 /* ESNext */:
117414
117504
  case 7 /* ES2022 */:
117415
117505
  case 6 /* ES2020 */:
117416
117506
  case 5 /* ES2015 */:
117417
- case 200 /* Preserve */:
117418
- return transformECMAScriptModule;
117419
- case 4 /* System */:
117420
- return transformSystemModule;
117421
117507
  case 100 /* Node16 */:
117422
117508
  case 199 /* NodeNext */:
117423
- return transformNodeModule;
117509
+ case 1 /* CommonJS */:
117510
+ return transformImpliedNodeFormatDependentModule;
117511
+ case 4 /* System */:
117512
+ return transformSystemModule;
117424
117513
  default:
117425
117514
  return transformModule;
117426
117515
  }
@@ -118148,6 +118237,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
118148
118237
  newLine: compilerOptions.newLine,
118149
118238
  noEmitHelpers: compilerOptions.noEmitHelpers,
118150
118239
  module: getEmitModuleKind(compilerOptions),
118240
+ moduleResolution: getEmitModuleResolutionKind(compilerOptions),
118151
118241
  target: getEmitScriptTarget(compilerOptions),
118152
118242
  sourceMap: compilerOptions.sourceMap,
118153
118243
  inlineSourceMap: compilerOptions.inlineSourceMap,
@@ -118210,8 +118300,9 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
118210
118300
  newLine: compilerOptions.newLine,
118211
118301
  noEmitHelpers: true,
118212
118302
  module: compilerOptions.module,
118303
+ moduleResolution: compilerOptions.moduleResolution,
118213
118304
  target: compilerOptions.target,
118214
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
118305
+ sourceMap: emitOnly !== 2 /* BuilderSignature */ && compilerOptions.declarationMap,
118215
118306
  inlineSourceMap: compilerOptions.inlineSourceMap,
118216
118307
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
118217
118308
  onlyPrintJsDocStyle: true,
@@ -123728,7 +123819,6 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
123728
123819
  return getModeForUsageLocationWorker(file, usage, compilerOptions);
123729
123820
  }
123730
123821
  function getModeForUsageLocationWorker(file, usage, compilerOptions) {
123731
- var _a;
123732
123822
  if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent) || isJSDocImportTag(usage.parent)) {
123733
123823
  const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
123734
123824
  if (isTypeOnly) {
@@ -123744,19 +123834,28 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
123744
123834
  return override;
123745
123835
  }
123746
123836
  }
123747
- if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
123748
- return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
123749
- usage.parent,
123750
- /*requireStringLiteralLikeArgument*/
123751
- false
123752
- ) ? 1 /* CommonJS */ : 99 /* ESNext */;
123837
+ if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
123838
+ return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
123753
123839
  }
123754
- if (file.impliedNodeFormat === void 0) return void 0;
123755
- if (file.impliedNodeFormat !== 99 /* ESNext */) {
123756
- return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
123840
+ }
123841
+ function getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions) {
123842
+ var _a;
123843
+ if (!compilerOptions) {
123844
+ return void 0;
123757
123845
  }
123758
123846
  const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
123759
- return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
123847
+ if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(
123848
+ usage.parent,
123849
+ /*requireStringLiteralLikeArgument*/
123850
+ false
123851
+ )) {
123852
+ return 1 /* CommonJS */;
123853
+ }
123854
+ if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
123855
+ return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
123856
+ }
123857
+ const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
123858
+ return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
123760
123859
  }
123761
123860
  function getResolutionModeOverride(node, grammarErrorOnNode) {
123762
123861
  if (!node) return void 0;
@@ -123813,7 +123912,7 @@ function getTypeReferenceResolutionName(entry) {
123813
123912
  }
123814
123913
  var typeReferenceResolutionNameAndModeGetter = {
123815
123914
  getName: getTypeReferenceResolutionName,
123816
- getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
123915
+ getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions))
123817
123916
  };
123818
123917
  function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
123819
123918
  return {
@@ -123999,7 +124098,7 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
123999
124098
  const packageJsonLocations = [];
124000
124099
  state.failedLookupLocations = packageJsonLocations;
124001
124100
  state.affectingLocations = packageJsonLocations;
124002
- const packageJsonScope = getPackageScopeForPath(fileName, state);
124101
+ const packageJsonScope = getPackageScopeForPath(getDirectoryPath(fileName), state);
124003
124102
  const impliedNodeFormat = (packageJsonScope == null ? void 0 : packageJsonScope.contents.packageJsonContent.type) === "module" ? 99 /* ESNext */ : 1 /* CommonJS */;
124004
124103
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
124005
124104
  }
@@ -124453,6 +124552,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124453
124552
  isSourceFileFromExternalLibrary,
124454
124553
  isSourceFileDefaultLibrary,
124455
124554
  getModeForUsageLocation: getModeForUsageLocation2,
124555
+ getEmitSyntaxForUsageLocation,
124456
124556
  getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
124457
124557
  getSourceFileFromReference,
124458
124558
  getLibFileFromReference,
@@ -124481,6 +124581,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124481
124581
  forEachResolvedProjectReference: forEachResolvedProjectReference2,
124482
124582
  isSourceOfProjectReferenceRedirect,
124483
124583
  getRedirectReferenceForResolutionFromSourceOfProject,
124584
+ getCompilerOptionsForFile,
124585
+ getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
124586
+ getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
124587
+ getImpliedNodeFormatForEmit: getImpliedNodeFormatForEmit2,
124588
+ shouldTransformImportCall,
124484
124589
  emitBuildInfo,
124485
124590
  fileExists,
124486
124591
  readFile,
@@ -125035,6 +125140,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125035
125140
  getSymlinkCache,
125036
125141
  writeFile: writeFileCallback || writeFile2,
125037
125142
  isEmitBlocked,
125143
+ shouldTransformImportCall,
125144
+ getEmitModuleFormatOfFile: getEmitModuleFormatOfFile2,
125145
+ getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
125146
+ getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
125038
125147
  readFile: (f) => host.readFile(f),
125039
125148
  fileExists: (f) => {
125040
125149
  const path = toPath3(f);
@@ -126114,10 +126223,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126114
126223
  const resolvedTypeReferenceDirective = resolutions[index];
126115
126224
  const fileName = ref.fileName;
126116
126225
  resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
126117
- const mode = ref.resolutionMode || file.impliedNodeFormat;
126226
+ const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
126118
126227
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
126119
126228
  }
126120
126229
  }
126230
+ function getCompilerOptionsForFile(file) {
126231
+ var _a2;
126232
+ return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
126233
+ }
126121
126234
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
126122
126235
  var _a2, _b2;
126123
126236
  (_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 });
@@ -126218,13 +126331,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126218
126331
  return host.getCanonicalFileName(fileName);
126219
126332
  }
126220
126333
  function processImportedModules(file) {
126221
- var _a2;
126222
126334
  collectExternalModuleReferences(file);
126223
126335
  if (file.imports.length || file.moduleAugmentations.length) {
126224
126336
  const moduleNames = getModuleNames(file);
126225
126337
  const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
126226
126338
  Debug.assert(resolutions.length === moduleNames.length);
126227
- const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
126339
+ const optionsForFile = getCompilerOptionsForFile(file);
126228
126340
  const resolutionsInFile = createModeAwareCache();
126229
126341
  (resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
126230
126342
  for (let index = 0; index < moduleNames.length; index++) {
@@ -126773,7 +126885,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126773
126885
  redirectInfo = cachedChain.redirectInfo;
126774
126886
  } else {
126775
126887
  reasons == null ? void 0 : reasons.forEach(processReason);
126776
- redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
126888
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
126777
126889
  }
126778
126890
  if (fileProcessingReason) processReason(fileProcessingReason);
126779
126891
  const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
@@ -127131,13 +127243,53 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
127131
127243
  return symlinks;
127132
127244
  }
127133
127245
  function getModeForUsageLocation2(file, usage) {
127134
- var _a2;
127135
- const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
127136
- return getModeForUsageLocationWorker(file, usage, optionsForFile);
127246
+ return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
127247
+ }
127248
+ function getEmitSyntaxForUsageLocation(file, usage) {
127249
+ return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
127137
127250
  }
127138
127251
  function getModeForResolutionAtIndex2(file, index) {
127139
127252
  return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
127140
127253
  }
127254
+ function getDefaultResolutionModeForFile2(sourceFile) {
127255
+ return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
127256
+ }
127257
+ function getImpliedNodeFormatForEmit2(sourceFile) {
127258
+ return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
127259
+ }
127260
+ function getEmitModuleFormatOfFile2(sourceFile) {
127261
+ return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
127262
+ }
127263
+ function shouldTransformImportCall(sourceFile) {
127264
+ return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
127265
+ }
127266
+ }
127267
+ function shouldTransformImportCallWorker(sourceFile, options) {
127268
+ const moduleKind = getEmitModuleKind(options);
127269
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
127270
+ return false;
127271
+ }
127272
+ return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
127273
+ }
127274
+ function getEmitModuleFormatOfFileWorker(sourceFile, options) {
127275
+ return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
127276
+ }
127277
+ function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
127278
+ var _a, _b;
127279
+ const moduleKind = getEmitModuleKind(options);
127280
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
127281
+ return sourceFile.impliedNodeFormat;
127282
+ }
127283
+ if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
127284
+ return 1 /* CommonJS */;
127285
+ }
127286
+ if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
127287
+ return 99 /* ESNext */;
127288
+ }
127289
+ return void 0;
127290
+ }
127291
+ function getDefaultResolutionModeForFileWorker(sourceFile, options) {
127292
+ return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
127141
127293
  }
127142
127294
  function updateHostForUseSourceOfProjectReferenceRedirect(host) {
127143
127295
  let setOfDeclarationDirectories;
@@ -127606,8 +127758,7 @@ var BuilderState;
127606
127758
  );
127607
127759
  },
127608
127760
  cancellationToken,
127609
- /*emitOnly*/
127610
- true,
127761
+ 2 /* BuilderSignature */,
127611
127762
  /*customTransformers*/
127612
127763
  void 0,
127613
127764
  /*forceDtsEmit*/
@@ -127943,7 +128094,12 @@ function repopulateDiagnostics(diagnostics, newProgram) {
127943
128094
  }
127944
128095
  function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo) {
127945
128096
  const info = repopulateInfo(chain);
127946
- if (info) {
128097
+ if (info === true) {
128098
+ return {
128099
+ ...createModeMismatchDetails(sourceFile),
128100
+ next: convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo)
128101
+ };
128102
+ } else if (info) {
127947
128103
  return {
127948
128104
  ...createModuleNotFoundChain(sourceFile, newProgram, info.moduleReference, info.mode, info.packageName || info.moduleReference),
127949
128105
  next: convertOrRepopulateDiagnosticMessageChainArray(chain.next, sourceFile, newProgram, repopulateInfo)
@@ -129706,7 +129862,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
129706
129862
  cleanupLibResolutionWatching(newProgram);
129707
129863
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
129708
129864
  var _a;
129709
- const expected = isExternalOrCommonJsModule(newFile) ? ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0 : 0;
129865
+ const expected = ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0;
129710
129866
  const existing = impliedFormatPackageJsons.get(newFile.resolvedPath) ?? emptyArray;
129711
129867
  for (let i = existing.length; i < expected; i++) {
129712
129868
  createFileWatcherOfAffectingLocation(
@@ -130598,10 +130754,10 @@ function explainFiles(program, write) {
130598
130754
  for (const file of program.getSourceFiles()) {
130599
130755
  write(`${toFileName(file, relativeFileName)}`);
130600
130756
  (_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
130601
- (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
130757
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
130602
130758
  }
130603
130759
  }
130604
- function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
130760
+ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConvertor) {
130605
130761
  var _a;
130606
130762
  let result;
130607
130763
  if (file.path !== file.resolvedPath) {
@@ -130621,7 +130777,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
130621
130777
  ));
130622
130778
  }
130623
130779
  if (isExternalOrCommonJsModule(file)) {
130624
- switch (file.impliedNodeFormat) {
130780
+ switch (getImpliedNodeFormatForEmitWorker(file, options)) {
130625
130781
  case 99 /* ESNext */:
130626
130782
  if (file.packageJsonScope) {
130627
130783
  (result ?? (result = [])).push(chainDiagnosticMessages(
@@ -137158,7 +137314,9 @@ function createModuleSpecifierResolutionHost(program, host) {
137158
137314
  isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
137159
137315
  getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
137160
137316
  getFileIncludeReasons: () => program.getFileIncludeReasons(),
137161
- getCommonSourceDirectory: () => program.getCommonSourceDirectory()
137317
+ getCommonSourceDirectory: () => program.getCommonSourceDirectory(),
137318
+ getDefaultResolutionModeForFile: (file) => program.getDefaultResolutionModeForFile(file),
137319
+ getModeForResolutionAtIndex: (file, index) => program.getModeForResolutionAtIndex(file, index)
137162
137320
  };
137163
137321
  }
137164
137322
  function getModuleSpecifierResolverHost(program, host) {
@@ -138255,36 +138413,12 @@ function mapOneOrMany(valueOrArray, f, resultSelector = identity) {
138255
138413
  function firstOrOnly(valueOrArray) {
138256
138414
  return isArray(valueOrArray) ? first(valueOrArray) : valueOrArray;
138257
138415
  }
138258
- function getNamesForExportedSymbol(symbol, scriptTarget) {
138259
- if (needsNameFromDeclaration(symbol)) {
138260
- const fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
138261
- if (fromDeclaration) return fromDeclaration;
138262
- const fileNameCase = moduleSymbolToValidIdentifier(
138263
- getSymbolParentOrFail(symbol),
138264
- scriptTarget,
138265
- /*forceCapitalize*/
138266
- false
138267
- );
138268
- const capitalized = moduleSymbolToValidIdentifier(
138269
- getSymbolParentOrFail(symbol),
138270
- scriptTarget,
138271
- /*forceCapitalize*/
138272
- true
138273
- );
138274
- if (fileNameCase === capitalized) return fileNameCase;
138275
- return [fileNameCase, capitalized];
138276
- }
138277
- return symbol.name;
138278
- }
138279
138416
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
138280
- if (needsNameFromDeclaration(symbol)) {
138417
+ if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) {
138281
138418
  return getDefaultLikeExportNameFromDeclaration(symbol) || moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
138282
138419
  }
138283
138420
  return symbol.name;
138284
138421
  }
138285
- function needsNameFromDeclaration(symbol) {
138286
- return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
138287
- }
138288
138422
  function getDefaultLikeExportNameFromDeclaration(symbol) {
138289
138423
  return firstDefined(symbol.declarations, (d) => {
138290
138424
  var _a, _b, _c;
@@ -138447,9 +138581,13 @@ function fileShouldUseJavaScriptRequire(file, program, host, preferRequire) {
138447
138581
  if (!hasJSFileExtension(fileName)) {
138448
138582
  return false;
138449
138583
  }
138450
- const compilerOptions = program.getCompilerOptions();
138584
+ const compilerOptions = typeof file === "string" ? program.getCompilerOptions() : program.getCompilerOptionsForFile(file);
138451
138585
  const moduleKind = getEmitModuleKind(compilerOptions);
138452
- const impliedNodeFormat = typeof file === "string" ? getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), host, compilerOptions) : file.impliedNodeFormat;
138586
+ const sourceFileLike = typeof file === "string" ? {
138587
+ fileName: file,
138588
+ impliedNodeFormat: getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), host, compilerOptions)
138589
+ } : file;
138590
+ const impliedNodeFormat = getImpliedNodeFormatForEmitWorker(sourceFileLike, compilerOptions);
138453
138591
  if (impliedNodeFormat === 99 /* ESNext */) {
138454
138592
  return false;
138455
138593
  }
@@ -138561,6 +138699,7 @@ function createCacheableExportInfoMap(host) {
138561
138699
  const namedSymbol = isDefault && getLocalSymbolForExportDefault(symbol) || symbol;
138562
138700
  const names = exportKind === 0 /* Named */ || isExternalModuleSymbol(namedSymbol) ? unescapeLeadingUnderscores(symbolTableKey) : getNamesForExportedSymbol(
138563
138701
  namedSymbol,
138702
+ checker,
138564
138703
  /*scriptTarget*/
138565
138704
  void 0
138566
138705
  );
@@ -138896,7 +139035,15 @@ function getDefaultLikeExportInfo(moduleSymbol, checker) {
138896
139035
  function isImportableSymbol(symbol, checker) {
138897
139036
  return !checker.isUndefinedSymbol(symbol) && !checker.isUnknownSymbol(symbol) && !isKnownSymbol(symbol) && !isPrivateIdentifierSymbol(symbol);
138898
139037
  }
138899
- function forEachNameOfDefaultExport(defaultExport, checker, compilerOptions, preferCapitalizedNames, cb) {
139038
+ function getNamesForExportedSymbol(defaultExport, checker, scriptTarget) {
139039
+ let names;
139040
+ forEachNameOfDefaultExport(defaultExport, checker, scriptTarget, (name, capitalizedName) => {
139041
+ names = capitalizedName ? [name, capitalizedName] : name;
139042
+ return true;
139043
+ });
139044
+ return Debug.checkDefined(names);
139045
+ }
139046
+ function forEachNameOfDefaultExport(defaultExport, checker, scriptTarget, cb) {
138900
139047
  let chain;
138901
139048
  let current = defaultExport;
138902
139049
  const seen = /* @__PURE__ */ new Map();
@@ -138916,7 +139063,20 @@ function forEachNameOfDefaultExport(defaultExport, checker, compilerOptions, pre
138916
139063
  }
138917
139064
  for (const symbol of chain ?? emptyArray) {
138918
139065
  if (symbol.parent && isExternalModuleSymbol(symbol.parent)) {
138919
- const final = cb(moduleSymbolToValidIdentifier(symbol.parent, getEmitScriptTarget(compilerOptions), preferCapitalizedNames));
139066
+ const final = cb(
139067
+ moduleSymbolToValidIdentifier(
139068
+ symbol.parent,
139069
+ scriptTarget,
139070
+ /*forceCapitalize*/
139071
+ false
139072
+ ),
139073
+ moduleSymbolToValidIdentifier(
139074
+ symbol.parent,
139075
+ scriptTarget,
139076
+ /*forceCapitalize*/
139077
+ true
139078
+ )
139079
+ );
138920
139080
  if (final) return final;
138921
139081
  }
138922
139082
  }
@@ -141442,7 +141602,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
141442
141602
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
141443
141603
  const diags = [];
141444
141604
  const checker = program.getTypeChecker();
141445
- const isCommonJSFile = sourceFile.impliedNodeFormat === 1 /* CommonJS */ || fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
141605
+ const isCommonJSFile = program.getImpliedNodeFormatForEmit(sourceFile) === 1 /* CommonJS */ || fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
141446
141606
  if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (programContainsEsModules(program) || compilerOptionsIndicateEsModules(program.getCompilerOptions())) && containsTopLevelCommonjs(sourceFile)) {
141447
141607
  diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
141448
141608
  }
@@ -154556,7 +154716,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
154556
154716
  compilerOptions,
154557
154717
  createModuleSpecifierResolutionHost(program, host)
154558
154718
  );
154559
- const importKind = getImportKind(futureExportingSourceFile, exportKind, compilerOptions);
154719
+ const importKind = getImportKind(futureExportingSourceFile, exportKind, program);
154560
154720
  const addAsTypeOnly = getAddAsTypeOnly(
154561
154721
  isImportUsageValidAsTypeOnly,
154562
154722
  /*isForNewImportDeclaration*/
@@ -154896,7 +155056,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
154896
155056
  }
154897
155057
  function createImportSpecifierResolver(importingFile, program, host, preferences) {
154898
155058
  const packageJsonImportFilter = createPackageJsonImportFilter(importingFile, preferences, host);
154899
- const importMap = createExistingImportMap(program.getTypeChecker(), importingFile, program.getCompilerOptions());
155059
+ const importMap = createExistingImportMap(importingFile, program);
154900
155060
  return { getModuleSpecifierForBestExportInfo };
154901
155061
  function getModuleSpecifierForBestExportInfo(exportInfo, position, isValidTypeOnlyUseSite, fromCacheOnly) {
154902
155062
  const { fixes, computedWithoutCacheCount } = getImportFixes(
@@ -155003,7 +155163,7 @@ function getSingleExportInfoForSymbol(symbol, symbolName2, moduleSymbol, program
155003
155163
  }
155004
155164
  }
155005
155165
  }
155006
- function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = isFullSourceFile(sourceFile) ? createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()) : void 0, fromCacheOnly) {
155166
+ function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = isFullSourceFile(sourceFile) ? createExistingImportMap(sourceFile, program) : void 0, fromCacheOnly) {
155007
155167
  const checker = program.getTypeChecker();
155008
155168
  const existingImports = importMap ? flatMap(exportInfos, importMap.getImportsForExportInfo) : emptyArray;
155009
155169
  const useNamespace = usagePosition !== void 0 && tryUseExistingNamespaceImport(existingImports, usagePosition);
@@ -155118,7 +155278,8 @@ function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker
155118
155278
  };
155119
155279
  }
155120
155280
  }
155121
- function createExistingImportMap(checker, importingFile, compilerOptions) {
155281
+ function createExistingImportMap(importingFile, program) {
155282
+ const checker = program.getTypeChecker();
155122
155283
  let importMap;
155123
155284
  for (const moduleSpecifier of importingFile.imports) {
155124
155285
  const i = importFromModuleSpecifier(moduleSpecifier);
@@ -155139,7 +155300,7 @@ function createExistingImportMap(checker, importingFile, compilerOptions) {
155139
155300
  const matchingDeclarations = importMap == null ? void 0 : importMap.get(getSymbolId(moduleSymbol));
155140
155301
  if (!matchingDeclarations) return emptyArray;
155141
155302
  if (isSourceFileJS(importingFile) && !(targetFlags & 111551 /* Value */) && !every(matchingDeclarations, isJSDocImportTag)) return emptyArray;
155142
- const importKind = getImportKind(importingFile, exportKind, compilerOptions);
155303
+ const importKind = getImportKind(importingFile, exportKind, program);
155143
155304
  return matchingDeclarations.map((declaration) => ({ declaration, importKind, symbol, targetFlags }));
155144
155305
  }
155145
155306
  };
@@ -155154,8 +155315,8 @@ function shouldUseRequire(sourceFile, program) {
155154
155315
  if (compilerOptions.configFile) {
155155
155316
  return getEmitModuleKind(compilerOptions) < 5 /* ES2015 */;
155156
155317
  }
155157
- if (sourceFile.impliedNodeFormat === 1 /* CommonJS */) return true;
155158
- if (sourceFile.impliedNodeFormat === 99 /* ESNext */) return false;
155318
+ if (getImpliedNodeFormatForEmit(sourceFile, program) === 1 /* CommonJS */) return true;
155319
+ if (getImpliedNodeFormatForEmit(sourceFile, program) === 99 /* ESNext */) return false;
155159
155320
  for (const otherFile of program.getSourceFiles()) {
155160
155321
  if (otherFile === sourceFile || !isSourceFileJS(otherFile) || program.isSourceFileFromExternalLibrary(otherFile)) continue;
155161
155322
  if (otherFile.commonJsModuleIndicator && !otherFile.externalModuleIndicator) return true;
@@ -155207,20 +155368,13 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
155207
155368
  if (!importedSymbolHasValueMeaning && isJs && usagePosition !== void 0) {
155208
155369
  return { kind: 1 /* JsdocTypeImport */, moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo: exportInfo2, isReExport: i > 0 };
155209
155370
  }
155210
- const importKind = getImportKind(sourceFile, exportInfo2.exportKind, compilerOptions);
155371
+ const importKind = getImportKind(sourceFile, exportInfo2.exportKind, program);
155211
155372
  let qualification;
155212
155373
  if (usagePosition !== void 0 && importKind === 3 /* CommonJS */ && exportInfo2.exportKind === 0 /* Named */) {
155213
155374
  const exportEquals = checker.resolveExternalModuleSymbol(exportInfo2.moduleSymbol);
155214
155375
  let namespacePrefix;
155215
155376
  if (exportEquals !== exportInfo2.moduleSymbol) {
155216
- namespacePrefix = forEachNameOfDefaultExport(
155217
- exportEquals,
155218
- checker,
155219
- compilerOptions,
155220
- /*preferCapitalizedNames*/
155221
- false,
155222
- identity
155223
- );
155377
+ namespacePrefix = forEachNameOfDefaultExport(exportEquals, checker, getEmitScriptTarget(compilerOptions), identity);
155224
155378
  }
155225
155379
  namespacePrefix || (namespacePrefix = moduleSymbolToValidIdentifier(
155226
155380
  exportInfo2.moduleSymbol,
@@ -155393,8 +155547,8 @@ function getUmdSymbol(token, checker) {
155393
155547
  }
155394
155548
  return void 0;
155395
155549
  }
155396
- function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) {
155397
- if (compilerOptions.verbatimModuleSyntax && (getEmitModuleKind(compilerOptions) === 1 /* CommonJS */ || importingFile.impliedNodeFormat === 1 /* CommonJS */)) {
155550
+ function getImportKind(importingFile, exportKind, program, forceImportKeyword) {
155551
+ if (program.getCompilerOptions().verbatimModuleSyntax && getEmitModuleFormatOfFile(importingFile, program) === 1 /* CommonJS */) {
155398
155552
  return 3 /* CommonJS */;
155399
155553
  }
155400
155554
  switch (exportKind) {
@@ -155403,18 +155557,18 @@ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKe
155403
155557
  case 1 /* Default */:
155404
155558
  return 1 /* Default */;
155405
155559
  case 2 /* ExportEquals */:
155406
- return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword);
155560
+ return getExportEqualsImportKind(importingFile, program.getCompilerOptions(), !!forceImportKeyword);
155407
155561
  case 3 /* UMD */:
155408
- return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword);
155562
+ return getUmdImportKind(importingFile, program, !!forceImportKeyword);
155409
155563
  default:
155410
155564
  return Debug.assertNever(exportKind);
155411
155565
  }
155412
155566
  }
155413
- function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
155414
- if (getAllowSyntheticDefaultImports(compilerOptions)) {
155567
+ function getUmdImportKind(importingFile, program, forceImportKeyword) {
155568
+ if (getAllowSyntheticDefaultImports(program.getCompilerOptions())) {
155415
155569
  return 1 /* Default */;
155416
155570
  }
155417
- const moduleKind = getEmitModuleKind(compilerOptions);
155571
+ const moduleKind = getEmitModuleKind(program.getCompilerOptions());
155418
155572
  switch (moduleKind) {
155419
155573
  case 2 /* AMD */:
155420
155574
  case 1 /* CommonJS */:
@@ -155433,7 +155587,7 @@ function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
155433
155587
  return 2 /* Namespace */;
155434
155588
  case 100 /* Node16 */:
155435
155589
  case 199 /* NodeNext */:
155436
- return importingFile.impliedNodeFormat === 99 /* ESNext */ ? 2 /* Namespace */ : 3 /* CommonJS */;
155590
+ return getImpliedNodeFormatForEmit(importingFile, program) === 99 /* ESNext */ ? 2 /* Namespace */ : 3 /* CommonJS */;
155437
155591
  default:
155438
155592
  return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`);
155439
155593
  }
@@ -155516,7 +155670,7 @@ function getExportInfos(symbolName2, isJsxTagName, currentTokenMeaning, cancella
155516
155670
  cancellationToken.throwIfCancellationRequested();
155517
155671
  const compilerOptions = program2.getCompilerOptions();
155518
155672
  const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker);
155519
- if (defaultInfo && symbolFlagsHaveMeaning(checker.getSymbolFlags(defaultInfo.symbol), currentTokenMeaning) && forEachNameOfDefaultExport(defaultInfo.symbol, checker, compilerOptions, isJsxTagName, (name) => name === symbolName2)) {
155673
+ if (defaultInfo && symbolFlagsHaveMeaning(checker.getSymbolFlags(defaultInfo.symbol), currentTokenMeaning) && forEachNameOfDefaultExport(defaultInfo.symbol, checker, getEmitScriptTarget(compilerOptions), (name, capitalizedName) => (isJsxTagName ? capitalizedName ?? name : name) === symbolName2)) {
155520
155674
  addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program2, isFromPackageJson);
155521
155675
  }
155522
155676
  const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName2, moduleSymbol);
@@ -155917,6 +156071,12 @@ function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) {
155917
156071
  function symbolFlagsHaveMeaning(flags, meaning) {
155918
156072
  return meaning === 7 /* All */ ? true : meaning & 1 /* Value */ ? !!(flags & 111551 /* Value */) : meaning & 2 /* Type */ ? !!(flags & 788968 /* Type */) : meaning & 4 /* Namespace */ ? !!(flags & 1920 /* Namespace */) : false;
155919
156073
  }
156074
+ function getImpliedNodeFormatForEmit(file, program) {
156075
+ return isFullSourceFile(file) ? program.getImpliedNodeFormatForEmit(file) : getImpliedNodeFormatForEmitWorker(file, program.getCompilerOptions());
156076
+ }
156077
+ function getEmitModuleFormatOfFile(file, program) {
156078
+ return isFullSourceFile(file) ? program.getEmitModuleFormatOfFile(file) : getEmitModuleFormatOfFileWorker(file, program.getCompilerOptions());
156079
+ }
155920
156080
 
155921
156081
  // src/services/codefixes/fixAddMissingConstraint.ts
155922
156082
  var fixId17 = "addMissingConstraint";
@@ -161571,6 +161731,14 @@ function tryGetAutoImportableReferenceFromTypeNode(importTypeNode, scriptTarget)
161571
161731
  function visit(node) {
161572
161732
  if (isLiteralImportTypeNode(node) && node.qualifier) {
161573
161733
  const firstIdentifier = getFirstIdentifier(node.qualifier);
161734
+ if (!firstIdentifier.symbol) {
161735
+ return visitEachChild(
161736
+ node,
161737
+ visit,
161738
+ /*context*/
161739
+ void 0
161740
+ );
161741
+ }
161574
161742
  const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
161575
161743
  const qualifier = name !== firstIdentifier.text ? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name)) : node.qualifier;
161576
161744
  symbols = append(symbols, firstIdentifier.symbol);
@@ -162073,7 +162241,7 @@ var errorCodes54 = [Diagnostics.require_call_may_be_converted_to_an_import.code]
162073
162241
  registerCodeFix({
162074
162242
  errorCodes: errorCodes54,
162075
162243
  getCodeActions(context) {
162076
- const info = getInfo18(context.sourceFile, context.program, context.span.start);
162244
+ const info = getInfo18(context.sourceFile, context.program, context.span.start, context.preferences);
162077
162245
  if (!info) {
162078
162246
  return void 0;
162079
162247
  }
@@ -162082,14 +162250,14 @@ registerCodeFix({
162082
162250
  },
162083
162251
  fixIds: [fixId42],
162084
162252
  getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
162085
- const info = getInfo18(diag2.file, context.program, diag2.start);
162253
+ const info = getInfo18(diag2.file, context.program, diag2.start, context.preferences);
162086
162254
  if (info) {
162087
162255
  doChange35(changes, context.sourceFile, info);
162088
162256
  }
162089
162257
  })
162090
162258
  });
162091
162259
  function doChange35(changes, sourceFile, info) {
162092
- const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
162260
+ const { allowSyntheticDefaults, defaultImportName, namedImports, statement, moduleSpecifier } = info;
162093
162261
  changes.replaceNode(
162094
162262
  sourceFile,
162095
162263
  statement,
@@ -162099,7 +162267,7 @@ function doChange35(changes, sourceFile, info) {
162099
162267
  /*isTypeOnly*/
162100
162268
  false,
162101
162269
  defaultImportName,
162102
- factory.createExternalModuleReference(required)
162270
+ factory.createExternalModuleReference(moduleSpecifier)
162103
162271
  ) : factory.createImportDeclaration(
162104
162272
  /*modifiers*/
162105
162273
  void 0,
@@ -162109,13 +162277,13 @@ function doChange35(changes, sourceFile, info) {
162109
162277
  defaultImportName,
162110
162278
  namedImports
162111
162279
  ),
162112
- required,
162280
+ moduleSpecifier,
162113
162281
  /*attributes*/
162114
162282
  void 0
162115
162283
  )
162116
162284
  );
162117
162285
  }
162118
- function getInfo18(sourceFile, program, pos) {
162286
+ function getInfo18(sourceFile, program, pos, preferences) {
162119
162287
  const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
162120
162288
  if (!isRequireCall(
162121
162289
  parent2,
@@ -162125,15 +162293,17 @@ function getInfo18(sourceFile, program, pos) {
162125
162293
  Debug.failBadSyntaxKind(parent2);
162126
162294
  }
162127
162295
  const decl = cast(parent2.parent, isVariableDeclaration);
162296
+ const quotePreference = getQuotePreference(sourceFile, preferences);
162128
162297
  const defaultImportName = tryCast(decl.name, isIdentifier);
162129
162298
  const namedImports = isObjectBindingPattern(decl.name) ? tryCreateNamedImportsFromObjectBindingPattern(decl.name) : void 0;
162130
162299
  if (defaultImportName || namedImports) {
162300
+ const moduleSpecifier = first(parent2.arguments);
162131
162301
  return {
162132
162302
  allowSyntheticDefaults: getAllowSyntheticDefaultImports(program.getCompilerOptions()),
162133
162303
  defaultImportName,
162134
162304
  namedImports,
162135
162305
  statement: cast(decl.parent.parent, isVariableStatement),
162136
- required: first(parent2.arguments)
162306
+ moduleSpecifier: isNoSubstitutionTemplateLiteral(moduleSpecifier) ? factory.createStringLiteral(moduleSpecifier.text, quotePreference === 0 /* Single */) : moduleSpecifier
162137
162307
  };
162138
162308
  }
162139
162309
  }
@@ -163189,10 +163359,12 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
163189
163359
  const printer = isSnippet ? createSnippetPrinter({
163190
163360
  removeComments: true,
163191
163361
  module: options.module,
163362
+ moduleResolution: options.moduleResolution,
163192
163363
  target: options.target
163193
163364
  }) : createPrinter({
163194
163365
  removeComments: true,
163195
163366
  module: options.module,
163367
+ moduleResolution: options.moduleResolution,
163196
163368
  target: options.target
163197
163369
  });
163198
163370
  setEmitFlags(typeNode, 1 /* SingleLine */);
@@ -163448,6 +163620,7 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
163448
163620
  const printer = createSnippetPrinter({
163449
163621
  removeComments: true,
163450
163622
  module: options.module,
163623
+ moduleResolution: options.moduleResolution,
163451
163624
  target: options.target,
163452
163625
  newLine: getNewLineKind(newLineChar)
163453
163626
  });
@@ -163634,7 +163807,7 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
163634
163807
  if (originIsResolvedExport(origin)) {
163635
163808
  sourceDisplay = [textPart(origin.moduleSpecifier)];
163636
163809
  if (importStatementCompletion) {
163637
- ({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences));
163810
+ ({ insertText, replacementSpan } = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, program, preferences));
163638
163811
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : void 0;
163639
163812
  }
163640
163813
  }
@@ -163775,6 +163948,7 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
163775
163948
  const printer = createSnippetPrinter({
163776
163949
  removeComments: true,
163777
163950
  module: options.module,
163951
+ moduleResolution: options.moduleResolution,
163778
163952
  target: options.target,
163779
163953
  omitTrailingSemicolon: false,
163780
163954
  newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
@@ -163925,6 +164099,7 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
163925
164099
  const printer = createSnippetPrinter({
163926
164100
  removeComments: true,
163927
164101
  module: options.module,
164102
+ moduleResolution: options.moduleResolution,
163928
164103
  target: options.target,
163929
164104
  omitTrailingSemicolon: false,
163930
164105
  newLine: getNewLineKind(getNewLineOrDefaultFromHost(host, formatContext == null ? void 0 : formatContext.options))
@@ -163945,6 +164120,7 @@ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclara
163945
164120
  const signaturePrinter = createPrinter({
163946
164121
  removeComments: true,
163947
164122
  module: options.module,
164123
+ moduleResolution: options.moduleResolution,
163948
164124
  target: options.target,
163949
164125
  omitTrailingSemicolon: true
163950
164126
  });
@@ -164206,7 +164382,7 @@ function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbo
164206
164382
  };
164207
164383
  return unresolvedOrigin;
164208
164384
  }
164209
- function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
164385
+ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, program, preferences) {
164210
164386
  const replacementSpan = importStatementCompletion.replacementSpan;
164211
164387
  const quotedModuleSpecifier = escapeSnippetText(quote(sourceFile, preferences, origin.moduleSpecifier));
164212
164388
  const exportKind = origin.isDefaultExport ? 1 /* Default */ : origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */;
@@ -164214,7 +164390,7 @@ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatemen
164214
164390
  const importKind = ts_codefix_exports.getImportKind(
164215
164391
  sourceFile,
164216
164392
  exportKind,
164217
- options,
164393
+ program,
164218
164394
  /*forceImportKeyword*/
164219
164395
  true
164220
164396
  );
@@ -166593,7 +166769,7 @@ function createNameAndKindSet() {
166593
166769
  }
166594
166770
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences, includeSymbol) {
166595
166771
  if (isInReferenceComment(sourceFile, position)) {
166596
- const entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
166772
+ const entries = getTripleSlashReferenceCompletion(sourceFile, position, program, host);
166597
166773
  return entries && convertPathCompletions(entries);
166598
166774
  }
166599
166775
  if (isInString(sourceFile, position, contextToken)) {
@@ -166916,7 +167092,7 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, prog
166916
167092
  const compilerOptions = program.getCompilerOptions();
166917
167093
  const typeChecker = program.getTypeChecker();
166918
167094
  const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
166919
- return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, extensionOptions, typeChecker);
167095
+ return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, program, host, extensionOptions);
166920
167096
  }
166921
167097
  function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile, typeChecker, preferences, resolutionMode) {
166922
167098
  return {
@@ -166927,14 +167103,15 @@ function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile
166927
167103
  resolutionMode
166928
167104
  };
166929
167105
  }
166930
- function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) {
167106
+ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) {
167107
+ const compilerOptions = program.getCompilerOptions();
166931
167108
  if (compilerOptions.rootDirs) {
166932
167109
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(
166933
167110
  compilerOptions.rootDirs,
166934
167111
  literalValue,
166935
167112
  scriptDirectory,
166936
167113
  extensionOptions,
166937
- compilerOptions,
167114
+ program,
166938
167115
  host,
166939
167116
  scriptPath
166940
167117
  );
@@ -166943,6 +167120,7 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, c
166943
167120
  literalValue,
166944
167121
  scriptDirectory,
166945
167122
  extensionOptions,
167123
+ program,
166946
167124
  host,
166947
167125
  /*moduleSpecifierIsRelative*/
166948
167126
  true,
@@ -166969,7 +167147,8 @@ function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ign
166969
167147
  compareStringsCaseSensitive
166970
167148
  );
166971
167149
  }
166972
- function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) {
167150
+ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, program, host, exclude) {
167151
+ const compilerOptions = program.getCompilerOptions();
166973
167152
  const basePath = compilerOptions.project || host.getCurrentDirectory();
166974
167153
  const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
166975
167154
  const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
@@ -166978,6 +167157,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
166978
167157
  fragment,
166979
167158
  baseDirectory,
166980
167159
  extensionOptions,
167160
+ program,
166981
167161
  host,
166982
167162
  /*moduleSpecifierIsRelative*/
166983
167163
  true,
@@ -166986,7 +167166,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
166986
167166
  (itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
166987
167167
  );
166988
167168
  }
166989
- function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
167169
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
166990
167170
  var _a;
166991
167171
  if (fragment === void 0) {
166992
167172
  fragment = "";
@@ -167011,7 +167191,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
167011
167191
  if (versionPaths) {
167012
167192
  const packageDirectory = getDirectoryPath(packageJsonPath);
167013
167193
  const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
167014
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
167194
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, program, host, versionPaths)) {
167015
167195
  return result;
167016
167196
  }
167017
167197
  }
@@ -167037,7 +167217,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
167037
167217
  }
167038
167218
  const { name, extension } = getFilenameWithExtensionOption(
167039
167219
  getBaseFileName(filePath),
167040
- host.getCompilationSettings(),
167220
+ program,
167041
167221
  extensionOptions,
167042
167222
  /*isExportsWildcard*/
167043
167223
  false
@@ -167056,7 +167236,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
167056
167236
  }
167057
167237
  return result;
167058
167238
  }
167059
- function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions, isExportsWildcard) {
167239
+ function getFilenameWithExtensionOption(name, program, extensionOptions, isExportsWildcard) {
167060
167240
  const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
167061
167241
  if (nonJsResult) {
167062
167242
  return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
@@ -167066,7 +167246,8 @@ function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions,
167066
167246
  }
167067
167247
  let allowedEndings = getModuleSpecifierPreferences(
167068
167248
  { importModuleSpecifierEnding: extensionOptions.endingPreference },
167069
- compilerOptions,
167249
+ program,
167250
+ program.getCompilerOptions(),
167070
167251
  extensionOptions.importingSourceFile
167071
167252
  ).getAllowedEndingsInPreferredOrder(extensionOptions.resolutionMode);
167072
167253
  if (isExportsWildcard) {
@@ -167076,16 +167257,16 @@ function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions,
167076
167257
  if (fileExtensionIsOneOf(name, supportedTSImplementationExtensions)) {
167077
167258
  return { name, extension: tryGetExtensionFromPath2(name) };
167078
167259
  }
167079
- const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
167260
+ const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
167080
167261
  return outputExtension2 ? { name: changeExtension(name, outputExtension2), extension: outputExtension2 } : { name, extension: tryGetExtensionFromPath2(name) };
167081
167262
  }
167082
167263
  if (!isExportsWildcard && (allowedEndings[0] === 0 /* Minimal */ || allowedEndings[0] === 1 /* Index */) && fileExtensionIsOneOf(name, [".js" /* Js */, ".jsx" /* Jsx */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */])) {
167083
167264
  return { name: removeFileExtension(name), extension: tryGetExtensionFromPath2(name) };
167084
167265
  }
167085
- const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, compilerOptions);
167266
+ const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
167086
167267
  return outputExtension ? { name: changeExtension(name, outputExtension), extension: outputExtension } : { name, extension: tryGetExtensionFromPath2(name) };
167087
167268
  }
167088
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
167269
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, program, host, paths) {
167089
167270
  const getPatternsForKey = (key) => paths[key];
167090
167271
  const comparePaths2 = (a, b) => {
167091
167272
  const patternA = tryParsePattern(a);
@@ -167101,13 +167282,14 @@ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensio
167101
167282
  fragment,
167102
167283
  baseDirectory,
167103
167284
  extensionOptions,
167285
+ program,
167104
167286
  host,
167105
167287
  getOwnKeys(paths),
167106
167288
  getPatternsForKey,
167107
167289
  comparePaths2
167108
167290
  );
167109
167291
  }
167110
- function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths2) {
167292
+ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, baseDirectory, extensionOptions, program, host, keys, getPatternsForKey, comparePaths2) {
167111
167293
  let pathResults = [];
167112
167294
  let matchedPath;
167113
167295
  for (const key of keys) {
@@ -167126,7 +167308,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
167126
167308
  if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(key, matchedPath) !== 1 /* GreaterThan */) {
167127
167309
  pathResults.push({
167128
167310
  matchedPattern: isMatch,
167129
- results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports && isMatch, host).map(({ name, kind, extension }) => nameAndKind(name, kind, extension))
167311
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports && isMatch, program, host).map(({ name, kind, extension }) => nameAndKind(name, kind, extension))
167130
167312
  });
167131
167313
  }
167132
167314
  }
@@ -167134,7 +167316,9 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
167134
167316
  pathResults.forEach((pathResult) => pathResult.results.forEach((r) => result.add(r)));
167135
167317
  return matchedPath !== void 0;
167136
167318
  }
167137
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, extensionOptions, typeChecker) {
167319
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, program, host, extensionOptions) {
167320
+ const typeChecker = program.getTypeChecker();
167321
+ const compilerOptions = program.getCompilerOptions();
167138
167322
  const { baseUrl, paths } = compilerOptions;
167139
167323
  const result = createNameAndKindSet();
167140
167324
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
@@ -167144,6 +167328,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
167144
167328
  fragment,
167145
167329
  absolute,
167146
167330
  extensionOptions,
167331
+ program,
167147
167332
  host,
167148
167333
  /*moduleSpecifierIsRelative*/
167149
167334
  false,
@@ -167154,7 +167339,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
167154
167339
  }
167155
167340
  if (paths) {
167156
167341
  const absolute = getPathsBasePath(compilerOptions, host);
167157
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
167342
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, program, host, paths);
167158
167343
  }
167159
167344
  const fragmentDirectory = getFragmentDirectory(fragment);
167160
167345
  for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
@@ -167165,7 +167350,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
167165
167350
  void 0
167166
167351
  ));
167167
167352
  }
167168
- getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
167353
+ getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDirectory, extensionOptions, result);
167169
167354
  if (moduleResolutionUsesNodeModules(moduleResolution)) {
167170
167355
  let foundGlobal = false;
167171
167356
  if (fragmentDirectory === void 0) {
@@ -167190,6 +167375,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
167190
167375
  fragment,
167191
167376
  nodeModules,
167192
167377
  extensionOptions,
167378
+ program,
167193
167379
  host,
167194
167380
  /*moduleSpecifierIsRelative*/
167195
167381
  false,
@@ -167234,6 +167420,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
167234
167420
  fragmentSubpath,
167235
167421
  packageDirectory,
167236
167422
  extensionOptions,
167423
+ program,
167237
167424
  host,
167238
167425
  keys,
167239
167426
  (key) => singleElementArray(getPatternFromFirstMatchingCondition(exports2[key], conditions)),
@@ -167266,7 +167453,7 @@ function getPatternFromFirstMatchingCondition(target, conditions) {
167266
167453
  function getFragmentDirectory(fragment) {
167267
167454
  return containsSlash(fragment) ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
167268
167455
  }
167269
- function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard, host) {
167456
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExportsWildcard, program, host) {
167270
167457
  if (!endsWith(path, "*")) {
167271
167458
  return !path.includes("*") ? justPathMappingName(path, "script" /* scriptElement */) : emptyArray;
167272
167459
  }
@@ -167276,15 +167463,15 @@ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory
167276
167463
  const starIsFullPathComponent = path[path.length - 2] === "/";
167277
167464
  return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : flatMap(patterns, (pattern) => {
167278
167465
  var _a;
167279
- return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExportsWildcard, host)) == null ? void 0 : _a.map(({ name, ...rest }) => ({ name: pathPrefix + name, ...rest }));
167466
+ return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExportsWildcard, program, host)) == null ? void 0 : _a.map(({ name, ...rest }) => ({ name: pathPrefix + name, ...rest }));
167280
167467
  });
167281
167468
  }
167282
- return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host));
167469
+ return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, program, host));
167283
167470
  function justPathMappingName(name, kind) {
167284
167471
  return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: void 0 }] : emptyArray;
167285
167472
  }
167286
167473
  }
167287
- function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, host) {
167474
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExportsWildcard, program, host) {
167288
167475
  if (!host.readDirectory) {
167289
167476
  return void 0;
167290
167477
  }
@@ -167317,7 +167504,7 @@ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensio
167317
167504
  if (containsSlash(trimmedWithPattern)) {
167318
167505
  return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
167319
167506
  }
167320
- const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions, isExportsWildcard);
167507
+ const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, program, extensionOptions, isExportsWildcard);
167321
167508
  return nameAndKind(name, "script" /* scriptElement */, extension);
167322
167509
  }
167323
167510
  });
@@ -167345,7 +167532,8 @@ function getAmbientModuleCompletions(fragment, fragmentDirectory, checker) {
167345
167532
  }
167346
167533
  return nonRelativeModuleNames;
167347
167534
  }
167348
- function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) {
167535
+ function getTripleSlashReferenceCompletion(sourceFile, position, program, host) {
167536
+ const compilerOptions = program.getCompilerOptions();
167349
167537
  const token = getTokenAtPosition(sourceFile, position);
167350
167538
  const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
167351
167539
  const range = commentRanges && find(commentRanges, (commentRange) => position >= commentRange.pos && position <= commentRange.end);
@@ -167363,14 +167551,16 @@ function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions
167363
167551
  toComplete,
167364
167552
  scriptPath,
167365
167553
  getExtensionOptions(compilerOptions, 0 /* Filename */, sourceFile),
167554
+ program,
167366
167555
  host,
167367
167556
  /*moduleSpecifierIsRelative*/
167368
167557
  true,
167369
167558
  sourceFile.path
167370
- ) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
167559
+ ) : kind === "types" ? getCompletionEntriesFromTypings(host, program, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
167371
167560
  return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
167372
167561
  }
167373
- function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
167562
+ function getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
167563
+ const options = program.getCompilerOptions();
167374
167564
  const seen = /* @__PURE__ */ new Map();
167375
167565
  const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
167376
167566
  for (const root of typeRoots) {
@@ -167404,6 +167594,7 @@ function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDire
167404
167594
  remainingFragment,
167405
167595
  baseDirectory,
167406
167596
  extensionOptions,
167597
+ program,
167407
167598
  host,
167408
167599
  /*moduleSpecifierIsRelative*/
167409
167600
  false,
@@ -178736,6 +178927,7 @@ __export(ts_exports2, {
178736
178927
  canHaveJSDoc: () => canHaveJSDoc,
178737
178928
  canHaveLocals: () => canHaveLocals,
178738
178929
  canHaveModifiers: () => canHaveModifiers,
178930
+ canHaveModuleSpecifier: () => canHaveModuleSpecifier,
178739
178931
  canHaveSymbol: () => canHaveSymbol,
178740
178932
  canIncludeBindAndCheckDiagnostics: () => canIncludeBindAndCheckDiagnostics,
178741
178933
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
@@ -178898,6 +179090,7 @@ __export(ts_exports2, {
178898
179090
  createMemberAccessForPropertyName: () => createMemberAccessForPropertyName,
178899
179091
  createModeAwareCache: () => createModeAwareCache,
178900
179092
  createModeAwareCacheKey: () => createModeAwareCacheKey,
179093
+ createModeMismatchDetails: () => createModeMismatchDetails,
178901
179094
  createModuleNotFoundChain: () => createModuleNotFoundChain,
178902
179095
  createModuleResolutionCache: () => createModuleResolutionCache,
178903
179096
  createModuleResolutionLoader: () => createModuleResolutionLoader,
@@ -179179,6 +179372,7 @@ __export(ts_exports2, {
179179
179372
  getDefaultLibFilePath: () => getDefaultLibFilePath,
179180
179373
  getDefaultLikeExportInfo: () => getDefaultLikeExportInfo,
179181
179374
  getDefaultLikeExportNameFromDeclaration: () => getDefaultLikeExportNameFromDeclaration,
179375
+ getDefaultResolutionModeForFileWorker: () => getDefaultResolutionModeForFileWorker,
179182
179376
  getDiagnosticText: () => getDiagnosticText,
179183
179377
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
179184
179378
  getDirectoryPath: () => getDirectoryPath,
@@ -179209,6 +179403,7 @@ __export(ts_exports2, {
179209
179403
  getEmitFlags: () => getEmitFlags,
179210
179404
  getEmitHelpers: () => getEmitHelpers,
179211
179405
  getEmitModuleDetectionKind: () => getEmitModuleDetectionKind,
179406
+ getEmitModuleFormatOfFileWorker: () => getEmitModuleFormatOfFileWorker,
179212
179407
  getEmitModuleKind: () => getEmitModuleKind,
179213
179408
  getEmitModuleResolutionKind: () => getEmitModuleResolutionKind,
179214
179409
  getEmitScriptTarget: () => getEmitScriptTarget,
@@ -179259,6 +179454,7 @@ __export(ts_exports2, {
179259
179454
  getIdentifierGeneratedImportReference: () => getIdentifierGeneratedImportReference,
179260
179455
  getIdentifierTypeArguments: () => getIdentifierTypeArguments,
179261
179456
  getImmediatelyInvokedFunctionExpression: () => getImmediatelyInvokedFunctionExpression,
179457
+ getImpliedNodeFormatForEmitWorker: () => getImpliedNodeFormatForEmitWorker,
179262
179458
  getImpliedNodeFormatForFile: () => getImpliedNodeFormatForFile,
179263
179459
  getImpliedNodeFormatForFileWorker: () => getImpliedNodeFormatForFileWorker,
179264
179460
  getImportNeedsImportDefaultHelper: () => getImportNeedsImportDefaultHelper,
@@ -179364,7 +179560,6 @@ __export(ts_exports2, {
179364
179560
  getNameOfScriptTarget: () => getNameOfScriptTarget,
179365
179561
  getNameOrArgument: () => getNameOrArgument,
179366
179562
  getNameTable: () => getNameTable,
179367
- getNamesForExportedSymbol: () => getNamesForExportedSymbol,
179368
179563
  getNamespaceDeclarationNode: () => getNamespaceDeclarationNode,
179369
179564
  getNewLineCharacter: () => getNewLineCharacter,
179370
179565
  getNewLineKind: () => getNewLineKind,
@@ -179601,6 +179796,7 @@ __export(ts_exports2, {
179601
179796
  ignoreSourceNewlines: () => ignoreSourceNewlines,
179602
179797
  ignoredPaths: () => ignoredPaths,
179603
179798
  importFromModuleSpecifier: () => importFromModuleSpecifier,
179799
+ importSyntaxAffectsModuleResolution: () => importSyntaxAffectsModuleResolution,
179604
179800
  indexOfAnyCharCode: () => indexOfAnyCharCode,
179605
179801
  indexOfNode: () => indexOfNode,
179606
179802
  indicesOf: () => indicesOf,
@@ -180646,11 +180842,11 @@ __export(ts_exports2, {
180646
180842
  transformESDecorators: () => transformESDecorators,
180647
180843
  transformESNext: () => transformESNext,
180648
180844
  transformGenerators: () => transformGenerators,
180845
+ transformImpliedNodeFormatDependentModule: () => transformImpliedNodeFormatDependentModule,
180649
180846
  transformJsx: () => transformJsx,
180650
180847
  transformLegacyDecorators: () => transformLegacyDecorators,
180651
180848
  transformModule: () => transformModule,
180652
180849
  transformNamedEvaluation: () => transformNamedEvaluation,
180653
- transformNodeModule: () => transformNodeModule,
180654
180850
  transformNodes: () => transformNodes,
180655
180851
  transformSystemModule: () => transformSystemModule,
180656
180852
  transformTypeScript: () => transformTypeScript,
@@ -181521,7 +181717,7 @@ __export(ts_server_protocol_exports, {
181521
181717
  NewLineKind: () => NewLineKind2,
181522
181718
  OrganizeImportsMode: () => OrganizeImportsMode,
181523
181719
  PollingWatchKind: () => PollingWatchKind2,
181524
- ScriptTarget: () => ScriptTarget10,
181720
+ ScriptTarget: () => ScriptTarget11,
181525
181721
  SemicolonPreference: () => SemicolonPreference,
181526
181722
  WatchDirectoryKind: () => WatchDirectoryKind2,
181527
181723
  WatchFileKind: () => WatchFileKind2
@@ -181712,24 +181908,24 @@ var NewLineKind2 = /* @__PURE__ */ ((NewLineKind3) => {
181712
181908
  NewLineKind3["Lf"] = "Lf";
181713
181909
  return NewLineKind3;
181714
181910
  })(NewLineKind2 || {});
181715
- var ScriptTarget10 = /* @__PURE__ */ ((ScriptTarget11) => {
181716
- ScriptTarget11["ES3"] = "es3";
181717
- ScriptTarget11["ES5"] = "es5";
181718
- ScriptTarget11["ES6"] = "es6";
181719
- ScriptTarget11["ES2015"] = "es2015";
181720
- ScriptTarget11["ES2016"] = "es2016";
181721
- ScriptTarget11["ES2017"] = "es2017";
181722
- ScriptTarget11["ES2018"] = "es2018";
181723
- ScriptTarget11["ES2019"] = "es2019";
181724
- ScriptTarget11["ES2020"] = "es2020";
181725
- ScriptTarget11["ES2021"] = "es2021";
181726
- ScriptTarget11["ES2022"] = "es2022";
181727
- ScriptTarget11["ES2023"] = "es2023";
181728
- ScriptTarget11["ESNext"] = "esnext";
181729
- ScriptTarget11["JSON"] = "json";
181730
- ScriptTarget11["Latest"] = "esnext" /* ESNext */;
181731
- return ScriptTarget11;
181732
- })(ScriptTarget10 || {});
181911
+ var ScriptTarget11 = /* @__PURE__ */ ((ScriptTarget12) => {
181912
+ ScriptTarget12["ES3"] = "es3";
181913
+ ScriptTarget12["ES5"] = "es5";
181914
+ ScriptTarget12["ES6"] = "es6";
181915
+ ScriptTarget12["ES2015"] = "es2015";
181916
+ ScriptTarget12["ES2016"] = "es2016";
181917
+ ScriptTarget12["ES2017"] = "es2017";
181918
+ ScriptTarget12["ES2018"] = "es2018";
181919
+ ScriptTarget12["ES2019"] = "es2019";
181920
+ ScriptTarget12["ES2020"] = "es2020";
181921
+ ScriptTarget12["ES2021"] = "es2021";
181922
+ ScriptTarget12["ES2022"] = "es2022";
181923
+ ScriptTarget12["ES2023"] = "es2023";
181924
+ ScriptTarget12["ESNext"] = "esnext";
181925
+ ScriptTarget12["JSON"] = "json";
181926
+ ScriptTarget12["Latest"] = "esnext" /* ESNext */;
181927
+ return ScriptTarget12;
181928
+ })(ScriptTarget11 || {});
181733
181929
  {
181734
181930
  }
181735
181931
 
@@ -190217,7 +190413,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
190217
190413
  const packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
190218
190414
  const packageJsonCache = (_a2 = project.getModuleResolutionCache()) == null ? void 0 : _a2.getPackageJsonInfoCache();
190219
190415
  const compilerOptions = project.getCompilationSettings();
190220
- const packageJson = getPackageScopeForPath(getNormalizedAbsolutePath(packageDirectory + "/package.json", project.getCurrentDirectory()), getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
190416
+ const packageJson = getPackageScopeForPath(getNormalizedAbsolutePath(packageDirectory, project.getCurrentDirectory()), getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
190221
190417
  if (!packageJson) return void 0;
190222
190418
  const entrypoints = getEntrypointsFromPackageJsonInfo(
190223
190419
  packageJson,
@@ -193094,6 +193290,7 @@ if (typeof console !== "undefined") {
193094
193290
  canHaveJSDoc,
193095
193291
  canHaveLocals,
193096
193292
  canHaveModifiers,
193293
+ canHaveModuleSpecifier,
193097
193294
  canHaveSymbol,
193098
193295
  canIncludeBindAndCheckDiagnostics,
193099
193296
  canJsonReportNoInputFiles,
@@ -193256,6 +193453,7 @@ if (typeof console !== "undefined") {
193256
193453
  createMemberAccessForPropertyName,
193257
193454
  createModeAwareCache,
193258
193455
  createModeAwareCacheKey,
193456
+ createModeMismatchDetails,
193259
193457
  createModuleNotFoundChain,
193260
193458
  createModuleResolutionCache,
193261
193459
  createModuleResolutionLoader,
@@ -193537,6 +193735,7 @@ if (typeof console !== "undefined") {
193537
193735
  getDefaultLibFilePath,
193538
193736
  getDefaultLikeExportInfo,
193539
193737
  getDefaultLikeExportNameFromDeclaration,
193738
+ getDefaultResolutionModeForFileWorker,
193540
193739
  getDiagnosticText,
193541
193740
  getDiagnosticsWithinSpan,
193542
193741
  getDirectoryPath,
@@ -193567,6 +193766,7 @@ if (typeof console !== "undefined") {
193567
193766
  getEmitFlags,
193568
193767
  getEmitHelpers,
193569
193768
  getEmitModuleDetectionKind,
193769
+ getEmitModuleFormatOfFileWorker,
193570
193770
  getEmitModuleKind,
193571
193771
  getEmitModuleResolutionKind,
193572
193772
  getEmitScriptTarget,
@@ -193617,6 +193817,7 @@ if (typeof console !== "undefined") {
193617
193817
  getIdentifierGeneratedImportReference,
193618
193818
  getIdentifierTypeArguments,
193619
193819
  getImmediatelyInvokedFunctionExpression,
193820
+ getImpliedNodeFormatForEmitWorker,
193620
193821
  getImpliedNodeFormatForFile,
193621
193822
  getImpliedNodeFormatForFileWorker,
193622
193823
  getImportNeedsImportDefaultHelper,
@@ -193722,7 +193923,6 @@ if (typeof console !== "undefined") {
193722
193923
  getNameOfScriptTarget,
193723
193924
  getNameOrArgument,
193724
193925
  getNameTable,
193725
- getNamesForExportedSymbol,
193726
193926
  getNamespaceDeclarationNode,
193727
193927
  getNewLineCharacter,
193728
193928
  getNewLineKind,
@@ -193959,6 +194159,7 @@ if (typeof console !== "undefined") {
193959
194159
  ignoreSourceNewlines,
193960
194160
  ignoredPaths,
193961
194161
  importFromModuleSpecifier,
194162
+ importSyntaxAffectsModuleResolution,
193962
194163
  indexOfAnyCharCode,
193963
194164
  indexOfNode,
193964
194165
  indicesOf,
@@ -195004,11 +195205,11 @@ if (typeof console !== "undefined") {
195004
195205
  transformESDecorators,
195005
195206
  transformESNext,
195006
195207
  transformGenerators,
195208
+ transformImpliedNodeFormatDependentModule,
195007
195209
  transformJsx,
195008
195210
  transformLegacyDecorators,
195009
195211
  transformModule,
195010
195212
  transformNamedEvaluation,
195011
- transformNodeModule,
195012
195213
  transformNodes,
195013
195214
  transformSystemModule,
195014
195215
  transformTypeScript,