typescript 5.0.0-dev.20230109 → 5.0.0-dev.20230110

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/tsserver.js CHANGED
@@ -2010,7 +2010,6 @@ __export(server_exports, {
2010
2010
  moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
2011
2011
  moduleResolutionOptionDeclarations: () => moduleResolutionOptionDeclarations,
2012
2012
  moduleResolutionSupportsPackageJsonExportsAndImports: () => moduleResolutionSupportsPackageJsonExportsAndImports,
2013
- moduleResolutionSupportsResolvingTsExtensions: () => moduleResolutionSupportsResolvingTsExtensions,
2014
2013
  moduleResolutionUsesNodeModules: () => moduleResolutionUsesNodeModules,
2015
2014
  moduleSpecifiers: () => ts_moduleSpecifiers_exports,
2016
2015
  moveEmitHelpers: () => moveEmitHelpers,
@@ -2662,7 +2661,7 @@ __export(ts_server_exports3, {
2662
2661
 
2663
2662
  // src/compiler/corePublic.ts
2664
2663
  var versionMajorMinor = "5.0";
2665
- var version = `${versionMajorMinor}.0-dev.20230109`;
2664
+ var version = `${versionMajorMinor}.0-dev.20230110`;
2666
2665
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2667
2666
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2668
2667
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -10939,6 +10938,9 @@ var Diagnostics = {
10939
10938
  Found_1_error_in_1: diag(6259, 3 /* Message */, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
10940
10939
  Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, 3 /* Message */, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
10941
10940
  Found_0_errors_in_1_files: diag(6261, 3 /* Message */, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
10941
+ File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
10942
+ Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
10943
+ Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
10942
10944
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
10943
10945
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
10944
10946
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -18484,13 +18486,13 @@ function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirect
18484
18486
  return removeFileExtension(path) + declarationExtension;
18485
18487
  }
18486
18488
  function getDeclarationEmitExtensionForPath(path) {
18487
- return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.json.d.ts` : (
18489
+ return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.d.json.ts` : (
18488
18490
  // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
18489
18491
  ".d.ts" /* Dts */
18490
18492
  );
18491
18493
  }
18492
18494
  function getPossibleOriginalInputExtensionForExtension(path) {
18493
- return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.json.d.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
18495
+ return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
18494
18496
  }
18495
18497
  function outFile(options) {
18496
18498
  return options.outFile || options.out;
@@ -20574,7 +20576,7 @@ function positionIsSynthesized(pos) {
20574
20576
  return !(pos >= 0);
20575
20577
  }
20576
20578
  function extensionIsTS(ext) {
20577
- return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */;
20579
+ return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */ || startsWith(ext, ".d.") && endsWith(ext, ".ts");
20578
20580
  }
20579
20581
  function resolutionExtensionIsTSOrJson(ext) {
20580
20582
  return extensionIsTS(ext) || ext === ".json" /* Json */;
@@ -36733,7 +36735,7 @@ var IncrementalParser;
36733
36735
  })(InvalidPosition || (InvalidPosition = {}));
36734
36736
  })(IncrementalParser || (IncrementalParser = {}));
36735
36737
  function isDeclarationFileName(fileName) {
36736
- return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions);
36738
+ return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions) || fileExtensionIs(fileName, ".ts" /* Ts */) && stringContains(getBaseFileName(fileName), ".d.");
36737
36739
  }
36738
36740
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
36739
36741
  if (!mode) {
@@ -37991,6 +37993,14 @@ var commandOptionsWithoutBuild = [
37991
37993
  description: Diagnostics.Enable_importing_json_files,
37992
37994
  defaultValueDescription: false
37993
37995
  },
37996
+ {
37997
+ name: "allowArbitraryExtensions",
37998
+ type: "boolean",
37999
+ affectsModuleResolution: true,
38000
+ category: Diagnostics.Modules,
38001
+ description: Diagnostics.Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present,
38002
+ defaultValueDescription: false
38003
+ },
37994
38004
  {
37995
38005
  name: "out",
37996
38006
  type: "string",
@@ -41527,14 +41537,19 @@ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
41527
41537
  }
41528
41538
  }
41529
41539
  function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
41530
- if (hasJSFileExtension(candidate) || extensions & 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */) || extensions & (1 /* TypeScript */ | 4 /* Declaration */) && moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) {
41531
- const extensionless = removeFileExtension(candidate);
41532
- const extension = candidate.substring(extensionless.length);
41533
- if (state.traceEnabled) {
41534
- trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
41535
- }
41536
- return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
41540
+ const filename = getBaseFileName(candidate);
41541
+ if (filename.indexOf(".") === -1) {
41542
+ return void 0;
41537
41543
  }
41544
+ let extensionless = removeFileExtension(candidate);
41545
+ if (extensionless === candidate) {
41546
+ extensionless = candidate.substring(0, candidate.lastIndexOf("."));
41547
+ }
41548
+ const extension = candidate.substring(extensionless.length);
41549
+ if (state.traceEnabled) {
41550
+ trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
41551
+ }
41552
+ return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
41538
41553
  }
41539
41554
  function loadFileNameFromPackageJsonField(extensions, candidate, onlyRecordFailures, state) {
41540
41555
  if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
@@ -41558,38 +41573,23 @@ function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecor
41558
41573
  case ".mjs" /* Mjs */:
41559
41574
  case ".mts" /* Mts */:
41560
41575
  case ".d.mts" /* Dmts */:
41561
- return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
41576
+ return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
41562
41577
  case ".cjs" /* Cjs */:
41563
41578
  case ".cts" /* Cts */:
41564
41579
  case ".d.cts" /* Dcts */:
41565
- return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
41580
+ return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
41566
41581
  case ".json" /* Json */:
41567
- const originalCandidate = candidate;
41568
- if (extensions & 4 /* Declaration */) {
41569
- candidate += ".json" /* Json */;
41570
- const result = tryExtension(".d.ts" /* Dts */);
41571
- if (result)
41572
- return result;
41573
- }
41574
- if (extensions & 8 /* Json */) {
41575
- candidate = originalCandidate;
41576
- const result = tryExtension(".json" /* Json */);
41577
- if (result)
41578
- return result;
41579
- }
41580
- return void 0;
41581
- case ".ts" /* Ts */:
41582
+ return extensions & 4 /* Declaration */ && tryExtension(".d.json.ts") || extensions & 8 /* Json */ && tryExtension(".json" /* Json */) || void 0;
41582
41583
  case ".tsx" /* Tsx */:
41584
+ case ".jsx" /* Jsx */:
41585
+ return extensions & 1 /* TypeScript */ && (tryExtension(".tsx" /* Tsx */, originalExtension === ".tsx" /* Tsx */) || tryExtension(".ts" /* Ts */, originalExtension === ".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".tsx" /* Tsx */) || extensions & 2 /* JavaScript */ && (tryExtension(".jsx" /* Jsx */) || tryExtension(".js" /* Js */)) || void 0;
41586
+ case ".ts" /* Ts */:
41583
41587
  case ".d.ts" /* Dts */:
41584
- if (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && extensionIsOk(extensions, originalExtension)) {
41585
- return tryExtension(
41586
- originalExtension,
41587
- /*resolvedUsingTsExtension*/
41588
- true
41589
- );
41590
- }
41588
+ case ".js" /* Js */:
41589
+ case "":
41590
+ return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || tryExtension(".tsx" /* Tsx */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
41591
41591
  default:
41592
- return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
41592
+ return extensions & 4 /* Declaration */ && !isDeclarationFileName(candidate + originalExtension) && tryExtension(`.d${originalExtension}.ts`) || void 0;
41593
41593
  }
41594
41594
  function tryExtension(ext, resolvedUsingTsExtension) {
41595
41595
  const path = tryFile(candidate + ext, onlyRecordFailures, state);
@@ -42629,11 +42629,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
42629
42629
  }
42630
42630
  }
42631
42631
  }
42632
- function moduleResolutionSupportsResolvingTsExtensions(compilerOptions) {
42633
- return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */;
42634
- }
42635
42632
  function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
42636
- return moduleResolutionSupportsResolvingTsExtensions(compilerOptions) && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
42633
+ return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
42637
42634
  }
42638
42635
  function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) {
42639
42636
  const traceEnabled = isTraceEnabled(compilerOptions, host);
@@ -45719,6 +45716,7 @@ __export(ts_moduleSpecifiers_exports, {
45719
45716
  getNodeModulesPackageName: () => getNodeModulesPackageName,
45720
45717
  tryGetJSExtensionForFile: () => tryGetJSExtensionForFile,
45721
45718
  tryGetModuleSpecifiersFromCache: () => tryGetModuleSpecifiersFromCache,
45719
+ tryGetRealFileNameForNonJsDeclarationFileName: () => tryGetRealFileNameForNonJsDeclarationFileName,
45722
45720
  updateModuleSpecifier: () => updateModuleSpecifier
45723
45721
  });
45724
45722
 
@@ -46376,6 +46374,8 @@ function processEnding(fileName, allowedEndings, options, host) {
46376
46374
  }
46377
46375
  if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
46378
46376
  return noExtension + getJSExtensionForFile(fileName, options);
46377
+ } else if (!fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */]) && fileExtensionIsOneOf(fileName, [".ts" /* Ts */]) && stringContains(fileName, ".d.")) {
46378
+ return tryGetRealFileNameForNonJsDeclarationFileName(fileName);
46379
46379
  }
