typescript 4.7.0-dev.20220506 → 4.8.0-dev.20220507

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  var ts;
70
70
  (function (ts) {
71
- ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220506";
71
+ ts.versionMajorMinor = "4.8";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220507";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -6184,6 +6184,7 @@ var ts;
6184
6184
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
6185
6185
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
6186
6186
  Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6187
+ Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6187
6188
  The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
6188
6189
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
6189
6190
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -14052,6 +14053,10 @@ var ts;
14052
14053
  return indentStrings[1].length;
14053
14054
  }
14054
14055
  ts.getIndentSize = getIndentSize;
14056
+ function isNightly() {
14057
+ return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
14058
+ }
14059
+ ts.isNightly = isNightly;
14055
14060
  function createTextWriter(newLine) {
14056
14061
  var output;
14057
14062
  var indent;
@@ -26464,6 +26469,7 @@ var ts;
26464
26469
  var startPos = scanner.getStartPos();
26465
26470
  var result = parseListElement(kind, parseElement);
26466
26471
  if (!result) {
26472
+ parsingContext = saveParsingContext;
26467
26473
  return undefined;
26468
26474
  }
26469
26475
  list.push(result);
@@ -71207,6 +71213,9 @@ var ts;
71207
71213
  var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
71208
71214
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
71209
71215
  if (validForTypeAssertions && override) {
71216
+ if (!ts.isNightly()) {
71217
+ grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
71218
+ }
71210
71219
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
71211
71220
  return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
71212
71221
  }
@@ -88856,23 +88865,33 @@ var ts;
88856
88865
  }
88857
88866
  function transformImportDeclaration(decl) {
88858
88867
  if (!decl.importClause) {
88859
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88868
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88860
88869
  }
88861
88870
  var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
88862
88871
  if (!decl.importClause.namedBindings) {
88863
- return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88872
+ return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88864
88873
  }
88865
88874
  if (decl.importClause.namedBindings.kind === 268) {
88866
88875
  var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
88867
- return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined;
88876
+ return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
88868
88877
  }
88869
88878
  var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
88870
88879
  if ((bindingList && bindingList.length) || visibleDefaultBinding) {
88871
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88880
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88872
88881
  }
88873
88882
  if (resolver.isImportRequiredByAugmentation(decl)) {
88874
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88883
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88884
+ }
88885
+ }
88886
+ function getResolutionModeOverrideForClauseInNightly(assertClause) {
88887
+ var mode = ts.getResolutionModeOverrideForClause(assertClause);
88888
+ if (mode !== undefined) {
88889
+ if (!ts.isNightly()) {
88890
+ context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
88891
+ }
88892
+ return assertClause;
88875
88893
  }
88894
+ return undefined;
88876
88895
  }
88877
88896
  function transformAndReplaceLatePaintedStatements(statements) {
88878
88897
  while (ts.length(lateMarkedStatements)) {
@@ -100612,14 +100631,14 @@ var ts;
100612
100631
  if (options === void 0) { options = {}; }
100613
100632
  var info = getInfo(importingSourceFile.path, host);
100614
100633
  var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
100615
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, true, options.overrideImportMode); });
100634
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, true, options.overrideImportMode); });
100616
100635
  }
100617
100636
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
100618
100637
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
100619
100638
  if (options === void 0) { options = {}; }
100620
100639
  var info = getInfo(importingSourceFileName, host);
100621
100640
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
100622
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode); }) ||
100641
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) ||
100623
100642
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
100624
100643
  }
100625
100644
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
@@ -100685,7 +100704,7 @@ var ts;
100685
100704
  var relativeSpecifiers;
100686
100705
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
100687
100706
  var modulePath = modulePaths_1[_i];
100688
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode);
100707
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode);
100689
100708
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
100690
100709
  if (specifier && modulePath.isRedirect) {
100691
100710
  return nodeModulesSpecifiers;
@@ -101016,7 +101035,7 @@ var ts;
101016
101035
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
101017
101036
  : ts.removeFileExtension(relativePath);
101018
101037
  }