46380
46380
  switch (allowedEndings[0]) {
46381
46381
  case 0 /* Minimal */:
@@ -46399,6 +46399,14 @@ function processEnding(fileName, allowedEndings, options, host) {
46399
46399
  return Debug.assertNever(allowedEndings[0]);
46400
46400
  }
46401
46401
  }
46402
+ function tryGetRealFileNameForNonJsDeclarationFileName(fileName) {
46403
+ const baseName = getBaseFileName(fileName);
46404
+ if (!endsWith(fileName, ".ts" /* Ts */) || !stringContains(baseName, ".d.") || fileExtensionIsOneOf(baseName, [".d.ts" /* Dts */]))
46405
+ return void 0;
46406
+ const noExtension = removeExtension(fileName, ".ts" /* Ts */);
46407
+ const ext = noExtension.substring(noExtension.lastIndexOf("."));
46408
+ return noExtension.substring(0, noExtension.indexOf(".d.")) + ext;
46409
+ }
46402
46410
  function getJSExtensionForFile(fileName, options) {
46403
46411
  var _a2;
46404
46412
  return (_a2 = tryGetJSExtensionForFile(fileName, options)) != null ? _a2 : Debug.fail(`Extension ${extensionFromPath(fileName)} is unsupported:: FileName:: ${fileName}`);
@@ -48824,7 +48832,7 @@ function createTypeChecker(host) {
48824
48832
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
48825
48833
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
48826
48834
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
48827
- if (hasExportAssignmentSymbol(moduleSymbol)) {
48835
+ if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
48828
48836
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
48829
48837
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
48830
48838
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -49619,7 +49627,7 @@ function createTypeChecker(host) {
49619
49627
  const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49620
49628
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
49621
49629
  const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode);
49622
- const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
49630
+ const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
49623
49631
  const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
49624
49632
  if (sourceFile) {
49625
49633
  if (resolutionDiagnostic) {
@@ -53573,7 +53581,9 @@ function createTypeChecker(host) {
53573
53581
  case 267 /* NamespaceExportDeclaration */:
53574
53582
  addResult(factory.createNamespaceExportDeclaration(idText(node.name)), 0 /* None */);
53575
53583
  break;
53576
- case 270 /* ImportClause */:
53584
+ case 270 /* ImportClause */: {
53585
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53586
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
53577
53587
  addResult(factory.createImportDeclaration(
53578
53588
  /*modifiers*/
53579
53589
  void 0,
@@ -53584,15 +53594,14 @@ function createTypeChecker(host) {
53584
53594
  /*namedBindings*/
53585
53595
  void 0
53586
53596
  ),
53587
- // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned
53588
- // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag
53589
- // In such cases, the `target` refers to the module itself already
53590
- factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
53591
- /*assertClause*/
53592
- void 0
53597
+ specifier2,
53598
+ node.parent.assertClause
53593
53599
  ), 0 /* None */);
53594
53600
  break;
53595
- case 271 /* NamespaceImport */:
53601
+ }
53602
+ case 271 /* NamespaceImport */: {
53603
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53604
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
53596
53605
  addResult(factory.createImportDeclaration(
53597
53606
  /*modifiers*/
53598
53607
  void 0,
@@ -53603,11 +53612,11 @@ function createTypeChecker(host) {
53603
53612
  void 0,
53604
53613
  factory.createNamespaceImport(factory.createIdentifier(localName))
53605
53614
  ),
53606
- factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)),
53607
- /*assertClause*/
53608
- void 0
53615
+ specifier2,
53616
+ node.parent.parent.assertClause
53609
53617
  ), 0 /* None */);
53610
53618
  break;
53619
+ }
53611
53620
  case 277 /* NamespaceExport */:
53612
53621
  addResult(factory.createExportDeclaration(
53613
53622
  /*modifiers*/
@@ -53618,7 +53627,9 @@ function createTypeChecker(host) {
53618
53627
  factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))
53619
53628
  ), 0 /* None */);
53620
53629
  break;
53621
- case 273 /* ImportSpecifier */:
53630
+ case 273 /* ImportSpecifier */: {
53631
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
53632
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
53622
53633
  addResult(factory.createImportDeclaration(
53623
53634
  /*modifiers*/
53624
53635
  void 0,
@@ -53636,11 +53647,11 @@ function createTypeChecker(host) {
53636
53647
  )
53637
53648
  ])
53638
53649
  ),
53639
- factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
53640
- /*assertClause*/
53641
- void 0
53650
+ specifier2,
53651
+ node.parent.parent.parent.assertClause
53642
53652
  ), 0 /* None */);
53643
53653
  break;
53654
+ }
53644
53655
  case 278 /* ExportSpecifier */:
53645
53656
  const specifier = node.parent.parent.moduleSpecifier;
53646
53657
  serializeExportSpecifier(
@@ -76294,7 +76305,7 @@ function createTypeChecker(host) {
76294
76305
  return getRegularTypeOfObjectLiteral(rightType);
76295
76306
  }
76296
76307
  case 27 /* CommaToken */:
76297
- if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
76308
+ if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isIndirectCall(left.parent)) {
76298
76309
  const sf = getSourceFileOfNode(left);
76299
76310
  const sourceText = sf.text;
76300
76311
  const start2 = skipTrivia(sourceText, left.pos);
@@ -76336,8 +76347,8 @@ function createTypeChecker(host) {
76336
76347
  }
76337
76348
  }
76338
76349
  }
76339
- function isEvalNode(node) {
76340
- return node.kind === 79 /* Identifier */ && node.escapedText === "eval";
76350
+ function isIndirectCall(node) {
76351
+ return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && (isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
76341
76352
  }
76342
76353
  function checkForDisallowedESSymbolOperand(operator2) {
76343
76354
  const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
@@ -76901,15 +76912,16 @@ function createTypeChecker(host) {
76901
76912
  }
76902
76913
  }
76903
76914
  expr = skipParentheses(node);
76915
+ if (isAwaitExpression(expr)) {
76916
+ const type = getQuickTypeOfExpression(expr.expression);
76917
+ return type ? getAwaitedType(type) : void 0;
76918
+ }
76904
76919
  if (isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !isRequireCall(
76905
76920
  expr,
76906
76921
  /*checkArgumentIsStringLiteralLike*/
76907
76922
  true
76908
76923
  ) && !isSymbolOrSymbolForCall(expr)) {
76909
- const type = isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
76910
- if (type) {
76911
- return type;
76912
- }
76924
+ return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
76913
76925
  } else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
76914
76926
  return getTypeFromTypeNode(expr.type);
76915
76927
  } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) {
@@ -82076,12 +82088,12 @@ function createTypeChecker(host) {
82076
82088
  if (node.flags & 16777216 /* Ambient */ && !isEntityNameExpression(node.expression)) {
82077
82089
  grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
82078
82090
  }
82079
- if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
82080
- if (moduleKind >= 5 /* ES2015 */ && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */) {
82091
+ if (node.isExportEquals) {
82092
+ if (moduleKind >= 5 /* ES2015 */ && (node.flags & 16777216 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 16777216 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
82081
82093
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
82082
- } else if (moduleKind === 4 /* System */) {
82094
+ } else if (moduleKind === 4 /* System */ && !(node.flags & 16777216 /* Ambient */)) {
82083
82095
  grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
82084
- } else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */) {
82096
+ } else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && !(node.flags & 16777216 /* Ambient */)) {
82085
82097
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_bundler_Consider_using_export_default_or_another_module_format_instead);
82086
82098
  }
82087
82099
  }
@@ -115841,7 +115853,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115841
115853
  currentNodeModulesDepth++;
115842
115854
  }