101019
- function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
101038
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
101020
101039
  var path = _a.path, isRedirect = _a.isRedirect;
101021
101040
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
101022
101041
  if (!host.fileExists || !host.readFile) {
@@ -101029,8 +101048,9 @@ var ts;
101029
101048
  var moduleSpecifier = path;
101030
101049
  var isPackageRootPath = false;
101031
101050
  if (!packageNameOnly) {
101051
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
101032
101052
  var packageRootIndex = parts.packageRootIndex;
101033
- var moduleFileNameForExtensionless = void 0;
101053
+ var moduleFileName = void 0;
101034
101054
  while (true) {
101035
101055
  var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
101036
101056
  if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
@@ -101046,11 +101066,11 @@ var ts;
101046
101066
  isPackageRootPath = true;
101047
101067
  break;
101048
101068
  }
101049
- if (!moduleFileNameForExtensionless)
101050
- moduleFileNameForExtensionless = moduleFileToTry;
101069
+ if (!moduleFileName)
101070
+ moduleFileName = moduleFileToTry;
101051
101071
  packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
101052
101072
  if (packageRootIndex === -1) {
101053
- moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
101073
+ moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
101054
101074
  break;
101055
101075
  }
101056
101076
  }
@@ -101099,7 +101119,7 @@ var ts;
101099
101119
  moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
101100
101120
  }
101101
101121
  }
101102
- var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
101122
+ var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
101103
101123
  if (ts.isString(mainFileRelative)) {
101104
101124
  var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
101105
101125
  if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
@@ -101107,14 +101127,13 @@ var ts;
101107
101127
  }
101108
101128
  }
101109
101129
  }
101110
- return { moduleFileToTry: moduleFileToTry };
101111
- }
101112
- function getExtensionlessFileName(path) {
101113
- var fullModulePathWithoutExtension = ts.removeFileExtension(path);
101114
- if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
101115
- return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
101130
+ else {
101131
+ var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
101132
+ if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
101133
+ return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
101134
+ }
101116
101135
  }
101117
- return fullModulePathWithoutExtension;
101136
+ return { moduleFileToTry: moduleFileToTry };
101118
101137
  }
101119
101138
  }
101120
101139
  function tryGetAnyFileFromPath(host, path) {
@@ -101135,7 +101154,7 @@ var ts;
101135
101154
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
101136
101155
  });
101137
101156
  }
101138
- function removeExtensionAndIndexPostFix(fileName, ending, options) {
101157
+ function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
101139
101158
  if (ts.fileExtensionIsOneOf(fileName, [".json", ".mjs", ".cjs"]))
101140
101159
  return fileName;
101141
101160
  var noExtension = ts.removeFileExtension(fileName);
@@ -101143,7 +101162,11 @@ var ts;
101143
101162
  return noExtension + getJSExtensionForFile(fileName, options);
101144
101163
  switch (ending) {
101145
101164
  case 0:
101146
- return ts.removeSuffix(noExtension, "/index");
101165
+ var withoutIndex = ts.removeSuffix(noExtension, "/index");
101166
+ if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
101167
+ return noExtension;
101168
+ }
101169
+ return withoutIndex;
101147
101170
  case 1:
101148
101171
  return noExtension;
101149
101172
  case 2:
package/lib/tsserver.js CHANGED
@@ -96,11 +96,11 @@ var ts;
96
96
  (function (ts) {
97
97
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
98
98
  // If changing the text in this section, be sure to test `configurePrerelease` too.
99
- ts.versionMajorMinor = "4.7";
99
+ ts.versionMajorMinor = "4.8";
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220506";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220507";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -9000,6 +9000,7 @@ var ts;
9000
9000
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
9001
9001
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
9002
9002
  Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9003
+ Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9003
9004
  The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
9004
9005
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
9005
9006
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -18006,6 +18007,10 @@ var ts;
18006
18007
  return indentStrings[1].length;
18007
18008
  }
18008
18009
  ts.getIndentSize = getIndentSize;
18010
+ function isNightly() {
18011
+ return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
18012
+ }
18013
+ ts.isNightly = isNightly;
18009
18014
  function createTextWriter(newLine) {
18010
18015
  var output;
18011
18016
  var indent;
@@ -32853,6 +32858,7 @@ var ts;
32853
32858
  var startPos = scanner.getStartPos();
32854
32859
  var result = parseListElement(kind, parseElement);
32855
32860
  if (!result) {
32861
+ parsingContext = saveParsingContext;
32856
32862
  return undefined;
32857
32863
  }
32858
32864
  list.push(result);
@@ -84995,6 +85001,9 @@ var ts;
84995
85001
  var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
84996
85002
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
84997
85003
  if (validForTypeAssertions && override) {
85004
+ if (!ts.isNightly()) {
85005
+ grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
85006
+ }
84998
85007
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
84999
85008
  return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85000
85009
  }
@@ -108393,34 +108402,44 @@ var ts;
108393
108402
  if (!decl.importClause) {
108394
108403
  // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc)
108395
108404
  return factory.updateImportDeclaration(decl,
108396
- /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
108405
+ /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
108397
108406
  }
108398
108407
  // The `importClause` visibility corresponds to the default's visibility.
108399
108408
  var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
108400
108409
  if (!decl.importClause.namedBindings) {
108401
108410
  // No named bindings (either namespace or list), meaning the import is just default or should be elided
108402
108411
  return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding,
108403
- /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
108412
+ /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
108404
108413
  }
108405
108414
  if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) {
108406
108415
  // Namespace import (optionally with visible default)
108407
108416
  var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined;
108408
- return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined;
108417
+ return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
108409
108418
  }
108410
108419
  // Named imports (optionally with visible default)
108411
108420
  var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
108412
108421
  if ((bindingList && bindingList.length) || visibleDefaultBinding) {
108413
108422
  return factory.updateImportDeclaration(decl,
108414
- /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
108423
+ /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
108415
108424
  }
108416
108425
  // Augmentation of export depends on import
108417
108426
  if (resolver.isImportRequiredByAugmentation(decl)) {
108418
108427
  return factory.updateImportDeclaration(decl,
108419
108428
  /*decorators*/ undefined, decl.modifiers,
108420
- /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
108429
+ /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
108421
108430
  }
108422
108431
  // Nothing visible
108423
108432
  }
108433
+ function getResolutionModeOverrideForClauseInNightly(assertClause) {
108434
+ var mode = ts.getResolutionModeOverrideForClause(assertClause);
108435
+ if (mode !== undefined) {
108436
+ if (!ts.isNightly()) {
108437
+ context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
108438
+ }
108439
+ return assertClause;
108440
+ }
108441
+ return undefined;
108442
+ }
108424
108443
  function transformAndReplaceLatePaintedStatements(statements) {
108425
108444
  // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
108426
108445
  // error handling which must now be included in the output and themselves checked for errors.
@@ -121728,14 +121747,14 @@ var ts;
121728
121747
  if (options === void 0) { options = {}; }
121729
121748
  var info = getInfo(importingSourceFile.path, host);
121730
121749
  var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
121731
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
121750
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
121732
121751
  }
121733
121752
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
121734
121753
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
121735
121754
  if (options === void 0) { options = {}; }
121736
121755
  var info = getInfo(importingSourceFileName, host);
121737
121756
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
121738
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
121757
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
121739
121758
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
121740
121759
  }
121741
121760
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
@@ -121811,7 +121830,7 @@ var ts;
121811
121830
  var relativeSpecifiers;
121812
121831
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
121813
121832
  var modulePath = modulePaths_1[_i];
121814
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
121833
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
121815
121834
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
121816
121835
  if (specifier && modulePath.isRedirect) {
121817
121836
  // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -122204,7 +122223,7 @@ var ts;
122204
122223
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
122205
122224
  : ts.removeFileExtension(relativePath);
122206
122225
  }
122207
- function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
122226
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
122208
122227
  var path = _a.path, isRedirect = _a.isRedirect;
122209
122228
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
122210
122229
  if (!host.fileExists || !host.readFile) {
@@ -122218,8 +122237,9 @@ var ts;
122218
122237
  var moduleSpecifier = path;
122219
122238
  var isPackageRootPath = false;
122220
122239
  if (!packageNameOnly) {
122240
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
122221
122241
  var packageRootIndex = parts.packageRootIndex;
122222
- var moduleFileNameForExtensionless = void 0;
122242
+ var moduleFileName = void 0;
122223
122243
  while (true) {
122224
122244
  // If the module could be imported by a directory name, use that directory's name
122225
122245
  var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
@@ -122236,12 +122256,12 @@ var ts;
122236
122256
  isPackageRootPath = true;
122237
122257
  break;
122238
122258
  }
122239
- if (!moduleFileNameForExtensionless)
122240
- moduleFileNameForExtensionless = moduleFileToTry;
122259
+ if (!moduleFileName)
122260
+ moduleFileName = moduleFileToTry;
122241
122261
  // try with next level of directory
122242
122262
  packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
122243
122263
  if (packageRootIndex === -1) {
122244
- moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
122264
+ moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
122245
122265
  break;
122246
122266
  }
122247
122267
  }
@@ -122299,7 +122319,7 @@ var ts;
122299
122319
  }
122300
122320
  }
122301
122321
  // If the file is the main module, it can be imported by the package name
122302
- var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
122322
+ var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
122303
122323
  if (ts.isString(mainFileRelative)) {
122304
122324
  var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
122305
122325
  if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
@@ -122307,17 +122327,14 @@ var ts;
122307
122327
  }
122308
122328
  }
122309
122329
  }