115843
115855
  const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
115844
- const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
115856
+ const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution, file) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
115845
115857
  if (elideImport) {
115846
115858
  modulesWithElidedImports.set(file.path, true);
115847
115859
  } else if (shouldAddFile) {
@@ -116184,7 +116196,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116184
116196
  if (options.preserveValueImports && getEmitModuleKind(options) < 5 /* ES2015 */) {
116185
116197
  createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later);
116186
116198
  }
116187
- if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) {
116199
+ if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly)) {
116188
116200
  createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_bundler_and_either_noEmit_or_emitDeclarationOnly_is_set);
116189
116201
  }
116190
116202
  const moduleResolution = getEmitModuleResolutionKind(options);
@@ -116836,19 +116848,27 @@ function resolveProjectReferencePath(hostOrRef, ref) {
116836
116848
  const passedInRef = ref ? ref : hostOrRef;
116837
116849
  return resolveConfigFileProjectName(passedInRef.path);
116838
116850
  }
116839
- function getResolutionDiagnostic(options, { extension }) {
116851
+ function getResolutionDiagnostic(options, { extension }, { isDeclarationFile }) {
116840
116852
  switch (extension) {
116841
116853
  case ".ts" /* Ts */:
116842
116854
  case ".d.ts" /* Dts */:
116855
+ case ".mts" /* Mts */:
116856
+ case ".d.mts" /* Dmts */:
116857
+ case ".cts" /* Cts */:
116858
+ case ".d.cts" /* Dcts */:
116843
116859
  return void 0;
116844
116860
  case ".tsx" /* Tsx */:
116845
116861
  return needJsx();
116846
116862
  case ".jsx" /* Jsx */:
116847
116863
  return needJsx() || needAllowJs();
116848
116864
  case ".js" /* Js */:
116865
+ case ".mjs" /* Mjs */:
116866
+ case ".cjs" /* Cjs */:
116849
116867
  return needAllowJs();
116850
116868
  case ".json" /* Json */:
116851
116869
  return needResolveJsonModule();
116870
+ default:
116871
+ return needAllowArbitraryExtensions();
116852
116872
  }
116853
116873
  function needJsx() {
116854
116874
  return options.jsx ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
@@ -116859,6 +116879,9 @@ function getResolutionDiagnostic(options, { extension }) {
116859
116879
  function needResolveJsonModule() {
116860
116880
  return getResolveJsonModule(options) ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
116861
116881
  }
116882
+ function needAllowArbitraryExtensions() {
116883
+ return isDeclarationFile || options.allowArbitraryExtensions ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set;
116884
+ }
116862
116885
  }
116863
116886
  function getModuleNames({ imports, moduleAugmentations }) {
116864
116887
  const res = imports.map((i) => i);
@@ -125127,7 +125150,6 @@ __export(ts_exports3, {
125127
125150
  moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
125128
125151
  moduleResolutionOptionDeclarations: () => moduleResolutionOptionDeclarations,
125129
125152
  moduleResolutionSupportsPackageJsonExportsAndImports: () => moduleResolutionSupportsPackageJsonExportsAndImports,
125130
- moduleResolutionSupportsResolvingTsExtensions: () => moduleResolutionSupportsResolvingTsExtensions,
125131
125153
  moduleResolutionUsesNodeModules: () => moduleResolutionUsesNodeModules,
125132
125154
  moduleSpecifiers: () => ts_moduleSpecifiers_exports,
125133
125155
  moveEmitHelpers: () => moveEmitHelpers,
@@ -148479,7 +148501,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
148479
148501
  break;
148480
148502
  case 291 /* JsxExpression */:
148481
148503
  case 290 /* JsxSpreadAttribute */:
148482
- if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) {
148504
+ if (previousToken.kind === 19 /* CloseBraceToken */ || (previousToken.kind === 79 /* Identifier */ || previousToken.parent.kind === 288 /* JsxAttribute */)) {
148483
148505
  isJsxIdentifierExpected = true;
148484
148506
  }
148485
148507
  break;
@@ -150577,6 +150599,10 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
150577
150599
  return result;
150578
150600
  }
150579
150601
  function getFilenameWithExtensionOption(name, compilerOptions, extensionOptions) {
150602
+ const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
150603
+ if (nonJsResult) {
150604
+ return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
150605
+ }
150580
150606
  if (extensionOptions.referenceKind === 0 /* Filename */) {
150581
150607
  return { name, extension: tryGetExtensionFromPath2(name) };
150582
150608
  }
@@ -151498,7 +151524,7 @@ function skipExportSpecifierSymbol(symbol, checker) {
151498
151524
  if (symbol.declarations) {
151499
151525
  for (const declaration of symbol.declarations) {
151500
151526
  if (isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) {
151501
- return checker.getExportSpecifierLocalTargetSymbol(declaration);
151527
+ return checker.getExportSpecifierLocalTargetSymbol(declaration) || symbol;
151502
151528
  } else if (isPropertyAccessExpression(declaration) && isModuleExportsAccessExpression(declaration.expression) && !isPrivateIdentifier(declaration.name)) {
151503
151529
  return checker.getSymbolAtLocation(declaration);
151504
151530
  } else if (isShorthandPropertyAssignment(declaration) && isBinaryExpression(declaration.parent.parent) && getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) {
@@ -180702,7 +180728,6 @@ start(initializeNodeSystem(), require("os").platform());
180702
180728
  moduleResolutionNameAndModeGetter,
180703
180729
  moduleResolutionOptionDeclarations,
180704
180730
  moduleResolutionSupportsPackageJsonExportsAndImports,
180705
- moduleResolutionSupportsResolvingTsExtensions,
180706
180731
  moduleResolutionUsesNodeModules,
180707
180732
  moduleSpecifiers,
180708
180733
  moveEmitHelpers,
@@ -7018,6 +7018,7 @@ declare namespace ts {
7018
7018
  interface CompilerOptions {
7019
7019
  allowImportingTsExtensions?: boolean;
7020
7020
  allowJs?: boolean;
7021
+ allowArbitraryExtensions?: boolean;
7021
7022
  allowSyntheticDefaultImports?: boolean;
7022
7023
  allowUmdGlobalAccess?: boolean;
7023
7024
  allowUnreachableCode?: boolean;
@@ -7281,7 +7282,7 @@ declare namespace ts {
7281
7282
  * Extension of resolvedFileName. This must match what's at the end of resolvedFileName.
7282
7283
  * This is optional for backwards-compatibility, but will be added if not provided.
7283
7284
  */
7284
- extension: Extension;
7285
+ extension: string;
7285
7286
  packageId?: PackageId;
7286
7287
  }
7287
7288
  /**
@@ -9212,7 +9213,6 @@ declare namespace ts {
9212
9213
  function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
9213
9214
  function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
9214
9215
  function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
9215
- function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean;
9216
9216
  function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined;
9217
9217
  interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, NonRelativeNameResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
9218
9218
  }