122310
- return { moduleFileToTry: moduleFileToTry };
122311
- }
122312
- function getExtensionlessFileName(path) {
122313
- // We still have a file name - remove the extension
122314
- var fullModulePathWithoutExtension = ts.removeFileExtension(path);
122315
- // If the file is /index, it can be imported by its directory name
122316
- // IFF there is not _also_ a file by the same name
122317
- if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
122318
- return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
122330
+ else {
122331
+ // No package.json exists; an index.js will still resolve as the package name
122332
+ var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
122333
+ if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
122334
+ return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
122335
+ }
122319
122336
  }
122320
- return fullModulePathWithoutExtension;
122337
+ return { moduleFileToTry: moduleFileToTry };
122321
122338
  }
122322
122339
  }
122323
122340
  function tryGetAnyFileFromPath(host, path) {
@@ -122339,7 +122356,7 @@ var ts;
122339
122356
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
122340
122357
  });
122341
122358
  }
122342
- function removeExtensionAndIndexPostFix(fileName, ending, options) {
122359
+ function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
122343
122360
  if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
122344
122361
  return fileName;
122345
122362
  var noExtension = ts.removeFileExtension(fileName);
@@ -122347,7 +122364,13 @@ var ts;
122347
122364
  return noExtension + getJSExtensionForFile(fileName, options);
122348
122365
  switch (ending) {
122349
122366
  case 0 /* Minimal */:
122350
- return ts.removeSuffix(noExtension, "/index");
122367
+ var withoutIndex = ts.removeSuffix(noExtension, "/index");
122368
+ if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
122369
+ // Can't remove index if there's a file by the same name as the directory.
122370
+ // Probably more callers should pass `host` so we can determine this?
122371
+ return noExtension;
122372
+ }
122373
+ return withoutIndex;
122351
122374
  case 1 /* Index */:
122352
122375
  return noExtension;
122353
122376
  case 2 /* JsExtension */:
@@ -14,7 +14,7 @@ and limitations under the License.
14
14
  ***************************************************************************** */
15
15
 
16
16
  declare namespace ts {
17
- const versionMajorMinor = "4.7";
17
+ const versionMajorMinor = "4.8";
18
18
  /** The version of the TypeScript compiler release */
19
19
  const version: string;
20
20
  /**